babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268
  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. * @param mimeType defines the optional mime type of the file being loaded
  1073. * @returns true if the loader can load the specified file
  1074. */
  1075. canLoad(extension: string, mimeType?: string): boolean;
  1076. /**
  1077. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Engines/IPipelineContext" {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _getVertexShaderCode(): string | null;
  1109. /** @hidden */
  1110. _getFragmentShaderCode(): string | null;
  1111. /** @hidden */
  1112. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1113. }
  1114. }
  1115. declare module "babylonjs/Meshes/dataBuffer" {
  1116. /**
  1117. * Class used to store gfx data (like WebGLBuffer)
  1118. */
  1119. export class DataBuffer {
  1120. /**
  1121. * Gets or sets the number of objects referencing this buffer
  1122. */
  1123. references: number;
  1124. /** Gets or sets the size of the underlying buffer */
  1125. capacity: number;
  1126. /**
  1127. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1128. */
  1129. is32Bits: boolean;
  1130. /**
  1131. * Gets the underlying buffer
  1132. */
  1133. get underlyingResource(): any;
  1134. }
  1135. }
  1136. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1137. /** @hidden */
  1138. export interface IShaderProcessor {
  1139. attributeProcessor?: (attribute: string) => string;
  1140. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1141. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1142. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1143. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1144. lineProcessor?: (line: string, isFragment: boolean) => string;
  1145. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1147. }
  1148. }
  1149. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1150. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1151. /** @hidden */
  1152. export interface ProcessingOptions {
  1153. defines: string[];
  1154. indexParameters: any;
  1155. isFragment: boolean;
  1156. shouldUseHighPrecisionShader: boolean;
  1157. supportsUniformBuffers: boolean;
  1158. shadersRepository: string;
  1159. includesShadersStore: {
  1160. [key: string]: string;
  1161. };
  1162. processor?: IShaderProcessor;
  1163. version: string;
  1164. platformName: string;
  1165. lookForClosingBracketForUniformBuffer?: boolean;
  1166. }
  1167. }
  1168. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1169. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1170. /** @hidden */
  1171. export class ShaderCodeNode {
  1172. line: string;
  1173. children: ShaderCodeNode[];
  1174. additionalDefineKey?: string;
  1175. additionalDefineValue?: string;
  1176. isValid(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. process(preprocessors: {
  1180. [key: string]: string;
  1181. }, options: ProcessingOptions): string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1185. /** @hidden */
  1186. export class ShaderCodeCursor {
  1187. private _lines;
  1188. lineIndex: number;
  1189. get currentLine(): string;
  1190. get canRead(): boolean;
  1191. set lines(value: string[]);
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1195. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1196. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1197. /** @hidden */
  1198. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1199. process(preprocessors: {
  1200. [key: string]: string;
  1201. }, options: ProcessingOptions): string;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1205. /** @hidden */
  1206. export class ShaderDefineExpression {
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. private static _OperatorPriority;
  1211. private static _Stack;
  1212. static postfixToInfix(postfix: string[]): string;
  1213. static infixToPostfix(infix: string): string[];
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1217. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1218. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1219. /** @hidden */
  1220. export class ShaderCodeTestNode extends ShaderCodeNode {
  1221. testExpression: ShaderDefineExpression;
  1222. isValid(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. not: boolean;
  1233. constructor(define: string, not?: boolean);
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1254. leftOperand: ShaderDefineExpression;
  1255. rightOperand: ShaderDefineExpression;
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1262. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Offline/IOfflineProvider" {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/filesInputStore" {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module "babylonjs/Misc/retryStrategy" {
  1326. import { WebRequest } from "babylonjs/Misc/webRequest";
  1327. /**
  1328. * Class used to define a retry strategy when error happens while loading assets
  1329. */
  1330. export class RetryStrategy {
  1331. /**
  1332. * Function used to defines an exponential back off strategy
  1333. * @param maxRetries defines the maximum number of retries (3 by default)
  1334. * @param baseInterval defines the interval between retries
  1335. * @returns the strategy function to use
  1336. */
  1337. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/baseError" {
  1341. /**
  1342. * @ignore
  1343. * Application error to support additional information when loading a file
  1344. */
  1345. export abstract class BaseError extends Error {
  1346. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1347. }
  1348. }
  1349. declare module "babylonjs/Misc/fileTools" {
  1350. import { WebRequest } from "babylonjs/Misc/webRequest";
  1351. import { Nullable } from "babylonjs/types";
  1352. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1353. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1354. import { BaseError } from "babylonjs/Misc/baseError";
  1355. /** @ignore */
  1356. export class LoadFileError extends BaseError {
  1357. request?: WebRequest;
  1358. file?: File;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. * @param file defines the optional file
  1364. */
  1365. constructor(message: string, object?: WebRequest | File);
  1366. }
  1367. /** @ignore */
  1368. export class RequestFileError extends BaseError {
  1369. request: WebRequest;
  1370. /**
  1371. * Creates a new LoadFileError
  1372. * @param message defines the message of the error
  1373. * @param request defines the optional web request
  1374. */
  1375. constructor(message: string, request: WebRequest);
  1376. }
  1377. /** @ignore */
  1378. export class ReadFileError extends BaseError {
  1379. file: File;
  1380. /**
  1381. * Creates a new ReadFileError
  1382. * @param message defines the message of the error
  1383. * @param file defines the optional file
  1384. */
  1385. constructor(message: string, file: File);
  1386. }
  1387. /**
  1388. * @hidden
  1389. */
  1390. export class FileTools {
  1391. /**
  1392. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1393. */
  1394. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1395. /**
  1396. * Gets or sets the base URL to use to load assets
  1397. */
  1398. static BaseUrl: string;
  1399. /**
  1400. * Default behaviour for cors in the application.
  1401. * It can be a string if the expected behavior is identical in the entire app.
  1402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1403. */
  1404. static CorsBehavior: string | ((url: string | string[]) => string);
  1405. /**
  1406. * Gets or sets a function used to pre-process url before using them to load assets
  1407. */
  1408. static PreprocessUrl: (url: string) => string;
  1409. /**
  1410. * Removes unwanted characters from an url
  1411. * @param url defines the url to clean
  1412. * @returns the cleaned url
  1413. */
  1414. private static _CleanUrl;
  1415. /**
  1416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1417. * @param url define the url we are trying
  1418. * @param element define the dom element where to configure the cors policy
  1419. */
  1420. static SetCorsBehavior(url: string | string[], element: {
  1421. crossOrigin: string | null;
  1422. }): void;
  1423. /**
  1424. * Loads an image as an HTMLImageElement.
  1425. * @param input url string, ArrayBuffer, or Blob to load
  1426. * @param onLoad callback called when the image successfully loads
  1427. * @param onError callback called when the image fails to load
  1428. * @param offlineProvider offline provider for caching
  1429. * @param mimeType optional mime type
  1430. * @returns the HTMLImageElement of the loaded image
  1431. */
  1432. 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>;
  1433. /**
  1434. * Reads a file from a File object
  1435. * @param file defines the file to load
  1436. * @param onSuccess defines the callback to call when data is loaded
  1437. * @param onProgress defines the callback to call during loading process
  1438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1439. * @param onError defines the callback to call when an error occurs
  1440. * @returns a file request object
  1441. */
  1442. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file from a url
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param offlineProvider defines the offline provider for caching
  1449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1450. * @param onError callback called when the file fails to load
  1451. * @returns a file request object
  1452. */
  1453. 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;
  1454. /**
  1455. * Loads a file
  1456. * @param url url to load
  1457. * @param onSuccess callback called when the file successfully loads
  1458. * @param onProgress callback called while file is loading (if the server supports this mode)
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @param onOpened callback called when the web request is opened
  1462. * @returns a file request object
  1463. */
  1464. 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;
  1465. /**
  1466. * Checks if the loaded document was accessed via `file:`-Protocol.
  1467. * @returns boolean
  1468. */
  1469. static IsFileURL(): boolean;
  1470. }
  1471. }
  1472. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1473. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1474. import { WebRequest } from "babylonjs/Misc/webRequest";
  1475. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1476. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1477. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1478. /** @hidden */
  1479. export class ShaderProcessor {
  1480. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1481. private static _ProcessPrecision;
  1482. private static _ExtractOperation;
  1483. private static _BuildSubExpression;
  1484. private static _BuildExpression;
  1485. private static _MoveCursorWithinIf;
  1486. private static _MoveCursor;
  1487. private static _EvaluatePreProcessors;
  1488. private static _PreparePreProcessors;
  1489. private static _ProcessShaderConversion;
  1490. private static _ProcessIncludes;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. * @hidden
  1501. */
  1502. 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;
  1503. }
  1504. }
  1505. declare module "babylonjs/Maths/math.like" {
  1506. import { float, int, DeepImmutable } from "babylonjs/types";
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor4Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. a: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IColor3Like {
  1520. r: float;
  1521. g: float;
  1522. b: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector4Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. w: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IVector3Like {
  1537. x: float;
  1538. y: float;
  1539. z: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector2Like {
  1545. x: float;
  1546. y: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IMatrixLike {
  1552. toArray(): DeepImmutable<Float32Array>;
  1553. updateFlag: int;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IViewportLike {
  1559. x: float;
  1560. y: float;
  1561. width: float;
  1562. height: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IPlaneLike {
  1568. normal: IVector3Like;
  1569. d: float;
  1570. normalize(): void;
  1571. }
  1572. }
  1573. declare module "babylonjs/Materials/iEffectFallbacks" {
  1574. import { Effect } from "babylonjs/Materials/effect";
  1575. /**
  1576. * Interface used to define common properties for effect fallbacks
  1577. */
  1578. export interface IEffectFallbacks {
  1579. /**
  1580. * Removes the defines that should be removed when falling back.
  1581. * @param currentDefines defines the current define statements for the shader.
  1582. * @param effect defines the current effect we try to compile
  1583. * @returns The resulting defines with defines of the current rank removed.
  1584. */
  1585. reduce(currentDefines: string, effect: Effect): string;
  1586. /**
  1587. * Removes the fallback from the bound mesh.
  1588. */
  1589. unBindMesh(): void;
  1590. /**
  1591. * Checks to see if more fallbacks are still availible.
  1592. */
  1593. hasMoreFallbacks: boolean;
  1594. }
  1595. }
  1596. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1597. /**
  1598. * Class used to evalaute queries containing `and` and `or` operators
  1599. */
  1600. export class AndOrNotEvaluator {
  1601. /**
  1602. * Evaluate a query
  1603. * @param query defines the query to evaluate
  1604. * @param evaluateCallback defines the callback used to filter result
  1605. * @returns true if the query matches
  1606. */
  1607. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1608. private static _HandleParenthesisContent;
  1609. private static _SimplifyNegation;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/tags" {
  1613. /**
  1614. * Class used to store custom tags
  1615. */
  1616. export class Tags {
  1617. /**
  1618. * Adds support for tags on the given object
  1619. * @param obj defines the object to use
  1620. */
  1621. static EnableFor(obj: any): void;
  1622. /**
  1623. * Removes tags support
  1624. * @param obj defines the object to use
  1625. */
  1626. static DisableFor(obj: any): void;
  1627. /**
  1628. * Gets a boolean indicating if the given object has tags
  1629. * @param obj defines the object to use
  1630. * @returns a boolean
  1631. */
  1632. static HasTags(obj: any): boolean;
  1633. /**
  1634. * Gets the tags available on a given object
  1635. * @param obj defines the object to use
  1636. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1637. * @returns the tags
  1638. */
  1639. static GetTags(obj: any, asString?: boolean): any;
  1640. /**
  1641. * Adds tags to an object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1644. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1645. */
  1646. static AddTagsTo(obj: any, tagsString: string): void;
  1647. /**
  1648. * @hidden
  1649. */
  1650. static _AddTagTo(obj: any, tag: string): void;
  1651. /**
  1652. * Removes specific tags from a specific object
  1653. * @param obj defines the object to use
  1654. * @param tagsString defines the tags to remove
  1655. */
  1656. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _RemoveTagFrom(obj: any, tag: string): void;
  1661. /**
  1662. * Defines if tags hosted on an object match a given query
  1663. * @param obj defines the object to use
  1664. * @param tagsQuery defines the tag query
  1665. * @returns a boolean
  1666. */
  1667. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1668. }
  1669. }
  1670. declare module "babylonjs/Maths/math.scalar" {
  1671. /**
  1672. * Scalar computation library
  1673. */
  1674. export class Scalar {
  1675. /**
  1676. * Two pi constants convenient for computation.
  1677. */
  1678. static TwoPi: number;
  1679. /**
  1680. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1681. * @param a number
  1682. * @param b number
  1683. * @param epsilon (default = 1.401298E-45)
  1684. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1685. */
  1686. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1687. /**
  1688. * Returns a string : the upper case translation of the number i to hexadecimal.
  1689. * @param i number
  1690. * @returns the upper case translation of the number i to hexadecimal.
  1691. */
  1692. static ToHex(i: number): string;
  1693. /**
  1694. * Returns -1 if value is negative and +1 is value is positive.
  1695. * @param value the value
  1696. * @returns the value itself if it's equal to zero.
  1697. */
  1698. static Sign(value: number): number;
  1699. /**
  1700. * Returns the value itself if it's between min and max.
  1701. * Returns min if the value is lower than min.
  1702. * Returns max if the value is greater than max.
  1703. * @param value the value to clmap
  1704. * @param min the min value to clamp to (default: 0)
  1705. * @param max the max value to clamp to (default: 1)
  1706. * @returns the clamped value
  1707. */
  1708. static Clamp(value: number, min?: number, max?: number): number;
  1709. /**
  1710. * the log2 of value.
  1711. * @param value the value to compute log2 of
  1712. * @returns the log2 of value.
  1713. */
  1714. static Log2(value: number): number;
  1715. /**
  1716. * Loops the value, so that it is never larger than length and never smaller than 0.
  1717. *
  1718. * This is similar to the modulo operator but it works with floating point numbers.
  1719. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1720. * With t = 5 and length = 2.5, the result would be 0.0.
  1721. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1722. * @param value the value
  1723. * @param length the length
  1724. * @returns the looped value
  1725. */
  1726. static Repeat(value: number, length: number): number;
  1727. /**
  1728. * Normalize the value between 0.0 and 1.0 using min and max values
  1729. * @param value value to normalize
  1730. * @param min max to normalize between
  1731. * @param max min to normalize between
  1732. * @returns the normalized value
  1733. */
  1734. static Normalize(value: number, min: number, max: number): number;
  1735. /**
  1736. * Denormalize the value from 0.0 and 1.0 using min and max values
  1737. * @param normalized value to denormalize
  1738. * @param min max to denormalize between
  1739. * @param max min to denormalize between
  1740. * @returns the denormalized value
  1741. */
  1742. static Denormalize(normalized: number, min: number, max: number): number;
  1743. /**
  1744. * Calculates the shortest difference between two given angles given in degrees.
  1745. * @param current current angle in degrees
  1746. * @param target target angle in degrees
  1747. * @returns the delta
  1748. */
  1749. static DeltaAngle(current: number, target: number): number;
  1750. /**
  1751. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1752. * @param tx value
  1753. * @param length length
  1754. * @returns The returned value will move back and forth between 0 and length
  1755. */
  1756. static PingPong(tx: number, length: number): number;
  1757. /**
  1758. * Interpolates between min and max with smoothing at the limits.
  1759. *
  1760. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1761. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1762. * @param from from
  1763. * @param to to
  1764. * @param tx value
  1765. * @returns the smooth stepped value
  1766. */
  1767. static SmoothStep(from: number, to: number, tx: number): number;
  1768. /**
  1769. * Moves a value current towards target.
  1770. *
  1771. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1772. * Negative values of maxDelta pushes the value away from target.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting value
  1777. */
  1778. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1781. *
  1782. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1783. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1784. * @param current current value
  1785. * @param target target value
  1786. * @param maxDelta max distance to move
  1787. * @returns resulting angle
  1788. */
  1789. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1790. /**
  1791. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static Lerp(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1800. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1801. * @param start start value
  1802. * @param end target value
  1803. * @param amount amount to lerp between
  1804. * @returns the lerped value
  1805. */
  1806. static LerpAngle(start: number, end: number, amount: number): number;
  1807. /**
  1808. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1809. * @param a start value
  1810. * @param b target value
  1811. * @param value value between a and b
  1812. * @returns the inverseLerp value
  1813. */
  1814. static InverseLerp(a: number, b: number, value: number): number;
  1815. /**
  1816. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1817. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1818. * @param value1 spline value
  1819. * @param tangent1 spline value
  1820. * @param value2 spline value
  1821. * @param tangent2 spline value
  1822. * @param amount input value
  1823. * @returns hermite result
  1824. */
  1825. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1826. /**
  1827. * Returns a random float number between and min and max values
  1828. * @param min min value of random
  1829. * @param max max value of random
  1830. * @returns random value
  1831. */
  1832. static RandomRange(min: number, max: number): number;
  1833. /**
  1834. * This function returns percentage of a number in a given range.
  1835. *
  1836. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1837. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1838. * @param number to convert to percentage
  1839. * @param min min range
  1840. * @param max max range
  1841. * @returns the percentage
  1842. */
  1843. static RangeToPercent(number: number, min: number, max: number): number;
  1844. /**
  1845. * This function returns number that corresponds to the percentage in a given range.
  1846. *
  1847. * PercentToRange(0.34,0,100) will return 34.
  1848. * @param percent to convert to number
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the number
  1852. */
  1853. static PercentToRange(percent: number, min: number, max: number): number;
  1854. /**
  1855. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1856. * @param angle The angle to normalize in radian.
  1857. * @return The converted angle.
  1858. */
  1859. static NormalizeRadians(angle: number): number;
  1860. }
  1861. }
  1862. declare module "babylonjs/Maths/math.constants" {
  1863. /**
  1864. * Constant used to convert a value to gamma space
  1865. * @ignorenaming
  1866. */
  1867. export const ToGammaSpace: number;
  1868. /**
  1869. * Constant used to convert a value to linear space
  1870. * @ignorenaming
  1871. */
  1872. export const ToLinearSpace = 2.2;
  1873. /**
  1874. * Constant used to define the minimal number value in Babylon.js
  1875. * @ignorenaming
  1876. */
  1877. let Epsilon: number;
  1878. export { Epsilon };
  1879. }
  1880. declare module "babylonjs/Maths/math.viewport" {
  1881. /**
  1882. * Class used to represent a viewport on screen
  1883. */
  1884. export class Viewport {
  1885. /** viewport left coordinate */
  1886. x: number;
  1887. /** viewport top coordinate */
  1888. y: number;
  1889. /**viewport width */
  1890. width: number;
  1891. /** viewport height */
  1892. height: number;
  1893. /**
  1894. * Creates a Viewport object located at (x, y) and sized (width, height)
  1895. * @param x defines viewport left coordinate
  1896. * @param y defines viewport top coordinate
  1897. * @param width defines the viewport width
  1898. * @param height defines the viewport height
  1899. */
  1900. constructor(
  1901. /** viewport left coordinate */
  1902. x: number,
  1903. /** viewport top coordinate */
  1904. y: number,
  1905. /**viewport width */
  1906. width: number,
  1907. /** viewport height */
  1908. height: number);
  1909. /**
  1910. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1911. * @param renderWidth defines the rendering width
  1912. * @param renderHeight defines the rendering height
  1913. * @returns a new Viewport
  1914. */
  1915. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1916. /**
  1917. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1918. * @param renderWidth defines the rendering width
  1919. * @param renderHeight defines the rendering height
  1920. * @param ref defines the target viewport
  1921. * @returns the current viewport
  1922. */
  1923. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1924. /**
  1925. * Returns a new Viewport copied from the current one
  1926. * @returns a new Viewport
  1927. */
  1928. clone(): Viewport;
  1929. }
  1930. }
  1931. declare module "babylonjs/Misc/arrayTools" {
  1932. /**
  1933. * Class containing a set of static utilities functions for arrays.
  1934. */
  1935. export class ArrayTools {
  1936. /**
  1937. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1938. * @param size the number of element to construct and put in the array
  1939. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1940. * @returns a new array filled with new objects
  1941. */
  1942. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1943. }
  1944. }
  1945. declare module "babylonjs/Maths/math.plane" {
  1946. import { DeepImmutable } from "babylonjs/types";
  1947. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1948. /**
  1949. * Represents a plane by the equation ax + by + cz + d = 0
  1950. */
  1951. export class Plane {
  1952. private static _TmpMatrix;
  1953. /**
  1954. * Normal of the plane (a,b,c)
  1955. */
  1956. normal: Vector3;
  1957. /**
  1958. * d component of the plane
  1959. */
  1960. d: number;
  1961. /**
  1962. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1963. * @param a a component of the plane
  1964. * @param b b component of the plane
  1965. * @param c c component of the plane
  1966. * @param d d component of the plane
  1967. */
  1968. constructor(a: number, b: number, c: number, d: number);
  1969. /**
  1970. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1971. */
  1972. asArray(): number[];
  1973. /**
  1974. * @returns a new plane copied from the current Plane.
  1975. */
  1976. clone(): Plane;
  1977. /**
  1978. * @returns the string "Plane".
  1979. */
  1980. getClassName(): string;
  1981. /**
  1982. * @returns the Plane hash code.
  1983. */
  1984. getHashCode(): number;
  1985. /**
  1986. * Normalize the current Plane in place.
  1987. * @returns the updated Plane.
  1988. */
  1989. normalize(): Plane;
  1990. /**
  1991. * Applies a transformation the plane and returns the result
  1992. * @param transformation the transformation matrix to be applied to the plane
  1993. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1994. */
  1995. transform(transformation: DeepImmutable<Matrix>): Plane;
  1996. /**
  1997. * Compute the dot product between the point and the plane normal
  1998. * @param point point to calculate the dot product with
  1999. * @returns the dot product (float) of the point coordinates and the plane normal.
  2000. */
  2001. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2002. /**
  2003. * Updates the current Plane from the plane defined by the three given points.
  2004. * @param point1 one of the points used to contruct the plane
  2005. * @param point2 one of the points used to contruct the plane
  2006. * @param point3 one of the points used to contruct the plane
  2007. * @returns the updated Plane.
  2008. */
  2009. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2010. /**
  2011. * Checks if the plane is facing a given direction
  2012. * @param direction the direction to check if the plane is facing
  2013. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2014. * @returns True is the vector "direction" is the same side than the plane normal.
  2015. */
  2016. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2017. /**
  2018. * Calculates the distance to a point
  2019. * @param point point to calculate distance to
  2020. * @returns the signed distance (float) from the given point to the Plane.
  2021. */
  2022. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2023. /**
  2024. * Creates a plane from an array
  2025. * @param array the array to create a plane from
  2026. * @returns a new Plane from the given array.
  2027. */
  2028. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2029. /**
  2030. * Creates a plane from three points
  2031. * @param point1 point used to create the plane
  2032. * @param point2 point used to create the plane
  2033. * @param point3 point used to create the plane
  2034. * @returns a new Plane defined by the three given points.
  2035. */
  2036. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2037. /**
  2038. * Creates a plane from an origin point and a normal
  2039. * @param origin origin of the plane to be constructed
  2040. * @param normal normal of the plane to be constructed
  2041. * @returns a new Plane the normal vector to this plane at the given origin point.
  2042. * Note : the vector "normal" is updated because normalized.
  2043. */
  2044. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2045. /**
  2046. * Calculates the distance from a plane and a point
  2047. * @param origin origin of the plane to be constructed
  2048. * @param normal normal of the plane to be constructed
  2049. * @param point point to calculate distance to
  2050. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2051. */
  2052. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2053. }
  2054. }
  2055. declare module "babylonjs/Maths/math.vector" {
  2056. import { Viewport } from "babylonjs/Maths/math.viewport";
  2057. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2058. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2059. import { Plane } from "babylonjs/Maths/math.plane";
  2060. /**
  2061. * Class representing a vector containing 2 coordinates
  2062. */
  2063. export class Vector2 {
  2064. /** defines the first coordinate */
  2065. x: number;
  2066. /** defines the second coordinate */
  2067. y: number;
  2068. /**
  2069. * Creates a new Vector2 from the given x and y coordinates
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. */
  2073. constructor(
  2074. /** defines the first coordinate */
  2075. x?: number,
  2076. /** defines the second coordinate */
  2077. y?: number);
  2078. /**
  2079. * Gets a string with the Vector2 coordinates
  2080. * @returns a string with the Vector2 coordinates
  2081. */
  2082. toString(): string;
  2083. /**
  2084. * Gets class name
  2085. * @returns the string "Vector2"
  2086. */
  2087. getClassName(): string;
  2088. /**
  2089. * Gets current vector hash code
  2090. * @returns the Vector2 hash code as a number
  2091. */
  2092. getHashCode(): number;
  2093. /**
  2094. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2095. * @param array defines the source array
  2096. * @param index defines the offset in source array
  2097. * @returns the current Vector2
  2098. */
  2099. toArray(array: FloatArray, index?: number): Vector2;
  2100. /**
  2101. * Copy the current vector to an array
  2102. * @returns a new array with 2 elements: the Vector2 coordinates.
  2103. */
  2104. asArray(): number[];
  2105. /**
  2106. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2107. * @param source defines the source Vector2
  2108. * @returns the current updated Vector2
  2109. */
  2110. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the Vector2 coordinates with the given floats
  2113. * @param x defines the first coordinate
  2114. * @param y defines the second coordinate
  2115. * @returns the current updated Vector2
  2116. */
  2117. copyFromFloats(x: number, y: number): Vector2;
  2118. /**
  2119. * Sets the Vector2 coordinates with the given floats
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. * @returns the current updated Vector2
  2123. */
  2124. set(x: number, y: number): Vector2;
  2125. /**
  2126. * Add another vector with the current one
  2127. * @param otherVector defines the other vector
  2128. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2129. */
  2130. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2131. /**
  2132. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2133. * @param otherVector defines the other vector
  2134. * @param result defines the target vector
  2135. * @returns the unmodified current Vector2
  2136. */
  2137. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2138. /**
  2139. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns the current updated Vector2
  2142. */
  2143. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2146. * @param otherVector defines the other vector
  2147. * @returns a new Vector2
  2148. */
  2149. addVector3(otherVector: Vector3): Vector2;
  2150. /**
  2151. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. subtract(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Multiplies in place the current Vector2 coordinates by the given ones
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2190. * @param x defines the first coordinate
  2191. * @param y defines the second coordinate
  2192. * @returns a new Vector2
  2193. */
  2194. multiplyByFloats(x: number, y: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns a new Vector2
  2199. */
  2200. divide(otherVector: Vector2): Vector2;
  2201. /**
  2202. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @param result defines the target vector
  2205. * @returns the unmodified current Vector2
  2206. */
  2207. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2208. /**
  2209. * Divides the current Vector2 coordinates by the given ones
  2210. * @param otherVector defines the other vector
  2211. * @returns the current updated Vector2
  2212. */
  2213. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 with current Vector2 negated coordinates
  2216. * @returns a new Vector2
  2217. */
  2218. negate(): Vector2;
  2219. /**
  2220. * Negate this vector in place
  2221. * @returns this
  2222. */
  2223. negateInPlace(): Vector2;
  2224. /**
  2225. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2226. * @param result defines the Vector3 object where to store the result
  2227. * @returns the current Vector2
  2228. */
  2229. negateToRef(result: Vector2): Vector2;
  2230. /**
  2231. * Multiply the Vector2 coordinates by scale
  2232. * @param scale defines the scaling factor
  2233. * @returns the current updated Vector2
  2234. */
  2235. scaleInPlace(scale: number): Vector2;
  2236. /**
  2237. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2238. * @param scale defines the scaling factor
  2239. * @returns a new Vector2
  2240. */
  2241. scale(scale: number): Vector2;
  2242. /**
  2243. * Scale the current Vector2 values by a factor to a given Vector2
  2244. * @param scale defines the scale factor
  2245. * @param result defines the Vector2 object where to store the result
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. scaleToRef(scale: number, result: Vector2): Vector2;
  2249. /**
  2250. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2251. * @param scale defines the scale factor
  2252. * @param result defines the Vector2 object where to store the result
  2253. * @returns the unmodified current Vector2
  2254. */
  2255. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2256. /**
  2257. * Gets a boolean if two vectors are equals
  2258. * @param otherVector defines the other vector
  2259. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2260. */
  2261. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2262. /**
  2263. * Gets a boolean if two vectors are equals (using an epsilon value)
  2264. * @param otherVector defines the other vector
  2265. * @param epsilon defines the minimal distance to consider equality
  2266. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2267. */
  2268. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. floor(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 from current Vector2 floored values
  2276. * @returns a new Vector2
  2277. */
  2278. fract(): Vector2;
  2279. /**
  2280. * Gets the length of the vector
  2281. * @returns the vector length (float)
  2282. */
  2283. length(): number;
  2284. /**
  2285. * Gets the vector squared length
  2286. * @returns the vector squared length (float)
  2287. */
  2288. lengthSquared(): number;
  2289. /**
  2290. * Normalize the vector
  2291. * @returns the current updated Vector2
  2292. */
  2293. normalize(): Vector2;
  2294. /**
  2295. * Gets a new Vector2 copied from the Vector2
  2296. * @returns a new Vector2
  2297. */
  2298. clone(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(0, 0)
  2301. * @returns a new Vector2
  2302. */
  2303. static Zero(): Vector2;
  2304. /**
  2305. * Gets a new Vector2(1, 1)
  2306. * @returns a new Vector2
  2307. */
  2308. static One(): Vector2;
  2309. /**
  2310. * Gets a new Vector2 set from the given index element of the given array
  2311. * @param array defines the data source
  2312. * @param offset defines the offset in the data source
  2313. * @returns a new Vector2
  2314. */
  2315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2316. /**
  2317. * Sets "result" from the given index element of the given array
  2318. * @param array defines the data source
  2319. * @param offset defines the offset in the data source
  2320. * @param result defines the target vector
  2321. */
  2322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2323. /**
  2324. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2325. * @param value1 defines 1st point of control
  2326. * @param value2 defines 2nd point of control
  2327. * @param value3 defines 3rd point of control
  2328. * @param value4 defines 4th point of control
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * 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".
  2335. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2336. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2337. * @param value defines the value to clamp
  2338. * @param min defines the lower limit
  2339. * @param max defines the upper limit
  2340. * @returns a new Vector2
  2341. */
  2342. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2345. * @param value1 defines the 1st control point
  2346. * @param tangent1 defines the outgoing tangent
  2347. * @param value2 defines the 2nd control point
  2348. * @param tangent2 defines the incoming tangent
  2349. * @param amount defines the interpolation factor
  2350. * @returns a new Vector2
  2351. */
  2352. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2353. /**
  2354. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2355. * @param start defines the start vector
  2356. * @param end defines the end vector
  2357. * @param amount defines the interpolation factor
  2358. * @returns a new Vector2
  2359. */
  2360. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2361. /**
  2362. * Gets the dot product of the vector "left" and the vector "right"
  2363. * @param left defines first vector
  2364. * @param right defines second vector
  2365. * @returns the dot product (float)
  2366. */
  2367. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2368. /**
  2369. * Returns a new Vector2 equal to the normalized given vector
  2370. * @param vector defines the vector to normalize
  2371. * @returns a new Vector2
  2372. */
  2373. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2376. * @param left defines 1st vector
  2377. * @param right defines 2nd vector
  2378. * @returns a new Vector2
  2379. */
  2380. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2383. * @param left defines 1st vector
  2384. * @param right defines 2nd vector
  2385. * @returns a new Vector2
  2386. */
  2387. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2388. /**
  2389. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2390. * @param vector defines the vector to transform
  2391. * @param transformation defines the matrix to apply
  2392. * @returns a new Vector2
  2393. */
  2394. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2395. /**
  2396. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2397. * @param vector defines the vector to transform
  2398. * @param transformation defines the matrix to apply
  2399. * @param result defines the target vector
  2400. */
  2401. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2402. /**
  2403. * Determines if a given vector is included in a triangle
  2404. * @param p defines the vector to test
  2405. * @param p0 defines 1st triangle point
  2406. * @param p1 defines 2nd triangle point
  2407. * @param p2 defines 3rd triangle point
  2408. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2409. */
  2410. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2411. /**
  2412. * Gets the distance between the vectors "value1" and "value2"
  2413. * @param value1 defines first vector
  2414. * @param value2 defines second vector
  2415. * @returns the distance between vectors
  2416. */
  2417. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2418. /**
  2419. * Returns the squared distance between the vectors "value1" and "value2"
  2420. * @param value1 defines first vector
  2421. * @param value2 defines second vector
  2422. * @returns the squared distance between vectors
  2423. */
  2424. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2427. * @param value1 defines first vector
  2428. * @param value2 defines second vector
  2429. * @returns a new Vector2
  2430. */
  2431. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2432. /**
  2433. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2434. * @param p defines the middle point
  2435. * @param segA defines one point of the segment
  2436. * @param segB defines the other point of the segment
  2437. * @returns the shortest distance
  2438. */
  2439. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2440. }
  2441. /**
  2442. * Class used to store (x,y,z) vector representation
  2443. * A Vector3 is the main object used in 3D geometry
  2444. * It can represent etiher the coordinates of a point the space, either a direction
  2445. * Reminder: js uses a left handed forward facing system
  2446. */
  2447. export class Vector3 {
  2448. private static _UpReadOnly;
  2449. private static _ZeroReadOnly;
  2450. /** @hidden */
  2451. _x: number;
  2452. /** @hidden */
  2453. _y: number;
  2454. /** @hidden */
  2455. _z: number;
  2456. /** @hidden */
  2457. _isDirty: boolean;
  2458. /** Gets or sets the x coordinate */
  2459. get x(): number;
  2460. set x(value: number);
  2461. /** Gets or sets the y coordinate */
  2462. get y(): number;
  2463. set y(value: number);
  2464. /** Gets or sets the z coordinate */
  2465. get z(): number;
  2466. set z(value: number);
  2467. /**
  2468. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2469. * @param x defines the first coordinates (on X axis)
  2470. * @param y defines the second coordinates (on Y axis)
  2471. * @param z defines the third coordinates (on Z axis)
  2472. */
  2473. constructor(x?: number, y?: number, z?: number);
  2474. /**
  2475. * Creates a string representation of the Vector3
  2476. * @returns a string with the Vector3 coordinates.
  2477. */
  2478. toString(): string;
  2479. /**
  2480. * Gets the class name
  2481. * @returns the string "Vector3"
  2482. */
  2483. getClassName(): string;
  2484. /**
  2485. * Creates the Vector3 hash code
  2486. * @returns a number which tends to be unique between Vector3 instances
  2487. */
  2488. getHashCode(): number;
  2489. /**
  2490. * Creates an array containing three elements : the coordinates of the Vector3
  2491. * @returns a new array of numbers
  2492. */
  2493. asArray(): number[];
  2494. /**
  2495. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2496. * @param array defines the destination array
  2497. * @param index defines the offset in the destination array
  2498. * @returns the current Vector3
  2499. */
  2500. toArray(array: FloatArray, index?: number): Vector3;
  2501. /**
  2502. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2503. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2504. */
  2505. toQuaternion(): Quaternion;
  2506. /**
  2507. * Adds the given vector to the current Vector3
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Adds the given coordinates to the current Vector3
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the resulting Vector3
  2524. */
  2525. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Subtract the given vector from the current Vector3
  2535. * @param otherVector defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the resulting Vector3
  2543. */
  2544. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the resulting Vector3
  2558. */
  2559. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2562. * @param x defines the x coordinate of the operand
  2563. * @param y defines the y coordinate of the operand
  2564. * @param z defines the z coordinate of the operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2569. /**
  2570. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2571. * @returns a new Vector3
  2572. */
  2573. negate(): Vector3;
  2574. /**
  2575. * Negate this vector in place
  2576. * @returns this
  2577. */
  2578. negateInPlace(): Vector3;
  2579. /**
  2580. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2581. * @param result defines the Vector3 object where to store the result
  2582. * @returns the current Vector3
  2583. */
  2584. negateToRef(result: Vector3): Vector3;
  2585. /**
  2586. * Multiplies the Vector3 coordinates by the float "scale"
  2587. * @param scale defines the multiplier factor
  2588. * @returns the current updated Vector3
  2589. */
  2590. scaleInPlace(scale: number): Vector3;
  2591. /**
  2592. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns a new Vector3
  2595. */
  2596. scale(scale: number): Vector3;
  2597. /**
  2598. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2599. * @param scale defines the multiplier factor
  2600. * @param result defines the Vector3 object where to store the result
  2601. * @returns the current Vector3
  2602. */
  2603. scaleToRef(scale: number, result: Vector3): Vector3;
  2604. /**
  2605. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2606. * @param scale defines the scale factor
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the unmodified current Vector3
  2609. */
  2610. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2611. /**
  2612. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2613. * @param origin defines the origin of the projection ray
  2614. * @param plane defines the plane to project to
  2615. * @returns the projected vector3
  2616. */
  2617. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2618. /**
  2619. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2620. * @param origin defines the origin of the projection ray
  2621. * @param plane defines the plane to project to
  2622. * @param result defines the Vector3 where to store the result
  2623. */
  2624. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2625. /**
  2626. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2627. * @param otherVector defines the second operand
  2628. * @returns true if both vectors are equals
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2633. * @param otherVector defines the second operand
  2634. * @param epsilon defines the minimal distance to define values as equals
  2635. * @returns true if both vectors are distant less than epsilon
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2638. /**
  2639. * Returns true if the current Vector3 coordinates equals the given floats
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns true if both vectors are equals
  2644. */
  2645. equalsToFloats(x: number, y: number, z: number): boolean;
  2646. /**
  2647. * Multiplies the current Vector3 coordinates by the given ones
  2648. * @param otherVector defines the second operand
  2649. * @returns the current updated Vector3
  2650. */
  2651. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2654. * @param otherVector defines the second operand
  2655. * @returns the new Vector3
  2656. */
  2657. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2660. * @param otherVector defines the second operand
  2661. * @param result defines the Vector3 object where to store the result
  2662. * @returns the current Vector3
  2663. */
  2664. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the new Vector3
  2671. */
  2672. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2675. * @param otherVector defines the second operand
  2676. * @returns the new Vector3
  2677. */
  2678. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2679. /**
  2680. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2681. * @param otherVector defines the second operand
  2682. * @param result defines the Vector3 object where to store the result
  2683. * @returns the current Vector3
  2684. */
  2685. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2686. /**
  2687. * Divides the current Vector3 coordinates by the given ones.
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. divideInPlace(otherVector: Vector3): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2694. * @param other defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2706. * @param x defines the x coordinate of the operand
  2707. * @param y defines the y coordinate of the operand
  2708. * @param z defines the z coordinate of the operand
  2709. * @returns the current updated Vector3
  2710. */
  2711. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2712. /**
  2713. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2720. /**
  2721. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2722. * Check if is non uniform within a certain amount of decimal places to account for this
  2723. * @param epsilon the amount the values can differ
  2724. * @returns if the the vector is non uniform to a certain number of decimal places
  2725. */
  2726. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2727. /**
  2728. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2729. */
  2730. get isNonUniform(): boolean;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. floor(): Vector3;
  2736. /**
  2737. * Gets a new Vector3 from current Vector3 floored values
  2738. * @returns a new Vector3
  2739. */
  2740. fract(): Vector3;
  2741. /**
  2742. * Gets the length of the Vector3
  2743. * @returns the length of the Vector3
  2744. */
  2745. length(): number;
  2746. /**
  2747. * Gets the squared length of the Vector3
  2748. * @returns squared length of the Vector3
  2749. */
  2750. lengthSquared(): number;
  2751. /**
  2752. * Normalize the current Vector3.
  2753. * Please note that this is an in place operation.
  2754. * @returns the current updated Vector3
  2755. */
  2756. normalize(): Vector3;
  2757. /**
  2758. * Reorders the x y z properties of the vector in place
  2759. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2760. * @returns the current updated vector
  2761. */
  2762. reorderInPlace(order: string): this;
  2763. /**
  2764. * Rotates the vector around 0,0,0 by a quaternion
  2765. * @param quaternion the rotation quaternion
  2766. * @param result vector to store the result
  2767. * @returns the resulting vector
  2768. */
  2769. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2770. /**
  2771. * Rotates a vector around a given point
  2772. * @param quaternion the rotation quaternion
  2773. * @param point the point to rotate around
  2774. * @param result vector to store the result
  2775. * @returns the resulting vector
  2776. */
  2777. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2778. /**
  2779. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2780. * The cross product is then orthogonal to both current and "other"
  2781. * @param other defines the right operand
  2782. * @returns the cross product
  2783. */
  2784. cross(other: Vector3): Vector3;
  2785. /**
  2786. * Normalize the current Vector3 with the given input length.
  2787. * Please note that this is an in place operation.
  2788. * @param len the length of the vector
  2789. * @returns the current updated Vector3
  2790. */
  2791. normalizeFromLength(len: number): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to a new vector
  2794. * @returns the new Vector3
  2795. */
  2796. normalizeToNew(): Vector3;
  2797. /**
  2798. * Normalize the current Vector3 to the reference
  2799. * @param reference define the Vector3 to update
  2800. * @returns the updated Vector3
  2801. */
  2802. normalizeToRef(reference: Vector3): Vector3;
  2803. /**
  2804. * Creates a new Vector3 copied from the current Vector3
  2805. * @returns the new Vector3
  2806. */
  2807. clone(): Vector3;
  2808. /**
  2809. * Copies the given vector coordinates to the current Vector3 ones
  2810. * @param source defines the source Vector3
  2811. * @returns the current updated Vector3
  2812. */
  2813. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * Copies the given floats to the current Vector3 coordinates
  2816. * @param x defines the x coordinate of the operand
  2817. * @param y defines the y coordinate of the operand
  2818. * @param z defines the z coordinate of the operand
  2819. * @returns the current updated Vector3
  2820. */
  2821. copyFromFloats(x: number, y: number, z: number): Vector3;
  2822. /**
  2823. * Copies the given floats to the current Vector3 coordinates
  2824. * @param x defines the x coordinate of the operand
  2825. * @param y defines the y coordinate of the operand
  2826. * @param z defines the z coordinate of the operand
  2827. * @returns the current updated Vector3
  2828. */
  2829. set(x: number, y: number, z: number): Vector3;
  2830. /**
  2831. * Copies the given float to the current Vector3 coordinates
  2832. * @param v defines the x, y and z coordinates of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. setAll(v: number): Vector3;
  2836. /**
  2837. * Get the clip factor between two vectors
  2838. * @param vector0 defines the first operand
  2839. * @param vector1 defines the second operand
  2840. * @param axis defines the axis to use
  2841. * @param size defines the size along the axis
  2842. * @returns the clip factor
  2843. */
  2844. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2845. /**
  2846. * Get angle between two vectors
  2847. * @param vector0 angle between vector0 and vector1
  2848. * @param vector1 angle between vector0 and vector1
  2849. * @param normal direction of the normal
  2850. * @return the angle between vector0 and vector1
  2851. */
  2852. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2853. /**
  2854. * Returns a new Vector3 set from the index "offset" of the given array
  2855. * @param array defines the source array
  2856. * @param offset defines the offset in the source array
  2857. * @returns the new Vector3
  2858. */
  2859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2860. /**
  2861. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2862. * @param array defines the source array
  2863. * @param offset defines the offset in the source array
  2864. * @returns the new Vector3
  2865. * @deprecated Please use FromArray instead.
  2866. */
  2867. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2868. /**
  2869. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2870. * @param array defines the source array
  2871. * @param offset defines the offset in the source array
  2872. * @param result defines the Vector3 where to store the result
  2873. */
  2874. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2875. /**
  2876. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2877. * @param array defines the source array
  2878. * @param offset defines the offset in the source array
  2879. * @param result defines the Vector3 where to store the result
  2880. * @deprecated Please use FromArrayToRef instead.
  2881. */
  2882. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2883. /**
  2884. * Sets the given vector "result" with the given floats.
  2885. * @param x defines the x coordinate of the source
  2886. * @param y defines the y coordinate of the source
  2887. * @param z defines the z coordinate of the source
  2888. * @param result defines the Vector3 where to store the result
  2889. */
  2890. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2891. /**
  2892. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2893. * @returns a new empty Vector3
  2894. */
  2895. static Zero(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2898. * @returns a new unit Vector3
  2899. */
  2900. static One(): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2903. * @returns a new up Vector3
  2904. */
  2905. static Up(): Vector3;
  2906. /**
  2907. * Gets a up Vector3 that must not be updated
  2908. */
  2909. static get UpReadOnly(): DeepImmutable<Vector3>;
  2910. /**
  2911. * Gets a zero Vector3 that must not be updated
  2912. */
  2913. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2916. * @returns a new down Vector3
  2917. */
  2918. static Down(): Vector3;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2921. * @param rightHandedSystem is the scene right-handed (negative z)
  2922. * @returns a new forward Vector3
  2923. */
  2924. static Forward(rightHandedSystem?: boolean): 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 Backward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2933. * @returns a new right Vector3
  2934. */
  2935. static Right(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2938. * @returns a new left Vector3
  2939. */
  2940. static Left(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2943. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2944. * @param vector defines the Vector3 to transform
  2945. * @param transformation defines the transformation matrix
  2946. * @returns the transformed Vector3
  2947. */
  2948. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2951. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2952. * @param vector defines the Vector3 to transform
  2953. * @param transformation defines the transformation matrix
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2959. * This method computes tranformed coordinates only, not transformed direction vectors
  2960. * @param x define the x coordinate of the source vector
  2961. * @param y define the y coordinate of the source vector
  2962. * @param z define the z coordinate of the source vector
  2963. * @param transformation defines the transformation matrix
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2970. * @param vector defines the Vector3 to transform
  2971. * @param transformation defines the transformation matrix
  2972. * @returns the new Vector3
  2973. */
  2974. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2975. /**
  2976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2977. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2978. * @param vector defines the Vector3 to transform
  2979. * @param transformation defines the transformation matrix
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2986. * @param x define the x coordinate of the source vector
  2987. * @param y define the y coordinate of the source vector
  2988. * @param z define the z coordinate of the source vector
  2989. * @param transformation defines the transformation matrix
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2995. * @param value1 defines the first control point
  2996. * @param value2 defines the second control point
  2997. * @param value3 defines the third control point
  2998. * @param value4 defines the fourth control point
  2999. * @param amount defines the amount on the spline to use
  3000. * @returns the new Vector3
  3001. */
  3002. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * 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"
  3005. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3006. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3007. * @param value defines the current value
  3008. * @param min defines the lower range value
  3009. * @param max defines the upper range value
  3010. * @returns the new Vector3
  3011. */
  3012. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * 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"
  3015. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3016. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3017. * @param value defines the current value
  3018. * @param min defines the lower range value
  3019. * @param max defines the upper range value
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3023. /**
  3024. * Checks if a given vector is inside a specific range
  3025. * @param v defines the vector to test
  3026. * @param min defines the minimum range
  3027. * @param max defines the maximum range
  3028. */
  3029. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3030. /**
  3031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3032. * @param value1 defines the first control point
  3033. * @param tangent1 defines the first tangent vector
  3034. * @param value2 defines the second control point
  3035. * @param tangent2 defines the second tangent vector
  3036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3037. * @returns the new Vector3
  3038. */
  3039. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3040. /**
  3041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3042. * @param start defines the start value
  3043. * @param end defines the end value
  3044. * @param amount max defines amount between both (between 0 and 1)
  3045. * @returns the new Vector3
  3046. */
  3047. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3050. * @param start defines the start value
  3051. * @param end defines the end value
  3052. * @param amount max defines amount between both (between 0 and 1)
  3053. * @param result defines the Vector3 where to store the result
  3054. */
  3055. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3056. /**
  3057. * Returns the dot product (float) between the vectors "left" and "right"
  3058. * @param left defines the left operand
  3059. * @param right defines the right operand
  3060. * @returns the dot product
  3061. */
  3062. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3063. /**
  3064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3065. * The cross product is then orthogonal to both "left" and "right"
  3066. * @param left defines the left operand
  3067. * @param right defines the right operand
  3068. * @returns the cross product
  3069. */
  3070. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Sets the given vector "result" with the cross product of "left" and "right"
  3073. * The cross product is then orthogonal to both "left" and "right"
  3074. * @param left defines the left operand
  3075. * @param right defines the right operand
  3076. * @param result defines the Vector3 where to store the result
  3077. */
  3078. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3079. /**
  3080. * Returns a new Vector3 as the normalization of the given vector
  3081. * @param vector defines the Vector3 to normalize
  3082. * @returns the new Vector3
  3083. */
  3084. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3085. /**
  3086. * Sets the given vector "result" with the normalization of the given first vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Project a Vector3 onto screen space
  3093. * @param vector defines the Vector3 to project
  3094. * @param world defines the world matrix to use
  3095. * @param transform defines the transform (view x projection) matrix to use
  3096. * @param viewport defines the screen viewport to use
  3097. * @returns the new Vector3
  3098. */
  3099. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3100. /** @hidden */
  3101. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3102. /**
  3103. * Unproject from screen space to object space
  3104. * @param source defines the screen space Vector3 to use
  3105. * @param viewportWidth defines the current width of the viewport
  3106. * @param viewportHeight defines the current height of the viewport
  3107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3108. * @param transform defines the transform (view x projection) matrix to use
  3109. * @returns the new Vector3
  3110. */
  3111. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3112. /**
  3113. * Unproject from screen space to object space
  3114. * @param source defines the screen space Vector3 to use
  3115. * @param viewportWidth defines the current width of the viewport
  3116. * @param viewportHeight defines the current height of the viewport
  3117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3118. * @param view defines the view matrix to use
  3119. * @param projection defines the projection matrix to use
  3120. * @returns the new Vector3
  3121. */
  3122. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3123. /**
  3124. * Unproject from screen space to object space
  3125. * @param source defines the screen space Vector3 to use
  3126. * @param viewportWidth defines the current width of the viewport
  3127. * @param viewportHeight defines the current height of the viewport
  3128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3129. * @param view defines the view matrix to use
  3130. * @param projection defines the projection matrix to use
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param sourceX defines the screen space x coordinate to use
  3137. * @param sourceY defines the screen space y coordinate to use
  3138. * @param sourceZ defines the screen space z coordinate to use
  3139. * @param viewportWidth defines the current width of the viewport
  3140. * @param viewportHeight defines the current height of the viewport
  3141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3142. * @param view defines the view matrix to use
  3143. * @param projection defines the projection matrix to use
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Gets the minimal coordinate values between two Vector3
  3149. * @param left defines the first operand
  3150. * @param right defines the second operand
  3151. * @returns the new Vector3
  3152. */
  3153. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3154. /**
  3155. * Gets the maximal coordinate values between two Vector3
  3156. * @param left defines the first operand
  3157. * @param right defines the second operand
  3158. * @returns the new Vector3
  3159. */
  3160. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Returns the distance between the vectors "value1" and "value2"
  3163. * @param value1 defines the first operand
  3164. * @param value2 defines the second operand
  3165. * @returns the distance
  3166. */
  3167. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3168. /**
  3169. * Returns the squared distance between the vectors "value1" and "value2"
  3170. * @param value1 defines the first operand
  3171. * @param value2 defines the second operand
  3172. * @returns the squared distance
  3173. */
  3174. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3175. /**
  3176. * Returns a new Vector3 located at the center between "value1" and "value2"
  3177. * @param value1 defines the first operand
  3178. * @param value2 defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3184. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3185. * to something in order to rotate it from its local system to the given target system
  3186. * Note: axis1, axis2 and axis3 are normalized during this operation
  3187. * @param axis1 defines the first axis
  3188. * @param axis2 defines the second axis
  3189. * @param axis3 defines the third axis
  3190. * @returns a new Vector3
  3191. */
  3192. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3195. * @param axis1 defines the first axis
  3196. * @param axis2 defines the second axis
  3197. * @param axis3 defines the third axis
  3198. * @param ref defines the Vector3 where to store the result
  3199. */
  3200. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3201. }
  3202. /**
  3203. * Vector4 class created for EulerAngle class conversion to Quaternion
  3204. */
  3205. export class Vector4 {
  3206. /** x value of the vector */
  3207. x: number;
  3208. /** y value of the vector */
  3209. y: number;
  3210. /** z value of the vector */
  3211. z: number;
  3212. /** w value of the vector */
  3213. w: number;
  3214. /**
  3215. * Creates a Vector4 object from the given floats.
  3216. * @param x x value of the vector
  3217. * @param y y value of the vector
  3218. * @param z z value of the vector
  3219. * @param w w value of the vector
  3220. */
  3221. constructor(
  3222. /** x value of the vector */
  3223. x: number,
  3224. /** y value of the vector */
  3225. y: number,
  3226. /** z value of the vector */
  3227. z: number,
  3228. /** w value of the vector */
  3229. w: number);
  3230. /**
  3231. * Returns the string with the Vector4 coordinates.
  3232. * @returns a string containing all the vector values
  3233. */
  3234. toString(): string;
  3235. /**
  3236. * Returns the string "Vector4".
  3237. * @returns "Vector4"
  3238. */
  3239. getClassName(): string;
  3240. /**
  3241. * Returns the Vector4 hash code.
  3242. * @returns a unique hash code
  3243. */
  3244. getHashCode(): number;
  3245. /**
  3246. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3247. * @returns the resulting array
  3248. */
  3249. asArray(): number[];
  3250. /**
  3251. * Populates the given array from the given index with the Vector4 coordinates.
  3252. * @param array array to populate
  3253. * @param index index of the array to start at (default: 0)
  3254. * @returns the Vector4.
  3255. */
  3256. toArray(array: FloatArray, index?: number): Vector4;
  3257. /**
  3258. * Adds the given vector to the current Vector4.
  3259. * @param otherVector the vector to add
  3260. * @returns the updated Vector4.
  3261. */
  3262. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3265. * @param otherVector the vector to add
  3266. * @returns the resulting vector
  3267. */
  3268. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @param result the vector to store the result
  3273. * @returns the current Vector4.
  3274. */
  3275. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3276. /**
  3277. * Subtract in place the given vector from the current Vector4.
  3278. * @param otherVector the vector to subtract
  3279. * @returns the updated Vector4.
  3280. */
  3281. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3284. * @param otherVector the vector to add
  3285. * @returns the new vector with the result
  3286. */
  3287. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to subtract
  3291. * @param result the vector to store the result
  3292. * @returns the current Vector4.
  3293. */
  3294. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3295. /**
  3296. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3297. */
  3298. /**
  3299. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3300. * @param x value to subtract
  3301. * @param y value to subtract
  3302. * @param z value to subtract
  3303. * @param w value to subtract
  3304. * @returns new vector containing the result
  3305. */
  3306. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3309. * @param x value to subtract
  3310. * @param y value to subtract
  3311. * @param z value to subtract
  3312. * @param w value to subtract
  3313. * @param result the vector to store the result in
  3314. * @returns the current Vector4.
  3315. */
  3316. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3317. /**
  3318. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3319. * @returns a new vector with the negated values
  3320. */
  3321. negate(): Vector4;
  3322. /**
  3323. * Negate this vector in place
  3324. * @returns this
  3325. */
  3326. negateInPlace(): Vector4;
  3327. /**
  3328. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3329. * @param result defines the Vector3 object where to store the result
  3330. * @returns the current Vector4
  3331. */
  3332. negateToRef(result: Vector4): Vector4;
  3333. /**
  3334. * Multiplies the current Vector4 coordinates by scale (float).
  3335. * @param scale the number to scale with
  3336. * @returns the updated Vector4.
  3337. */
  3338. scaleInPlace(scale: number): Vector4;
  3339. /**
  3340. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns a new vector with the result
  3343. */
  3344. scale(scale: number): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @param result a vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. scaleToRef(scale: number, result: Vector4): Vector4;
  3352. /**
  3353. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3354. * @param scale defines the scale factor
  3355. * @param result defines the Vector4 object where to store the result
  3356. * @returns the unmodified current Vector4
  3357. */
  3358. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3359. /**
  3360. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3361. * @param otherVector the vector to compare against
  3362. * @returns true if they are equal
  3363. */
  3364. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3367. * @param otherVector vector to compare against
  3368. * @param epsilon (Default: very small number)
  3369. * @returns true if they are equal
  3370. */
  3371. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3372. /**
  3373. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3374. * @param x x value to compare against
  3375. * @param y y value to compare against
  3376. * @param z z value to compare against
  3377. * @param w w value to compare against
  3378. * @returns true if equal
  3379. */
  3380. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3381. /**
  3382. * Multiplies in place the current Vector4 by the given one.
  3383. * @param otherVector vector to multiple with
  3384. * @returns the updated Vector4.
  3385. */
  3386. multiplyInPlace(otherVector: Vector4): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns resulting new vector
  3391. */
  3392. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @param result vector to store the result
  3397. * @returns the current Vector4.
  3398. */
  3399. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3400. /**
  3401. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3402. * @param x x value multiply with
  3403. * @param y y value multiply with
  3404. * @param z z value multiply with
  3405. * @param w w value multiply with
  3406. * @returns resulting new vector
  3407. */
  3408. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3411. * @param otherVector vector to devide with
  3412. * @returns resulting new vector
  3413. */
  3414. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @param result vector to store the result
  3419. * @returns the current Vector4.
  3420. */
  3421. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3422. /**
  3423. * Divides the current Vector3 coordinates by the given ones.
  3424. * @param otherVector vector to devide with
  3425. * @returns the updated Vector3.
  3426. */
  3427. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3430. * @param other defines the second operand
  3431. * @returns the current updated Vector4
  3432. */
  3433. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector4 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. floor(): Vector4;
  3445. /**
  3446. * Gets a new Vector4 from current Vector3 floored values
  3447. * @returns a new Vector4
  3448. */
  3449. fract(): Vector4;
  3450. /**
  3451. * Returns the Vector4 length (float).
  3452. * @returns the length
  3453. */
  3454. length(): number;
  3455. /**
  3456. * Returns the Vector4 squared length (float).
  3457. * @returns the length squared
  3458. */
  3459. lengthSquared(): number;
  3460. /**
  3461. * Normalizes in place the Vector4.
  3462. * @returns the updated Vector4.
  3463. */
  3464. normalize(): Vector4;
  3465. /**
  3466. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3467. * @returns this converted to a new vector3
  3468. */
  3469. toVector3(): Vector3;
  3470. /**
  3471. * Returns a new Vector4 copied from the current one.
  3472. * @returns the new cloned vector
  3473. */
  3474. clone(): Vector4;
  3475. /**
  3476. * Updates the current Vector4 with the given one coordinates.
  3477. * @param source the source vector to copy from
  3478. * @returns the updated Vector4.
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3481. /**
  3482. * Updates the current Vector4 coordinates with the given floats.
  3483. * @param x float to copy from
  3484. * @param y float to copy from
  3485. * @param z float to copy from
  3486. * @param w float to copy from
  3487. * @returns the updated Vector4.
  3488. */
  3489. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Updates the current Vector4 coordinates with the given floats.
  3492. * @param x float to set from
  3493. * @param y float to set from
  3494. * @param z float to set from
  3495. * @param w float to set from
  3496. * @returns the updated Vector4.
  3497. */
  3498. set(x: number, y: number, z: number, w: number): Vector4;
  3499. /**
  3500. * Copies the given float to the current Vector3 coordinates
  3501. * @param v defines the x, y, z and w coordinates of the operand
  3502. * @returns the current updated Vector3
  3503. */
  3504. setAll(v: number): Vector4;
  3505. /**
  3506. * Returns a new Vector4 set from the starting index of the given array.
  3507. * @param array the array to pull values from
  3508. * @param offset the offset into the array to start at
  3509. * @returns the new vector
  3510. */
  3511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3512. /**
  3513. * Updates the given vector "result" from the starting index of the given array.
  3514. * @param array the array to pull values from
  3515. * @param offset the offset into the array to start at
  3516. * @param result the vector to store the result in
  3517. */
  3518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3519. /**
  3520. * Updates the given vector "result" from the starting index of the given Float32Array.
  3521. * @param array the array to pull values from
  3522. * @param offset the offset into the array to start at
  3523. * @param result the vector to store the result in
  3524. */
  3525. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3526. /**
  3527. * Updates the given vector "result" coordinates from the given floats.
  3528. * @param x float to set from
  3529. * @param y float to set from
  3530. * @param z float to set from
  3531. * @param w float to set from
  3532. * @param result the vector to the floats in
  3533. */
  3534. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3535. /**
  3536. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3537. * @returns the new vector
  3538. */
  3539. static Zero(): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3542. * @returns the new vector
  3543. */
  3544. static One(): Vector4;
  3545. /**
  3546. * Returns a new normalized Vector4 from the given one.
  3547. * @param vector the vector to normalize
  3548. * @returns the vector
  3549. */
  3550. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the normalization of the given one.
  3553. * @param vector the vector to normalize
  3554. * @param result the vector to store the result in
  3555. */
  3556. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3557. /**
  3558. * Returns a vector with the minimum values from the left and right vectors
  3559. * @param left left vector to minimize
  3560. * @param right right vector to minimize
  3561. * @returns a new vector with the minimum of the left and right vector values
  3562. */
  3563. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3564. /**
  3565. * Returns a vector with the maximum values from the left and right vectors
  3566. * @param left left vector to maximize
  3567. * @param right right vector to maximize
  3568. * @returns a new vector with the maximum of the left and right vector values
  3569. */
  3570. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3571. /**
  3572. * Returns the distance (float) between the vectors "value1" and "value2".
  3573. * @param value1 value to calulate the distance between
  3574. * @param value2 value to calulate the distance between
  3575. * @return the distance between the two vectors
  3576. */
  3577. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3578. /**
  3579. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3580. * @param value1 value to calulate the distance between
  3581. * @param value2 value to calulate the distance between
  3582. * @return the distance between the two vectors squared
  3583. */
  3584. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3585. /**
  3586. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3587. * @param value1 value to calulate the center between
  3588. * @param value2 value to calulate the center between
  3589. * @return the center between the two vectors
  3590. */
  3591. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3594. * This methods computes transformed normalized direction vectors only.
  3595. * @param vector the vector to transform
  3596. * @param transformation the transformation matrix to apply
  3597. * @returns the new vector
  3598. */
  3599. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3600. /**
  3601. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3602. * This methods computes transformed normalized direction vectors only.
  3603. * @param vector the vector to transform
  3604. * @param transformation the transformation matrix to apply
  3605. * @param result the vector to store the result in
  3606. */
  3607. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3608. /**
  3609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param x value to transform
  3612. * @param y value to transform
  3613. * @param z value to transform
  3614. * @param w value to transform
  3615. * @param transformation the transformation matrix to apply
  3616. * @param result the vector to store the results in
  3617. */
  3618. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3619. /**
  3620. * Creates a new Vector4 from a Vector3
  3621. * @param source defines the source data
  3622. * @param w defines the 4th component (default is 0)
  3623. * @returns a new Vector4
  3624. */
  3625. static FromVector3(source: Vector3, w?: number): Vector4;
  3626. }
  3627. /**
  3628. * Class used to store quaternion data
  3629. * @see https://en.wikipedia.org/wiki/Quaternion
  3630. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3631. */
  3632. export class Quaternion {
  3633. /** @hidden */
  3634. _x: number;
  3635. /** @hidden */
  3636. _y: number;
  3637. /** @hidden */
  3638. _z: number;
  3639. /** @hidden */
  3640. _w: number;
  3641. /** @hidden */
  3642. _isDirty: boolean;
  3643. /** Gets or sets the x coordinate */
  3644. get x(): number;
  3645. set x(value: number);
  3646. /** Gets or sets the y coordinate */
  3647. get y(): number;
  3648. set y(value: number);
  3649. /** Gets or sets the z coordinate */
  3650. get z(): number;
  3651. set z(value: number);
  3652. /** Gets or sets the w coordinate */
  3653. get w(): number;
  3654. set w(value: number);
  3655. /**
  3656. * Creates a new Quaternion from the given floats
  3657. * @param x defines the first component (0 by default)
  3658. * @param y defines the second component (0 by default)
  3659. * @param z defines the third component (0 by default)
  3660. * @param w defines the fourth component (1.0 by default)
  3661. */
  3662. constructor(x?: number, y?: number, z?: number, w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5102. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. subMeshFaceId: number;
  10488. /** Id of the the submesh that was picked */
  10489. subMeshId: number;
  10490. /** If a sprite was picked, this will be the sprite the pick collided with */
  10491. pickedSprite: Nullable<Sprite>;
  10492. /**
  10493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10494. */
  10495. originMesh: Nullable<AbstractMesh>;
  10496. /**
  10497. * The ray that was used to perform the picking.
  10498. */
  10499. ray: Nullable<Ray>;
  10500. /**
  10501. * Gets the normal correspodning to the face the pick collided with
  10502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10504. * @returns The normal correspodning to the face the pick collided with
  10505. */
  10506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10507. /**
  10508. * Gets the texture coordinates of where the pick occured
  10509. * @returns the vector containing the coordnates of the texture
  10510. */
  10511. getTextureCoordinates(): Nullable<Vector2>;
  10512. }
  10513. }
  10514. declare module "babylonjs/Culling/ray" {
  10515. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10516. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10518. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10519. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10520. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10521. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10522. import { Plane } from "babylonjs/Maths/math.plane";
  10523. /**
  10524. * Class representing a ray with position and direction
  10525. */
  10526. export class Ray {
  10527. /** origin point */
  10528. origin: Vector3;
  10529. /** direction */
  10530. direction: Vector3;
  10531. /** length of the ray */
  10532. length: number;
  10533. private static readonly TmpVector3;
  10534. private _tmpRay;
  10535. /**
  10536. * Creates a new ray
  10537. * @param origin origin point
  10538. * @param direction direction
  10539. * @param length length of the ray
  10540. */
  10541. constructor(
  10542. /** origin point */
  10543. origin: Vector3,
  10544. /** direction */
  10545. direction: Vector3,
  10546. /** length of the ray */
  10547. length?: number);
  10548. /**
  10549. * Checks if the ray intersects a box
  10550. * This does not account for the ray lenght by design to improve perfs.
  10551. * @param minimum bound of the box
  10552. * @param maximum bound of the box
  10553. * @param intersectionTreshold extra extend to be added to the box in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * Checks if the ray intersects a box
  10559. * This does not account for the ray lenght by design to improve perfs.
  10560. * @param box the bounding box to check
  10561. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10562. * @returns if the box was hit
  10563. */
  10564. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10565. /**
  10566. * If the ray hits a sphere
  10567. * @param sphere the bounding sphere to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10569. * @returns true if it hits the sphere
  10570. */
  10571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a triange
  10574. * @param vertex0 triangle vertex
  10575. * @param vertex1 triangle vertex
  10576. * @param vertex2 triangle vertex
  10577. * @returns intersection information if hit
  10578. */
  10579. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10580. /**
  10581. * Checks if ray intersects a plane
  10582. * @param plane the plane to check
  10583. * @returns the distance away it was hit
  10584. */
  10585. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10586. /**
  10587. * Calculate the intercept of a ray on a given axis
  10588. * @param axis to check 'x' | 'y' | 'z'
  10589. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10590. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10591. */
  10592. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10593. /**
  10594. * Checks if ray intersects a mesh
  10595. * @param mesh the mesh to check
  10596. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10597. * @returns picking info of the intersecton
  10598. */
  10599. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param meshes the meshes to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @param results array to store result in
  10605. * @returns Array of picking infos
  10606. */
  10607. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10608. private _comparePickingInfo;
  10609. private static smallnum;
  10610. private static rayl;
  10611. /**
  10612. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10613. * @param sega the first point of the segment to test the intersection against
  10614. * @param segb the second point of the segment to test the intersection against
  10615. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10616. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10617. */
  10618. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10619. /**
  10620. * Update the ray from viewport position
  10621. * @param x position
  10622. * @param y y position
  10623. * @param viewportWidth viewport width
  10624. * @param viewportHeight viewport height
  10625. * @param world world matrix
  10626. * @param view view matrix
  10627. * @param projection projection matrix
  10628. * @returns this ray updated
  10629. */
  10630. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10631. /**
  10632. * Creates a ray with origin and direction of 0,0,0
  10633. * @returns the new ray
  10634. */
  10635. static Zero(): Ray;
  10636. /**
  10637. * Creates a new ray from screen space and viewport
  10638. * @param x position
  10639. * @param y y position
  10640. * @param viewportWidth viewport width
  10641. * @param viewportHeight viewport height
  10642. * @param world world matrix
  10643. * @param view view matrix
  10644. * @param projection projection matrix
  10645. * @returns new ray
  10646. */
  10647. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10648. /**
  10649. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10650. * transformed to the given world matrix.
  10651. * @param origin The origin point
  10652. * @param end The end point
  10653. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10654. * @returns the new ray
  10655. */
  10656. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10657. /**
  10658. * Transforms a ray by a matrix
  10659. * @param ray ray to transform
  10660. * @param matrix matrix to apply
  10661. * @returns the resulting new ray
  10662. */
  10663. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @param result ray to store result in
  10669. */
  10670. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10671. /**
  10672. * Unproject a ray from screen space to object space
  10673. * @param sourceX defines the screen space x coordinate to use
  10674. * @param sourceY defines the screen space y coordinate to use
  10675. * @param viewportWidth defines the current width of the viewport
  10676. * @param viewportHeight defines the current height of the viewport
  10677. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10678. * @param view defines the view matrix to use
  10679. * @param projection defines the projection matrix to use
  10680. */
  10681. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10682. }
  10683. /**
  10684. * Type used to define predicate used to select faces when a mesh intersection is detected
  10685. */
  10686. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10687. module "babylonjs/scene" {
  10688. interface Scene {
  10689. /** @hidden */
  10690. _tempPickingRay: Nullable<Ray>;
  10691. /** @hidden */
  10692. _cachedRayForTransform: Ray;
  10693. /** @hidden */
  10694. _pickWithRayInverseMatrix: Matrix;
  10695. /** @hidden */
  10696. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10697. /** @hidden */
  10698. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10699. }
  10700. }
  10701. }
  10702. declare module "babylonjs/sceneComponent" {
  10703. import { Scene } from "babylonjs/scene";
  10704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10705. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10706. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10707. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10708. import { Nullable } from "babylonjs/types";
  10709. import { Camera } from "babylonjs/Cameras/camera";
  10710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10712. import { AbstractScene } from "babylonjs/abstractScene";
  10713. import { Mesh } from "babylonjs/Meshes/mesh";
  10714. /**
  10715. * Groups all the scene component constants in one place to ease maintenance.
  10716. * @hidden
  10717. */
  10718. export class SceneComponentConstants {
  10719. static readonly NAME_EFFECTLAYER: string;
  10720. static readonly NAME_LAYER: string;
  10721. static readonly NAME_LENSFLARESYSTEM: string;
  10722. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10723. static readonly NAME_PARTICLESYSTEM: string;
  10724. static readonly NAME_GAMEPAD: string;
  10725. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10726. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10727. static readonly NAME_DEPTHRENDERER: string;
  10728. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10729. static readonly NAME_SPRITE: string;
  10730. static readonly NAME_OUTLINERENDERER: string;
  10731. static readonly NAME_PROCEDURALTEXTURE: string;
  10732. static readonly NAME_SHADOWGENERATOR: string;
  10733. static readonly NAME_OCTREE: string;
  10734. static readonly NAME_PHYSICSENGINE: string;
  10735. static readonly NAME_AUDIO: string;
  10736. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10737. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10739. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10740. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10742. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10744. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10747. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10749. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10750. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10751. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10754. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10755. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_POINTERMOVE_SPRITE: number;
  10763. static readonly STEP_POINTERDOWN_SPRITE: number;
  10764. static readonly STEP_POINTERUP_SPRITE: number;
  10765. }
  10766. /**
  10767. * This represents a scene component.
  10768. *
  10769. * This is used to decouple the dependency the scene is having on the different workloads like
  10770. * layers, post processes...
  10771. */
  10772. export interface ISceneComponent {
  10773. /**
  10774. * The name of the component. Each component must have a unique name.
  10775. */
  10776. name: string;
  10777. /**
  10778. * The scene the component belongs to.
  10779. */
  10780. scene: Scene;
  10781. /**
  10782. * Register the component to one instance of a scene.
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. }
  10795. /**
  10796. * This represents a SERIALIZABLE scene component.
  10797. *
  10798. * This extends Scene Component to add Serialization methods on top.
  10799. */
  10800. export interface ISceneSerializableComponent extends ISceneComponent {
  10801. /**
  10802. * Adds all the elements from the container to the scene
  10803. * @param container the container holding the elements
  10804. */
  10805. addFromContainer(container: AbstractScene): void;
  10806. /**
  10807. * Removes all the elements in the container from the scene
  10808. * @param container contains the elements to remove
  10809. * @param dispose if the removed element should be disposed (default: false)
  10810. */
  10811. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10812. /**
  10813. * Serializes the component data to the specified json object
  10814. * @param serializationObject The object to serialize to
  10815. */
  10816. serialize(serializationObject: any): void;
  10817. }
  10818. /**
  10819. * Strong typing of a Mesh related stage step action
  10820. */
  10821. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10822. /**
  10823. * Strong typing of a Evaluate Sub Mesh related stage step action
  10824. */
  10825. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10826. /**
  10827. * Strong typing of a Active Mesh related stage step action
  10828. */
  10829. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10830. /**
  10831. * Strong typing of a Camera related stage step action
  10832. */
  10833. export type CameraStageAction = (camera: Camera) => void;
  10834. /**
  10835. * Strong typing of a Camera Frame buffer related stage step action
  10836. */
  10837. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10838. /**
  10839. * Strong typing of a Render Target related stage step action
  10840. */
  10841. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10842. /**
  10843. * Strong typing of a RenderingGroup related stage step action
  10844. */
  10845. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10846. /**
  10847. * Strong typing of a Mesh Render related stage step action
  10848. */
  10849. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10850. /**
  10851. * Strong typing of a simple stage step action
  10852. */
  10853. export type SimpleStageAction = () => void;
  10854. /**
  10855. * Strong typing of a render target action.
  10856. */
  10857. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10858. /**
  10859. * Strong typing of a pointer move action.
  10860. */
  10861. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10862. /**
  10863. * Strong typing of a pointer up/down action.
  10864. */
  10865. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10866. /**
  10867. * Representation of a stage in the scene (Basically a list of ordered steps)
  10868. * @hidden
  10869. */
  10870. export class Stage<T extends Function> extends Array<{
  10871. index: number;
  10872. component: ISceneComponent;
  10873. action: T;
  10874. }> {
  10875. /**
  10876. * Hide ctor from the rest of the world.
  10877. * @param items The items to add.
  10878. */
  10879. private constructor();
  10880. /**
  10881. * Creates a new Stage.
  10882. * @returns A new instance of a Stage
  10883. */
  10884. static Create<T extends Function>(): Stage<T>;
  10885. /**
  10886. * Registers a step in an ordered way in the targeted stage.
  10887. * @param index Defines the position to register the step in
  10888. * @param component Defines the component attached to the step
  10889. * @param action Defines the action to launch during the step
  10890. */
  10891. registerStep(index: number, component: ISceneComponent, action: T): void;
  10892. /**
  10893. * Clears all the steps from the stage.
  10894. */
  10895. clear(): void;
  10896. }
  10897. }
  10898. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10899. import { Nullable } from "babylonjs/types";
  10900. import { Observable } from "babylonjs/Misc/observable";
  10901. import { Scene } from "babylonjs/scene";
  10902. import { Sprite } from "babylonjs/Sprites/sprite";
  10903. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10904. import { Ray } from "babylonjs/Culling/ray";
  10905. import { Camera } from "babylonjs/Cameras/camera";
  10906. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10907. import { ISceneComponent } from "babylonjs/sceneComponent";
  10908. module "babylonjs/scene" {
  10909. interface Scene {
  10910. /** @hidden */
  10911. _pointerOverSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _pickedDownSprite: Nullable<Sprite>;
  10914. /** @hidden */
  10915. _tempSpritePickingRay: Nullable<Ray>;
  10916. /**
  10917. * All of the sprite managers added to this scene
  10918. * @see http://doc.babylonjs.com/babylon101/sprites
  10919. */
  10920. spriteManagers: Array<ISpriteManager>;
  10921. /**
  10922. * An event triggered when sprites rendering is about to start
  10923. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10924. */
  10925. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10926. /**
  10927. * An event triggered when sprites rendering is done
  10928. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10929. */
  10930. onAfterSpritesRenderingObservable: Observable<Scene>;
  10931. /** @hidden */
  10932. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Launch a ray to try to pick a sprite in the scene
  10934. * @param x position on screen
  10935. * @param y position on screen
  10936. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10937. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10938. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10939. * @returns a PickingInfo
  10940. */
  10941. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10942. /** Use the given ray to pick a sprite in the scene
  10943. * @param ray The ray (in world space) to use to pick meshes
  10944. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10945. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10946. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10947. * @returns a PickingInfo
  10948. */
  10949. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10950. /** @hidden */
  10951. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10952. /** Launch a ray to try to pick sprites in the scene
  10953. * @param x position on screen
  10954. * @param y position on screen
  10955. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10956. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10957. * @returns a PickingInfo array
  10958. */
  10959. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10960. /** Use the given ray to pick sprites in the scene
  10961. * @param ray The ray (in world space) to use to pick meshes
  10962. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10963. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10964. * @returns a PickingInfo array
  10965. */
  10966. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10967. /**
  10968. * Force the sprite under the pointer
  10969. * @param sprite defines the sprite to use
  10970. */
  10971. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10972. /**
  10973. * Gets the sprite under the pointer
  10974. * @returns a Sprite or null if no sprite is under the pointer
  10975. */
  10976. getPointerOverSprite(): Nullable<Sprite>;
  10977. }
  10978. }
  10979. /**
  10980. * Defines the sprite scene component responsible to manage sprites
  10981. * in a given scene.
  10982. */
  10983. export class SpriteSceneComponent implements ISceneComponent {
  10984. /**
  10985. * The component name helpfull to identify the component in the list of scene components.
  10986. */
  10987. readonly name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /** @hidden */
  10993. private _spritePredicate;
  10994. /**
  10995. * Creates a new instance of the component for the given scene
  10996. * @param scene Defines the scene to register the component in
  10997. */
  10998. constructor(scene: Scene);
  10999. /**
  11000. * Registers the component in a given scene
  11001. */
  11002. register(): void;
  11003. /**
  11004. * Rebuilds the elements related to this component in case of
  11005. * context lost for instance.
  11006. */
  11007. rebuild(): void;
  11008. /**
  11009. * Disposes the component and the associated ressources.
  11010. */
  11011. dispose(): void;
  11012. private _pickSpriteButKeepRay;
  11013. private _pointerMove;
  11014. private _pointerDown;
  11015. private _pointerUp;
  11016. }
  11017. }
  11018. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11019. /** @hidden */
  11020. export var fogFragmentDeclaration: {
  11021. name: string;
  11022. shader: string;
  11023. };
  11024. }
  11025. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11026. /** @hidden */
  11027. export var fogFragment: {
  11028. name: string;
  11029. shader: string;
  11030. };
  11031. }
  11032. declare module "babylonjs/Shaders/sprites.fragment" {
  11033. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11034. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11035. /** @hidden */
  11036. export var spritesPixelShader: {
  11037. name: string;
  11038. shader: string;
  11039. };
  11040. }
  11041. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11042. /** @hidden */
  11043. export var fogVertexDeclaration: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module "babylonjs/Shaders/sprites.vertex" {
  11049. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11050. /** @hidden */
  11051. export var spritesVertexShader: {
  11052. name: string;
  11053. shader: string;
  11054. };
  11055. }
  11056. declare module "babylonjs/Sprites/spriteManager" {
  11057. import { IDisposable, Scene } from "babylonjs/scene";
  11058. import { Nullable } from "babylonjs/types";
  11059. import { Observable } from "babylonjs/Misc/observable";
  11060. import { Sprite } from "babylonjs/Sprites/sprite";
  11061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11062. import { Camera } from "babylonjs/Cameras/camera";
  11063. import { Texture } from "babylonjs/Materials/Textures/texture";
  11064. import "babylonjs/Shaders/sprites.fragment";
  11065. import "babylonjs/Shaders/sprites.vertex";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. /**
  11068. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11069. */
  11070. export interface ISpriteManager extends IDisposable {
  11071. /**
  11072. * Gets manager's name
  11073. */
  11074. name: string;
  11075. /**
  11076. * Restricts the camera to viewing objects with the same layerMask.
  11077. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11078. */
  11079. layerMask: number;
  11080. /**
  11081. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11082. */
  11083. isPickable: boolean;
  11084. /**
  11085. * Gets the hosting scene
  11086. */
  11087. scene: Scene;
  11088. /**
  11089. * Specifies the rendering group id for this mesh (0 by default)
  11090. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11091. */
  11092. renderingGroupId: number;
  11093. /**
  11094. * Defines the list of sprites managed by the manager.
  11095. */
  11096. sprites: Array<Sprite>;
  11097. /**
  11098. * Gets or sets the spritesheet texture
  11099. */
  11100. texture: Texture;
  11101. /** Defines the default width of a cell in the spritesheet */
  11102. cellWidth: number;
  11103. /** Defines the default height of a cell in the spritesheet */
  11104. cellHeight: number;
  11105. /**
  11106. * Tests the intersection of a sprite with a specific ray.
  11107. * @param ray The ray we are sending to test the collision
  11108. * @param camera The camera space we are sending rays in
  11109. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11110. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11111. * @returns picking info or null.
  11112. */
  11113. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11114. /**
  11115. * Intersects the sprites with a ray
  11116. * @param ray defines the ray to intersect with
  11117. * @param camera defines the current active camera
  11118. * @param predicate defines a predicate used to select candidate sprites
  11119. * @returns null if no hit or a PickingInfo array
  11120. */
  11121. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11122. /**
  11123. * Renders the list of sprites on screen.
  11124. */
  11125. render(): void;
  11126. }
  11127. /**
  11128. * Class used to manage multiple sprites on the same spritesheet
  11129. * @see http://doc.babylonjs.com/babylon101/sprites
  11130. */
  11131. export class SpriteManager implements ISpriteManager {
  11132. /** defines the manager's name */
  11133. name: string;
  11134. /** Define the Url to load snippets */
  11135. static SnippetUrl: string;
  11136. /** Snippet ID if the manager was created from the snippet server */
  11137. snippetId: string;
  11138. /** Gets the list of sprites */
  11139. sprites: Sprite[];
  11140. /** Gets or sets the rendering group id (0 by default) */
  11141. renderingGroupId: number;
  11142. /** Gets or sets camera layer mask */
  11143. layerMask: number;
  11144. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11145. fogEnabled: boolean;
  11146. /** Gets or sets a boolean indicating if the sprites are pickable */
  11147. isPickable: boolean;
  11148. /** Defines the default width of a cell in the spritesheet */
  11149. cellWidth: number;
  11150. /** Defines the default height of a cell in the spritesheet */
  11151. cellHeight: number;
  11152. /** Associative array from JSON sprite data file */
  11153. private _cellData;
  11154. /** Array of sprite names from JSON sprite data file */
  11155. private _spriteMap;
  11156. /** True when packed cell data from JSON file is ready*/
  11157. private _packedAndReady;
  11158. private _textureContent;
  11159. /**
  11160. * An event triggered when the manager is disposed.
  11161. */
  11162. onDisposeObservable: Observable<SpriteManager>;
  11163. private _onDisposeObserver;
  11164. /**
  11165. * Callback called when the manager is disposed
  11166. */
  11167. set onDispose(callback: () => void);
  11168. private _capacity;
  11169. private _fromPacked;
  11170. private _spriteTexture;
  11171. private _epsilon;
  11172. private _scene;
  11173. private _vertexData;
  11174. private _buffer;
  11175. private _vertexBuffers;
  11176. private _indexBuffer;
  11177. private _effectBase;
  11178. private _effectFog;
  11179. /**
  11180. * Gets or sets the unique id of the sprite
  11181. */
  11182. uniqueId: number;
  11183. /**
  11184. * Gets the array of sprites
  11185. */
  11186. get children(): Sprite[];
  11187. /**
  11188. * Gets the hosting scene
  11189. */
  11190. get scene(): Scene;
  11191. /**
  11192. * Gets the capacity of the manager
  11193. */
  11194. get capacity(): number;
  11195. /**
  11196. * Gets or sets the spritesheet texture
  11197. */
  11198. get texture(): Texture;
  11199. set texture(value: Texture);
  11200. private _blendMode;
  11201. /**
  11202. * Blend mode use to render the particle, it can be any of
  11203. * the static Constants.ALPHA_x properties provided in this class.
  11204. * Default value is Constants.ALPHA_COMBINE
  11205. */
  11206. get blendMode(): number;
  11207. set blendMode(blendMode: number);
  11208. /** Disables writing to the depth buffer when rendering the sprites.
  11209. * It can be handy to disable depth writing when using textures without alpha channel
  11210. * and setting some specific blend modes.
  11211. */
  11212. disableDepthWrite: boolean;
  11213. /**
  11214. * Creates a new sprite manager
  11215. * @param name defines the manager's name
  11216. * @param imgUrl defines the sprite sheet url
  11217. * @param capacity defines the maximum allowed number of sprites
  11218. * @param cellSize defines the size of a sprite cell
  11219. * @param scene defines the hosting scene
  11220. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11221. * @param samplingMode defines the smapling mode to use with spritesheet
  11222. * @param fromPacked set to false; do not alter
  11223. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11224. */
  11225. constructor(
  11226. /** defines the manager's name */
  11227. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11228. /**
  11229. * Returns the string "SpriteManager"
  11230. * @returns "SpriteManager"
  11231. */
  11232. getClassName(): string;
  11233. private _makePacked;
  11234. private _appendSpriteVertex;
  11235. private _checkTextureAlpha;
  11236. /**
  11237. * Intersects the sprites with a ray
  11238. * @param ray defines the ray to intersect with
  11239. * @param camera defines the current active camera
  11240. * @param predicate defines a predicate used to select candidate sprites
  11241. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11242. * @returns null if no hit or a PickingInfo
  11243. */
  11244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11245. /**
  11246. * Intersects the sprites with a ray
  11247. * @param ray defines the ray to intersect with
  11248. * @param camera defines the current active camera
  11249. * @param predicate defines a predicate used to select candidate sprites
  11250. * @returns null if no hit or a PickingInfo array
  11251. */
  11252. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11253. /**
  11254. * Render all child sprites
  11255. */
  11256. render(): void;
  11257. /**
  11258. * Release associated resources
  11259. */
  11260. dispose(): void;
  11261. /**
  11262. * Serializes the sprite manager to a JSON object
  11263. * @param serializeTexture defines if the texture must be serialized as well
  11264. * @returns the JSON object
  11265. */
  11266. serialize(serializeTexture?: boolean): any;
  11267. /**
  11268. * Parses a JSON object to create a new sprite manager.
  11269. * @param parsedManager The JSON object to parse
  11270. * @param scene The scene to create the sprite managerin
  11271. * @param rootUrl The root url to use to load external dependencies like texture
  11272. * @returns the new sprite manager
  11273. */
  11274. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11275. /**
  11276. * Creates a sprite manager from a snippet saved in a remote file
  11277. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11278. * @param url defines the url to load from
  11279. * @param scene defines the hosting scene
  11280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11281. * @returns a promise that will resolve to the new sprite manager
  11282. */
  11283. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11284. /**
  11285. * Creates a sprite manager from a snippet saved by the sprite editor
  11286. * @param snippetId defines the snippet to load
  11287. * @param scene defines the hosting scene
  11288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11289. * @returns a promise that will resolve to the new sprite manager
  11290. */
  11291. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11292. }
  11293. }
  11294. declare module "babylonjs/Misc/gradients" {
  11295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11296. /** Interface used by value gradients (color, factor, ...) */
  11297. export interface IValueGradient {
  11298. /**
  11299. * Gets or sets the gradient value (between 0 and 1)
  11300. */
  11301. gradient: number;
  11302. }
  11303. /** Class used to store color4 gradient */
  11304. export class ColorGradient implements IValueGradient {
  11305. /**
  11306. * Gets or sets the gradient value (between 0 and 1)
  11307. */
  11308. gradient: number;
  11309. /**
  11310. * Gets or sets first associated color
  11311. */
  11312. color1: Color4;
  11313. /**
  11314. * Gets or sets second associated color
  11315. */
  11316. color2?: Color4 | undefined;
  11317. /**
  11318. * Creates a new color4 gradient
  11319. * @param gradient gets or sets the gradient value (between 0 and 1)
  11320. * @param color1 gets or sets first associated color
  11321. * @param color2 gets or sets first second color
  11322. */
  11323. constructor(
  11324. /**
  11325. * Gets or sets the gradient value (between 0 and 1)
  11326. */
  11327. gradient: number,
  11328. /**
  11329. * Gets or sets first associated color
  11330. */
  11331. color1: Color4,
  11332. /**
  11333. * Gets or sets second associated color
  11334. */
  11335. color2?: Color4 | undefined);
  11336. /**
  11337. * Will get a color picked randomly between color1 and color2.
  11338. * If color2 is undefined then color1 will be used
  11339. * @param result defines the target Color4 to store the result in
  11340. */
  11341. getColorToRef(result: Color4): void;
  11342. }
  11343. /** Class used to store color 3 gradient */
  11344. export class Color3Gradient implements IValueGradient {
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number;
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3;
  11353. /**
  11354. * Creates a new color3 gradient
  11355. * @param gradient gets or sets the gradient value (between 0 and 1)
  11356. * @param color gets or sets associated color
  11357. */
  11358. constructor(
  11359. /**
  11360. * Gets or sets the gradient value (between 0 and 1)
  11361. */
  11362. gradient: number,
  11363. /**
  11364. * Gets or sets the associated color
  11365. */
  11366. color: Color3);
  11367. }
  11368. /** Class used to store factor gradient */
  11369. export class FactorGradient implements IValueGradient {
  11370. /**
  11371. * Gets or sets the gradient value (between 0 and 1)
  11372. */
  11373. gradient: number;
  11374. /**
  11375. * Gets or sets first associated factor
  11376. */
  11377. factor1: number;
  11378. /**
  11379. * Gets or sets second associated factor
  11380. */
  11381. factor2?: number | undefined;
  11382. /**
  11383. * Creates a new factor gradient
  11384. * @param gradient gets or sets the gradient value (between 0 and 1)
  11385. * @param factor1 gets or sets first associated factor
  11386. * @param factor2 gets or sets second associated factor
  11387. */
  11388. constructor(
  11389. /**
  11390. * Gets or sets the gradient value (between 0 and 1)
  11391. */
  11392. gradient: number,
  11393. /**
  11394. * Gets or sets first associated factor
  11395. */
  11396. factor1: number,
  11397. /**
  11398. * Gets or sets second associated factor
  11399. */
  11400. factor2?: number | undefined);
  11401. /**
  11402. * Will get a number picked randomly between factor1 and factor2.
  11403. * If factor2 is undefined then factor1 will be used
  11404. * @returns the picked number
  11405. */
  11406. getFactor(): number;
  11407. }
  11408. /**
  11409. * Helper used to simplify some generic gradient tasks
  11410. */
  11411. export class GradientHelper {
  11412. /**
  11413. * Gets the current gradient from an array of IValueGradient
  11414. * @param ratio defines the current ratio to get
  11415. * @param gradients defines the array of IValueGradient
  11416. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11417. */
  11418. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11419. }
  11420. }
  11421. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11422. import { Nullable } from "babylonjs/types";
  11423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11424. import { Scene } from "babylonjs/scene";
  11425. module "babylonjs/Engines/thinEngine" {
  11426. interface ThinEngine {
  11427. /**
  11428. * Creates a raw texture
  11429. * @param data defines the data to store in the texture
  11430. * @param width defines the width of the texture
  11431. * @param height defines the height of the texture
  11432. * @param format defines the format of the data
  11433. * @param generateMipMaps defines if the engine should generate the mip levels
  11434. * @param invertY defines if data must be stored with Y axis inverted
  11435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11436. * @param compression defines the compression used (null by default)
  11437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11438. * @returns the raw texture inside an InternalTexture
  11439. */
  11440. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11441. /**
  11442. * Update a raw texture
  11443. * @param texture defines the texture to update
  11444. * @param data defines the data to store in the texture
  11445. * @param format defines the format of the data
  11446. * @param invertY defines if data must be stored with Y axis inverted
  11447. */
  11448. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11449. /**
  11450. * Update a raw texture
  11451. * @param texture defines the texture to update
  11452. * @param data defines the data to store in the texture
  11453. * @param format defines the format of the data
  11454. * @param invertY defines if data must be stored with Y axis inverted
  11455. * @param compression defines the compression used (null by default)
  11456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11457. */
  11458. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11459. /**
  11460. * Creates a new raw cube texture
  11461. * @param data defines the array of data to use to create each face
  11462. * @param size defines the size of the textures
  11463. * @param format defines the format of the data
  11464. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11465. * @param generateMipMaps defines if the engine should generate the mip levels
  11466. * @param invertY defines if data must be stored with Y axis inverted
  11467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11468. * @param compression defines the compression used (null by default)
  11469. * @returns the cube texture as an InternalTexture
  11470. */
  11471. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11472. /**
  11473. * Update a raw cube texture
  11474. * @param texture defines the texture to udpdate
  11475. * @param data defines the data to store
  11476. * @param format defines the data format
  11477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11478. * @param invertY defines if data must be stored with Y axis inverted
  11479. */
  11480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11481. /**
  11482. * Update a raw cube texture
  11483. * @param texture defines the texture to udpdate
  11484. * @param data defines the data to store
  11485. * @param format defines the data format
  11486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11487. * @param invertY defines if data must be stored with Y axis inverted
  11488. * @param compression defines the compression used (null by default)
  11489. */
  11490. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11491. /**
  11492. * Update a raw cube texture
  11493. * @param texture defines the texture to udpdate
  11494. * @param data defines the data to store
  11495. * @param format defines the data format
  11496. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11497. * @param invertY defines if data must be stored with Y axis inverted
  11498. * @param compression defines the compression used (null by default)
  11499. * @param level defines which level of the texture to update
  11500. */
  11501. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11502. /**
  11503. * Creates a new raw cube texture from a specified url
  11504. * @param url defines the url where the data is located
  11505. * @param scene defines the current scene
  11506. * @param size defines the size of the textures
  11507. * @param format defines the format of the data
  11508. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11509. * @param noMipmap defines if the engine should avoid generating the mip levels
  11510. * @param callback defines a callback used to extract texture data from loaded data
  11511. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11512. * @param onLoad defines a callback called when texture is loaded
  11513. * @param onError defines a callback called if there is an error
  11514. * @returns the cube texture as an InternalTexture
  11515. */
  11516. 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;
  11517. /**
  11518. * Creates a new raw cube texture from a specified url
  11519. * @param url defines the url where the data is located
  11520. * @param scene defines the current scene
  11521. * @param size defines the size of the textures
  11522. * @param format defines the format of the data
  11523. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11524. * @param noMipmap defines if the engine should avoid generating the mip levels
  11525. * @param callback defines a callback used to extract texture data from loaded data
  11526. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11527. * @param onLoad defines a callback called when texture is loaded
  11528. * @param onError defines a callback called if there is an error
  11529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11530. * @param invertY defines if data must be stored with Y axis inverted
  11531. * @returns the cube texture as an InternalTexture
  11532. */
  11533. 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;
  11534. /**
  11535. * Creates a new raw 3D texture
  11536. * @param data defines the data used to create the texture
  11537. * @param width defines the width of the texture
  11538. * @param height defines the height of the texture
  11539. * @param depth defines the depth of the texture
  11540. * @param format defines the format of the texture
  11541. * @param generateMipMaps defines if the engine must generate mip levels
  11542. * @param invertY defines if data must be stored with Y axis inverted
  11543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11544. * @param compression defines the compressed used (can be null)
  11545. * @param textureType defines the compressed used (can be null)
  11546. * @returns a new raw 3D texture (stored in an InternalTexture)
  11547. */
  11548. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11549. /**
  11550. * Update a raw 3D texture
  11551. * @param texture defines the texture to update
  11552. * @param data defines the data to store
  11553. * @param format defines the data format
  11554. * @param invertY defines if data must be stored with Y axis inverted
  11555. */
  11556. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11557. /**
  11558. * Update a raw 3D texture
  11559. * @param texture defines the texture to update
  11560. * @param data defines the data to store
  11561. * @param format defines the data format
  11562. * @param invertY defines if data must be stored with Y axis inverted
  11563. * @param compression defines the used compression (can be null)
  11564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11565. */
  11566. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11567. /**
  11568. * Creates a new raw 2D array texture
  11569. * @param data defines the data used to create the texture
  11570. * @param width defines the width of the texture
  11571. * @param height defines the height of the texture
  11572. * @param depth defines the number of layers of the texture
  11573. * @param format defines the format of the texture
  11574. * @param generateMipMaps defines if the engine must generate mip levels
  11575. * @param invertY defines if data must be stored with Y axis inverted
  11576. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11577. * @param compression defines the compressed used (can be null)
  11578. * @param textureType defines the compressed used (can be null)
  11579. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11580. */
  11581. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11582. /**
  11583. * Update a raw 2D array texture
  11584. * @param texture defines the texture to update
  11585. * @param data defines the data to store
  11586. * @param format defines the data format
  11587. * @param invertY defines if data must be stored with Y axis inverted
  11588. */
  11589. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11590. /**
  11591. * Update a raw 2D array texture
  11592. * @param texture defines the texture to update
  11593. * @param data defines the data to store
  11594. * @param format defines the data format
  11595. * @param invertY defines if data must be stored with Y axis inverted
  11596. * @param compression defines the used compression (can be null)
  11597. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11598. */
  11599. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11600. }
  11601. }
  11602. }
  11603. declare module "babylonjs/Materials/Textures/rawTexture" {
  11604. import { Scene } from "babylonjs/scene";
  11605. import { Texture } from "babylonjs/Materials/Textures/texture";
  11606. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11607. /**
  11608. * Raw texture can help creating a texture directly from an array of data.
  11609. * This can be super useful if you either get the data from an uncompressed source or
  11610. * if you wish to create your texture pixel by pixel.
  11611. */
  11612. export class RawTexture extends Texture {
  11613. /**
  11614. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11615. */
  11616. format: number;
  11617. /**
  11618. * Instantiates a new RawTexture.
  11619. * Raw texture can help creating a texture directly from an array of data.
  11620. * This can be super useful if you either get the data from an uncompressed source or
  11621. * if you wish to create your texture pixel by pixel.
  11622. * @param data define the array of data to use to create the texture
  11623. * @param width define the width of the texture
  11624. * @param height define the height of the texture
  11625. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11626. * @param scene define the scene the texture belongs to
  11627. * @param generateMipMaps define whether mip maps should be generated or not
  11628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11631. */
  11632. constructor(data: ArrayBufferView, width: number, height: number,
  11633. /**
  11634. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11635. */
  11636. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11637. /**
  11638. * Updates the texture underlying data.
  11639. * @param data Define the new data of the texture
  11640. */
  11641. update(data: ArrayBufferView): void;
  11642. /**
  11643. * Creates a luminance texture from some data.
  11644. * @param data Define the texture data
  11645. * @param width Define the width of the texture
  11646. * @param height Define the height of the texture
  11647. * @param scene Define the scene the texture belongs to
  11648. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11649. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11650. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11651. * @returns the luminance texture
  11652. */
  11653. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11654. /**
  11655. * Creates a luminance alpha texture from some data.
  11656. * @param data Define the texture data
  11657. * @param width Define the width of the texture
  11658. * @param height Define the height of the texture
  11659. * @param scene Define the scene the texture belongs to
  11660. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11663. * @returns the luminance alpha texture
  11664. */
  11665. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11666. /**
  11667. * Creates an alpha texture from some data.
  11668. * @param data Define the texture data
  11669. * @param width Define the width of the texture
  11670. * @param height Define the height of the texture
  11671. * @param scene Define the scene the texture belongs to
  11672. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11673. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11674. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11675. * @returns the alpha texture
  11676. */
  11677. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11678. /**
  11679. * Creates a RGB texture from some data.
  11680. * @param data Define the texture data
  11681. * @param width Define the width of the texture
  11682. * @param height Define the height of the texture
  11683. * @param scene Define the scene the texture belongs to
  11684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11687. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11688. * @returns the RGB alpha texture
  11689. */
  11690. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11691. /**
  11692. * Creates a RGBA texture from some data.
  11693. * @param data Define the texture data
  11694. * @param width Define the width of the texture
  11695. * @param height Define the height of the texture
  11696. * @param scene Define the scene the texture belongs to
  11697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11700. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11701. * @returns the RGBA texture
  11702. */
  11703. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11704. /**
  11705. * Creates a R texture from some data.
  11706. * @param data Define the texture data
  11707. * @param width Define the width of the texture
  11708. * @param height Define the height of the texture
  11709. * @param scene Define the scene the texture belongs to
  11710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11713. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11714. * @returns the R texture
  11715. */
  11716. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11717. }
  11718. }
  11719. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11720. import { Scene } from "babylonjs/scene";
  11721. import { ISceneComponent } from "babylonjs/sceneComponent";
  11722. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11723. module "babylonjs/abstractScene" {
  11724. interface AbstractScene {
  11725. /**
  11726. * The list of procedural textures added to the scene
  11727. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11728. */
  11729. proceduralTextures: Array<ProceduralTexture>;
  11730. }
  11731. }
  11732. /**
  11733. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11734. * in a given scene.
  11735. */
  11736. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11737. /**
  11738. * The component name helpfull to identify the component in the list of scene components.
  11739. */
  11740. readonly name: string;
  11741. /**
  11742. * The scene the component belongs to.
  11743. */
  11744. scene: Scene;
  11745. /**
  11746. * Creates a new instance of the component for the given scene
  11747. * @param scene Defines the scene to register the component in
  11748. */
  11749. constructor(scene: Scene);
  11750. /**
  11751. * Registers the component in a given scene
  11752. */
  11753. register(): void;
  11754. /**
  11755. * Rebuilds the elements related to this component in case of
  11756. * context lost for instance.
  11757. */
  11758. rebuild(): void;
  11759. /**
  11760. * Disposes the component and the associated ressources.
  11761. */
  11762. dispose(): void;
  11763. private _beforeClear;
  11764. }
  11765. }
  11766. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11767. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11768. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11769. module "babylonjs/Engines/thinEngine" {
  11770. interface ThinEngine {
  11771. /**
  11772. * Creates a new render target cube texture
  11773. * @param size defines the size of the texture
  11774. * @param options defines the options used to create the texture
  11775. * @returns a new render target cube texture stored in an InternalTexture
  11776. */
  11777. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11778. }
  11779. }
  11780. }
  11781. declare module "babylonjs/Shaders/procedural.vertex" {
  11782. /** @hidden */
  11783. export var proceduralVertexShader: {
  11784. name: string;
  11785. shader: string;
  11786. };
  11787. }
  11788. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11789. import { Observable } from "babylonjs/Misc/observable";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { Scene } from "babylonjs/scene";
  11792. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11793. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11794. import { Effect } from "babylonjs/Materials/effect";
  11795. import { Texture } from "babylonjs/Materials/Textures/texture";
  11796. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11797. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11798. import "babylonjs/Shaders/procedural.vertex";
  11799. /**
  11800. * 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.
  11801. * This is the base class of any Procedural texture and contains most of the shareable code.
  11802. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11803. */
  11804. export class ProceduralTexture extends Texture {
  11805. isCube: boolean;
  11806. /**
  11807. * Define if the texture is enabled or not (disabled texture will not render)
  11808. */
  11809. isEnabled: boolean;
  11810. /**
  11811. * Define if the texture must be cleared before rendering (default is true)
  11812. */
  11813. autoClear: boolean;
  11814. /**
  11815. * Callback called when the texture is generated
  11816. */
  11817. onGenerated: () => void;
  11818. /**
  11819. * Event raised when the texture is generated
  11820. */
  11821. onGeneratedObservable: Observable<ProceduralTexture>;
  11822. /** @hidden */
  11823. _generateMipMaps: boolean;
  11824. /** @hidden **/
  11825. _effect: Effect;
  11826. /** @hidden */
  11827. _textures: {
  11828. [key: string]: Texture;
  11829. };
  11830. /** @hidden */
  11831. protected _fallbackTexture: Nullable<Texture>;
  11832. private _size;
  11833. private _currentRefreshId;
  11834. private _frameId;
  11835. private _refreshRate;
  11836. private _vertexBuffers;
  11837. private _indexBuffer;
  11838. private _uniforms;
  11839. private _samplers;
  11840. private _fragment;
  11841. private _floats;
  11842. private _ints;
  11843. private _floatsArrays;
  11844. private _colors3;
  11845. private _colors4;
  11846. private _vectors2;
  11847. private _vectors3;
  11848. private _matrices;
  11849. private _fallbackTextureUsed;
  11850. private _fullEngine;
  11851. private _cachedDefines;
  11852. private _contentUpdateId;
  11853. private _contentData;
  11854. /**
  11855. * Instantiates a new procedural texture.
  11856. * 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.
  11857. * This is the base class of any Procedural texture and contains most of the shareable code.
  11858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11859. * @param name Define the name of the texture
  11860. * @param size Define the size of the texture to create
  11861. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11862. * @param scene Define the scene the texture belongs to
  11863. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11864. * @param generateMipMaps Define if the texture should creates mip maps or not
  11865. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11866. */
  11867. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11868. /**
  11869. * The effect that is created when initializing the post process.
  11870. * @returns The created effect corresponding the the postprocess.
  11871. */
  11872. getEffect(): Effect;
  11873. /**
  11874. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11875. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11876. */
  11877. getContent(): Nullable<ArrayBufferView>;
  11878. private _createIndexBuffer;
  11879. /** @hidden */
  11880. _rebuild(): void;
  11881. /**
  11882. * Resets the texture in order to recreate its associated resources.
  11883. * This can be called in case of context loss
  11884. */
  11885. reset(): void;
  11886. protected _getDefines(): string;
  11887. /**
  11888. * Is the texture ready to be used ? (rendered at least once)
  11889. * @returns true if ready, otherwise, false.
  11890. */
  11891. isReady(): boolean;
  11892. /**
  11893. * Resets the refresh counter of the texture and start bak from scratch.
  11894. * Could be useful to regenerate the texture if it is setup to render only once.
  11895. */
  11896. resetRefreshCounter(): void;
  11897. /**
  11898. * Set the fragment shader to use in order to render the texture.
  11899. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11900. */
  11901. setFragment(fragment: any): void;
  11902. /**
  11903. * Define the refresh rate of the texture or the rendering frequency.
  11904. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11905. */
  11906. get refreshRate(): number;
  11907. set refreshRate(value: number);
  11908. /** @hidden */
  11909. _shouldRender(): boolean;
  11910. /**
  11911. * Get the size the texture is rendering at.
  11912. * @returns the size (texture is always squared)
  11913. */
  11914. getRenderSize(): number;
  11915. /**
  11916. * Resize the texture to new value.
  11917. * @param size Define the new size the texture should have
  11918. * @param generateMipMaps Define whether the new texture should create mip maps
  11919. */
  11920. resize(size: number, generateMipMaps: boolean): void;
  11921. private _checkUniform;
  11922. /**
  11923. * Set a texture in the shader program used to render.
  11924. * @param name Define the name of the uniform samplers as defined in the shader
  11925. * @param texture Define the texture to bind to this sampler
  11926. * @return the texture itself allowing "fluent" like uniform updates
  11927. */
  11928. setTexture(name: string, texture: Texture): ProceduralTexture;
  11929. /**
  11930. * Set a float in the shader.
  11931. * @param name Define the name of the uniform as defined in the shader
  11932. * @param value Define the value to give to the uniform
  11933. * @return the texture itself allowing "fluent" like uniform updates
  11934. */
  11935. setFloat(name: string, value: number): ProceduralTexture;
  11936. /**
  11937. * Set a int in the shader.
  11938. * @param name Define the name of the uniform as defined in the shader
  11939. * @param value Define the value to give to the uniform
  11940. * @return the texture itself allowing "fluent" like uniform updates
  11941. */
  11942. setInt(name: string, value: number): ProceduralTexture;
  11943. /**
  11944. * Set an array of floats in the shader.
  11945. * @param name Define the name of the uniform as defined in the shader
  11946. * @param value Define the value to give to the uniform
  11947. * @return the texture itself allowing "fluent" like uniform updates
  11948. */
  11949. setFloats(name: string, value: number[]): ProceduralTexture;
  11950. /**
  11951. * Set a vec3 in the shader from a Color3.
  11952. * @param name Define the name of the uniform as defined in the shader
  11953. * @param value Define the value to give to the uniform
  11954. * @return the texture itself allowing "fluent" like uniform updates
  11955. */
  11956. setColor3(name: string, value: Color3): ProceduralTexture;
  11957. /**
  11958. * Set a vec4 in the shader from a Color4.
  11959. * @param name Define the name of the uniform as defined in the shader
  11960. * @param value Define the value to give to the uniform
  11961. * @return the texture itself allowing "fluent" like uniform updates
  11962. */
  11963. setColor4(name: string, value: Color4): ProceduralTexture;
  11964. /**
  11965. * Set a vec2 in the shader from a Vector2.
  11966. * @param name Define the name of the uniform as defined in the shader
  11967. * @param value Define the value to give to the uniform
  11968. * @return the texture itself allowing "fluent" like uniform updates
  11969. */
  11970. setVector2(name: string, value: Vector2): ProceduralTexture;
  11971. /**
  11972. * Set a vec3 in the shader from a Vector3.
  11973. * @param name Define the name of the uniform as defined in the shader
  11974. * @param value Define the value to give to the uniform
  11975. * @return the texture itself allowing "fluent" like uniform updates
  11976. */
  11977. setVector3(name: string, value: Vector3): ProceduralTexture;
  11978. /**
  11979. * Set a mat4 in the shader from a MAtrix.
  11980. * @param name Define the name of the uniform as defined in the shader
  11981. * @param value Define the value to give to the uniform
  11982. * @return the texture itself allowing "fluent" like uniform updates
  11983. */
  11984. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11985. /**
  11986. * Render the texture to its associated render target.
  11987. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11988. */
  11989. render(useCameraPostProcess?: boolean): void;
  11990. /**
  11991. * Clone the texture.
  11992. * @returns the cloned texture
  11993. */
  11994. clone(): ProceduralTexture;
  11995. /**
  11996. * Dispose the texture and release its asoociated resources.
  11997. */
  11998. dispose(): void;
  11999. }
  12000. }
  12001. declare module "babylonjs/Particles/baseParticleSystem" {
  12002. import { Nullable } from "babylonjs/types";
  12003. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12005. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12006. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12007. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12008. import { Scene } from "babylonjs/scene";
  12009. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12010. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12011. import { Texture } from "babylonjs/Materials/Textures/texture";
  12012. import { Color4 } from "babylonjs/Maths/math.color";
  12013. import { Animation } from "babylonjs/Animations/animation";
  12014. /**
  12015. * This represents the base class for particle system in Babylon.
  12016. * 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.
  12017. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12018. * @example https://doc.babylonjs.com/babylon101/particles
  12019. */
  12020. export class BaseParticleSystem {
  12021. /**
  12022. * Source color is added to the destination color without alpha affecting the result
  12023. */
  12024. static BLENDMODE_ONEONE: number;
  12025. /**
  12026. * Blend current color and particle color using particle’s alpha
  12027. */
  12028. static BLENDMODE_STANDARD: number;
  12029. /**
  12030. * Add current color and particle color multiplied by particle’s alpha
  12031. */
  12032. static BLENDMODE_ADD: number;
  12033. /**
  12034. * Multiply current color with particle color
  12035. */
  12036. static BLENDMODE_MULTIPLY: number;
  12037. /**
  12038. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12039. */
  12040. static BLENDMODE_MULTIPLYADD: number;
  12041. /**
  12042. * List of animations used by the particle system.
  12043. */
  12044. animations: Animation[];
  12045. /**
  12046. * Gets or sets the unique id of the particle system
  12047. */
  12048. uniqueId: number;
  12049. /**
  12050. * The id of the Particle system.
  12051. */
  12052. id: string;
  12053. /**
  12054. * The friendly name of the Particle system.
  12055. */
  12056. name: string;
  12057. /**
  12058. * Snippet ID if the particle system was created from the snippet server
  12059. */
  12060. snippetId: string;
  12061. /**
  12062. * The rendering group used by the Particle system to chose when to render.
  12063. */
  12064. renderingGroupId: number;
  12065. /**
  12066. * The emitter represents the Mesh or position we are attaching the particle system to.
  12067. */
  12068. emitter: Nullable<AbstractMesh | Vector3>;
  12069. /**
  12070. * The maximum number of particles to emit per frame
  12071. */
  12072. emitRate: number;
  12073. /**
  12074. * If you want to launch only a few particles at once, that can be done, as well.
  12075. */
  12076. manualEmitCount: number;
  12077. /**
  12078. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12079. */
  12080. updateSpeed: number;
  12081. /**
  12082. * The amount of time the particle system is running (depends of the overall update speed).
  12083. */
  12084. targetStopDuration: number;
  12085. /**
  12086. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12087. */
  12088. disposeOnStop: boolean;
  12089. /**
  12090. * Minimum power of emitting particles.
  12091. */
  12092. minEmitPower: number;
  12093. /**
  12094. * Maximum power of emitting particles.
  12095. */
  12096. maxEmitPower: number;
  12097. /**
  12098. * Minimum life time of emitting particles.
  12099. */
  12100. minLifeTime: number;
  12101. /**
  12102. * Maximum life time of emitting particles.
  12103. */
  12104. maxLifeTime: number;
  12105. /**
  12106. * Minimum Size of emitting particles.
  12107. */
  12108. minSize: number;
  12109. /**
  12110. * Maximum Size of emitting particles.
  12111. */
  12112. maxSize: number;
  12113. /**
  12114. * Minimum scale of emitting particles on X axis.
  12115. */
  12116. minScaleX: number;
  12117. /**
  12118. * Maximum scale of emitting particles on X axis.
  12119. */
  12120. maxScaleX: number;
  12121. /**
  12122. * Minimum scale of emitting particles on Y axis.
  12123. */
  12124. minScaleY: number;
  12125. /**
  12126. * Maximum scale of emitting particles on Y axis.
  12127. */
  12128. maxScaleY: number;
  12129. /**
  12130. * Gets or sets the minimal initial rotation in radians.
  12131. */
  12132. minInitialRotation: number;
  12133. /**
  12134. * Gets or sets the maximal initial rotation in radians.
  12135. */
  12136. maxInitialRotation: number;
  12137. /**
  12138. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12139. */
  12140. minAngularSpeed: number;
  12141. /**
  12142. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12143. */
  12144. maxAngularSpeed: number;
  12145. /**
  12146. * The texture used to render each particle. (this can be a spritesheet)
  12147. */
  12148. particleTexture: Nullable<Texture>;
  12149. /**
  12150. * The layer mask we are rendering the particles through.
  12151. */
  12152. layerMask: number;
  12153. /**
  12154. * This can help using your own shader to render the particle system.
  12155. * The according effect will be created
  12156. */
  12157. customShader: any;
  12158. /**
  12159. * By default particle system starts as soon as they are created. This prevents the
  12160. * automatic start to happen and let you decide when to start emitting particles.
  12161. */
  12162. preventAutoStart: boolean;
  12163. private _noiseTexture;
  12164. /**
  12165. * Gets or sets a texture used to add random noise to particle positions
  12166. */
  12167. get noiseTexture(): Nullable<ProceduralTexture>;
  12168. set noiseTexture(value: Nullable<ProceduralTexture>);
  12169. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12170. noiseStrength: Vector3;
  12171. /**
  12172. * Callback triggered when the particle animation is ending.
  12173. */
  12174. onAnimationEnd: Nullable<() => void>;
  12175. /**
  12176. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12177. */
  12178. blendMode: number;
  12179. /**
  12180. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12181. * to override the particles.
  12182. */
  12183. forceDepthWrite: boolean;
  12184. /** 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 */
  12185. preWarmCycles: number;
  12186. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12187. preWarmStepOffset: number;
  12188. /**
  12189. * 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)
  12190. */
  12191. spriteCellChangeSpeed: number;
  12192. /**
  12193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12194. */
  12195. startSpriteCellID: number;
  12196. /**
  12197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12198. */
  12199. endSpriteCellID: number;
  12200. /**
  12201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12202. */
  12203. spriteCellWidth: number;
  12204. /**
  12205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12206. */
  12207. spriteCellHeight: number;
  12208. /**
  12209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12210. */
  12211. spriteRandomStartCell: boolean;
  12212. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12213. translationPivot: Vector2;
  12214. /** @hidden */
  12215. protected _isAnimationSheetEnabled: boolean;
  12216. /**
  12217. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12218. */
  12219. beginAnimationOnStart: boolean;
  12220. /**
  12221. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12222. */
  12223. beginAnimationFrom: number;
  12224. /**
  12225. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12226. */
  12227. beginAnimationTo: number;
  12228. /**
  12229. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12230. */
  12231. beginAnimationLoop: boolean;
  12232. /**
  12233. * Gets or sets a world offset applied to all particles
  12234. */
  12235. worldOffset: Vector3;
  12236. /**
  12237. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12238. */
  12239. get isAnimationSheetEnabled(): boolean;
  12240. set isAnimationSheetEnabled(value: boolean);
  12241. /**
  12242. * Get hosting scene
  12243. * @returns the scene
  12244. */
  12245. getScene(): Scene;
  12246. /**
  12247. * You can use gravity if you want to give an orientation to your particles.
  12248. */
  12249. gravity: Vector3;
  12250. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12251. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12252. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12253. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12254. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12255. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12256. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12257. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12258. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12259. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12260. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12261. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12262. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12263. /**
  12264. * Defines the delay in milliseconds before starting the system (0 by default)
  12265. */
  12266. startDelay: number;
  12267. /**
  12268. * Gets the current list of drag gradients.
  12269. * You must use addDragGradient and removeDragGradient to udpate this list
  12270. * @returns the list of drag gradients
  12271. */
  12272. getDragGradients(): Nullable<Array<FactorGradient>>;
  12273. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12274. limitVelocityDamping: number;
  12275. /**
  12276. * Gets the current list of limit velocity gradients.
  12277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12278. * @returns the list of limit velocity gradients
  12279. */
  12280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12281. /**
  12282. * Gets the current list of color gradients.
  12283. * You must use addColorGradient and removeColorGradient to udpate this list
  12284. * @returns the list of color gradients
  12285. */
  12286. getColorGradients(): Nullable<Array<ColorGradient>>;
  12287. /**
  12288. * Gets the current list of size gradients.
  12289. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12290. * @returns the list of size gradients
  12291. */
  12292. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12293. /**
  12294. * Gets the current list of color remap gradients.
  12295. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12296. * @returns the list of color remap gradients
  12297. */
  12298. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12299. /**
  12300. * Gets the current list of alpha remap gradients.
  12301. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12302. * @returns the list of alpha remap gradients
  12303. */
  12304. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12305. /**
  12306. * Gets the current list of life time gradients.
  12307. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12308. * @returns the list of life time gradients
  12309. */
  12310. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12311. /**
  12312. * Gets the current list of angular speed gradients.
  12313. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12314. * @returns the list of angular speed gradients
  12315. */
  12316. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12317. /**
  12318. * Gets the current list of velocity gradients.
  12319. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12320. * @returns the list of velocity gradients
  12321. */
  12322. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12323. /**
  12324. * Gets the current list of start size gradients.
  12325. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12326. * @returns the list of start size gradients
  12327. */
  12328. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12329. /**
  12330. * Gets the current list of emit rate gradients.
  12331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12332. * @returns the list of emit rate gradients
  12333. */
  12334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12335. /**
  12336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12337. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12338. */
  12339. get direction1(): Vector3;
  12340. set direction1(value: Vector3);
  12341. /**
  12342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12344. */
  12345. get direction2(): Vector3;
  12346. set direction2(value: Vector3);
  12347. /**
  12348. * 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.
  12349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12350. */
  12351. get minEmitBox(): Vector3;
  12352. set minEmitBox(value: Vector3);
  12353. /**
  12354. * 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.
  12355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12356. */
  12357. get maxEmitBox(): Vector3;
  12358. set maxEmitBox(value: Vector3);
  12359. /**
  12360. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12361. */
  12362. color1: Color4;
  12363. /**
  12364. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12365. */
  12366. color2: Color4;
  12367. /**
  12368. * Color the particle will have at the end of its lifetime
  12369. */
  12370. colorDead: Color4;
  12371. /**
  12372. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12373. */
  12374. textureMask: Color4;
  12375. /**
  12376. * The particle emitter type defines the emitter used by the particle system.
  12377. * It can be for example box, sphere, or cone...
  12378. */
  12379. particleEmitterType: IParticleEmitterType;
  12380. /** @hidden */
  12381. _isSubEmitter: boolean;
  12382. /**
  12383. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12384. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12385. */
  12386. billboardMode: number;
  12387. protected _isBillboardBased: boolean;
  12388. /**
  12389. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12390. */
  12391. get isBillboardBased(): boolean;
  12392. set isBillboardBased(value: boolean);
  12393. /**
  12394. * The scene the particle system belongs to.
  12395. */
  12396. protected _scene: Scene;
  12397. /**
  12398. * Local cache of defines for image processing.
  12399. */
  12400. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12401. /**
  12402. * Default configuration related to image processing available in the standard Material.
  12403. */
  12404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12405. /**
  12406. * Gets the image processing configuration used either in this material.
  12407. */
  12408. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12409. /**
  12410. * Sets the Default image processing configuration used either in the this material.
  12411. *
  12412. * If sets to null, the scene one is in use.
  12413. */
  12414. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12415. /**
  12416. * Attaches a new image processing configuration to the Standard Material.
  12417. * @param configuration
  12418. */
  12419. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12420. /** @hidden */
  12421. protected _reset(): void;
  12422. /** @hidden */
  12423. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12424. /**
  12425. * Instantiates a particle system.
  12426. * 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.
  12427. * @param name The name of the particle system
  12428. */
  12429. constructor(name: string);
  12430. /**
  12431. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12434. * @returns the emitter
  12435. */
  12436. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12437. /**
  12438. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12439. * @param radius The radius of the hemisphere to emit from
  12440. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12441. * @returns the emitter
  12442. */
  12443. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12444. /**
  12445. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12446. * @param radius The radius of the sphere to emit from
  12447. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12448. * @returns the emitter
  12449. */
  12450. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12451. /**
  12452. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12453. * @param radius The radius of the sphere to emit from
  12454. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12455. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12456. * @returns the emitter
  12457. */
  12458. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12459. /**
  12460. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12461. * @param radius The radius of the emission cylinder
  12462. * @param height The height of the emission cylinder
  12463. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12464. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12465. * @returns the emitter
  12466. */
  12467. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12468. /**
  12469. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12470. * @param radius The radius of the cylinder to emit from
  12471. * @param height The height of the emission cylinder
  12472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12475. * @returns the emitter
  12476. */
  12477. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12478. /**
  12479. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12480. * @param radius The radius of the cone to emit from
  12481. * @param angle The base angle of the cone
  12482. * @returns the emitter
  12483. */
  12484. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12485. /**
  12486. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12489. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12490. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12491. * @returns the emitter
  12492. */
  12493. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12494. }
  12495. }
  12496. declare module "babylonjs/Particles/subEmitter" {
  12497. import { Scene } from "babylonjs/scene";
  12498. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12499. /**
  12500. * Type of sub emitter
  12501. */
  12502. export enum SubEmitterType {
  12503. /**
  12504. * Attached to the particle over it's lifetime
  12505. */
  12506. ATTACHED = 0,
  12507. /**
  12508. * Created when the particle dies
  12509. */
  12510. END = 1
  12511. }
  12512. /**
  12513. * Sub emitter class used to emit particles from an existing particle
  12514. */
  12515. export class SubEmitter {
  12516. /**
  12517. * the particle system to be used by the sub emitter
  12518. */
  12519. particleSystem: ParticleSystem;
  12520. /**
  12521. * Type of the submitter (Default: END)
  12522. */
  12523. type: SubEmitterType;
  12524. /**
  12525. * 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)
  12526. * Note: This only is supported when using an emitter of type Mesh
  12527. */
  12528. inheritDirection: boolean;
  12529. /**
  12530. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12531. */
  12532. inheritedVelocityAmount: number;
  12533. /**
  12534. * Creates a sub emitter
  12535. * @param particleSystem the particle system to be used by the sub emitter
  12536. */
  12537. constructor(
  12538. /**
  12539. * the particle system to be used by the sub emitter
  12540. */
  12541. particleSystem: ParticleSystem);
  12542. /**
  12543. * Clones the sub emitter
  12544. * @returns the cloned sub emitter
  12545. */
  12546. clone(): SubEmitter;
  12547. /**
  12548. * Serialize current object to a JSON object
  12549. * @returns the serialized object
  12550. */
  12551. serialize(): any;
  12552. /** @hidden */
  12553. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12554. /**
  12555. * Creates a new SubEmitter from a serialized JSON version
  12556. * @param serializationObject defines the JSON object to read from
  12557. * @param scene defines the hosting scene
  12558. * @param rootUrl defines the rootUrl for data loading
  12559. * @returns a new SubEmitter
  12560. */
  12561. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12562. /** Release associated resources */
  12563. dispose(): void;
  12564. }
  12565. }
  12566. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12567. /** @hidden */
  12568. export var imageProcessingDeclaration: {
  12569. name: string;
  12570. shader: string;
  12571. };
  12572. }
  12573. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12574. /** @hidden */
  12575. export var imageProcessingFunctions: {
  12576. name: string;
  12577. shader: string;
  12578. };
  12579. }
  12580. declare module "babylonjs/Shaders/particles.fragment" {
  12581. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12582. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12583. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12584. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12585. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12586. /** @hidden */
  12587. export var particlesPixelShader: {
  12588. name: string;
  12589. shader: string;
  12590. };
  12591. }
  12592. declare module "babylonjs/Shaders/particles.vertex" {
  12593. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12594. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12595. /** @hidden */
  12596. export var particlesVertexShader: {
  12597. name: string;
  12598. shader: string;
  12599. };
  12600. }
  12601. declare module "babylonjs/Particles/particleSystem" {
  12602. import { Nullable } from "babylonjs/types";
  12603. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12604. import { Observable } from "babylonjs/Misc/observable";
  12605. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12606. import { Effect } from "babylonjs/Materials/effect";
  12607. import { Scene, IDisposable } from "babylonjs/scene";
  12608. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12609. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12610. import { Particle } from "babylonjs/Particles/particle";
  12611. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12612. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12613. import "babylonjs/Shaders/particles.fragment";
  12614. import "babylonjs/Shaders/particles.vertex";
  12615. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12616. /**
  12617. * This represents a particle system in Babylon.
  12618. * 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.
  12619. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12620. * @example https://doc.babylonjs.com/babylon101/particles
  12621. */
  12622. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12623. /**
  12624. * Billboard mode will only apply to Y axis
  12625. */
  12626. static readonly BILLBOARDMODE_Y: number;
  12627. /**
  12628. * Billboard mode will apply to all axes
  12629. */
  12630. static readonly BILLBOARDMODE_ALL: number;
  12631. /**
  12632. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12633. */
  12634. static readonly BILLBOARDMODE_STRETCHED: number;
  12635. /**
  12636. * This function can be defined to provide custom update for active particles.
  12637. * This function will be called instead of regular update (age, position, color, etc.).
  12638. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12639. */
  12640. updateFunction: (particles: Particle[]) => void;
  12641. private _emitterWorldMatrix;
  12642. /**
  12643. * This function can be defined to specify initial direction for every new particle.
  12644. * It by default use the emitterType defined function
  12645. */
  12646. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12647. /**
  12648. * This function can be defined to specify initial position for every new particle.
  12649. * It by default use the emitterType defined function
  12650. */
  12651. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12652. /**
  12653. * @hidden
  12654. */
  12655. _inheritedVelocityOffset: Vector3;
  12656. /**
  12657. * An event triggered when the system is disposed
  12658. */
  12659. onDisposeObservable: Observable<IParticleSystem>;
  12660. private _onDisposeObserver;
  12661. /**
  12662. * Sets a callback that will be triggered when the system is disposed
  12663. */
  12664. set onDispose(callback: () => void);
  12665. private _particles;
  12666. private _epsilon;
  12667. private _capacity;
  12668. private _stockParticles;
  12669. private _newPartsExcess;
  12670. private _vertexData;
  12671. private _vertexBuffer;
  12672. private _vertexBuffers;
  12673. private _spriteBuffer;
  12674. private _indexBuffer;
  12675. private _effect;
  12676. private _customEffect;
  12677. private _cachedDefines;
  12678. private _scaledColorStep;
  12679. private _colorDiff;
  12680. private _scaledDirection;
  12681. private _scaledGravity;
  12682. private _currentRenderId;
  12683. private _alive;
  12684. private _useInstancing;
  12685. private _started;
  12686. private _stopped;
  12687. private _actualFrame;
  12688. private _scaledUpdateSpeed;
  12689. private _vertexBufferSize;
  12690. /** @hidden */
  12691. _currentEmitRateGradient: Nullable<FactorGradient>;
  12692. /** @hidden */
  12693. _currentEmitRate1: number;
  12694. /** @hidden */
  12695. _currentEmitRate2: number;
  12696. /** @hidden */
  12697. _currentStartSizeGradient: Nullable<FactorGradient>;
  12698. /** @hidden */
  12699. _currentStartSize1: number;
  12700. /** @hidden */
  12701. _currentStartSize2: number;
  12702. private readonly _rawTextureWidth;
  12703. private _rampGradientsTexture;
  12704. private _useRampGradients;
  12705. /** Gets or sets a boolean indicating that ramp gradients must be used
  12706. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12707. */
  12708. get useRampGradients(): boolean;
  12709. set useRampGradients(value: boolean);
  12710. /**
  12711. * 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.
  12712. * 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: [])
  12713. */
  12714. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12715. private _subEmitters;
  12716. /**
  12717. * @hidden
  12718. * If the particle systems emitter should be disposed when the particle system is disposed
  12719. */
  12720. _disposeEmitterOnDispose: boolean;
  12721. /**
  12722. * The current active Sub-systems, this property is used by the root particle system only.
  12723. */
  12724. activeSubSystems: Array<ParticleSystem>;
  12725. /**
  12726. * Specifies if the particles are updated in emitter local space or world space
  12727. */
  12728. isLocal: boolean;
  12729. private _rootParticleSystem;
  12730. /**
  12731. * Gets the current list of active particles
  12732. */
  12733. get particles(): Particle[];
  12734. /**
  12735. * Gets the number of particles active at the same time.
  12736. * @returns The number of active particles.
  12737. */
  12738. getActiveCount(): number;
  12739. /**
  12740. * Returns the string "ParticleSystem"
  12741. * @returns a string containing the class name
  12742. */
  12743. getClassName(): string;
  12744. /**
  12745. * Gets a boolean indicating that the system is stopping
  12746. * @returns true if the system is currently stopping
  12747. */
  12748. isStopping(): boolean;
  12749. /**
  12750. * Gets the custom effect used to render the particles
  12751. * @param blendMode Blend mode for which the effect should be retrieved
  12752. * @returns The effect
  12753. */
  12754. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12755. /**
  12756. * Sets the custom effect used to render the particles
  12757. * @param effect The effect to set
  12758. * @param blendMode Blend mode for which the effect should be set
  12759. */
  12760. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12761. /** @hidden */
  12762. private _onBeforeDrawParticlesObservable;
  12763. /**
  12764. * Observable that will be called just before the particles are drawn
  12765. */
  12766. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12767. /**
  12768. * Gets the name of the particle vertex shader
  12769. */
  12770. get vertexShaderName(): string;
  12771. /**
  12772. * Instantiates a particle system.
  12773. * 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.
  12774. * @param name The name of the particle system
  12775. * @param capacity The max number of particles alive at the same time
  12776. * @param scene The scene the particle system belongs to
  12777. * @param customEffect a custom effect used to change the way particles are rendered by default
  12778. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12779. * @param epsilon Offset used to render the particles
  12780. */
  12781. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12782. private _addFactorGradient;
  12783. private _removeFactorGradient;
  12784. /**
  12785. * Adds a new life time gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the life time factor to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific life time gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new size gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the size factor to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific size gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeSizeGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new color remap gradient
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param min defines the color remap minimal range
  12816. * @param max defines the color remap maximal range
  12817. * @returns the current particle system
  12818. */
  12819. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific color remap gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeColorRemapGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new alpha remap gradient
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param min defines the alpha remap minimal range
  12830. * @param max defines the alpha remap maximal range
  12831. * @returns the current particle system
  12832. */
  12833. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific alpha remap gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12840. /**
  12841. * Adds a new angular speed gradient
  12842. * @param gradient defines the gradient to use (between 0 and 1)
  12843. * @param factor defines the angular speed to affect to the specified gradient
  12844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12845. * @returns the current particle system
  12846. */
  12847. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12848. /**
  12849. * Remove a specific angular speed gradient
  12850. * @param gradient defines the gradient to remove
  12851. * @returns the current particle system
  12852. */
  12853. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12854. /**
  12855. * Adds a new velocity gradient
  12856. * @param gradient defines the gradient to use (between 0 and 1)
  12857. * @param factor defines the velocity to affect to the specified gradient
  12858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12859. * @returns the current particle system
  12860. */
  12861. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12862. /**
  12863. * Remove a specific velocity gradient
  12864. * @param gradient defines the gradient to remove
  12865. * @returns the current particle system
  12866. */
  12867. removeVelocityGradient(gradient: number): IParticleSystem;
  12868. /**
  12869. * Adds a new limit velocity gradient
  12870. * @param gradient defines the gradient to use (between 0 and 1)
  12871. * @param factor defines the limit velocity value to affect to the specified gradient
  12872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12873. * @returns the current particle system
  12874. */
  12875. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12876. /**
  12877. * Remove a specific limit velocity gradient
  12878. * @param gradient defines the gradient to remove
  12879. * @returns the current particle system
  12880. */
  12881. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12882. /**
  12883. * Adds a new drag gradient
  12884. * @param gradient defines the gradient to use (between 0 and 1)
  12885. * @param factor defines the drag value to affect to the specified gradient
  12886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12887. * @returns the current particle system
  12888. */
  12889. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12890. /**
  12891. * Remove a specific drag gradient
  12892. * @param gradient defines the gradient to remove
  12893. * @returns the current particle system
  12894. */
  12895. removeDragGradient(gradient: number): IParticleSystem;
  12896. /**
  12897. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12898. * @param gradient defines the gradient to use (between 0 and 1)
  12899. * @param factor defines the emit rate value to affect to the specified gradient
  12900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12901. * @returns the current particle system
  12902. */
  12903. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12904. /**
  12905. * Remove a specific emit rate gradient
  12906. * @param gradient defines the gradient to remove
  12907. * @returns the current particle system
  12908. */
  12909. removeEmitRateGradient(gradient: number): IParticleSystem;
  12910. /**
  12911. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12912. * @param gradient defines the gradient to use (between 0 and 1)
  12913. * @param factor defines the start size value to affect to the specified gradient
  12914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12915. * @returns the current particle system
  12916. */
  12917. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12918. /**
  12919. * Remove a specific start size gradient
  12920. * @param gradient defines the gradient to remove
  12921. * @returns the current particle system
  12922. */
  12923. removeStartSizeGradient(gradient: number): IParticleSystem;
  12924. private _createRampGradientTexture;
  12925. /**
  12926. * Gets the current list of ramp gradients.
  12927. * You must use addRampGradient and removeRampGradient to udpate this list
  12928. * @returns the list of ramp gradients
  12929. */
  12930. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12931. /** Force the system to rebuild all gradients that need to be resync */
  12932. forceRefreshGradients(): void;
  12933. private _syncRampGradientTexture;
  12934. /**
  12935. * Adds a new ramp gradient used to remap particle colors
  12936. * @param gradient defines the gradient to use (between 0 and 1)
  12937. * @param color defines the color to affect to the specified gradient
  12938. * @returns the current particle system
  12939. */
  12940. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12941. /**
  12942. * Remove a specific ramp gradient
  12943. * @param gradient defines the gradient to remove
  12944. * @returns the current particle system
  12945. */
  12946. removeRampGradient(gradient: number): ParticleSystem;
  12947. /**
  12948. * Adds a new color gradient
  12949. * @param gradient defines the gradient to use (between 0 and 1)
  12950. * @param color1 defines the color to affect to the specified gradient
  12951. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12952. * @returns this particle system
  12953. */
  12954. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12955. /**
  12956. * Remove a specific color gradient
  12957. * @param gradient defines the gradient to remove
  12958. * @returns this particle system
  12959. */
  12960. removeColorGradient(gradient: number): IParticleSystem;
  12961. private _fetchR;
  12962. protected _reset(): void;
  12963. private _resetEffect;
  12964. private _createVertexBuffers;
  12965. private _createIndexBuffer;
  12966. /**
  12967. * Gets the maximum number of particles active at the same time.
  12968. * @returns The max number of active particles.
  12969. */
  12970. getCapacity(): number;
  12971. /**
  12972. * Gets whether there are still active particles in the system.
  12973. * @returns True if it is alive, otherwise false.
  12974. */
  12975. isAlive(): boolean;
  12976. /**
  12977. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12978. * @returns True if it has been started, otherwise false.
  12979. */
  12980. isStarted(): boolean;
  12981. private _prepareSubEmitterInternalArray;
  12982. /**
  12983. * Starts the particle system and begins to emit
  12984. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12985. */
  12986. start(delay?: number): void;
  12987. /**
  12988. * Stops the particle system.
  12989. * @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.
  12990. */
  12991. stop(stopSubEmitters?: boolean): void;
  12992. /**
  12993. * Remove all active particles
  12994. */
  12995. reset(): void;
  12996. /**
  12997. * @hidden (for internal use only)
  12998. */
  12999. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13000. /**
  13001. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13002. * Its lifetime will start back at 0.
  13003. */
  13004. recycleParticle: (particle: Particle) => void;
  13005. private _stopSubEmitters;
  13006. private _createParticle;
  13007. private _removeFromRoot;
  13008. private _emitFromParticle;
  13009. private _update;
  13010. /** @hidden */
  13011. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13012. /** @hidden */
  13013. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13014. /**
  13015. * Fill the defines array according to the current settings of the particle system
  13016. * @param defines Array to be updated
  13017. * @param blendMode blend mode to take into account when updating the array
  13018. */
  13019. fillDefines(defines: Array<string>, blendMode: number): void;
  13020. /**
  13021. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13022. * @param uniforms Uniforms array to fill
  13023. * @param attributes Attributes array to fill
  13024. * @param samplers Samplers array to fill
  13025. */
  13026. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13027. /** @hidden */
  13028. private _getEffect;
  13029. /**
  13030. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13031. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13032. */
  13033. animate(preWarmOnly?: boolean): void;
  13034. private _appendParticleVertices;
  13035. /**
  13036. * Rebuilds the particle system.
  13037. */
  13038. rebuild(): void;
  13039. /**
  13040. * Is this system ready to be used/rendered
  13041. * @return true if the system is ready
  13042. */
  13043. isReady(): boolean;
  13044. private _render;
  13045. /**
  13046. * Renders the particle system in its current state.
  13047. * @returns the current number of particles
  13048. */
  13049. render(): number;
  13050. /**
  13051. * Disposes the particle system and free the associated resources
  13052. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13053. */
  13054. dispose(disposeTexture?: boolean): void;
  13055. /**
  13056. * Clones the particle system.
  13057. * @param name The name of the cloned object
  13058. * @param newEmitter The new emitter to use
  13059. * @returns the cloned particle system
  13060. */
  13061. clone(name: string, newEmitter: any): ParticleSystem;
  13062. /**
  13063. * Serializes the particle system to a JSON object
  13064. * @param serializeTexture defines if the texture must be serialized as well
  13065. * @returns the JSON object
  13066. */
  13067. serialize(serializeTexture?: boolean): any;
  13068. /** @hidden */
  13069. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13070. /** @hidden */
  13071. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13072. /**
  13073. * Parses a JSON object to create a particle system.
  13074. * @param parsedParticleSystem The JSON object to parse
  13075. * @param scene The scene to create the particle system in
  13076. * @param rootUrl The root url to use to load external dependencies like texture
  13077. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13078. * @returns the Parsed particle system
  13079. */
  13080. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13081. }
  13082. }
  13083. declare module "babylonjs/Particles/particle" {
  13084. import { Nullable } from "babylonjs/types";
  13085. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13086. import { Color4 } from "babylonjs/Maths/math.color";
  13087. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13088. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13089. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13090. /**
  13091. * A particle represents one of the element emitted by a particle system.
  13092. * This is mainly define by its coordinates, direction, velocity and age.
  13093. */
  13094. export class Particle {
  13095. /**
  13096. * The particle system the particle belongs to.
  13097. */
  13098. particleSystem: ParticleSystem;
  13099. private static _Count;
  13100. /**
  13101. * Unique ID of the particle
  13102. */
  13103. id: number;
  13104. /**
  13105. * The world position of the particle in the scene.
  13106. */
  13107. position: Vector3;
  13108. /**
  13109. * The world direction of the particle in the scene.
  13110. */
  13111. direction: Vector3;
  13112. /**
  13113. * The color of the particle.
  13114. */
  13115. color: Color4;
  13116. /**
  13117. * The color change of the particle per step.
  13118. */
  13119. colorStep: Color4;
  13120. /**
  13121. * Defines how long will the life of the particle be.
  13122. */
  13123. lifeTime: number;
  13124. /**
  13125. * The current age of the particle.
  13126. */
  13127. age: number;
  13128. /**
  13129. * The current size of the particle.
  13130. */
  13131. size: number;
  13132. /**
  13133. * The current scale of the particle.
  13134. */
  13135. scale: Vector2;
  13136. /**
  13137. * The current angle of the particle.
  13138. */
  13139. angle: number;
  13140. /**
  13141. * Defines how fast is the angle changing.
  13142. */
  13143. angularSpeed: number;
  13144. /**
  13145. * Defines the cell index used by the particle to be rendered from a sprite.
  13146. */
  13147. cellIndex: number;
  13148. /**
  13149. * The information required to support color remapping
  13150. */
  13151. remapData: Vector4;
  13152. /** @hidden */
  13153. _randomCellOffset?: number;
  13154. /** @hidden */
  13155. _initialDirection: Nullable<Vector3>;
  13156. /** @hidden */
  13157. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13158. /** @hidden */
  13159. _initialStartSpriteCellID: number;
  13160. /** @hidden */
  13161. _initialEndSpriteCellID: number;
  13162. /** @hidden */
  13163. _currentColorGradient: Nullable<ColorGradient>;
  13164. /** @hidden */
  13165. _currentColor1: Color4;
  13166. /** @hidden */
  13167. _currentColor2: Color4;
  13168. /** @hidden */
  13169. _currentSizeGradient: Nullable<FactorGradient>;
  13170. /** @hidden */
  13171. _currentSize1: number;
  13172. /** @hidden */
  13173. _currentSize2: number;
  13174. /** @hidden */
  13175. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13176. /** @hidden */
  13177. _currentAngularSpeed1: number;
  13178. /** @hidden */
  13179. _currentAngularSpeed2: number;
  13180. /** @hidden */
  13181. _currentVelocityGradient: Nullable<FactorGradient>;
  13182. /** @hidden */
  13183. _currentVelocity1: number;
  13184. /** @hidden */
  13185. _currentVelocity2: number;
  13186. /** @hidden */
  13187. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13188. /** @hidden */
  13189. _currentLimitVelocity1: number;
  13190. /** @hidden */
  13191. _currentLimitVelocity2: number;
  13192. /** @hidden */
  13193. _currentDragGradient: Nullable<FactorGradient>;
  13194. /** @hidden */
  13195. _currentDrag1: number;
  13196. /** @hidden */
  13197. _currentDrag2: number;
  13198. /** @hidden */
  13199. _randomNoiseCoordinates1: Vector3;
  13200. /** @hidden */
  13201. _randomNoiseCoordinates2: Vector3;
  13202. /** @hidden */
  13203. _localPosition?: Vector3;
  13204. /**
  13205. * Creates a new instance Particle
  13206. * @param particleSystem the particle system the particle belongs to
  13207. */
  13208. constructor(
  13209. /**
  13210. * The particle system the particle belongs to.
  13211. */
  13212. particleSystem: ParticleSystem);
  13213. private updateCellInfoFromSystem;
  13214. /**
  13215. * Defines how the sprite cell index is updated for the particle
  13216. */
  13217. updateCellIndex(): void;
  13218. /** @hidden */
  13219. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13220. /** @hidden */
  13221. _inheritParticleInfoToSubEmitters(): void;
  13222. /** @hidden */
  13223. _reset(): void;
  13224. /**
  13225. * Copy the properties of particle to another one.
  13226. * @param other the particle to copy the information to.
  13227. */
  13228. copyTo(other: Particle): void;
  13229. }
  13230. }
  13231. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13232. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13233. import { Effect } from "babylonjs/Materials/effect";
  13234. import { Particle } from "babylonjs/Particles/particle";
  13235. import { Scene } from "babylonjs/scene";
  13236. /**
  13237. * Particle emitter represents a volume emitting particles.
  13238. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13239. */
  13240. export interface IParticleEmitterType {
  13241. /**
  13242. * Called by the particle System when the direction is computed for the created particle.
  13243. * @param worldMatrix is the world matrix of the particle system
  13244. * @param directionToUpdate is the direction vector to update with the result
  13245. * @param particle is the particle we are computed the direction for
  13246. * @param isLocal defines if the direction should be set in local space
  13247. */
  13248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13249. /**
  13250. * Called by the particle System when the position is computed for the created particle.
  13251. * @param worldMatrix is the world matrix of the particle system
  13252. * @param positionToUpdate is the position vector to update with the result
  13253. * @param particle is the particle we are computed the position for
  13254. * @param isLocal defines if the position should be set in local space
  13255. */
  13256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13257. /**
  13258. * Clones the current emitter and returns a copy of it
  13259. * @returns the new emitter
  13260. */
  13261. clone(): IParticleEmitterType;
  13262. /**
  13263. * Called by the GPUParticleSystem to setup the update shader
  13264. * @param effect defines the update shader
  13265. */
  13266. applyToShader(effect: Effect): void;
  13267. /**
  13268. * Returns a string to use to update the GPU particles update shader
  13269. * @returns the effect defines string
  13270. */
  13271. getEffectDefines(): string;
  13272. /**
  13273. * Returns a string representing the class name
  13274. * @returns a string containing the class name
  13275. */
  13276. getClassName(): string;
  13277. /**
  13278. * Serializes the particle system to a JSON object.
  13279. * @returns the JSON object
  13280. */
  13281. serialize(): any;
  13282. /**
  13283. * Parse properties from a JSON object
  13284. * @param serializationObject defines the JSON object
  13285. * @param scene defines the hosting scene
  13286. */
  13287. parse(serializationObject: any, scene: Scene): void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13292. import { Effect } from "babylonjs/Materials/effect";
  13293. import { Particle } from "babylonjs/Particles/particle";
  13294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13295. /**
  13296. * Particle emitter emitting particles from the inside of a box.
  13297. * It emits the particles randomly between 2 given directions.
  13298. */
  13299. export class BoxParticleEmitter implements IParticleEmitterType {
  13300. /**
  13301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13302. */
  13303. direction1: Vector3;
  13304. /**
  13305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13306. */
  13307. direction2: Vector3;
  13308. /**
  13309. * 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.
  13310. */
  13311. minEmitBox: Vector3;
  13312. /**
  13313. * 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.
  13314. */
  13315. maxEmitBox: Vector3;
  13316. /**
  13317. * Creates a new instance BoxParticleEmitter
  13318. */
  13319. constructor();
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. * @param isLocal defines if the direction should be set in local space
  13326. */
  13327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Called by the particle System when the position is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param positionToUpdate is the position vector to update with the result
  13332. * @param particle is the particle we are computed the position for
  13333. * @param isLocal defines if the position should be set in local space
  13334. */
  13335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Clones the current emitter and returns a copy of it
  13338. * @returns the new emitter
  13339. */
  13340. clone(): BoxParticleEmitter;
  13341. /**
  13342. * Called by the GPUParticleSystem to setup the update shader
  13343. * @param effect defines the update shader
  13344. */
  13345. applyToShader(effect: Effect): void;
  13346. /**
  13347. * Returns a string to use to update the GPU particles update shader
  13348. * @returns a string containng the defines string
  13349. */
  13350. getEffectDefines(): string;
  13351. /**
  13352. * Returns the string "BoxParticleEmitter"
  13353. * @returns a string containing the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Serializes the particle system to a JSON object.
  13358. * @returns the JSON object
  13359. */
  13360. serialize(): any;
  13361. /**
  13362. * Parse properties from a JSON object
  13363. * @param serializationObject defines the JSON object
  13364. */
  13365. parse(serializationObject: any): void;
  13366. }
  13367. }
  13368. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13369. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13370. import { Effect } from "babylonjs/Materials/effect";
  13371. import { Particle } from "babylonjs/Particles/particle";
  13372. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13373. /**
  13374. * Particle emitter emitting particles from the inside of a cone.
  13375. * It emits the particles alongside the cone volume from the base to the particle.
  13376. * The emission direction might be randomized.
  13377. */
  13378. export class ConeParticleEmitter implements IParticleEmitterType {
  13379. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13380. directionRandomizer: number;
  13381. private _radius;
  13382. private _angle;
  13383. private _height;
  13384. /**
  13385. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13386. */
  13387. radiusRange: number;
  13388. /**
  13389. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13390. */
  13391. heightRange: number;
  13392. /**
  13393. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13394. */
  13395. emitFromSpawnPointOnly: boolean;
  13396. /**
  13397. * Gets or sets the radius of the emission cone
  13398. */
  13399. get radius(): number;
  13400. set radius(value: number);
  13401. /**
  13402. * Gets or sets the angle of the emission cone
  13403. */
  13404. get angle(): number;
  13405. set angle(value: number);
  13406. private _buildHeight;
  13407. /**
  13408. * Creates a new instance ConeParticleEmitter
  13409. * @param radius the radius of the emission cone (1 by default)
  13410. * @param angle the cone base angle (PI by default)
  13411. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13412. */
  13413. constructor(radius?: number, angle?: number,
  13414. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13415. directionRandomizer?: number);
  13416. /**
  13417. * Called by the particle System when the direction is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param directionToUpdate is the direction vector to update with the result
  13420. * @param particle is the particle we are computed the direction for
  13421. * @param isLocal defines if the direction should be set in local space
  13422. */
  13423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Called by the particle System when the position is computed for the created particle.
  13426. * @param worldMatrix is the world matrix of the particle system
  13427. * @param positionToUpdate is the position vector to update with the result
  13428. * @param particle is the particle we are computed the position for
  13429. * @param isLocal defines if the position should be set in local space
  13430. */
  13431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13432. /**
  13433. * Clones the current emitter and returns a copy of it
  13434. * @returns the new emitter
  13435. */
  13436. clone(): ConeParticleEmitter;
  13437. /**
  13438. * Called by the GPUParticleSystem to setup the update shader
  13439. * @param effect defines the update shader
  13440. */
  13441. applyToShader(effect: Effect): void;
  13442. /**
  13443. * Returns a string to use to update the GPU particles update shader
  13444. * @returns a string containng the defines string
  13445. */
  13446. getEffectDefines(): string;
  13447. /**
  13448. * Returns the string "ConeParticleEmitter"
  13449. * @returns a string containing the class name
  13450. */
  13451. getClassName(): string;
  13452. /**
  13453. * Serializes the particle system to a JSON object.
  13454. * @returns the JSON object
  13455. */
  13456. serialize(): any;
  13457. /**
  13458. * Parse properties from a JSON object
  13459. * @param serializationObject defines the JSON object
  13460. */
  13461. parse(serializationObject: any): void;
  13462. }
  13463. }
  13464. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13465. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13466. import { Effect } from "babylonjs/Materials/effect";
  13467. import { Particle } from "babylonjs/Particles/particle";
  13468. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13469. /**
  13470. * Particle emitter emitting particles from the inside of a cylinder.
  13471. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13472. */
  13473. export class CylinderParticleEmitter implements IParticleEmitterType {
  13474. /**
  13475. * The radius of the emission cylinder.
  13476. */
  13477. radius: number;
  13478. /**
  13479. * The height of the emission cylinder.
  13480. */
  13481. height: number;
  13482. /**
  13483. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13484. */
  13485. radiusRange: number;
  13486. /**
  13487. * How much to randomize the particle direction [0-1].
  13488. */
  13489. directionRandomizer: number;
  13490. /**
  13491. * Creates a new instance CylinderParticleEmitter
  13492. * @param radius the radius of the emission cylinder (1 by default)
  13493. * @param height the height of the emission cylinder (1 by default)
  13494. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13495. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13496. */
  13497. constructor(
  13498. /**
  13499. * The radius of the emission cylinder.
  13500. */
  13501. radius?: number,
  13502. /**
  13503. * The height of the emission cylinder.
  13504. */
  13505. height?: number,
  13506. /**
  13507. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13508. */
  13509. radiusRange?: number,
  13510. /**
  13511. * How much to randomize the particle direction [0-1].
  13512. */
  13513. directionRandomizer?: number);
  13514. /**
  13515. * Called by the particle System when the direction is computed for the created particle.
  13516. * @param worldMatrix is the world matrix of the particle system
  13517. * @param directionToUpdate is the direction vector to update with the result
  13518. * @param particle is the particle we are computed the direction for
  13519. * @param isLocal defines if the direction should be set in local space
  13520. */
  13521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13522. /**
  13523. * Called by the particle System when the position is computed for the created particle.
  13524. * @param worldMatrix is the world matrix of the particle system
  13525. * @param positionToUpdate is the position vector to update with the result
  13526. * @param particle is the particle we are computed the position for
  13527. * @param isLocal defines if the position should be set in local space
  13528. */
  13529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13530. /**
  13531. * Clones the current emitter and returns a copy of it
  13532. * @returns the new emitter
  13533. */
  13534. clone(): CylinderParticleEmitter;
  13535. /**
  13536. * Called by the GPUParticleSystem to setup the update shader
  13537. * @param effect defines the update shader
  13538. */
  13539. applyToShader(effect: Effect): void;
  13540. /**
  13541. * Returns a string to use to update the GPU particles update shader
  13542. * @returns a string containng the defines string
  13543. */
  13544. getEffectDefines(): string;
  13545. /**
  13546. * Returns the string "CylinderParticleEmitter"
  13547. * @returns a string containing the class name
  13548. */
  13549. getClassName(): string;
  13550. /**
  13551. * Serializes the particle system to a JSON object.
  13552. * @returns the JSON object
  13553. */
  13554. serialize(): any;
  13555. /**
  13556. * Parse properties from a JSON object
  13557. * @param serializationObject defines the JSON object
  13558. */
  13559. parse(serializationObject: any): void;
  13560. }
  13561. /**
  13562. * Particle emitter emitting particles from the inside of a cylinder.
  13563. * It emits the particles randomly between two vectors.
  13564. */
  13565. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13566. /**
  13567. * The min limit of the emission direction.
  13568. */
  13569. direction1: Vector3;
  13570. /**
  13571. * The max limit of the emission direction.
  13572. */
  13573. direction2: Vector3;
  13574. /**
  13575. * Creates a new instance CylinderDirectedParticleEmitter
  13576. * @param radius the radius of the emission cylinder (1 by default)
  13577. * @param height the height of the emission cylinder (1 by default)
  13578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13579. * @param direction1 the min limit of the emission direction (up vector by default)
  13580. * @param direction2 the max limit of the emission direction (up vector by default)
  13581. */
  13582. constructor(radius?: number, height?: number, radiusRange?: number,
  13583. /**
  13584. * The min limit of the emission direction.
  13585. */
  13586. direction1?: Vector3,
  13587. /**
  13588. * The max limit of the emission direction.
  13589. */
  13590. direction2?: Vector3);
  13591. /**
  13592. * Called by the particle System when the direction is computed for the created particle.
  13593. * @param worldMatrix is the world matrix of the particle system
  13594. * @param directionToUpdate is the direction vector to update with the result
  13595. * @param particle is the particle we are computed the direction for
  13596. */
  13597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13598. /**
  13599. * Clones the current emitter and returns a copy of it
  13600. * @returns the new emitter
  13601. */
  13602. clone(): CylinderDirectedParticleEmitter;
  13603. /**
  13604. * Called by the GPUParticleSystem to setup the update shader
  13605. * @param effect defines the update shader
  13606. */
  13607. applyToShader(effect: Effect): void;
  13608. /**
  13609. * Returns a string to use to update the GPU particles update shader
  13610. * @returns a string containng the defines string
  13611. */
  13612. getEffectDefines(): string;
  13613. /**
  13614. * Returns the string "CylinderDirectedParticleEmitter"
  13615. * @returns a string containing the class name
  13616. */
  13617. getClassName(): string;
  13618. /**
  13619. * Serializes the particle system to a JSON object.
  13620. * @returns the JSON object
  13621. */
  13622. serialize(): any;
  13623. /**
  13624. * Parse properties from a JSON object
  13625. * @param serializationObject defines the JSON object
  13626. */
  13627. parse(serializationObject: any): void;
  13628. }
  13629. }
  13630. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13631. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13632. import { Effect } from "babylonjs/Materials/effect";
  13633. import { Particle } from "babylonjs/Particles/particle";
  13634. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13635. /**
  13636. * Particle emitter emitting particles from the inside of a hemisphere.
  13637. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13638. */
  13639. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13640. /**
  13641. * The radius of the emission hemisphere.
  13642. */
  13643. radius: number;
  13644. /**
  13645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13646. */
  13647. radiusRange: number;
  13648. /**
  13649. * How much to randomize the particle direction [0-1].
  13650. */
  13651. directionRandomizer: number;
  13652. /**
  13653. * Creates a new instance HemisphericParticleEmitter
  13654. * @param radius the radius of the emission hemisphere (1 by default)
  13655. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13656. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13657. */
  13658. constructor(
  13659. /**
  13660. * The radius of the emission hemisphere.
  13661. */
  13662. radius?: number,
  13663. /**
  13664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13665. */
  13666. radiusRange?: number,
  13667. /**
  13668. * How much to randomize the particle direction [0-1].
  13669. */
  13670. directionRandomizer?: number);
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. * @param isLocal defines if the direction should be set in local space
  13677. */
  13678. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13679. /**
  13680. * Called by the particle System when the position is computed for the created particle.
  13681. * @param worldMatrix is the world matrix of the particle system
  13682. * @param positionToUpdate is the position vector to update with the result
  13683. * @param particle is the particle we are computed the position for
  13684. * @param isLocal defines if the position should be set in local space
  13685. */
  13686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13687. /**
  13688. * Clones the current emitter and returns a copy of it
  13689. * @returns the new emitter
  13690. */
  13691. clone(): HemisphericParticleEmitter;
  13692. /**
  13693. * Called by the GPUParticleSystem to setup the update shader
  13694. * @param effect defines the update shader
  13695. */
  13696. applyToShader(effect: Effect): void;
  13697. /**
  13698. * Returns a string to use to update the GPU particles update shader
  13699. * @returns a string containng the defines string
  13700. */
  13701. getEffectDefines(): string;
  13702. /**
  13703. * Returns the string "HemisphericParticleEmitter"
  13704. * @returns a string containing the class name
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Serializes the particle system to a JSON object.
  13709. * @returns the JSON object
  13710. */
  13711. serialize(): any;
  13712. /**
  13713. * Parse properties from a JSON object
  13714. * @param serializationObject defines the JSON object
  13715. */
  13716. parse(serializationObject: any): void;
  13717. }
  13718. }
  13719. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13720. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13721. import { Effect } from "babylonjs/Materials/effect";
  13722. import { Particle } from "babylonjs/Particles/particle";
  13723. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13724. /**
  13725. * Particle emitter emitting particles from a point.
  13726. * It emits the particles randomly between 2 given directions.
  13727. */
  13728. export class PointParticleEmitter implements IParticleEmitterType {
  13729. /**
  13730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13731. */
  13732. direction1: Vector3;
  13733. /**
  13734. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13735. */
  13736. direction2: Vector3;
  13737. /**
  13738. * Creates a new instance PointParticleEmitter
  13739. */
  13740. constructor();
  13741. /**
  13742. * Called by the particle System when the direction is computed for the created particle.
  13743. * @param worldMatrix is the world matrix of the particle system
  13744. * @param directionToUpdate is the direction vector to update with the result
  13745. * @param particle is the particle we are computed the direction for
  13746. * @param isLocal defines if the direction should be set in local space
  13747. */
  13748. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13749. /**
  13750. * Called by the particle System when the position is computed for the created particle.
  13751. * @param worldMatrix is the world matrix of the particle system
  13752. * @param positionToUpdate is the position vector to update with the result
  13753. * @param particle is the particle we are computed the position for
  13754. * @param isLocal defines if the position should be set in local space
  13755. */
  13756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13757. /**
  13758. * Clones the current emitter and returns a copy of it
  13759. * @returns the new emitter
  13760. */
  13761. clone(): PointParticleEmitter;
  13762. /**
  13763. * Called by the GPUParticleSystem to setup the update shader
  13764. * @param effect defines the update shader
  13765. */
  13766. applyToShader(effect: Effect): void;
  13767. /**
  13768. * Returns a string to use to update the GPU particles update shader
  13769. * @returns a string containng the defines string
  13770. */
  13771. getEffectDefines(): string;
  13772. /**
  13773. * Returns the string "PointParticleEmitter"
  13774. * @returns a string containing the class name
  13775. */
  13776. getClassName(): string;
  13777. /**
  13778. * Serializes the particle system to a JSON object.
  13779. * @returns the JSON object
  13780. */
  13781. serialize(): any;
  13782. /**
  13783. * Parse properties from a JSON object
  13784. * @param serializationObject defines the JSON object
  13785. */
  13786. parse(serializationObject: any): void;
  13787. }
  13788. }
  13789. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13790. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13791. import { Effect } from "babylonjs/Materials/effect";
  13792. import { Particle } from "babylonjs/Particles/particle";
  13793. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13794. /**
  13795. * Particle emitter emitting particles from the inside of a sphere.
  13796. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13797. */
  13798. export class SphereParticleEmitter implements IParticleEmitterType {
  13799. /**
  13800. * The radius of the emission sphere.
  13801. */
  13802. radius: number;
  13803. /**
  13804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13805. */
  13806. radiusRange: number;
  13807. /**
  13808. * How much to randomize the particle direction [0-1].
  13809. */
  13810. directionRandomizer: number;
  13811. /**
  13812. * Creates a new instance SphereParticleEmitter
  13813. * @param radius the radius of the emission sphere (1 by default)
  13814. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13815. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13816. */
  13817. constructor(
  13818. /**
  13819. * The radius of the emission sphere.
  13820. */
  13821. radius?: number,
  13822. /**
  13823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13824. */
  13825. radiusRange?: number,
  13826. /**
  13827. * How much to randomize the particle direction [0-1].
  13828. */
  13829. directionRandomizer?: number);
  13830. /**
  13831. * Called by the particle System when the direction is computed for the created particle.
  13832. * @param worldMatrix is the world matrix of the particle system
  13833. * @param directionToUpdate is the direction vector to update with the result
  13834. * @param particle is the particle we are computed the direction for
  13835. * @param isLocal defines if the direction should be set in local space
  13836. */
  13837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13838. /**
  13839. * Called by the particle System when the position is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param positionToUpdate is the position vector to update with the result
  13842. * @param particle is the particle we are computed the position for
  13843. * @param isLocal defines if the position should be set in local space
  13844. */
  13845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Clones the current emitter and returns a copy of it
  13848. * @returns the new emitter
  13849. */
  13850. clone(): SphereParticleEmitter;
  13851. /**
  13852. * Called by the GPUParticleSystem to setup the update shader
  13853. * @param effect defines the update shader
  13854. */
  13855. applyToShader(effect: Effect): void;
  13856. /**
  13857. * Returns a string to use to update the GPU particles update shader
  13858. * @returns a string containng the defines string
  13859. */
  13860. getEffectDefines(): string;
  13861. /**
  13862. * Returns the string "SphereParticleEmitter"
  13863. * @returns a string containing the class name
  13864. */
  13865. getClassName(): string;
  13866. /**
  13867. * Serializes the particle system to a JSON object.
  13868. * @returns the JSON object
  13869. */
  13870. serialize(): any;
  13871. /**
  13872. * Parse properties from a JSON object
  13873. * @param serializationObject defines the JSON object
  13874. */
  13875. parse(serializationObject: any): void;
  13876. }
  13877. /**
  13878. * Particle emitter emitting particles from the inside of a sphere.
  13879. * It emits the particles randomly between two vectors.
  13880. */
  13881. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13882. /**
  13883. * The min limit of the emission direction.
  13884. */
  13885. direction1: Vector3;
  13886. /**
  13887. * The max limit of the emission direction.
  13888. */
  13889. direction2: Vector3;
  13890. /**
  13891. * Creates a new instance SphereDirectedParticleEmitter
  13892. * @param radius the radius of the emission sphere (1 by default)
  13893. * @param direction1 the min limit of the emission direction (up vector by default)
  13894. * @param direction2 the max limit of the emission direction (up vector by default)
  13895. */
  13896. constructor(radius?: number,
  13897. /**
  13898. * The min limit of the emission direction.
  13899. */
  13900. direction1?: Vector3,
  13901. /**
  13902. * The max limit of the emission direction.
  13903. */
  13904. direction2?: Vector3);
  13905. /**
  13906. * Called by the particle System when the direction is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param directionToUpdate is the direction vector to update with the result
  13909. * @param particle is the particle we are computed the direction for
  13910. */
  13911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13912. /**
  13913. * Clones the current emitter and returns a copy of it
  13914. * @returns the new emitter
  13915. */
  13916. clone(): SphereDirectedParticleEmitter;
  13917. /**
  13918. * Called by the GPUParticleSystem to setup the update shader
  13919. * @param effect defines the update shader
  13920. */
  13921. applyToShader(effect: Effect): void;
  13922. /**
  13923. * Returns a string to use to update the GPU particles update shader
  13924. * @returns a string containng the defines string
  13925. */
  13926. getEffectDefines(): string;
  13927. /**
  13928. * Returns the string "SphereDirectedParticleEmitter"
  13929. * @returns a string containing the class name
  13930. */
  13931. getClassName(): string;
  13932. /**
  13933. * Serializes the particle system to a JSON object.
  13934. * @returns the JSON object
  13935. */
  13936. serialize(): any;
  13937. /**
  13938. * Parse properties from a JSON object
  13939. * @param serializationObject defines the JSON object
  13940. */
  13941. parse(serializationObject: any): void;
  13942. }
  13943. }
  13944. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13945. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13946. import { Effect } from "babylonjs/Materials/effect";
  13947. import { Particle } from "babylonjs/Particles/particle";
  13948. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13949. import { Nullable } from "babylonjs/types";
  13950. /**
  13951. * Particle emitter emitting particles from a custom list of positions.
  13952. */
  13953. export class CustomParticleEmitter implements IParticleEmitterType {
  13954. /**
  13955. * Gets or sets the position generator that will create the inital position of each particle.
  13956. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13957. */
  13958. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13959. /**
  13960. * Gets or sets the destination generator that will create the final destination of each particle.
  13961. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13962. */
  13963. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13964. /**
  13965. * Creates a new instance CustomParticleEmitter
  13966. */
  13967. constructor();
  13968. /**
  13969. * Called by the particle System when the direction is computed for the created particle.
  13970. * @param worldMatrix is the world matrix of the particle system
  13971. * @param directionToUpdate is the direction vector to update with the result
  13972. * @param particle is the particle we are computed the direction for
  13973. * @param isLocal defines if the direction should be set in local space
  13974. */
  13975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13976. /**
  13977. * Called by the particle System when the position is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param positionToUpdate is the position vector to update with the result
  13980. * @param particle is the particle we are computed the position for
  13981. * @param isLocal defines if the position should be set in local space
  13982. */
  13983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Clones the current emitter and returns a copy of it
  13986. * @returns the new emitter
  13987. */
  13988. clone(): CustomParticleEmitter;
  13989. /**
  13990. * Called by the GPUParticleSystem to setup the update shader
  13991. * @param effect defines the update shader
  13992. */
  13993. applyToShader(effect: Effect): void;
  13994. /**
  13995. * Returns a string to use to update the GPU particles update shader
  13996. * @returns a string containng the defines string
  13997. */
  13998. getEffectDefines(): string;
  13999. /**
  14000. * Returns the string "PointParticleEmitter"
  14001. * @returns a string containing the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Serializes the particle system to a JSON object.
  14006. * @returns the JSON object
  14007. */
  14008. serialize(): any;
  14009. /**
  14010. * Parse properties from a JSON object
  14011. * @param serializationObject defines the JSON object
  14012. */
  14013. parse(serializationObject: any): void;
  14014. }
  14015. }
  14016. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14017. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14018. import { Effect } from "babylonjs/Materials/effect";
  14019. import { Particle } from "babylonjs/Particles/particle";
  14020. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14021. import { Nullable } from "babylonjs/types";
  14022. import { Scene } from "babylonjs/scene";
  14023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14024. /**
  14025. * Particle emitter emitting particles from the inside of a box.
  14026. * It emits the particles randomly between 2 given directions.
  14027. */
  14028. export class MeshParticleEmitter implements IParticleEmitterType {
  14029. private _indices;
  14030. private _positions;
  14031. private _normals;
  14032. private _storedNormal;
  14033. private _mesh;
  14034. /**
  14035. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14036. */
  14037. direction1: Vector3;
  14038. /**
  14039. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14040. */
  14041. direction2: Vector3;
  14042. /**
  14043. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14044. */
  14045. useMeshNormalsForDirection: boolean;
  14046. /** Defines the mesh to use as source */
  14047. get mesh(): Nullable<AbstractMesh>;
  14048. set mesh(value: Nullable<AbstractMesh>);
  14049. /**
  14050. * Creates a new instance MeshParticleEmitter
  14051. * @param mesh defines the mesh to use as source
  14052. */
  14053. constructor(mesh?: Nullable<AbstractMesh>);
  14054. /**
  14055. * Called by the particle System when the direction is computed for the created particle.
  14056. * @param worldMatrix is the world matrix of the particle system
  14057. * @param directionToUpdate is the direction vector to update with the result
  14058. * @param particle is the particle we are computed the direction for
  14059. * @param isLocal defines if the direction should be set in local space
  14060. */
  14061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14062. /**
  14063. * Called by the particle System when the position is computed for the created particle.
  14064. * @param worldMatrix is the world matrix of the particle system
  14065. * @param positionToUpdate is the position vector to update with the result
  14066. * @param particle is the particle we are computed the position for
  14067. * @param isLocal defines if the position should be set in local space
  14068. */
  14069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14070. /**
  14071. * Clones the current emitter and returns a copy of it
  14072. * @returns the new emitter
  14073. */
  14074. clone(): MeshParticleEmitter;
  14075. /**
  14076. * Called by the GPUParticleSystem to setup the update shader
  14077. * @param effect defines the update shader
  14078. */
  14079. applyToShader(effect: Effect): void;
  14080. /**
  14081. * Returns a string to use to update the GPU particles update shader
  14082. * @returns a string containng the defines string
  14083. */
  14084. getEffectDefines(): string;
  14085. /**
  14086. * Returns the string "BoxParticleEmitter"
  14087. * @returns a string containing the class name
  14088. */
  14089. getClassName(): string;
  14090. /**
  14091. * Serializes the particle system to a JSON object.
  14092. * @returns the JSON object
  14093. */
  14094. serialize(): any;
  14095. /**
  14096. * Parse properties from a JSON object
  14097. * @param serializationObject defines the JSON object
  14098. * @param scene defines the hosting scene
  14099. */
  14100. parse(serializationObject: any, scene: Scene): void;
  14101. }
  14102. }
  14103. declare module "babylonjs/Particles/EmitterTypes/index" {
  14104. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14105. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14106. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14107. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14108. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14109. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14110. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14111. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14112. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14113. }
  14114. declare module "babylonjs/Particles/IParticleSystem" {
  14115. import { Nullable } from "babylonjs/types";
  14116. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14117. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14120. import { Texture } from "babylonjs/Materials/Textures/texture";
  14121. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14122. import { Scene } from "babylonjs/scene";
  14123. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14124. import { Effect } from "babylonjs/Materials/effect";
  14125. import { Observable } from "babylonjs/Misc/observable";
  14126. import { Animation } from "babylonjs/Animations/animation";
  14127. /**
  14128. * Interface representing a particle system in Babylon.js.
  14129. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14130. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14131. */
  14132. export interface IParticleSystem {
  14133. /**
  14134. * List of animations used by the particle system.
  14135. */
  14136. animations: Animation[];
  14137. /**
  14138. * The id of the Particle system.
  14139. */
  14140. id: string;
  14141. /**
  14142. * The name of the Particle system.
  14143. */
  14144. name: string;
  14145. /**
  14146. * The emitter represents the Mesh or position we are attaching the particle system to.
  14147. */
  14148. emitter: Nullable<AbstractMesh | Vector3>;
  14149. /**
  14150. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14151. */
  14152. isBillboardBased: boolean;
  14153. /**
  14154. * The rendering group used by the Particle system to chose when to render.
  14155. */
  14156. renderingGroupId: number;
  14157. /**
  14158. * The layer mask we are rendering the particles through.
  14159. */
  14160. layerMask: number;
  14161. /**
  14162. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14163. */
  14164. updateSpeed: number;
  14165. /**
  14166. * The amount of time the particle system is running (depends of the overall update speed).
  14167. */
  14168. targetStopDuration: number;
  14169. /**
  14170. * The texture used to render each particle. (this can be a spritesheet)
  14171. */
  14172. particleTexture: Nullable<Texture>;
  14173. /**
  14174. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14175. */
  14176. blendMode: number;
  14177. /**
  14178. * Minimum life time of emitting particles.
  14179. */
  14180. minLifeTime: number;
  14181. /**
  14182. * Maximum life time of emitting particles.
  14183. */
  14184. maxLifeTime: number;
  14185. /**
  14186. * Minimum Size of emitting particles.
  14187. */
  14188. minSize: number;
  14189. /**
  14190. * Maximum Size of emitting particles.
  14191. */
  14192. maxSize: number;
  14193. /**
  14194. * Minimum scale of emitting particles on X axis.
  14195. */
  14196. minScaleX: number;
  14197. /**
  14198. * Maximum scale of emitting particles on X axis.
  14199. */
  14200. maxScaleX: number;
  14201. /**
  14202. * Minimum scale of emitting particles on Y axis.
  14203. */
  14204. minScaleY: number;
  14205. /**
  14206. * Maximum scale of emitting particles on Y axis.
  14207. */
  14208. maxScaleY: number;
  14209. /**
  14210. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14211. */
  14212. color1: Color4;
  14213. /**
  14214. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14215. */
  14216. color2: Color4;
  14217. /**
  14218. * Color the particle will have at the end of its lifetime.
  14219. */
  14220. colorDead: Color4;
  14221. /**
  14222. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14223. */
  14224. emitRate: number;
  14225. /**
  14226. * You can use gravity if you want to give an orientation to your particles.
  14227. */
  14228. gravity: Vector3;
  14229. /**
  14230. * Minimum power of emitting particles.
  14231. */
  14232. minEmitPower: number;
  14233. /**
  14234. * Maximum power of emitting particles.
  14235. */
  14236. maxEmitPower: number;
  14237. /**
  14238. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14239. */
  14240. minAngularSpeed: number;
  14241. /**
  14242. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14243. */
  14244. maxAngularSpeed: number;
  14245. /**
  14246. * Gets or sets the minimal initial rotation in radians.
  14247. */
  14248. minInitialRotation: number;
  14249. /**
  14250. * Gets or sets the maximal initial rotation in radians.
  14251. */
  14252. maxInitialRotation: number;
  14253. /**
  14254. * The particle emitter type defines the emitter used by the particle system.
  14255. * It can be for example box, sphere, or cone...
  14256. */
  14257. particleEmitterType: Nullable<IParticleEmitterType>;
  14258. /**
  14259. * Defines the delay in milliseconds before starting the system (0 by default)
  14260. */
  14261. startDelay: number;
  14262. /**
  14263. * 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
  14264. */
  14265. preWarmCycles: number;
  14266. /**
  14267. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14268. */
  14269. preWarmStepOffset: number;
  14270. /**
  14271. * 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)
  14272. */
  14273. spriteCellChangeSpeed: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14276. */
  14277. startSpriteCellID: number;
  14278. /**
  14279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14280. */
  14281. endSpriteCellID: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14284. */
  14285. spriteCellWidth: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14288. */
  14289. spriteCellHeight: number;
  14290. /**
  14291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14292. */
  14293. spriteRandomStartCell: boolean;
  14294. /**
  14295. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14296. */
  14297. isAnimationSheetEnabled: boolean;
  14298. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14299. translationPivot: Vector2;
  14300. /**
  14301. * Gets or sets a texture used to add random noise to particle positions
  14302. */
  14303. noiseTexture: Nullable<BaseTexture>;
  14304. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14305. noiseStrength: Vector3;
  14306. /**
  14307. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14308. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14309. */
  14310. billboardMode: number;
  14311. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14312. limitVelocityDamping: number;
  14313. /**
  14314. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14315. */
  14316. beginAnimationOnStart: boolean;
  14317. /**
  14318. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14319. */
  14320. beginAnimationFrom: number;
  14321. /**
  14322. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14323. */
  14324. beginAnimationTo: number;
  14325. /**
  14326. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14327. */
  14328. beginAnimationLoop: boolean;
  14329. /**
  14330. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14331. */
  14332. disposeOnStop: boolean;
  14333. /**
  14334. * Specifies if the particles are updated in emitter local space or world space
  14335. */
  14336. isLocal: boolean;
  14337. /** Snippet ID if the particle system was created from the snippet server */
  14338. snippetId: string;
  14339. /**
  14340. * Gets the maximum number of particles active at the same time.
  14341. * @returns The max number of active particles.
  14342. */
  14343. getCapacity(): number;
  14344. /**
  14345. * Gets the number of particles active at the same time.
  14346. * @returns The number of active particles.
  14347. */
  14348. getActiveCount(): number;
  14349. /**
  14350. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14351. * @returns True if it has been started, otherwise false.
  14352. */
  14353. isStarted(): boolean;
  14354. /**
  14355. * Animates the particle system for this frame.
  14356. */
  14357. animate(): void;
  14358. /**
  14359. * Renders the particle system in its current state.
  14360. * @returns the current number of particles
  14361. */
  14362. render(): number;
  14363. /**
  14364. * Dispose the particle system and frees its associated resources.
  14365. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14366. */
  14367. dispose(disposeTexture?: boolean): void;
  14368. /**
  14369. * An event triggered when the system is disposed
  14370. */
  14371. onDisposeObservable: Observable<IParticleSystem>;
  14372. /**
  14373. * Clones the particle system.
  14374. * @param name The name of the cloned object
  14375. * @param newEmitter The new emitter to use
  14376. * @returns the cloned particle system
  14377. */
  14378. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14379. /**
  14380. * Serializes the particle system to a JSON object
  14381. * @param serializeTexture defines if the texture must be serialized as well
  14382. * @returns the JSON object
  14383. */
  14384. serialize(serializeTexture: boolean): any;
  14385. /**
  14386. * Rebuild the particle system
  14387. */
  14388. rebuild(): void;
  14389. /** Force the system to rebuild all gradients that need to be resync */
  14390. forceRefreshGradients(): void;
  14391. /**
  14392. * Starts the particle system and begins to emit
  14393. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14394. */
  14395. start(delay?: number): void;
  14396. /**
  14397. * Stops the particle system.
  14398. */
  14399. stop(): void;
  14400. /**
  14401. * Remove all active particles
  14402. */
  14403. reset(): void;
  14404. /**
  14405. * Gets a boolean indicating that the system is stopping
  14406. * @returns true if the system is currently stopping
  14407. */
  14408. isStopping(): boolean;
  14409. /**
  14410. * Is this system ready to be used/rendered
  14411. * @return true if the system is ready
  14412. */
  14413. isReady(): boolean;
  14414. /**
  14415. * Returns the string "ParticleSystem"
  14416. * @returns a string containing the class name
  14417. */
  14418. getClassName(): string;
  14419. /**
  14420. * Gets the custom effect used to render the particles
  14421. * @param blendMode Blend mode for which the effect should be retrieved
  14422. * @returns The effect
  14423. */
  14424. getCustomEffect(blendMode: number): Nullable<Effect>;
  14425. /**
  14426. * Sets the custom effect used to render the particles
  14427. * @param effect The effect to set
  14428. * @param blendMode Blend mode for which the effect should be set
  14429. */
  14430. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14431. /**
  14432. * Fill the defines array according to the current settings of the particle system
  14433. * @param defines Array to be updated
  14434. * @param blendMode blend mode to take into account when updating the array
  14435. */
  14436. fillDefines(defines: Array<string>, blendMode: number): void;
  14437. /**
  14438. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14439. * @param uniforms Uniforms array to fill
  14440. * @param attributes Attributes array to fill
  14441. * @param samplers Samplers array to fill
  14442. */
  14443. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14444. /**
  14445. * Observable that will be called just before the particles are drawn
  14446. */
  14447. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14448. /**
  14449. * Gets the name of the particle vertex shader
  14450. */
  14451. vertexShaderName: string;
  14452. /**
  14453. * Adds a new color gradient
  14454. * @param gradient defines the gradient to use (between 0 and 1)
  14455. * @param color1 defines the color to affect to the specified gradient
  14456. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14457. * @returns the current particle system
  14458. */
  14459. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14460. /**
  14461. * Remove a specific color gradient
  14462. * @param gradient defines the gradient to remove
  14463. * @returns the current particle system
  14464. */
  14465. removeColorGradient(gradient: number): IParticleSystem;
  14466. /**
  14467. * Adds a new size gradient
  14468. * @param gradient defines the gradient to use (between 0 and 1)
  14469. * @param factor defines the size factor to affect to the specified gradient
  14470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14471. * @returns the current particle system
  14472. */
  14473. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14474. /**
  14475. * Remove a specific size gradient
  14476. * @param gradient defines the gradient to remove
  14477. * @returns the current particle system
  14478. */
  14479. removeSizeGradient(gradient: number): IParticleSystem;
  14480. /**
  14481. * Gets the current list of color gradients.
  14482. * You must use addColorGradient and removeColorGradient to udpate this list
  14483. * @returns the list of color gradients
  14484. */
  14485. getColorGradients(): Nullable<Array<ColorGradient>>;
  14486. /**
  14487. * Gets the current list of size gradients.
  14488. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14489. * @returns the list of size gradients
  14490. */
  14491. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14492. /**
  14493. * Gets the current list of angular speed gradients.
  14494. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14495. * @returns the list of angular speed gradients
  14496. */
  14497. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Adds a new angular speed gradient
  14500. * @param gradient defines the gradient to use (between 0 and 1)
  14501. * @param factor defines the angular speed to affect to the specified gradient
  14502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14503. * @returns the current particle system
  14504. */
  14505. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14506. /**
  14507. * Remove a specific angular speed gradient
  14508. * @param gradient defines the gradient to remove
  14509. * @returns the current particle system
  14510. */
  14511. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of velocity gradients.
  14514. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14515. * @returns the list of velocity gradients
  14516. */
  14517. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new velocity gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param factor defines the velocity to affect to the specified gradient
  14522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14523. * @returns the current particle system
  14524. */
  14525. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14526. /**
  14527. * Remove a specific velocity gradient
  14528. * @param gradient defines the gradient to remove
  14529. * @returns the current particle system
  14530. */
  14531. removeVelocityGradient(gradient: number): IParticleSystem;
  14532. /**
  14533. * Gets the current list of limit velocity gradients.
  14534. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14535. * @returns the list of limit velocity gradients
  14536. */
  14537. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Adds a new limit velocity gradient
  14540. * @param gradient defines the gradient to use (between 0 and 1)
  14541. * @param factor defines the limit velocity to affect to the specified gradient
  14542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14543. * @returns the current particle system
  14544. */
  14545. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14546. /**
  14547. * Remove a specific limit velocity gradient
  14548. * @param gradient defines the gradient to remove
  14549. * @returns the current particle system
  14550. */
  14551. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14552. /**
  14553. * Adds a new drag gradient
  14554. * @param gradient defines the gradient to use (between 0 and 1)
  14555. * @param factor defines the drag to affect to the specified gradient
  14556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14557. * @returns the current particle system
  14558. */
  14559. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14560. /**
  14561. * Remove a specific drag gradient
  14562. * @param gradient defines the gradient to remove
  14563. * @returns the current particle system
  14564. */
  14565. removeDragGradient(gradient: number): IParticleSystem;
  14566. /**
  14567. * Gets the current list of drag gradients.
  14568. * You must use addDragGradient and removeDragGradient to udpate this list
  14569. * @returns the list of drag gradients
  14570. */
  14571. getDragGradients(): Nullable<Array<FactorGradient>>;
  14572. /**
  14573. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14574. * @param gradient defines the gradient to use (between 0 and 1)
  14575. * @param factor defines the emit rate to affect to the specified gradient
  14576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14577. * @returns the current particle system
  14578. */
  14579. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14580. /**
  14581. * Remove a specific emit rate gradient
  14582. * @param gradient defines the gradient to remove
  14583. * @returns the current particle system
  14584. */
  14585. removeEmitRateGradient(gradient: number): IParticleSystem;
  14586. /**
  14587. * Gets the current list of emit rate gradients.
  14588. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14589. * @returns the list of emit rate gradients
  14590. */
  14591. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param factor defines the start size to affect to the specified gradient
  14596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14597. * @returns the current particle system
  14598. */
  14599. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14600. /**
  14601. * Remove a specific start size gradient
  14602. * @param gradient defines the gradient to remove
  14603. * @returns the current particle system
  14604. */
  14605. removeStartSizeGradient(gradient: number): IParticleSystem;
  14606. /**
  14607. * Gets the current list of start size gradients.
  14608. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14609. * @returns the list of start size gradients
  14610. */
  14611. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14612. /**
  14613. * Adds a new life time gradient
  14614. * @param gradient defines the gradient to use (between 0 and 1)
  14615. * @param factor defines the life time factor to affect to the specified gradient
  14616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14617. * @returns the current particle system
  14618. */
  14619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14620. /**
  14621. * Remove a specific life time gradient
  14622. * @param gradient defines the gradient to remove
  14623. * @returns the current particle system
  14624. */
  14625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14626. /**
  14627. * Gets the current list of life time gradients.
  14628. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14629. * @returns the list of life time gradients
  14630. */
  14631. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Gets the current list of color gradients.
  14634. * You must use addColorGradient and removeColorGradient to udpate this list
  14635. * @returns the list of color gradients
  14636. */
  14637. getColorGradients(): Nullable<Array<ColorGradient>>;
  14638. /**
  14639. * Adds a new ramp gradient used to remap particle colors
  14640. * @param gradient defines the gradient to use (between 0 and 1)
  14641. * @param color defines the color to affect to the specified gradient
  14642. * @returns the current particle system
  14643. */
  14644. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14645. /**
  14646. * Gets the current list of ramp gradients.
  14647. * You must use addRampGradient and removeRampGradient to udpate this list
  14648. * @returns the list of ramp gradients
  14649. */
  14650. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14651. /** Gets or sets a boolean indicating that ramp gradients must be used
  14652. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14653. */
  14654. useRampGradients: boolean;
  14655. /**
  14656. * Adds a new color remap gradient
  14657. * @param gradient defines the gradient to use (between 0 and 1)
  14658. * @param min defines the color remap minimal range
  14659. * @param max defines the color remap maximal range
  14660. * @returns the current particle system
  14661. */
  14662. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14663. /**
  14664. * Gets the current list of color remap gradients.
  14665. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14666. * @returns the list of color remap gradients
  14667. */
  14668. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14669. /**
  14670. * Adds a new alpha remap gradient
  14671. * @param gradient defines the gradient to use (between 0 and 1)
  14672. * @param min defines the alpha remap minimal range
  14673. * @param max defines the alpha remap maximal range
  14674. * @returns the current particle system
  14675. */
  14676. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14677. /**
  14678. * Gets the current list of alpha remap gradients.
  14679. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14680. * @returns the list of alpha remap gradients
  14681. */
  14682. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14683. /**
  14684. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14687. * @returns the emitter
  14688. */
  14689. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14690. /**
  14691. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14692. * @param radius The radius of the hemisphere to emit from
  14693. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14694. * @returns the emitter
  14695. */
  14696. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14697. /**
  14698. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14699. * @param radius The radius of the sphere to emit from
  14700. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14701. * @returns the emitter
  14702. */
  14703. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14704. /**
  14705. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14706. * @param radius The radius of the sphere to emit from
  14707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14709. * @returns the emitter
  14710. */
  14711. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14712. /**
  14713. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14714. * @param radius The radius of the emission cylinder
  14715. * @param height The height of the emission cylinder
  14716. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14717. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14718. * @returns the emitter
  14719. */
  14720. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14721. /**
  14722. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14723. * @param radius The radius of the cylinder to emit from
  14724. * @param height The height of the emission cylinder
  14725. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14728. * @returns the emitter
  14729. */
  14730. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14731. /**
  14732. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14733. * @param radius The radius of the cone to emit from
  14734. * @param angle The base angle of the cone
  14735. * @returns the emitter
  14736. */
  14737. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14738. /**
  14739. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14740. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14741. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14742. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14743. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14744. * @returns the emitter
  14745. */
  14746. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14747. /**
  14748. * Get hosting scene
  14749. * @returns the scene
  14750. */
  14751. getScene(): Scene;
  14752. }
  14753. }
  14754. declare module "babylonjs/Meshes/transformNode" {
  14755. import { DeepImmutable } from "babylonjs/types";
  14756. import { Observable } from "babylonjs/Misc/observable";
  14757. import { Nullable } from "babylonjs/types";
  14758. import { Camera } from "babylonjs/Cameras/camera";
  14759. import { Scene } from "babylonjs/scene";
  14760. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14761. import { Node } from "babylonjs/node";
  14762. import { Bone } from "babylonjs/Bones/bone";
  14763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14764. import { Space } from "babylonjs/Maths/math.axis";
  14765. /**
  14766. * 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.
  14767. * @see https://doc.babylonjs.com/how_to/transformnode
  14768. */
  14769. export class TransformNode extends Node {
  14770. /**
  14771. * Object will not rotate to face the camera
  14772. */
  14773. static BILLBOARDMODE_NONE: number;
  14774. /**
  14775. * Object will rotate to face the camera but only on the x axis
  14776. */
  14777. static BILLBOARDMODE_X: number;
  14778. /**
  14779. * Object will rotate to face the camera but only on the y axis
  14780. */
  14781. static BILLBOARDMODE_Y: number;
  14782. /**
  14783. * Object will rotate to face the camera but only on the z axis
  14784. */
  14785. static BILLBOARDMODE_Z: number;
  14786. /**
  14787. * Object will rotate to face the camera
  14788. */
  14789. static BILLBOARDMODE_ALL: number;
  14790. /**
  14791. * Object will rotate to face the camera's position instead of orientation
  14792. */
  14793. static BILLBOARDMODE_USE_POSITION: number;
  14794. private static _TmpRotation;
  14795. private static _TmpScaling;
  14796. private static _TmpTranslation;
  14797. private _forward;
  14798. private _forwardInverted;
  14799. private _up;
  14800. private _right;
  14801. private _rightInverted;
  14802. private _position;
  14803. private _rotation;
  14804. private _rotationQuaternion;
  14805. protected _scaling: Vector3;
  14806. protected _isDirty: boolean;
  14807. private _transformToBoneReferal;
  14808. private _isAbsoluteSynced;
  14809. private _billboardMode;
  14810. /**
  14811. * Gets or sets the billboard mode. Default is 0.
  14812. *
  14813. * | Value | Type | Description |
  14814. * | --- | --- | --- |
  14815. * | 0 | BILLBOARDMODE_NONE | |
  14816. * | 1 | BILLBOARDMODE_X | |
  14817. * | 2 | BILLBOARDMODE_Y | |
  14818. * | 4 | BILLBOARDMODE_Z | |
  14819. * | 7 | BILLBOARDMODE_ALL | |
  14820. *
  14821. */
  14822. get billboardMode(): number;
  14823. set billboardMode(value: number);
  14824. private _preserveParentRotationForBillboard;
  14825. /**
  14826. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14827. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14828. */
  14829. get preserveParentRotationForBillboard(): boolean;
  14830. set preserveParentRotationForBillboard(value: boolean);
  14831. /**
  14832. * 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
  14833. */
  14834. scalingDeterminant: number;
  14835. private _infiniteDistance;
  14836. /**
  14837. * Gets or sets the distance of the object to max, often used by skybox
  14838. */
  14839. get infiniteDistance(): boolean;
  14840. set infiniteDistance(value: boolean);
  14841. /**
  14842. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14843. * By default the system will update normals to compensate
  14844. */
  14845. ignoreNonUniformScaling: boolean;
  14846. /**
  14847. * 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
  14848. */
  14849. reIntegrateRotationIntoRotationQuaternion: boolean;
  14850. /** @hidden */
  14851. _poseMatrix: Nullable<Matrix>;
  14852. /** @hidden */
  14853. _localMatrix: Matrix;
  14854. private _usePivotMatrix;
  14855. private _absolutePosition;
  14856. private _absoluteScaling;
  14857. private _absoluteRotationQuaternion;
  14858. private _pivotMatrix;
  14859. private _pivotMatrixInverse;
  14860. protected _postMultiplyPivotMatrix: boolean;
  14861. protected _isWorldMatrixFrozen: boolean;
  14862. /** @hidden */
  14863. _indexInSceneTransformNodesArray: number;
  14864. /**
  14865. * An event triggered after the world matrix is updated
  14866. */
  14867. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14868. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14869. /**
  14870. * Gets a string identifying the name of the class
  14871. * @returns "TransformNode" string
  14872. */
  14873. getClassName(): string;
  14874. /**
  14875. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14876. */
  14877. get position(): Vector3;
  14878. set position(newPosition: Vector3);
  14879. /**
  14880. * 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)).
  14881. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14882. */
  14883. get rotation(): Vector3;
  14884. set rotation(newRotation: Vector3);
  14885. /**
  14886. * 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)).
  14887. */
  14888. get scaling(): Vector3;
  14889. set scaling(newScaling: Vector3);
  14890. /**
  14891. * 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).
  14892. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14893. */
  14894. get rotationQuaternion(): Nullable<Quaternion>;
  14895. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14896. /**
  14897. * The forward direction of that transform in world space.
  14898. */
  14899. get forward(): Vector3;
  14900. /**
  14901. * The up direction of that transform in world space.
  14902. */
  14903. get up(): Vector3;
  14904. /**
  14905. * The right direction of that transform in world space.
  14906. */
  14907. get right(): Vector3;
  14908. /**
  14909. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14910. * @param matrix the matrix to copy the pose from
  14911. * @returns this TransformNode.
  14912. */
  14913. updatePoseMatrix(matrix: Matrix): TransformNode;
  14914. /**
  14915. * Returns the mesh Pose matrix.
  14916. * @returns the pose matrix
  14917. */
  14918. getPoseMatrix(): Matrix;
  14919. /** @hidden */
  14920. _isSynchronized(): boolean;
  14921. /** @hidden */
  14922. _initCache(): void;
  14923. /**
  14924. * Flag the transform node as dirty (Forcing it to update everything)
  14925. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14926. * @returns this transform node
  14927. */
  14928. markAsDirty(property: string): TransformNode;
  14929. /**
  14930. * Returns the current mesh absolute position.
  14931. * Returns a Vector3.
  14932. */
  14933. get absolutePosition(): Vector3;
  14934. /**
  14935. * Returns the current mesh absolute scaling.
  14936. * Returns a Vector3.
  14937. */
  14938. get absoluteScaling(): Vector3;
  14939. /**
  14940. * Returns the current mesh absolute rotation.
  14941. * Returns a Quaternion.
  14942. */
  14943. get absoluteRotationQuaternion(): Quaternion;
  14944. /**
  14945. * Sets a new matrix to apply before all other transformation
  14946. * @param matrix defines the transform matrix
  14947. * @returns the current TransformNode
  14948. */
  14949. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14950. /**
  14951. * Sets a new pivot matrix to the current node
  14952. * @param matrix defines the new pivot matrix to use
  14953. * @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
  14954. * @returns the current TransformNode
  14955. */
  14956. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14957. /**
  14958. * Returns the mesh pivot matrix.
  14959. * Default : Identity.
  14960. * @returns the matrix
  14961. */
  14962. getPivotMatrix(): Matrix;
  14963. /**
  14964. * Instantiate (when possible) or clone that node with its hierarchy
  14965. * @param newParent defines the new parent to use for the instance (or clone)
  14966. * @param options defines options to configure how copy is done
  14967. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14968. * @returns an instance (or a clone) of the current node with its hiearchy
  14969. */
  14970. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14971. doNotInstantiate: boolean;
  14972. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14973. /**
  14974. * Prevents the World matrix to be computed any longer
  14975. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14976. * @returns the TransformNode.
  14977. */
  14978. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14979. /**
  14980. * Allows back the World matrix computation.
  14981. * @returns the TransformNode.
  14982. */
  14983. unfreezeWorldMatrix(): this;
  14984. /**
  14985. * True if the World matrix has been frozen.
  14986. */
  14987. get isWorldMatrixFrozen(): boolean;
  14988. /**
  14989. * Retuns the mesh absolute position in the World.
  14990. * @returns a Vector3.
  14991. */
  14992. getAbsolutePosition(): Vector3;
  14993. /**
  14994. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14995. * @param absolutePosition the absolute position to set
  14996. * @returns the TransformNode.
  14997. */
  14998. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14999. /**
  15000. * Sets the mesh position in its local space.
  15001. * @param vector3 the position to set in localspace
  15002. * @returns the TransformNode.
  15003. */
  15004. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15005. /**
  15006. * Returns the mesh position in the local space from the current World matrix values.
  15007. * @returns a new Vector3.
  15008. */
  15009. getPositionExpressedInLocalSpace(): Vector3;
  15010. /**
  15011. * Translates the mesh along the passed Vector3 in its local space.
  15012. * @param vector3 the distance to translate in localspace
  15013. * @returns the TransformNode.
  15014. */
  15015. locallyTranslate(vector3: Vector3): TransformNode;
  15016. private static _lookAtVectorCache;
  15017. /**
  15018. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15019. * @param targetPoint the position (must be in same space as current mesh) to look at
  15020. * @param yawCor optional yaw (y-axis) correction in radians
  15021. * @param pitchCor optional pitch (x-axis) correction in radians
  15022. * @param rollCor optional roll (z-axis) correction in radians
  15023. * @param space the choosen space of the target
  15024. * @returns the TransformNode.
  15025. */
  15026. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15027. /**
  15028. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15029. * This Vector3 is expressed in the World space.
  15030. * @param localAxis axis to rotate
  15031. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15032. */
  15033. getDirection(localAxis: Vector3): Vector3;
  15034. /**
  15035. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15036. * localAxis is expressed in the mesh local space.
  15037. * result is computed in the Wordl space from the mesh World matrix.
  15038. * @param localAxis axis to rotate
  15039. * @param result the resulting transformnode
  15040. * @returns this TransformNode.
  15041. */
  15042. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15043. /**
  15044. * Sets this transform node rotation to the given local axis.
  15045. * @param localAxis the axis in local space
  15046. * @param yawCor optional yaw (y-axis) correction in radians
  15047. * @param pitchCor optional pitch (x-axis) correction in radians
  15048. * @param rollCor optional roll (z-axis) correction in radians
  15049. * @returns this TransformNode
  15050. */
  15051. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15052. /**
  15053. * Sets a new pivot point to the current node
  15054. * @param point defines the new pivot point to use
  15055. * @param space defines if the point is in world or local space (local by default)
  15056. * @returns the current TransformNode
  15057. */
  15058. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15059. /**
  15060. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15061. * @returns the pivot point
  15062. */
  15063. getPivotPoint(): Vector3;
  15064. /**
  15065. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15066. * @param result the vector3 to store the result
  15067. * @returns this TransformNode.
  15068. */
  15069. getPivotPointToRef(result: Vector3): TransformNode;
  15070. /**
  15071. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15072. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15073. */
  15074. getAbsolutePivotPoint(): Vector3;
  15075. /**
  15076. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15077. * @param result vector3 to store the result
  15078. * @returns this TransformNode.
  15079. */
  15080. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15081. /**
  15082. * Defines the passed node as the parent of the current node.
  15083. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15084. * @see https://doc.babylonjs.com/how_to/parenting
  15085. * @param node the node ot set as the parent
  15086. * @returns this TransformNode.
  15087. */
  15088. setParent(node: Nullable<Node>): TransformNode;
  15089. private _nonUniformScaling;
  15090. /**
  15091. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15092. */
  15093. get nonUniformScaling(): boolean;
  15094. /** @hidden */
  15095. _updateNonUniformScalingState(value: boolean): boolean;
  15096. /**
  15097. * Attach the current TransformNode to another TransformNode associated with a bone
  15098. * @param bone Bone affecting the TransformNode
  15099. * @param affectedTransformNode TransformNode associated with the bone
  15100. * @returns this object
  15101. */
  15102. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15103. /**
  15104. * Detach the transform node if its associated with a bone
  15105. * @returns this object
  15106. */
  15107. detachFromBone(): TransformNode;
  15108. private static _rotationAxisCache;
  15109. /**
  15110. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15111. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15112. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15113. * The passed axis is also normalized.
  15114. * @param axis the axis to rotate around
  15115. * @param amount the amount to rotate in radians
  15116. * @param space Space to rotate in (Default: local)
  15117. * @returns the TransformNode.
  15118. */
  15119. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15120. /**
  15121. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15122. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15123. * The passed axis is also normalized. .
  15124. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15125. * @param point the point to rotate around
  15126. * @param axis the axis to rotate around
  15127. * @param amount the amount to rotate in radians
  15128. * @returns the TransformNode
  15129. */
  15130. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15131. /**
  15132. * Translates the mesh along the axis vector for the passed distance in the given space.
  15133. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15134. * @param axis the axis to translate in
  15135. * @param distance the distance to translate
  15136. * @param space Space to rotate in (Default: local)
  15137. * @returns the TransformNode.
  15138. */
  15139. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15140. /**
  15141. * Adds a rotation step to the mesh current rotation.
  15142. * x, y, z are Euler angles expressed in radians.
  15143. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15144. * This means this rotation is made in the mesh local space only.
  15145. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15146. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15147. * ```javascript
  15148. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15149. * ```
  15150. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15151. * 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.
  15152. * @param x Rotation to add
  15153. * @param y Rotation to add
  15154. * @param z Rotation to add
  15155. * @returns the TransformNode.
  15156. */
  15157. addRotation(x: number, y: number, z: number): TransformNode;
  15158. /**
  15159. * @hidden
  15160. */
  15161. protected _getEffectiveParent(): Nullable<Node>;
  15162. /**
  15163. * Computes the world matrix of the node
  15164. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15165. * @returns the world matrix
  15166. */
  15167. computeWorldMatrix(force?: boolean): Matrix;
  15168. /**
  15169. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15170. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15171. */
  15172. resetLocalMatrix(independentOfChildren?: boolean): void;
  15173. protected _afterComputeWorldMatrix(): void;
  15174. /**
  15175. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15176. * @param func callback function to add
  15177. *
  15178. * @returns the TransformNode.
  15179. */
  15180. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15181. /**
  15182. * Removes a registered callback function.
  15183. * @param func callback function to remove
  15184. * @returns the TransformNode.
  15185. */
  15186. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15187. /**
  15188. * Gets the position of the current mesh in camera space
  15189. * @param camera defines the camera to use
  15190. * @returns a position
  15191. */
  15192. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15193. /**
  15194. * Returns the distance from the mesh to the active camera
  15195. * @param camera defines the camera to use
  15196. * @returns the distance
  15197. */
  15198. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15199. /**
  15200. * Clone the current transform node
  15201. * @param name Name of the new clone
  15202. * @param newParent New parent for the clone
  15203. * @param doNotCloneChildren Do not clone children hierarchy
  15204. * @returns the new transform node
  15205. */
  15206. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15207. /**
  15208. * Serializes the objects information.
  15209. * @param currentSerializationObject defines the object to serialize in
  15210. * @returns the serialized object
  15211. */
  15212. serialize(currentSerializationObject?: any): any;
  15213. /**
  15214. * Returns a new TransformNode object parsed from the source provided.
  15215. * @param parsedTransformNode is the source.
  15216. * @param scene the scne the object belongs to
  15217. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15218. * @returns a new TransformNode object parsed from the source provided.
  15219. */
  15220. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15221. /**
  15222. * Get all child-transformNodes of this node
  15223. * @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
  15224. * @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
  15225. * @returns an array of TransformNode
  15226. */
  15227. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15228. /**
  15229. * Releases resources associated with this transform node.
  15230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15232. */
  15233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15234. /**
  15235. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15236. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15237. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15238. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15239. * @returns the current mesh
  15240. */
  15241. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15242. private _syncAbsoluteScalingAndRotation;
  15243. }
  15244. }
  15245. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15246. /**
  15247. * Class used to override all child animations of a given target
  15248. */
  15249. export class AnimationPropertiesOverride {
  15250. /**
  15251. * Gets or sets a value indicating if animation blending must be used
  15252. */
  15253. enableBlending: boolean;
  15254. /**
  15255. * Gets or sets the blending speed to use when enableBlending is true
  15256. */
  15257. blendingSpeed: number;
  15258. /**
  15259. * Gets or sets the default loop mode to use
  15260. */
  15261. loopMode: number;
  15262. }
  15263. }
  15264. declare module "babylonjs/Bones/bone" {
  15265. import { Skeleton } from "babylonjs/Bones/skeleton";
  15266. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15267. import { Nullable } from "babylonjs/types";
  15268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15270. import { Node } from "babylonjs/node";
  15271. import { Space } from "babylonjs/Maths/math.axis";
  15272. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15273. /**
  15274. * Class used to store bone information
  15275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15276. */
  15277. export class Bone extends Node {
  15278. /**
  15279. * defines the bone name
  15280. */
  15281. name: string;
  15282. private static _tmpVecs;
  15283. private static _tmpQuat;
  15284. private static _tmpMats;
  15285. /**
  15286. * Gets the list of child bones
  15287. */
  15288. children: Bone[];
  15289. /** Gets the animations associated with this bone */
  15290. animations: import("babylonjs/Animations/animation").Animation[];
  15291. /**
  15292. * Gets or sets bone length
  15293. */
  15294. length: number;
  15295. /**
  15296. * @hidden Internal only
  15297. * Set this value to map this bone to a different index in the transform matrices
  15298. * Set this value to -1 to exclude the bone from the transform matrices
  15299. */
  15300. _index: Nullable<number>;
  15301. private _skeleton;
  15302. private _localMatrix;
  15303. private _restPose;
  15304. private _baseMatrix;
  15305. private _absoluteTransform;
  15306. private _invertedAbsoluteTransform;
  15307. private _parent;
  15308. private _scalingDeterminant;
  15309. private _worldTransform;
  15310. private _localScaling;
  15311. private _localRotation;
  15312. private _localPosition;
  15313. private _needToDecompose;
  15314. private _needToCompose;
  15315. /** @hidden */
  15316. _linkedTransformNode: Nullable<TransformNode>;
  15317. /** @hidden */
  15318. _waitingTransformNodeId: Nullable<string>;
  15319. /** @hidden */
  15320. get _matrix(): Matrix;
  15321. /** @hidden */
  15322. set _matrix(value: Matrix);
  15323. /**
  15324. * Create a new bone
  15325. * @param name defines the bone name
  15326. * @param skeleton defines the parent skeleton
  15327. * @param parentBone defines the parent (can be null if the bone is the root)
  15328. * @param localMatrix defines the local matrix
  15329. * @param restPose defines the rest pose matrix
  15330. * @param baseMatrix defines the base matrix
  15331. * @param index defines index of the bone in the hiearchy
  15332. */
  15333. constructor(
  15334. /**
  15335. * defines the bone name
  15336. */
  15337. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15338. /**
  15339. * Gets the current object class name.
  15340. * @return the class name
  15341. */
  15342. getClassName(): string;
  15343. /**
  15344. * Gets the parent skeleton
  15345. * @returns a skeleton
  15346. */
  15347. getSkeleton(): Skeleton;
  15348. /**
  15349. * Gets parent bone
  15350. * @returns a bone or null if the bone is the root of the bone hierarchy
  15351. */
  15352. getParent(): Nullable<Bone>;
  15353. /**
  15354. * Returns an array containing the root bones
  15355. * @returns an array containing the root bones
  15356. */
  15357. getChildren(): Array<Bone>;
  15358. /**
  15359. * Gets the node index in matrix array generated for rendering
  15360. * @returns the node index
  15361. */
  15362. getIndex(): number;
  15363. /**
  15364. * Sets the parent bone
  15365. * @param parent defines the parent (can be null if the bone is the root)
  15366. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15367. */
  15368. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15369. /**
  15370. * Gets the local matrix
  15371. * @returns a matrix
  15372. */
  15373. getLocalMatrix(): Matrix;
  15374. /**
  15375. * Gets the base matrix (initial matrix which remains unchanged)
  15376. * @returns a matrix
  15377. */
  15378. getBaseMatrix(): Matrix;
  15379. /**
  15380. * Gets the rest pose matrix
  15381. * @returns a matrix
  15382. */
  15383. getRestPose(): Matrix;
  15384. /**
  15385. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15386. */
  15387. getWorldMatrix(): Matrix;
  15388. /**
  15389. * Sets the local matrix to rest pose matrix
  15390. */
  15391. returnToRest(): void;
  15392. /**
  15393. * Gets the inverse of the absolute transform matrix.
  15394. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15395. * @returns a matrix
  15396. */
  15397. getInvertedAbsoluteTransform(): Matrix;
  15398. /**
  15399. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15400. * @returns a matrix
  15401. */
  15402. getAbsoluteTransform(): Matrix;
  15403. /**
  15404. * Links with the given transform node.
  15405. * The local matrix of this bone is copied from the transform node every frame.
  15406. * @param transformNode defines the transform node to link to
  15407. */
  15408. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15409. /**
  15410. * Gets the node used to drive the bone's transformation
  15411. * @returns a transform node or null
  15412. */
  15413. getTransformNode(): Nullable<TransformNode>;
  15414. /** Gets or sets current position (in local space) */
  15415. get position(): Vector3;
  15416. set position(newPosition: Vector3);
  15417. /** Gets or sets current rotation (in local space) */
  15418. get rotation(): Vector3;
  15419. set rotation(newRotation: Vector3);
  15420. /** Gets or sets current rotation quaternion (in local space) */
  15421. get rotationQuaternion(): Quaternion;
  15422. set rotationQuaternion(newRotation: Quaternion);
  15423. /** Gets or sets current scaling (in local space) */
  15424. get scaling(): Vector3;
  15425. set scaling(newScaling: Vector3);
  15426. /**
  15427. * Gets the animation properties override
  15428. */
  15429. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15430. private _decompose;
  15431. private _compose;
  15432. /**
  15433. * Update the base and local matrices
  15434. * @param matrix defines the new base or local matrix
  15435. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15436. * @param updateLocalMatrix defines if the local matrix should be updated
  15437. */
  15438. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15439. /** @hidden */
  15440. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15441. /**
  15442. * Flag the bone as dirty (Forcing it to update everything)
  15443. */
  15444. markAsDirty(): void;
  15445. /** @hidden */
  15446. _markAsDirtyAndCompose(): void;
  15447. private _markAsDirtyAndDecompose;
  15448. /**
  15449. * Translate the bone in local or world space
  15450. * @param vec The amount to translate the bone
  15451. * @param space The space that the translation is in
  15452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15453. */
  15454. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15455. /**
  15456. * Set the postion of the bone in local or world space
  15457. * @param position The position to set the bone
  15458. * @param space The space that the position is in
  15459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15460. */
  15461. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15462. /**
  15463. * Set the absolute position of the bone (world space)
  15464. * @param position The position to set the bone
  15465. * @param mesh The mesh that this bone is attached to
  15466. */
  15467. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Scale the bone on the x, y and z axes (in local space)
  15470. * @param x The amount to scale the bone on the x axis
  15471. * @param y The amount to scale the bone on the y axis
  15472. * @param z The amount to scale the bone on the z axis
  15473. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15474. */
  15475. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15476. /**
  15477. * Set the bone scaling in local space
  15478. * @param scale defines the scaling vector
  15479. */
  15480. setScale(scale: Vector3): void;
  15481. /**
  15482. * Gets the current scaling in local space
  15483. * @returns the current scaling vector
  15484. */
  15485. getScale(): Vector3;
  15486. /**
  15487. * Gets the current scaling in local space and stores it in a target vector
  15488. * @param result defines the target vector
  15489. */
  15490. getScaleToRef(result: Vector3): void;
  15491. /**
  15492. * Set the yaw, pitch, and roll of the bone in local or world space
  15493. * @param yaw The rotation of the bone on the y axis
  15494. * @param pitch The rotation of the bone on the x axis
  15495. * @param roll The rotation of the bone on the z axis
  15496. * @param space The space that the axes of rotation are in
  15497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15498. */
  15499. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15500. /**
  15501. * Add a rotation to the bone on an axis in local or world space
  15502. * @param axis The axis to rotate the bone on
  15503. * @param amount The amount to rotate the bone
  15504. * @param space The space that the axis is in
  15505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15506. */
  15507. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15508. /**
  15509. * Set the rotation of the bone to a particular axis angle in local or world space
  15510. * @param axis The axis to rotate the bone on
  15511. * @param angle The angle that the bone should be rotated to
  15512. * @param space The space that the axis is in
  15513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15514. */
  15515. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15516. /**
  15517. * Set the euler rotation of the bone in local of world space
  15518. * @param rotation The euler rotation that the bone should be set to
  15519. * @param space The space that the rotation is in
  15520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15521. */
  15522. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15523. /**
  15524. * Set the quaternion rotation of the bone in local of world space
  15525. * @param quat The quaternion rotation that the bone should be set to
  15526. * @param space The space that the rotation is in
  15527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15528. */
  15529. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15530. /**
  15531. * Set the rotation matrix of the bone in local of world space
  15532. * @param rotMat The rotation matrix that the bone should be set to
  15533. * @param space The space that the rotation is in
  15534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15535. */
  15536. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15537. private _rotateWithMatrix;
  15538. private _getNegativeRotationToRef;
  15539. /**
  15540. * Get the position of the bone in local or world space
  15541. * @param space The space that the returned position is in
  15542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15543. * @returns The position of the bone
  15544. */
  15545. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15546. /**
  15547. * Copy the position of the bone to a vector3 in local or world space
  15548. * @param space The space that the returned position is in
  15549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15550. * @param result The vector3 to copy the position to
  15551. */
  15552. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15553. /**
  15554. * Get the absolute position of the bone (world space)
  15555. * @param mesh The mesh that this bone is attached to
  15556. * @returns The absolute position of the bone
  15557. */
  15558. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15559. /**
  15560. * Copy the absolute position of the bone (world space) to the result param
  15561. * @param mesh The mesh that this bone is attached to
  15562. * @param result The vector3 to copy the absolute position to
  15563. */
  15564. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15565. /**
  15566. * Compute the absolute transforms of this bone and its children
  15567. */
  15568. computeAbsoluteTransforms(): void;
  15569. /**
  15570. * Get the world direction from an axis that is in the local space of the bone
  15571. * @param localAxis The local direction that is used to compute the world direction
  15572. * @param mesh The mesh that this bone is attached to
  15573. * @returns The world direction
  15574. */
  15575. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15576. /**
  15577. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15578. * @param localAxis The local direction that is used to compute the world direction
  15579. * @param mesh The mesh that this bone is attached to
  15580. * @param result The vector3 that the world direction will be copied to
  15581. */
  15582. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15583. /**
  15584. * Get the euler rotation of the bone in local or world space
  15585. * @param space The space that the rotation should be in
  15586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15587. * @returns The euler rotation
  15588. */
  15589. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15590. /**
  15591. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15592. * @param space The space that the rotation should be in
  15593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15594. * @param result The vector3 that the rotation should be copied to
  15595. */
  15596. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15597. /**
  15598. * Get the quaternion rotation of the bone in either local or world space
  15599. * @param space The space that the rotation should be in
  15600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15601. * @returns The quaternion rotation
  15602. */
  15603. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15604. /**
  15605. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15606. * @param space The space that the rotation should be in
  15607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15608. * @param result The quaternion that the rotation should be copied to
  15609. */
  15610. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15611. /**
  15612. * Get the rotation matrix of the bone in local or world space
  15613. * @param space The space that the rotation should be in
  15614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15615. * @returns The rotation matrix
  15616. */
  15617. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15618. /**
  15619. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15620. * @param space The space that the rotation should be in
  15621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15622. * @param result The quaternion that the rotation should be copied to
  15623. */
  15624. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15625. /**
  15626. * Get the world position of a point that is in the local space of the bone
  15627. * @param position The local position
  15628. * @param mesh The mesh that this bone is attached to
  15629. * @returns The world position
  15630. */
  15631. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15632. /**
  15633. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15634. * @param position The local position
  15635. * @param mesh The mesh that this bone is attached to
  15636. * @param result The vector3 that the world position should be copied to
  15637. */
  15638. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15639. /**
  15640. * Get the local position of a point that is in world space
  15641. * @param position The world position
  15642. * @param mesh The mesh that this bone is attached to
  15643. * @returns The local position
  15644. */
  15645. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15646. /**
  15647. * Get the local position of a point that is in world space and copy it to the result param
  15648. * @param position The world position
  15649. * @param mesh The mesh that this bone is attached to
  15650. * @param result The vector3 that the local position should be copied to
  15651. */
  15652. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15653. }
  15654. }
  15655. declare module "babylonjs/Animations/runtimeAnimation" {
  15656. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15657. import { Animatable } from "babylonjs/Animations/animatable";
  15658. import { Scene } from "babylonjs/scene";
  15659. /**
  15660. * Defines a runtime animation
  15661. */
  15662. export class RuntimeAnimation {
  15663. private _events;
  15664. /**
  15665. * The current frame of the runtime animation
  15666. */
  15667. private _currentFrame;
  15668. /**
  15669. * The animation used by the runtime animation
  15670. */
  15671. private _animation;
  15672. /**
  15673. * The target of the runtime animation
  15674. */
  15675. private _target;
  15676. /**
  15677. * The initiating animatable
  15678. */
  15679. private _host;
  15680. /**
  15681. * The original value of the runtime animation
  15682. */
  15683. private _originalValue;
  15684. /**
  15685. * The original blend value of the runtime animation
  15686. */
  15687. private _originalBlendValue;
  15688. /**
  15689. * The offsets cache of the runtime animation
  15690. */
  15691. private _offsetsCache;
  15692. /**
  15693. * The high limits cache of the runtime animation
  15694. */
  15695. private _highLimitsCache;
  15696. /**
  15697. * Specifies if the runtime animation has been stopped
  15698. */
  15699. private _stopped;
  15700. /**
  15701. * The blending factor of the runtime animation
  15702. */
  15703. private _blendingFactor;
  15704. /**
  15705. * The BabylonJS scene
  15706. */
  15707. private _scene;
  15708. /**
  15709. * The current value of the runtime animation
  15710. */
  15711. private _currentValue;
  15712. /** @hidden */
  15713. _animationState: _IAnimationState;
  15714. /**
  15715. * The active target of the runtime animation
  15716. */
  15717. private _activeTargets;
  15718. private _currentActiveTarget;
  15719. private _directTarget;
  15720. /**
  15721. * The target path of the runtime animation
  15722. */
  15723. private _targetPath;
  15724. /**
  15725. * The weight of the runtime animation
  15726. */
  15727. private _weight;
  15728. /**
  15729. * The ratio offset of the runtime animation
  15730. */
  15731. private _ratioOffset;
  15732. /**
  15733. * The previous delay of the runtime animation
  15734. */
  15735. private _previousDelay;
  15736. /**
  15737. * The previous ratio of the runtime animation
  15738. */
  15739. private _previousRatio;
  15740. private _enableBlending;
  15741. private _keys;
  15742. private _minFrame;
  15743. private _maxFrame;
  15744. private _minValue;
  15745. private _maxValue;
  15746. private _targetIsArray;
  15747. /**
  15748. * Gets the current frame of the runtime animation
  15749. */
  15750. get currentFrame(): number;
  15751. /**
  15752. * Gets the weight of the runtime animation
  15753. */
  15754. get weight(): number;
  15755. /**
  15756. * Gets the current value of the runtime animation
  15757. */
  15758. get currentValue(): any;
  15759. /**
  15760. * Gets the target path of the runtime animation
  15761. */
  15762. get targetPath(): string;
  15763. /**
  15764. * Gets the actual target of the runtime animation
  15765. */
  15766. get target(): any;
  15767. /**
  15768. * Gets the additive state of the runtime animation
  15769. */
  15770. get isAdditive(): boolean;
  15771. /** @hidden */
  15772. _onLoop: () => void;
  15773. /**
  15774. * Create a new RuntimeAnimation object
  15775. * @param target defines the target of the animation
  15776. * @param animation defines the source animation object
  15777. * @param scene defines the hosting scene
  15778. * @param host defines the initiating Animatable
  15779. */
  15780. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15781. private _preparePath;
  15782. /**
  15783. * Gets the animation from the runtime animation
  15784. */
  15785. get animation(): Animation;
  15786. /**
  15787. * Resets the runtime animation to the beginning
  15788. * @param restoreOriginal defines whether to restore the target property to the original value
  15789. */
  15790. reset(restoreOriginal?: boolean): void;
  15791. /**
  15792. * Specifies if the runtime animation is stopped
  15793. * @returns Boolean specifying if the runtime animation is stopped
  15794. */
  15795. isStopped(): boolean;
  15796. /**
  15797. * Disposes of the runtime animation
  15798. */
  15799. dispose(): void;
  15800. /**
  15801. * Apply the interpolated value to the target
  15802. * @param currentValue defines the value computed by the animation
  15803. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15804. */
  15805. setValue(currentValue: any, weight: number): void;
  15806. private _getOriginalValues;
  15807. private _setValue;
  15808. /**
  15809. * Gets the loop pmode of the runtime animation
  15810. * @returns Loop Mode
  15811. */
  15812. private _getCorrectLoopMode;
  15813. /**
  15814. * Move the current animation to a given frame
  15815. * @param frame defines the frame to move to
  15816. */
  15817. goToFrame(frame: number): void;
  15818. /**
  15819. * @hidden Internal use only
  15820. */
  15821. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15822. /**
  15823. * Execute the current animation
  15824. * @param delay defines the delay to add to the current frame
  15825. * @param from defines the lower bound of the animation range
  15826. * @param to defines the upper bound of the animation range
  15827. * @param loop defines if the current animation must loop
  15828. * @param speedRatio defines the current speed ratio
  15829. * @param weight defines the weight of the animation (default is -1 so no weight)
  15830. * @param onLoop optional callback called when animation loops
  15831. * @returns a boolean indicating if the animation is running
  15832. */
  15833. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15834. }
  15835. }
  15836. declare module "babylonjs/Animations/animatable" {
  15837. import { Animation } from "babylonjs/Animations/animation";
  15838. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15839. import { Nullable } from "babylonjs/types";
  15840. import { Observable } from "babylonjs/Misc/observable";
  15841. import { Scene } from "babylonjs/scene";
  15842. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15843. import { Node } from "babylonjs/node";
  15844. /**
  15845. * Class used to store an actual running animation
  15846. */
  15847. export class Animatable {
  15848. /** defines the target object */
  15849. target: any;
  15850. /** defines the starting frame number (default is 0) */
  15851. fromFrame: number;
  15852. /** defines the ending frame number (default is 100) */
  15853. toFrame: number;
  15854. /** defines if the animation must loop (default is false) */
  15855. loopAnimation: boolean;
  15856. /** defines a callback to call when animation ends if it is not looping */
  15857. onAnimationEnd?: (() => void) | null | undefined;
  15858. /** defines a callback to call when animation loops */
  15859. onAnimationLoop?: (() => void) | null | undefined;
  15860. /** defines whether the animation should be evaluated additively */
  15861. isAdditive: boolean;
  15862. private _localDelayOffset;
  15863. private _pausedDelay;
  15864. private _runtimeAnimations;
  15865. private _paused;
  15866. private _scene;
  15867. private _speedRatio;
  15868. private _weight;
  15869. private _syncRoot;
  15870. /**
  15871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15872. * This will only apply for non looping animation (default is true)
  15873. */
  15874. disposeOnEnd: boolean;
  15875. /**
  15876. * Gets a boolean indicating if the animation has started
  15877. */
  15878. animationStarted: boolean;
  15879. /**
  15880. * Observer raised when the animation ends
  15881. */
  15882. onAnimationEndObservable: Observable<Animatable>;
  15883. /**
  15884. * Observer raised when the animation loops
  15885. */
  15886. onAnimationLoopObservable: Observable<Animatable>;
  15887. /**
  15888. * Gets the root Animatable used to synchronize and normalize animations
  15889. */
  15890. get syncRoot(): Nullable<Animatable>;
  15891. /**
  15892. * Gets the current frame of the first RuntimeAnimation
  15893. * Used to synchronize Animatables
  15894. */
  15895. get masterFrame(): number;
  15896. /**
  15897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15898. */
  15899. get weight(): number;
  15900. set weight(value: number);
  15901. /**
  15902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15903. */
  15904. get speedRatio(): number;
  15905. set speedRatio(value: number);
  15906. /**
  15907. * Creates a new Animatable
  15908. * @param scene defines the hosting scene
  15909. * @param target defines the target object
  15910. * @param fromFrame defines the starting frame number (default is 0)
  15911. * @param toFrame defines the ending frame number (default is 100)
  15912. * @param loopAnimation defines if the animation must loop (default is false)
  15913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15915. * @param animations defines a group of animation to add to the new Animatable
  15916. * @param onAnimationLoop defines a callback to call when animation loops
  15917. * @param isAdditive defines whether the animation should be evaluated additively
  15918. */
  15919. constructor(scene: Scene,
  15920. /** defines the target object */
  15921. target: any,
  15922. /** defines the starting frame number (default is 0) */
  15923. fromFrame?: number,
  15924. /** defines the ending frame number (default is 100) */
  15925. toFrame?: number,
  15926. /** defines if the animation must loop (default is false) */
  15927. loopAnimation?: boolean, speedRatio?: number,
  15928. /** defines a callback to call when animation ends if it is not looping */
  15929. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15930. /** defines a callback to call when animation loops */
  15931. onAnimationLoop?: (() => void) | null | undefined,
  15932. /** defines whether the animation should be evaluated additively */
  15933. isAdditive?: boolean);
  15934. /**
  15935. * Synchronize and normalize current Animatable with a source Animatable
  15936. * This is useful when using animation weights and when animations are not of the same length
  15937. * @param root defines the root Animatable to synchronize with
  15938. * @returns the current Animatable
  15939. */
  15940. syncWith(root: Animatable): Animatable;
  15941. /**
  15942. * Gets the list of runtime animations
  15943. * @returns an array of RuntimeAnimation
  15944. */
  15945. getAnimations(): RuntimeAnimation[];
  15946. /**
  15947. * Adds more animations to the current animatable
  15948. * @param target defines the target of the animations
  15949. * @param animations defines the new animations to add
  15950. */
  15951. appendAnimations(target: any, animations: Animation[]): void;
  15952. /**
  15953. * Gets the source animation for a specific property
  15954. * @param property defines the propertyu to look for
  15955. * @returns null or the source animation for the given property
  15956. */
  15957. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15958. /**
  15959. * Gets the runtime animation for a specific property
  15960. * @param property defines the propertyu to look for
  15961. * @returns null or the runtime animation for the given property
  15962. */
  15963. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15964. /**
  15965. * Resets the animatable to its original state
  15966. */
  15967. reset(): void;
  15968. /**
  15969. * Allows the animatable to blend with current running animations
  15970. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15971. * @param blendingSpeed defines the blending speed to use
  15972. */
  15973. enableBlending(blendingSpeed: number): void;
  15974. /**
  15975. * Disable animation blending
  15976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15977. */
  15978. disableBlending(): void;
  15979. /**
  15980. * Jump directly to a given frame
  15981. * @param frame defines the frame to jump to
  15982. */
  15983. goToFrame(frame: number): void;
  15984. /**
  15985. * Pause the animation
  15986. */
  15987. pause(): void;
  15988. /**
  15989. * Restart the animation
  15990. */
  15991. restart(): void;
  15992. private _raiseOnAnimationEnd;
  15993. /**
  15994. * Stop and delete the current animation
  15995. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15996. * @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)
  15997. */
  15998. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15999. /**
  16000. * Wait asynchronously for the animation to end
  16001. * @returns a promise which will be fullfilled when the animation ends
  16002. */
  16003. waitAsync(): Promise<Animatable>;
  16004. /** @hidden */
  16005. _animate(delay: number): boolean;
  16006. }
  16007. module "babylonjs/scene" {
  16008. interface Scene {
  16009. /** @hidden */
  16010. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16011. /** @hidden */
  16012. _processLateAnimationBindingsForMatrices(holder: {
  16013. totalWeight: number;
  16014. totalAdditiveWeight: number;
  16015. animations: RuntimeAnimation[];
  16016. additiveAnimations: RuntimeAnimation[];
  16017. originalValue: Matrix;
  16018. }): any;
  16019. /** @hidden */
  16020. _processLateAnimationBindingsForQuaternions(holder: {
  16021. totalWeight: number;
  16022. totalAdditiveWeight: number;
  16023. animations: RuntimeAnimation[];
  16024. additiveAnimations: RuntimeAnimation[];
  16025. originalValue: Quaternion;
  16026. }, refQuaternion: Quaternion): Quaternion;
  16027. /** @hidden */
  16028. _processLateAnimationBindings(): void;
  16029. /**
  16030. * Will start the animation sequence of a given target
  16031. * @param target defines the target
  16032. * @param from defines from which frame should animation start
  16033. * @param to defines until which frame should animation run.
  16034. * @param weight defines the weight to apply to the animation (1.0 by default)
  16035. * @param loop defines if the animation loops
  16036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16037. * @param onAnimationEnd defines the function to be executed when the animation ends
  16038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16039. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16040. * @param onAnimationLoop defines the callback to call when an animation loops
  16041. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16042. * @returns the animatable object created for this animation
  16043. */
  16044. 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;
  16045. /**
  16046. * Will start the animation sequence of a given target
  16047. * @param target defines the target
  16048. * @param from defines from which frame should animation start
  16049. * @param to defines until which frame should animation run.
  16050. * @param loop defines if the animation loops
  16051. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16052. * @param onAnimationEnd defines the function to be executed when the animation ends
  16053. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16054. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16055. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16056. * @param onAnimationLoop defines the callback to call when an animation loops
  16057. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16058. * @returns the animatable object created for this animation
  16059. */
  16060. 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;
  16061. /**
  16062. * Will start the animation sequence of a given target and its hierarchy
  16063. * @param target defines the target
  16064. * @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.
  16065. * @param from defines from which frame should animation start
  16066. * @param to defines until which frame should animation run.
  16067. * @param loop defines if the animation loops
  16068. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16069. * @param onAnimationEnd defines the function to be executed when the animation ends
  16070. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16071. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16072. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16073. * @param onAnimationLoop defines the callback to call when an animation loops
  16074. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16075. * @returns the list of created animatables
  16076. */
  16077. 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[];
  16078. /**
  16079. * Begin a new animation on a given node
  16080. * @param target defines the target where the animation will take place
  16081. * @param animations defines the list of animations to start
  16082. * @param from defines the initial value
  16083. * @param to defines the final value
  16084. * @param loop defines if you want animation to loop (off by default)
  16085. * @param speedRatio defines the speed ratio to apply to all animations
  16086. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16087. * @param onAnimationLoop defines the callback to call when an animation loops
  16088. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16089. * @returns the list of created animatables
  16090. */
  16091. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16092. /**
  16093. * Begin a new animation on a given node and its hierarchy
  16094. * @param target defines the root node where the animation will take place
  16095. * @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.
  16096. * @param animations defines the list of animations to start
  16097. * @param from defines the initial value
  16098. * @param to defines the final value
  16099. * @param loop defines if you want animation to loop (off by default)
  16100. * @param speedRatio defines the speed ratio to apply to all animations
  16101. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16102. * @param onAnimationLoop defines the callback to call when an animation loops
  16103. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16104. * @returns the list of animatables created for all nodes
  16105. */
  16106. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16107. /**
  16108. * Gets the animatable associated with a specific target
  16109. * @param target defines the target of the animatable
  16110. * @returns the required animatable if found
  16111. */
  16112. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16113. /**
  16114. * Gets all animatables associated with a given target
  16115. * @param target defines the target to look animatables for
  16116. * @returns an array of Animatables
  16117. */
  16118. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16119. /**
  16120. * Stops and removes all animations that have been applied to the scene
  16121. */
  16122. stopAllAnimations(): void;
  16123. /**
  16124. * Gets the current delta time used by animation engine
  16125. */
  16126. deltaTime: number;
  16127. }
  16128. }
  16129. module "babylonjs/Bones/bone" {
  16130. interface Bone {
  16131. /**
  16132. * Copy an animation range from another bone
  16133. * @param source defines the source bone
  16134. * @param rangeName defines the range name to copy
  16135. * @param frameOffset defines the frame offset
  16136. * @param rescaleAsRequired defines if rescaling must be applied if required
  16137. * @param skelDimensionsRatio defines the scaling ratio
  16138. * @returns true if operation was successful
  16139. */
  16140. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16141. }
  16142. }
  16143. }
  16144. declare module "babylonjs/Bones/skeleton" {
  16145. import { Bone } from "babylonjs/Bones/bone";
  16146. import { Observable } from "babylonjs/Misc/observable";
  16147. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16148. import { Scene } from "babylonjs/scene";
  16149. import { Nullable } from "babylonjs/types";
  16150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16151. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16152. import { Animatable } from "babylonjs/Animations/animatable";
  16153. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16154. import { Animation } from "babylonjs/Animations/animation";
  16155. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16156. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16158. /**
  16159. * Class used to handle skinning animations
  16160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16161. */
  16162. export class Skeleton implements IAnimatable {
  16163. /** defines the skeleton name */
  16164. name: string;
  16165. /** defines the skeleton Id */
  16166. id: string;
  16167. /**
  16168. * Defines the list of child bones
  16169. */
  16170. bones: Bone[];
  16171. /**
  16172. * Defines an estimate of the dimension of the skeleton at rest
  16173. */
  16174. dimensionsAtRest: Vector3;
  16175. /**
  16176. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16177. */
  16178. needInitialSkinMatrix: boolean;
  16179. /**
  16180. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16181. */
  16182. overrideMesh: Nullable<AbstractMesh>;
  16183. /**
  16184. * Gets the list of animations attached to this skeleton
  16185. */
  16186. animations: Array<Animation>;
  16187. private _scene;
  16188. private _isDirty;
  16189. private _transformMatrices;
  16190. private _transformMatrixTexture;
  16191. private _meshesWithPoseMatrix;
  16192. private _animatables;
  16193. private _identity;
  16194. private _synchronizedWithMesh;
  16195. private _ranges;
  16196. private _lastAbsoluteTransformsUpdateId;
  16197. private _canUseTextureForBones;
  16198. private _uniqueId;
  16199. /** @hidden */
  16200. _numBonesWithLinkedTransformNode: number;
  16201. /** @hidden */
  16202. _hasWaitingData: Nullable<boolean>;
  16203. /**
  16204. * Specifies if the skeleton should be serialized
  16205. */
  16206. doNotSerialize: boolean;
  16207. private _useTextureToStoreBoneMatrices;
  16208. /**
  16209. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16210. * Please note that this option is not available if the hardware does not support it
  16211. */
  16212. get useTextureToStoreBoneMatrices(): boolean;
  16213. set useTextureToStoreBoneMatrices(value: boolean);
  16214. private _animationPropertiesOverride;
  16215. /**
  16216. * Gets or sets the animation properties override
  16217. */
  16218. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16219. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16220. /**
  16221. * List of inspectable custom properties (used by the Inspector)
  16222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16223. */
  16224. inspectableCustomProperties: IInspectable[];
  16225. /**
  16226. * An observable triggered before computing the skeleton's matrices
  16227. */
  16228. onBeforeComputeObservable: Observable<Skeleton>;
  16229. /**
  16230. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16231. */
  16232. get isUsingTextureForMatrices(): boolean;
  16233. /**
  16234. * Gets the unique ID of this skeleton
  16235. */
  16236. get uniqueId(): number;
  16237. /**
  16238. * Creates a new skeleton
  16239. * @param name defines the skeleton name
  16240. * @param id defines the skeleton Id
  16241. * @param scene defines the hosting scene
  16242. */
  16243. constructor(
  16244. /** defines the skeleton name */
  16245. name: string,
  16246. /** defines the skeleton Id */
  16247. id: string, scene: Scene);
  16248. /**
  16249. * Gets the current object class name.
  16250. * @return the class name
  16251. */
  16252. getClassName(): string;
  16253. /**
  16254. * Returns an array containing the root bones
  16255. * @returns an array containing the root bones
  16256. */
  16257. getChildren(): Array<Bone>;
  16258. /**
  16259. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16260. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16261. * @returns a Float32Array containing matrices data
  16262. */
  16263. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16264. /**
  16265. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16266. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16267. * @returns a raw texture containing the data
  16268. */
  16269. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16270. /**
  16271. * Gets the current hosting scene
  16272. * @returns a scene object
  16273. */
  16274. getScene(): Scene;
  16275. /**
  16276. * Gets a string representing the current skeleton data
  16277. * @param fullDetails defines a boolean indicating if we want a verbose version
  16278. * @returns a string representing the current skeleton data
  16279. */
  16280. toString(fullDetails?: boolean): string;
  16281. /**
  16282. * Get bone's index searching by name
  16283. * @param name defines bone's name to search for
  16284. * @return the indice of the bone. Returns -1 if not found
  16285. */
  16286. getBoneIndexByName(name: string): number;
  16287. /**
  16288. * Creater a new animation range
  16289. * @param name defines the name of the range
  16290. * @param from defines the start key
  16291. * @param to defines the end key
  16292. */
  16293. createAnimationRange(name: string, from: number, to: number): void;
  16294. /**
  16295. * Delete a specific animation range
  16296. * @param name defines the name of the range
  16297. * @param deleteFrames defines if frames must be removed as well
  16298. */
  16299. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16300. /**
  16301. * Gets a specific animation range
  16302. * @param name defines the name of the range to look for
  16303. * @returns the requested animation range or null if not found
  16304. */
  16305. getAnimationRange(name: string): Nullable<AnimationRange>;
  16306. /**
  16307. * Gets the list of all animation ranges defined on this skeleton
  16308. * @returns an array
  16309. */
  16310. getAnimationRanges(): Nullable<AnimationRange>[];
  16311. /**
  16312. * Copy animation range from a source skeleton.
  16313. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16314. * @param source defines the source skeleton
  16315. * @param name defines the name of the range to copy
  16316. * @param rescaleAsRequired defines if rescaling must be applied if required
  16317. * @returns true if operation was successful
  16318. */
  16319. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16320. /**
  16321. * Forces the skeleton to go to rest pose
  16322. */
  16323. returnToRest(): void;
  16324. private _getHighestAnimationFrame;
  16325. /**
  16326. * Begin a specific animation range
  16327. * @param name defines the name of the range to start
  16328. * @param loop defines if looping must be turned on (false by default)
  16329. * @param speedRatio defines the speed ratio to apply (1 by default)
  16330. * @param onAnimationEnd defines a callback which will be called when animation will end
  16331. * @returns a new animatable
  16332. */
  16333. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16334. /**
  16335. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16336. * @param skeleton defines the Skeleton containing the animation range to convert
  16337. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16338. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16339. * @returns the original skeleton
  16340. */
  16341. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16342. /** @hidden */
  16343. _markAsDirty(): void;
  16344. /** @hidden */
  16345. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16346. /** @hidden */
  16347. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16348. private _computeTransformMatrices;
  16349. /**
  16350. * Build all resources required to render a skeleton
  16351. */
  16352. prepare(): void;
  16353. /**
  16354. * Gets the list of animatables currently running for this skeleton
  16355. * @returns an array of animatables
  16356. */
  16357. getAnimatables(): IAnimatable[];
  16358. /**
  16359. * Clone the current skeleton
  16360. * @param name defines the name of the new skeleton
  16361. * @param id defines the id of the new skeleton
  16362. * @returns the new skeleton
  16363. */
  16364. clone(name: string, id?: string): Skeleton;
  16365. /**
  16366. * Enable animation blending for this skeleton
  16367. * @param blendingSpeed defines the blending speed to apply
  16368. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16369. */
  16370. enableBlending(blendingSpeed?: number): void;
  16371. /**
  16372. * Releases all resources associated with the current skeleton
  16373. */
  16374. dispose(): void;
  16375. /**
  16376. * Serialize the skeleton in a JSON object
  16377. * @returns a JSON object
  16378. */
  16379. serialize(): any;
  16380. /**
  16381. * Creates a new skeleton from serialized data
  16382. * @param parsedSkeleton defines the serialized data
  16383. * @param scene defines the hosting scene
  16384. * @returns a new skeleton
  16385. */
  16386. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16387. /**
  16388. * Compute all node absolute transforms
  16389. * @param forceUpdate defines if computation must be done even if cache is up to date
  16390. */
  16391. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16392. /**
  16393. * Gets the root pose matrix
  16394. * @returns a matrix
  16395. */
  16396. getPoseMatrix(): Nullable<Matrix>;
  16397. /**
  16398. * Sorts bones per internal index
  16399. */
  16400. sortBones(): void;
  16401. private _sortBones;
  16402. }
  16403. }
  16404. declare module "babylonjs/Meshes/instancedMesh" {
  16405. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16406. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16407. import { Camera } from "babylonjs/Cameras/camera";
  16408. import { Node } from "babylonjs/node";
  16409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16410. import { Mesh } from "babylonjs/Meshes/mesh";
  16411. import { Material } from "babylonjs/Materials/material";
  16412. import { Skeleton } from "babylonjs/Bones/skeleton";
  16413. import { Light } from "babylonjs/Lights/light";
  16414. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16415. /**
  16416. * Creates an instance based on a source mesh.
  16417. */
  16418. export class InstancedMesh extends AbstractMesh {
  16419. private _sourceMesh;
  16420. private _currentLOD;
  16421. /** @hidden */
  16422. _indexInSourceMeshInstanceArray: number;
  16423. constructor(name: string, source: Mesh);
  16424. /**
  16425. * Returns the string "InstancedMesh".
  16426. */
  16427. getClassName(): string;
  16428. /** Gets the list of lights affecting that mesh */
  16429. get lightSources(): Light[];
  16430. _resyncLightSources(): void;
  16431. _resyncLightSource(light: Light): void;
  16432. _removeLightSource(light: Light, dispose: boolean): void;
  16433. /**
  16434. * If the source mesh receives shadows
  16435. */
  16436. get receiveShadows(): boolean;
  16437. /**
  16438. * The material of the source mesh
  16439. */
  16440. get material(): Nullable<Material>;
  16441. /**
  16442. * Visibility of the source mesh
  16443. */
  16444. get visibility(): number;
  16445. /**
  16446. * Skeleton of the source mesh
  16447. */
  16448. get skeleton(): Nullable<Skeleton>;
  16449. /**
  16450. * Rendering ground id of the source mesh
  16451. */
  16452. get renderingGroupId(): number;
  16453. set renderingGroupId(value: number);
  16454. /**
  16455. * Returns the total number of vertices (integer).
  16456. */
  16457. getTotalVertices(): number;
  16458. /**
  16459. * Returns a positive integer : the total number of indices in this mesh geometry.
  16460. * @returns the numner of indices or zero if the mesh has no geometry.
  16461. */
  16462. getTotalIndices(): number;
  16463. /**
  16464. * The source mesh of the instance
  16465. */
  16466. get sourceMesh(): Mesh;
  16467. /**
  16468. * Creates a new InstancedMesh object from the mesh model.
  16469. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16470. * @param name defines the name of the new instance
  16471. * @returns a new InstancedMesh
  16472. */
  16473. createInstance(name: string): InstancedMesh;
  16474. /**
  16475. * Is this node ready to be used/rendered
  16476. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16477. * @return {boolean} is it ready
  16478. */
  16479. isReady(completeCheck?: boolean): boolean;
  16480. /**
  16481. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16482. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16483. * @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.
  16484. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16485. */
  16486. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16487. /**
  16488. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16489. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16490. * The `data` are either a numeric array either a Float32Array.
  16491. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16492. * 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).
  16493. * Note that a new underlying VertexBuffer object is created each call.
  16494. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16495. *
  16496. * Possible `kind` values :
  16497. * - VertexBuffer.PositionKind
  16498. * - VertexBuffer.UVKind
  16499. * - VertexBuffer.UV2Kind
  16500. * - VertexBuffer.UV3Kind
  16501. * - VertexBuffer.UV4Kind
  16502. * - VertexBuffer.UV5Kind
  16503. * - VertexBuffer.UV6Kind
  16504. * - VertexBuffer.ColorKind
  16505. * - VertexBuffer.MatricesIndicesKind
  16506. * - VertexBuffer.MatricesIndicesExtraKind
  16507. * - VertexBuffer.MatricesWeightsKind
  16508. * - VertexBuffer.MatricesWeightsExtraKind
  16509. *
  16510. * Returns the Mesh.
  16511. */
  16512. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16513. /**
  16514. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16515. * If the mesh has no geometry, it is simply returned as it is.
  16516. * The `data` are either a numeric array either a Float32Array.
  16517. * No new underlying VertexBuffer object is created.
  16518. * 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.
  16519. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16520. *
  16521. * Possible `kind` values :
  16522. * - VertexBuffer.PositionKind
  16523. * - VertexBuffer.UVKind
  16524. * - VertexBuffer.UV2Kind
  16525. * - VertexBuffer.UV3Kind
  16526. * - VertexBuffer.UV4Kind
  16527. * - VertexBuffer.UV5Kind
  16528. * - VertexBuffer.UV6Kind
  16529. * - VertexBuffer.ColorKind
  16530. * - VertexBuffer.MatricesIndicesKind
  16531. * - VertexBuffer.MatricesIndicesExtraKind
  16532. * - VertexBuffer.MatricesWeightsKind
  16533. * - VertexBuffer.MatricesWeightsExtraKind
  16534. *
  16535. * Returns the Mesh.
  16536. */
  16537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16538. /**
  16539. * Sets the mesh indices.
  16540. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16541. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16542. * This method creates a new index buffer each call.
  16543. * Returns the Mesh.
  16544. */
  16545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16546. /**
  16547. * Boolean : True if the mesh owns the requested kind of data.
  16548. */
  16549. isVerticesDataPresent(kind: string): boolean;
  16550. /**
  16551. * Returns an array of indices (IndicesArray).
  16552. */
  16553. getIndices(): Nullable<IndicesArray>;
  16554. get _positions(): Nullable<Vector3[]>;
  16555. /**
  16556. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16557. * This means the mesh underlying bounding box and sphere are recomputed.
  16558. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16559. * @returns the current mesh
  16560. */
  16561. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16562. /** @hidden */
  16563. _preActivate(): InstancedMesh;
  16564. /** @hidden */
  16565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16566. /** @hidden */
  16567. _postActivate(): void;
  16568. getWorldMatrix(): Matrix;
  16569. get isAnInstance(): boolean;
  16570. /**
  16571. * Returns the current associated LOD AbstractMesh.
  16572. */
  16573. getLOD(camera: Camera): AbstractMesh;
  16574. /** @hidden */
  16575. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16576. /** @hidden */
  16577. _syncSubMeshes(): InstancedMesh;
  16578. /** @hidden */
  16579. _generatePointsArray(): boolean;
  16580. /**
  16581. * Creates a new InstancedMesh from the current mesh.
  16582. * - name (string) : the cloned mesh name
  16583. * - newParent (optional Node) : the optional Node to parent the clone to.
  16584. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16585. *
  16586. * Returns the clone.
  16587. */
  16588. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16589. /**
  16590. * Disposes the InstancedMesh.
  16591. * Returns nothing.
  16592. */
  16593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16594. }
  16595. module "babylonjs/Meshes/mesh" {
  16596. interface Mesh {
  16597. /**
  16598. * Register a custom buffer that will be instanced
  16599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16600. * @param kind defines the buffer kind
  16601. * @param stride defines the stride in floats
  16602. */
  16603. registerInstancedBuffer(kind: string, stride: number): void;
  16604. /**
  16605. * true to use the edge renderer for all instances of this mesh
  16606. */
  16607. edgesShareWithInstances: boolean;
  16608. /** @hidden */
  16609. _userInstancedBuffersStorage: {
  16610. data: {
  16611. [key: string]: Float32Array;
  16612. };
  16613. sizes: {
  16614. [key: string]: number;
  16615. };
  16616. vertexBuffers: {
  16617. [key: string]: Nullable<VertexBuffer>;
  16618. };
  16619. strides: {
  16620. [key: string]: number;
  16621. };
  16622. };
  16623. }
  16624. }
  16625. module "babylonjs/Meshes/abstractMesh" {
  16626. interface AbstractMesh {
  16627. /**
  16628. * Object used to store instanced buffers defined by user
  16629. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16630. */
  16631. instancedBuffers: {
  16632. [key: string]: any;
  16633. };
  16634. }
  16635. }
  16636. }
  16637. declare module "babylonjs/Materials/shaderMaterial" {
  16638. import { Nullable } from "babylonjs/types";
  16639. import { Scene } from "babylonjs/scene";
  16640. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16642. import { Mesh } from "babylonjs/Meshes/mesh";
  16643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16645. import { Effect } from "babylonjs/Materials/effect";
  16646. import { Material } from "babylonjs/Materials/material";
  16647. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16648. /**
  16649. * Defines the options associated with the creation of a shader material.
  16650. */
  16651. export interface IShaderMaterialOptions {
  16652. /**
  16653. * Does the material work in alpha blend mode
  16654. */
  16655. needAlphaBlending: boolean;
  16656. /**
  16657. * Does the material work in alpha test mode
  16658. */
  16659. needAlphaTesting: boolean;
  16660. /**
  16661. * The list of attribute names used in the shader
  16662. */
  16663. attributes: string[];
  16664. /**
  16665. * The list of unifrom names used in the shader
  16666. */
  16667. uniforms: string[];
  16668. /**
  16669. * The list of UBO names used in the shader
  16670. */
  16671. uniformBuffers: string[];
  16672. /**
  16673. * The list of sampler names used in the shader
  16674. */
  16675. samplers: string[];
  16676. /**
  16677. * The list of defines used in the shader
  16678. */
  16679. defines: string[];
  16680. }
  16681. /**
  16682. * 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.
  16683. *
  16684. * This returned material effects how the mesh will look based on the code in the shaders.
  16685. *
  16686. * @see http://doc.babylonjs.com/how_to/shader_material
  16687. */
  16688. export class ShaderMaterial extends Material {
  16689. private _shaderPath;
  16690. private _options;
  16691. private _textures;
  16692. private _textureArrays;
  16693. private _floats;
  16694. private _ints;
  16695. private _floatsArrays;
  16696. private _colors3;
  16697. private _colors3Arrays;
  16698. private _colors4;
  16699. private _colors4Arrays;
  16700. private _vectors2;
  16701. private _vectors3;
  16702. private _vectors4;
  16703. private _matrices;
  16704. private _matrixArrays;
  16705. private _matrices3x3;
  16706. private _matrices2x2;
  16707. private _vectors2Arrays;
  16708. private _vectors3Arrays;
  16709. private _vectors4Arrays;
  16710. private _cachedWorldViewMatrix;
  16711. private _cachedWorldViewProjectionMatrix;
  16712. private _renderId;
  16713. private _multiview;
  16714. private _cachedDefines;
  16715. /** Define the Url to load snippets */
  16716. static SnippetUrl: string;
  16717. /** Snippet ID if the material was created from the snippet server */
  16718. snippetId: string;
  16719. /**
  16720. * Instantiate a new shader material.
  16721. * 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.
  16722. * This returned material effects how the mesh will look based on the code in the shaders.
  16723. * @see http://doc.babylonjs.com/how_to/shader_material
  16724. * @param name Define the name of the material in the scene
  16725. * @param scene Define the scene the material belongs to
  16726. * @param shaderPath Defines the route to the shader code in one of three ways:
  16727. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16728. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16729. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16730. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16731. * @param options Define the options used to create the shader
  16732. */
  16733. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16734. /**
  16735. * Gets the shader path used to define the shader code
  16736. * It can be modified to trigger a new compilation
  16737. */
  16738. get shaderPath(): any;
  16739. /**
  16740. * Sets the shader path used to define the shader code
  16741. * It can be modified to trigger a new compilation
  16742. */
  16743. set shaderPath(shaderPath: any);
  16744. /**
  16745. * Gets the options used to compile the shader.
  16746. * They can be modified to trigger a new compilation
  16747. */
  16748. get options(): IShaderMaterialOptions;
  16749. /**
  16750. * Gets the current class name of the material e.g. "ShaderMaterial"
  16751. * Mainly use in serialization.
  16752. * @returns the class name
  16753. */
  16754. getClassName(): string;
  16755. /**
  16756. * Specifies if the material will require alpha blending
  16757. * @returns a boolean specifying if alpha blending is needed
  16758. */
  16759. needAlphaBlending(): boolean;
  16760. /**
  16761. * Specifies if this material should be rendered in alpha test mode
  16762. * @returns a boolean specifying if an alpha test is needed.
  16763. */
  16764. needAlphaTesting(): boolean;
  16765. private _checkUniform;
  16766. /**
  16767. * Set a texture in the shader.
  16768. * @param name Define the name of the uniform samplers as defined in the shader
  16769. * @param texture Define the texture to bind to this sampler
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16773. /**
  16774. * Set a texture array in the shader.
  16775. * @param name Define the name of the uniform sampler array as defined in the shader
  16776. * @param textures Define the list of textures to bind to this sampler
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16780. /**
  16781. * Set a float in the shader.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setFloat(name: string, value: number): ShaderMaterial;
  16787. /**
  16788. * Set a int in the shader.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setInt(name: string, value: number): ShaderMaterial;
  16794. /**
  16795. * Set an array of floats in the shader.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setFloats(name: string, value: number[]): ShaderMaterial;
  16801. /**
  16802. * Set a vec3 in the shader from a Color3.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setColor3(name: string, value: Color3): ShaderMaterial;
  16808. /**
  16809. * Set a vec3 array in the shader from a Color3 array.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16815. /**
  16816. * Set a vec4 in the shader from a Color4.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setColor4(name: string, value: Color4): ShaderMaterial;
  16822. /**
  16823. * Set a vec4 array in the shader from a Color4 array.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16829. /**
  16830. * Set a vec2 in the shader from a Vector2.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setVector2(name: string, value: Vector2): ShaderMaterial;
  16836. /**
  16837. * Set a vec3 in the shader from a Vector3.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setVector3(name: string, value: Vector3): ShaderMaterial;
  16843. /**
  16844. * Set a vec4 in the shader from a Vector4.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the material itself allowing "fluent" like uniform updates
  16848. */
  16849. setVector4(name: string, value: Vector4): ShaderMaterial;
  16850. /**
  16851. * Set a mat4 in the shader from a Matrix.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the material itself allowing "fluent" like uniform updates
  16855. */
  16856. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16857. /**
  16858. * Set a float32Array in the shader from a matrix array.
  16859. * @param name Define the name of the uniform as defined in the shader
  16860. * @param value Define the value to give to the uniform
  16861. * @return the material itself allowing "fluent" like uniform updates
  16862. */
  16863. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16864. /**
  16865. * Set a mat3 in the shader from a Float32Array.
  16866. * @param name Define the name of the uniform as defined in the shader
  16867. * @param value Define the value to give to the uniform
  16868. * @return the material itself allowing "fluent" like uniform updates
  16869. */
  16870. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16871. /**
  16872. * Set a mat2 in the shader from a Float32Array.
  16873. * @param name Define the name of the uniform as defined in the shader
  16874. * @param value Define the value to give to the uniform
  16875. * @return the material itself allowing "fluent" like uniform updates
  16876. */
  16877. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16878. /**
  16879. * Set a vec2 array in the shader from a number array.
  16880. * @param name Define the name of the uniform as defined in the shader
  16881. * @param value Define the value to give to the uniform
  16882. * @return the material itself allowing "fluent" like uniform updates
  16883. */
  16884. setArray2(name: string, value: number[]): ShaderMaterial;
  16885. /**
  16886. * Set a vec3 array in the shader from a number array.
  16887. * @param name Define the name of the uniform as defined in the shader
  16888. * @param value Define the value to give to the uniform
  16889. * @return the material itself allowing "fluent" like uniform updates
  16890. */
  16891. setArray3(name: string, value: number[]): ShaderMaterial;
  16892. /**
  16893. * Set a vec4 array in the shader from a number array.
  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. setArray4(name: string, value: number[]): ShaderMaterial;
  16899. private _checkCache;
  16900. /**
  16901. * Specifies that the submesh is ready to be used
  16902. * @param mesh defines the mesh to check
  16903. * @param subMesh defines which submesh to check
  16904. * @param useInstances specifies that instances should be used
  16905. * @returns a boolean indicating that the submesh is ready or not
  16906. */
  16907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16908. /**
  16909. * Checks if the material is ready to render the requested mesh
  16910. * @param mesh Define the mesh to render
  16911. * @param useInstances Define whether or not the material is used with instances
  16912. * @returns true if ready, otherwise false
  16913. */
  16914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16915. /**
  16916. * Binds the world matrix to the material
  16917. * @param world defines the world transformation matrix
  16918. * @param effectOverride - If provided, use this effect instead of internal effect
  16919. */
  16920. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16921. /**
  16922. * Binds the submesh to this material by preparing the effect and shader to draw
  16923. * @param world defines the world transformation matrix
  16924. * @param mesh defines the mesh containing the submesh
  16925. * @param subMesh defines the submesh to bind the material to
  16926. */
  16927. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16928. /**
  16929. * Binds the material to the mesh
  16930. * @param world defines the world transformation matrix
  16931. * @param mesh defines the mesh to bind the material to
  16932. * @param effectOverride - If provided, use this effect instead of internal effect
  16933. */
  16934. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16935. protected _afterBind(mesh?: Mesh): void;
  16936. /**
  16937. * Gets the active textures from the material
  16938. * @returns an array of textures
  16939. */
  16940. getActiveTextures(): BaseTexture[];
  16941. /**
  16942. * Specifies if the material uses a texture
  16943. * @param texture defines the texture to check against the material
  16944. * @returns a boolean specifying if the material uses the texture
  16945. */
  16946. hasTexture(texture: BaseTexture): boolean;
  16947. /**
  16948. * Makes a duplicate of the material, and gives it a new name
  16949. * @param name defines the new name for the duplicated material
  16950. * @returns the cloned material
  16951. */
  16952. clone(name: string): ShaderMaterial;
  16953. /**
  16954. * Disposes the material
  16955. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16956. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16957. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16958. */
  16959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16960. /**
  16961. * Serializes this material in a JSON representation
  16962. * @returns the serialized material object
  16963. */
  16964. serialize(): any;
  16965. /**
  16966. * Creates a shader material from parsed shader material data
  16967. * @param source defines the JSON represnetation of the material
  16968. * @param scene defines the hosting scene
  16969. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16970. * @returns a new material
  16971. */
  16972. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16973. /**
  16974. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16975. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16976. * @param url defines the url to load from
  16977. * @param scene defines the hosting scene
  16978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16979. * @returns a promise that will resolve to the new ShaderMaterial
  16980. */
  16981. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16982. /**
  16983. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16984. * @param snippetId defines the snippet to load
  16985. * @param scene defines the hosting scene
  16986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16987. * @returns a promise that will resolve to the new ShaderMaterial
  16988. */
  16989. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16990. }
  16991. }
  16992. declare module "babylonjs/Shaders/color.fragment" {
  16993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16995. /** @hidden */
  16996. export var colorPixelShader: {
  16997. name: string;
  16998. shader: string;
  16999. };
  17000. }
  17001. declare module "babylonjs/Shaders/color.vertex" {
  17002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17008. /** @hidden */
  17009. export var colorVertexShader: {
  17010. name: string;
  17011. shader: string;
  17012. };
  17013. }
  17014. declare module "babylonjs/Meshes/linesMesh" {
  17015. import { Nullable } from "babylonjs/types";
  17016. import { Scene } from "babylonjs/scene";
  17017. import { Color3 } from "babylonjs/Maths/math.color";
  17018. import { Node } from "babylonjs/node";
  17019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17020. import { Mesh } from "babylonjs/Meshes/mesh";
  17021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17022. import { Effect } from "babylonjs/Materials/effect";
  17023. import { Material } from "babylonjs/Materials/material";
  17024. import "babylonjs/Shaders/color.fragment";
  17025. import "babylonjs/Shaders/color.vertex";
  17026. /**
  17027. * Line mesh
  17028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17029. */
  17030. export class LinesMesh extends Mesh {
  17031. /**
  17032. * If vertex color should be applied to the mesh
  17033. */
  17034. readonly useVertexColor?: boolean | undefined;
  17035. /**
  17036. * If vertex alpha should be applied to the mesh
  17037. */
  17038. readonly useVertexAlpha?: boolean | undefined;
  17039. /**
  17040. * Color of the line (Default: White)
  17041. */
  17042. color: Color3;
  17043. /**
  17044. * Alpha of the line (Default: 1)
  17045. */
  17046. alpha: number;
  17047. /**
  17048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17049. * This margin is expressed in world space coordinates, so its value may vary.
  17050. * Default value is 0.1
  17051. */
  17052. intersectionThreshold: number;
  17053. private _colorShader;
  17054. private color4;
  17055. /**
  17056. * Creates a new LinesMesh
  17057. * @param name defines the name
  17058. * @param scene defines the hosting scene
  17059. * @param parent defines the parent mesh if any
  17060. * @param source defines the optional source LinesMesh used to clone data from
  17061. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17062. * When false, achieved by calling a clone(), also passing False.
  17063. * This will make creation of children, recursive.
  17064. * @param useVertexColor defines if this LinesMesh supports vertex color
  17065. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17066. */
  17067. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17068. /**
  17069. * If vertex color should be applied to the mesh
  17070. */
  17071. useVertexColor?: boolean | undefined,
  17072. /**
  17073. * If vertex alpha should be applied to the mesh
  17074. */
  17075. useVertexAlpha?: boolean | undefined);
  17076. private _addClipPlaneDefine;
  17077. private _removeClipPlaneDefine;
  17078. isReady(): boolean;
  17079. /**
  17080. * Returns the string "LineMesh"
  17081. */
  17082. getClassName(): string;
  17083. /**
  17084. * @hidden
  17085. */
  17086. get material(): Material;
  17087. /**
  17088. * @hidden
  17089. */
  17090. set material(value: Material);
  17091. /**
  17092. * @hidden
  17093. */
  17094. get checkCollisions(): boolean;
  17095. /** @hidden */
  17096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17097. /** @hidden */
  17098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17099. /**
  17100. * Disposes of the line mesh
  17101. * @param doNotRecurse If children should be disposed
  17102. */
  17103. dispose(doNotRecurse?: boolean): void;
  17104. /**
  17105. * Returns a new LineMesh object cloned from the current one.
  17106. */
  17107. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17108. /**
  17109. * Creates a new InstancedLinesMesh object from the mesh model.
  17110. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17111. * @param name defines the name of the new instance
  17112. * @returns a new InstancedLinesMesh
  17113. */
  17114. createInstance(name: string): InstancedLinesMesh;
  17115. }
  17116. /**
  17117. * Creates an instance based on a source LinesMesh
  17118. */
  17119. export class InstancedLinesMesh extends InstancedMesh {
  17120. /**
  17121. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17122. * This margin is expressed in world space coordinates, so its value may vary.
  17123. * Initilized with the intersectionThreshold value of the source LinesMesh
  17124. */
  17125. intersectionThreshold: number;
  17126. constructor(name: string, source: LinesMesh);
  17127. /**
  17128. * Returns the string "InstancedLinesMesh".
  17129. */
  17130. getClassName(): string;
  17131. }
  17132. }
  17133. declare module "babylonjs/Shaders/line.fragment" {
  17134. /** @hidden */
  17135. export var linePixelShader: {
  17136. name: string;
  17137. shader: string;
  17138. };
  17139. }
  17140. declare module "babylonjs/Shaders/line.vertex" {
  17141. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17142. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17143. /** @hidden */
  17144. export var lineVertexShader: {
  17145. name: string;
  17146. shader: string;
  17147. };
  17148. }
  17149. declare module "babylonjs/Rendering/edgesRenderer" {
  17150. import { Nullable } from "babylonjs/types";
  17151. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17154. import { IDisposable } from "babylonjs/scene";
  17155. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17156. import "babylonjs/Shaders/line.fragment";
  17157. import "babylonjs/Shaders/line.vertex";
  17158. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17159. import { SmartArray } from "babylonjs/Misc/smartArray";
  17160. module "babylonjs/scene" {
  17161. interface Scene {
  17162. /** @hidden */
  17163. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17164. }
  17165. }
  17166. module "babylonjs/Meshes/abstractMesh" {
  17167. interface AbstractMesh {
  17168. /**
  17169. * Gets the edgesRenderer associated with the mesh
  17170. */
  17171. edgesRenderer: Nullable<EdgesRenderer>;
  17172. }
  17173. }
  17174. module "babylonjs/Meshes/linesMesh" {
  17175. interface LinesMesh {
  17176. /**
  17177. * Enables the edge rendering mode on the mesh.
  17178. * This mode makes the mesh edges visible
  17179. * @param epsilon defines the maximal distance between two angles to detect a face
  17180. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17181. * @returns the currentAbstractMesh
  17182. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17183. */
  17184. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17185. }
  17186. }
  17187. module "babylonjs/Meshes/linesMesh" {
  17188. interface InstancedLinesMesh {
  17189. /**
  17190. * Enables the edge rendering mode on the mesh.
  17191. * This mode makes the mesh edges visible
  17192. * @param epsilon defines the maximal distance between two angles to detect a face
  17193. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17194. * @returns the current InstancedLinesMesh
  17195. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17196. */
  17197. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17198. }
  17199. }
  17200. /**
  17201. * Defines the minimum contract an Edges renderer should follow.
  17202. */
  17203. export interface IEdgesRenderer extends IDisposable {
  17204. /**
  17205. * Gets or sets a boolean indicating if the edgesRenderer is active
  17206. */
  17207. isEnabled: boolean;
  17208. /**
  17209. * Renders the edges of the attached mesh,
  17210. */
  17211. render(): void;
  17212. /**
  17213. * Checks wether or not the edges renderer is ready to render.
  17214. * @return true if ready, otherwise false.
  17215. */
  17216. isReady(): boolean;
  17217. /**
  17218. * List of instances to render in case the source mesh has instances
  17219. */
  17220. customInstances: SmartArray<Matrix>;
  17221. }
  17222. /**
  17223. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17224. */
  17225. export class EdgesRenderer implements IEdgesRenderer {
  17226. /**
  17227. * Define the size of the edges with an orthographic camera
  17228. */
  17229. edgesWidthScalerForOrthographic: number;
  17230. /**
  17231. * Define the size of the edges with a perspective camera
  17232. */
  17233. edgesWidthScalerForPerspective: number;
  17234. protected _source: AbstractMesh;
  17235. protected _linesPositions: number[];
  17236. protected _linesNormals: number[];
  17237. protected _linesIndices: number[];
  17238. protected _epsilon: number;
  17239. protected _indicesCount: number;
  17240. protected _lineShader: ShaderMaterial;
  17241. protected _ib: DataBuffer;
  17242. protected _buffers: {
  17243. [key: string]: Nullable<VertexBuffer>;
  17244. };
  17245. protected _buffersForInstances: {
  17246. [key: string]: Nullable<VertexBuffer>;
  17247. };
  17248. protected _checkVerticesInsteadOfIndices: boolean;
  17249. private _meshRebuildObserver;
  17250. private _meshDisposeObserver;
  17251. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17252. isEnabled: boolean;
  17253. /**
  17254. * List of instances to render in case the source mesh has instances
  17255. */
  17256. customInstances: SmartArray<Matrix>;
  17257. private static GetShader;
  17258. /**
  17259. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17260. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17261. * @param source Mesh used to create edges
  17262. * @param epsilon sum of angles in adjacency to check for edge
  17263. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17264. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17265. */
  17266. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17267. protected _prepareRessources(): void;
  17268. /** @hidden */
  17269. _rebuild(): void;
  17270. /**
  17271. * Releases the required resources for the edges renderer
  17272. */
  17273. dispose(): void;
  17274. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17275. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17276. /**
  17277. * Checks if the pair of p0 and p1 is en edge
  17278. * @param faceIndex
  17279. * @param edge
  17280. * @param faceNormals
  17281. * @param p0
  17282. * @param p1
  17283. * @private
  17284. */
  17285. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17286. /**
  17287. * push line into the position, normal and index buffer
  17288. * @protected
  17289. */
  17290. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17291. /**
  17292. * Generates lines edges from adjacencjes
  17293. * @private
  17294. */
  17295. _generateEdgesLines(): void;
  17296. /**
  17297. * Checks wether or not the edges renderer is ready to render.
  17298. * @return true if ready, otherwise false.
  17299. */
  17300. isReady(): boolean;
  17301. /**
  17302. * Renders the edges of the attached mesh,
  17303. */
  17304. render(): void;
  17305. }
  17306. /**
  17307. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17308. */
  17309. export class LineEdgesRenderer extends EdgesRenderer {
  17310. /**
  17311. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17312. * @param source LineMesh used to generate edges
  17313. * @param epsilon not important (specified angle for edge detection)
  17314. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17315. */
  17316. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17317. /**
  17318. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17319. */
  17320. _generateEdgesLines(): void;
  17321. }
  17322. }
  17323. declare module "babylonjs/Rendering/renderingGroup" {
  17324. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17327. import { Nullable } from "babylonjs/types";
  17328. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17329. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17330. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17331. import { Material } from "babylonjs/Materials/material";
  17332. import { Scene } from "babylonjs/scene";
  17333. /**
  17334. * This represents the object necessary to create a rendering group.
  17335. * This is exclusively used and created by the rendering manager.
  17336. * To modify the behavior, you use the available helpers in your scene or meshes.
  17337. * @hidden
  17338. */
  17339. export class RenderingGroup {
  17340. index: number;
  17341. private static _zeroVector;
  17342. private _scene;
  17343. private _opaqueSubMeshes;
  17344. private _transparentSubMeshes;
  17345. private _alphaTestSubMeshes;
  17346. private _depthOnlySubMeshes;
  17347. private _particleSystems;
  17348. private _spriteManagers;
  17349. private _opaqueSortCompareFn;
  17350. private _alphaTestSortCompareFn;
  17351. private _transparentSortCompareFn;
  17352. private _renderOpaque;
  17353. private _renderAlphaTest;
  17354. private _renderTransparent;
  17355. /** @hidden */
  17356. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17357. onBeforeTransparentRendering: () => void;
  17358. /**
  17359. * Set the opaque sort comparison function.
  17360. * If null the sub meshes will be render in the order they were created
  17361. */
  17362. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17363. /**
  17364. * Set the alpha test sort comparison function.
  17365. * If null the sub meshes will be render in the order they were created
  17366. */
  17367. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17368. /**
  17369. * Set the transparent sort comparison function.
  17370. * If null the sub meshes will be render in the order they were created
  17371. */
  17372. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17373. /**
  17374. * Creates a new rendering group.
  17375. * @param index The rendering group index
  17376. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17377. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17378. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17379. */
  17380. 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>);
  17381. /**
  17382. * Render all the sub meshes contained in the group.
  17383. * @param customRenderFunction Used to override the default render behaviour of the group.
  17384. * @returns true if rendered some submeshes.
  17385. */
  17386. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17387. /**
  17388. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17389. * @param subMeshes The submeshes to render
  17390. */
  17391. private renderOpaqueSorted;
  17392. /**
  17393. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17394. * @param subMeshes The submeshes to render
  17395. */
  17396. private renderAlphaTestSorted;
  17397. /**
  17398. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17399. * @param subMeshes The submeshes to render
  17400. */
  17401. private renderTransparentSorted;
  17402. /**
  17403. * Renders the submeshes in a specified order.
  17404. * @param subMeshes The submeshes to sort before render
  17405. * @param sortCompareFn The comparison function use to sort
  17406. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17407. * @param transparent Specifies to activate blending if true
  17408. */
  17409. private static renderSorted;
  17410. /**
  17411. * Renders the submeshes in the order they were dispatched (no sort applied).
  17412. * @param subMeshes The submeshes to render
  17413. */
  17414. private static renderUnsorted;
  17415. /**
  17416. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17417. * are rendered back to front if in the same alpha index.
  17418. *
  17419. * @param a The first submesh
  17420. * @param b The second submesh
  17421. * @returns The result of the comparison
  17422. */
  17423. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17424. /**
  17425. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17426. * are rendered back to front.
  17427. *
  17428. * @param a The first submesh
  17429. * @param b The second submesh
  17430. * @returns The result of the comparison
  17431. */
  17432. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17433. /**
  17434. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17435. * are rendered front to back (prevent overdraw).
  17436. *
  17437. * @param a The first submesh
  17438. * @param b The second submesh
  17439. * @returns The result of the comparison
  17440. */
  17441. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17442. /**
  17443. * Resets the different lists of submeshes to prepare a new frame.
  17444. */
  17445. prepare(): void;
  17446. dispose(): void;
  17447. /**
  17448. * Inserts the submesh in its correct queue depending on its material.
  17449. * @param subMesh The submesh to dispatch
  17450. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17451. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17452. */
  17453. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17454. dispatchSprites(spriteManager: ISpriteManager): void;
  17455. dispatchParticles(particleSystem: IParticleSystem): void;
  17456. private _renderParticles;
  17457. private _renderSprites;
  17458. }
  17459. }
  17460. declare module "babylonjs/Rendering/renderingManager" {
  17461. import { Nullable } from "babylonjs/types";
  17462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17464. import { SmartArray } from "babylonjs/Misc/smartArray";
  17465. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17466. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17467. import { Material } from "babylonjs/Materials/material";
  17468. import { Scene } from "babylonjs/scene";
  17469. import { Camera } from "babylonjs/Cameras/camera";
  17470. /**
  17471. * Interface describing the different options available in the rendering manager
  17472. * regarding Auto Clear between groups.
  17473. */
  17474. export interface IRenderingManagerAutoClearSetup {
  17475. /**
  17476. * Defines whether or not autoclear is enable.
  17477. */
  17478. autoClear: boolean;
  17479. /**
  17480. * Defines whether or not to autoclear the depth buffer.
  17481. */
  17482. depth: boolean;
  17483. /**
  17484. * Defines whether or not to autoclear the stencil buffer.
  17485. */
  17486. stencil: boolean;
  17487. }
  17488. /**
  17489. * This class is used by the onRenderingGroupObservable
  17490. */
  17491. export class RenderingGroupInfo {
  17492. /**
  17493. * The Scene that being rendered
  17494. */
  17495. scene: Scene;
  17496. /**
  17497. * The camera currently used for the rendering pass
  17498. */
  17499. camera: Nullable<Camera>;
  17500. /**
  17501. * The ID of the renderingGroup being processed
  17502. */
  17503. renderingGroupId: number;
  17504. }
  17505. /**
  17506. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17507. * It is enable to manage the different groups as well as the different necessary sort functions.
  17508. * This should not be used directly aside of the few static configurations
  17509. */
  17510. export class RenderingManager {
  17511. /**
  17512. * The max id used for rendering groups (not included)
  17513. */
  17514. static MAX_RENDERINGGROUPS: number;
  17515. /**
  17516. * The min id used for rendering groups (included)
  17517. */
  17518. static MIN_RENDERINGGROUPS: number;
  17519. /**
  17520. * Used to globally prevent autoclearing scenes.
  17521. */
  17522. static AUTOCLEAR: boolean;
  17523. /**
  17524. * @hidden
  17525. */
  17526. _useSceneAutoClearSetup: boolean;
  17527. private _scene;
  17528. private _renderingGroups;
  17529. private _depthStencilBufferAlreadyCleaned;
  17530. private _autoClearDepthStencil;
  17531. private _customOpaqueSortCompareFn;
  17532. private _customAlphaTestSortCompareFn;
  17533. private _customTransparentSortCompareFn;
  17534. private _renderingGroupInfo;
  17535. /**
  17536. * Instantiates a new rendering group for a particular scene
  17537. * @param scene Defines the scene the groups belongs to
  17538. */
  17539. constructor(scene: Scene);
  17540. private _clearDepthStencilBuffer;
  17541. /**
  17542. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17543. * @hidden
  17544. */
  17545. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17546. /**
  17547. * Resets the different information of the group to prepare a new frame
  17548. * @hidden
  17549. */
  17550. reset(): void;
  17551. /**
  17552. * Dispose and release the group and its associated resources.
  17553. * @hidden
  17554. */
  17555. dispose(): void;
  17556. /**
  17557. * Clear the info related to rendering groups preventing retention points during dispose.
  17558. */
  17559. freeRenderingGroups(): void;
  17560. private _prepareRenderingGroup;
  17561. /**
  17562. * Add a sprite manager to the rendering manager in order to render it this frame.
  17563. * @param spriteManager Define the sprite manager to render
  17564. */
  17565. dispatchSprites(spriteManager: ISpriteManager): void;
  17566. /**
  17567. * Add a particle system to the rendering manager in order to render it this frame.
  17568. * @param particleSystem Define the particle system to render
  17569. */
  17570. dispatchParticles(particleSystem: IParticleSystem): void;
  17571. /**
  17572. * Add a submesh to the manager in order to render it this frame
  17573. * @param subMesh The submesh to dispatch
  17574. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17575. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17576. */
  17577. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17578. /**
  17579. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17580. * This allowed control for front to back rendering or reversly depending of the special needs.
  17581. *
  17582. * @param renderingGroupId The rendering group id corresponding to its index
  17583. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17584. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17585. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17586. */
  17587. 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;
  17588. /**
  17589. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17590. *
  17591. * @param renderingGroupId The rendering group id corresponding to its index
  17592. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17593. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17594. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17595. */
  17596. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17597. /**
  17598. * Gets the current auto clear configuration for one rendering group of the rendering
  17599. * manager.
  17600. * @param index the rendering group index to get the information for
  17601. * @returns The auto clear setup for the requested rendering group
  17602. */
  17603. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17604. }
  17605. }
  17606. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17607. import { SmartArray } from "babylonjs/Misc/smartArray";
  17608. import { Nullable } from "babylonjs/types";
  17609. import { Scene } from "babylonjs/scene";
  17610. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17613. import { Mesh } from "babylonjs/Meshes/mesh";
  17614. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17615. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17616. import { Effect } from "babylonjs/Materials/effect";
  17617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17618. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17619. import "babylonjs/Shaders/shadowMap.fragment";
  17620. import "babylonjs/Shaders/shadowMap.vertex";
  17621. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17622. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17623. import { Observable } from "babylonjs/Misc/observable";
  17624. /**
  17625. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17626. */
  17627. export interface ICustomShaderOptions {
  17628. /**
  17629. * Gets or sets the custom shader name to use
  17630. */
  17631. shaderName: string;
  17632. /**
  17633. * The list of attribute names used in the shader
  17634. */
  17635. attributes?: string[];
  17636. /**
  17637. * The list of unifrom names used in the shader
  17638. */
  17639. uniforms?: string[];
  17640. /**
  17641. * The list of sampler names used in the shader
  17642. */
  17643. samplers?: string[];
  17644. /**
  17645. * The list of defines used in the shader
  17646. */
  17647. defines?: string[];
  17648. }
  17649. /**
  17650. * Interface to implement to create a shadow generator compatible with BJS.
  17651. */
  17652. export interface IShadowGenerator {
  17653. /**
  17654. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17655. * @returns The render target texture if present otherwise, null
  17656. */
  17657. getShadowMap(): Nullable<RenderTargetTexture>;
  17658. /**
  17659. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17660. * @param subMesh The submesh we want to render in the shadow map
  17661. * @param useInstances Defines wether will draw in the map using instances
  17662. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17663. * @returns true if ready otherwise, false
  17664. */
  17665. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17666. /**
  17667. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17668. * @param defines Defines of the material we want to update
  17669. * @param lightIndex Index of the light in the enabled light list of the material
  17670. */
  17671. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17672. /**
  17673. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17674. * defined in the generator but impacting the effect).
  17675. * It implies the unifroms available on the materials are the standard BJS ones.
  17676. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17677. * @param effect The effect we are binfing the information for
  17678. */
  17679. bindShadowLight(lightIndex: string, effect: Effect): void;
  17680. /**
  17681. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17682. * (eq to shadow prjection matrix * light transform matrix)
  17683. * @returns The transform matrix used to create the shadow map
  17684. */
  17685. getTransformMatrix(): Matrix;
  17686. /**
  17687. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17688. * Cube and 2D textures for instance.
  17689. */
  17690. recreateShadowMap(): void;
  17691. /**
  17692. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17693. * @param onCompiled Callback triggered at the and of the effects compilation
  17694. * @param options Sets of optional options forcing the compilation with different modes
  17695. */
  17696. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17697. useInstances: boolean;
  17698. }>): void;
  17699. /**
  17700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17701. * @param options Sets of optional options forcing the compilation with different modes
  17702. * @returns A promise that resolves when the compilation completes
  17703. */
  17704. forceCompilationAsync(options?: Partial<{
  17705. useInstances: boolean;
  17706. }>): Promise<void>;
  17707. /**
  17708. * Serializes the shadow generator setup to a json object.
  17709. * @returns The serialized JSON object
  17710. */
  17711. serialize(): any;
  17712. /**
  17713. * Disposes the Shadow map and related Textures and effects.
  17714. */
  17715. dispose(): void;
  17716. }
  17717. /**
  17718. * Default implementation IShadowGenerator.
  17719. * This is the main object responsible of generating shadows in the framework.
  17720. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17721. */
  17722. export class ShadowGenerator implements IShadowGenerator {
  17723. /**
  17724. * Name of the shadow generator class
  17725. */
  17726. static CLASSNAME: string;
  17727. /**
  17728. * Shadow generator mode None: no filtering applied.
  17729. */
  17730. static readonly FILTER_NONE: number;
  17731. /**
  17732. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17733. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17734. */
  17735. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17736. /**
  17737. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17738. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17739. */
  17740. static readonly FILTER_POISSONSAMPLING: number;
  17741. /**
  17742. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17744. */
  17745. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17746. /**
  17747. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17748. * edge artifacts on steep falloff.
  17749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17750. */
  17751. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17752. /**
  17753. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17754. * edge artifacts on steep falloff.
  17755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17756. */
  17757. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17758. /**
  17759. * Shadow generator mode PCF: Percentage Closer Filtering
  17760. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17761. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17762. */
  17763. static readonly FILTER_PCF: number;
  17764. /**
  17765. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17767. * Contact Hardening
  17768. */
  17769. static readonly FILTER_PCSS: number;
  17770. /**
  17771. * Reserved for PCF and PCSS
  17772. * Highest Quality.
  17773. *
  17774. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17775. *
  17776. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17777. */
  17778. static readonly QUALITY_HIGH: number;
  17779. /**
  17780. * Reserved for PCF and PCSS
  17781. * Good tradeoff for quality/perf cross devices
  17782. *
  17783. * Execute PCF on a 3*3 kernel.
  17784. *
  17785. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17786. */
  17787. static readonly QUALITY_MEDIUM: number;
  17788. /**
  17789. * Reserved for PCF and PCSS
  17790. * The lowest quality but the fastest.
  17791. *
  17792. * Execute PCF on a 1*1 kernel.
  17793. *
  17794. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17795. */
  17796. static readonly QUALITY_LOW: number;
  17797. /** Gets or sets the custom shader name to use */
  17798. customShaderOptions: ICustomShaderOptions;
  17799. /**
  17800. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17801. */
  17802. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17803. /**
  17804. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17805. */
  17806. onAfterShadowMapRenderObservable: Observable<Effect>;
  17807. /**
  17808. * Observable triggered before a mesh is rendered in the shadow map.
  17809. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17810. */
  17811. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17812. /**
  17813. * Observable triggered after a mesh is rendered in the shadow map.
  17814. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17815. */
  17816. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17817. protected _bias: number;
  17818. /**
  17819. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17820. */
  17821. get bias(): number;
  17822. /**
  17823. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17824. */
  17825. set bias(bias: number);
  17826. protected _normalBias: number;
  17827. /**
  17828. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17829. */
  17830. get normalBias(): number;
  17831. /**
  17832. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17833. */
  17834. set normalBias(normalBias: number);
  17835. protected _blurBoxOffset: number;
  17836. /**
  17837. * Gets the blur box offset: offset applied during the blur pass.
  17838. * Only useful if useKernelBlur = false
  17839. */
  17840. get blurBoxOffset(): number;
  17841. /**
  17842. * Sets the blur box offset: offset applied during the blur pass.
  17843. * Only useful if useKernelBlur = false
  17844. */
  17845. set blurBoxOffset(value: number);
  17846. protected _blurScale: number;
  17847. /**
  17848. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17849. * 2 means half of the size.
  17850. */
  17851. get blurScale(): number;
  17852. /**
  17853. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17854. * 2 means half of the size.
  17855. */
  17856. set blurScale(value: number);
  17857. protected _blurKernel: number;
  17858. /**
  17859. * Gets the blur kernel: kernel size of the blur pass.
  17860. * Only useful if useKernelBlur = true
  17861. */
  17862. get blurKernel(): number;
  17863. /**
  17864. * Sets the blur kernel: kernel size of the blur pass.
  17865. * Only useful if useKernelBlur = true
  17866. */
  17867. set blurKernel(value: number);
  17868. protected _useKernelBlur: boolean;
  17869. /**
  17870. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17871. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17872. */
  17873. get useKernelBlur(): boolean;
  17874. /**
  17875. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17876. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17877. */
  17878. set useKernelBlur(value: boolean);
  17879. protected _depthScale: number;
  17880. /**
  17881. * Gets the depth scale used in ESM mode.
  17882. */
  17883. get depthScale(): number;
  17884. /**
  17885. * Sets the depth scale used in ESM mode.
  17886. * This can override the scale stored on the light.
  17887. */
  17888. set depthScale(value: number);
  17889. protected _validateFilter(filter: number): number;
  17890. protected _filter: number;
  17891. /**
  17892. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17893. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17894. */
  17895. get filter(): number;
  17896. /**
  17897. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17898. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17899. */
  17900. set filter(value: number);
  17901. /**
  17902. * Gets if the current filter is set to Poisson Sampling.
  17903. */
  17904. get usePoissonSampling(): boolean;
  17905. /**
  17906. * Sets the current filter to Poisson Sampling.
  17907. */
  17908. set usePoissonSampling(value: boolean);
  17909. /**
  17910. * Gets if the current filter is set to ESM.
  17911. */
  17912. get useExponentialShadowMap(): boolean;
  17913. /**
  17914. * Sets the current filter is to ESM.
  17915. */
  17916. set useExponentialShadowMap(value: boolean);
  17917. /**
  17918. * Gets if the current filter is set to filtered ESM.
  17919. */
  17920. get useBlurExponentialShadowMap(): boolean;
  17921. /**
  17922. * Gets if the current filter is set to filtered ESM.
  17923. */
  17924. set useBlurExponentialShadowMap(value: boolean);
  17925. /**
  17926. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17927. * exponential to prevent steep falloff artifacts).
  17928. */
  17929. get useCloseExponentialShadowMap(): boolean;
  17930. /**
  17931. * Sets the current filter to "close ESM" (using the inverse of the
  17932. * exponential to prevent steep falloff artifacts).
  17933. */
  17934. set useCloseExponentialShadowMap(value: boolean);
  17935. /**
  17936. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17937. * exponential to prevent steep falloff artifacts).
  17938. */
  17939. get useBlurCloseExponentialShadowMap(): boolean;
  17940. /**
  17941. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17942. * exponential to prevent steep falloff artifacts).
  17943. */
  17944. set useBlurCloseExponentialShadowMap(value: boolean);
  17945. /**
  17946. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17947. */
  17948. get usePercentageCloserFiltering(): boolean;
  17949. /**
  17950. * Sets the current filter to "PCF" (percentage closer filtering).
  17951. */
  17952. set usePercentageCloserFiltering(value: boolean);
  17953. protected _filteringQuality: number;
  17954. /**
  17955. * Gets the PCF or PCSS Quality.
  17956. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17957. */
  17958. get filteringQuality(): number;
  17959. /**
  17960. * Sets the PCF or PCSS Quality.
  17961. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17962. */
  17963. set filteringQuality(filteringQuality: number);
  17964. /**
  17965. * Gets if the current filter is set to "PCSS" (contact hardening).
  17966. */
  17967. get useContactHardeningShadow(): boolean;
  17968. /**
  17969. * Sets the current filter to "PCSS" (contact hardening).
  17970. */
  17971. set useContactHardeningShadow(value: boolean);
  17972. protected _contactHardeningLightSizeUVRatio: number;
  17973. /**
  17974. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17975. * Using a ratio helps keeping shape stability independently of the map size.
  17976. *
  17977. * It does not account for the light projection as it was having too much
  17978. * instability during the light setup or during light position changes.
  17979. *
  17980. * Only valid if useContactHardeningShadow is true.
  17981. */
  17982. get contactHardeningLightSizeUVRatio(): number;
  17983. /**
  17984. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17985. * Using a ratio helps keeping shape stability independently of the map size.
  17986. *
  17987. * It does not account for the light projection as it was having too much
  17988. * instability during the light setup or during light position changes.
  17989. *
  17990. * Only valid if useContactHardeningShadow is true.
  17991. */
  17992. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17993. protected _darkness: number;
  17994. /** Gets or sets the actual darkness of a shadow */
  17995. get darkness(): number;
  17996. set darkness(value: number);
  17997. /**
  17998. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17999. * 0 means strongest and 1 would means no shadow.
  18000. * @returns the darkness.
  18001. */
  18002. getDarkness(): number;
  18003. /**
  18004. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18005. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18006. * @returns the shadow generator allowing fluent coding.
  18007. */
  18008. setDarkness(darkness: number): ShadowGenerator;
  18009. protected _transparencyShadow: boolean;
  18010. /** Gets or sets the ability to have transparent shadow */
  18011. get transparencyShadow(): boolean;
  18012. set transparencyShadow(value: boolean);
  18013. /**
  18014. * Sets the ability to have transparent shadow (boolean).
  18015. * @param transparent True if transparent else False
  18016. * @returns the shadow generator allowing fluent coding
  18017. */
  18018. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18019. /**
  18020. * Enables or disables shadows with varying strength based on the transparency
  18021. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18022. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18023. * mesh.visibility * alphaTexture.a
  18024. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18025. */
  18026. enableSoftTransparentShadow: boolean;
  18027. protected _shadowMap: Nullable<RenderTargetTexture>;
  18028. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18029. /**
  18030. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18031. * @returns The render target texture if present otherwise, null
  18032. */
  18033. getShadowMap(): Nullable<RenderTargetTexture>;
  18034. /**
  18035. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18036. * @returns The render target texture if the shadow map is present otherwise, null
  18037. */
  18038. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18039. /**
  18040. * Gets the class name of that object
  18041. * @returns "ShadowGenerator"
  18042. */
  18043. getClassName(): string;
  18044. /**
  18045. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18046. * @param mesh Mesh to add
  18047. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18048. * @returns the Shadow Generator itself
  18049. */
  18050. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18051. /**
  18052. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18053. * @param mesh Mesh to remove
  18054. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18055. * @returns the Shadow Generator itself
  18056. */
  18057. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18058. /**
  18059. * Controls the extent to which the shadows fade out at the edge of the frustum
  18060. */
  18061. frustumEdgeFalloff: number;
  18062. protected _light: IShadowLight;
  18063. /**
  18064. * Returns the associated light object.
  18065. * @returns the light generating the shadow
  18066. */
  18067. getLight(): IShadowLight;
  18068. /**
  18069. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18070. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18071. * It might on the other hand introduce peter panning.
  18072. */
  18073. forceBackFacesOnly: boolean;
  18074. protected _scene: Scene;
  18075. protected _lightDirection: Vector3;
  18076. protected _effect: Effect;
  18077. protected _viewMatrix: Matrix;
  18078. protected _projectionMatrix: Matrix;
  18079. protected _transformMatrix: Matrix;
  18080. protected _cachedPosition: Vector3;
  18081. protected _cachedDirection: Vector3;
  18082. protected _cachedDefines: string;
  18083. protected _currentRenderID: number;
  18084. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18085. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18086. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18087. protected _blurPostProcesses: PostProcess[];
  18088. protected _mapSize: number;
  18089. protected _currentFaceIndex: number;
  18090. protected _currentFaceIndexCache: number;
  18091. protected _textureType: number;
  18092. protected _defaultTextureMatrix: Matrix;
  18093. protected _storedUniqueId: Nullable<number>;
  18094. /** @hidden */
  18095. static _SceneComponentInitialization: (scene: Scene) => void;
  18096. /**
  18097. * Creates a ShadowGenerator object.
  18098. * A ShadowGenerator is the required tool to use the shadows.
  18099. * Each light casting shadows needs to use its own ShadowGenerator.
  18100. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18101. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18102. * @param light The light object generating the shadows.
  18103. * @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.
  18104. */
  18105. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18106. protected _initializeGenerator(): void;
  18107. protected _createTargetRenderTexture(): void;
  18108. protected _initializeShadowMap(): void;
  18109. protected _initializeBlurRTTAndPostProcesses(): void;
  18110. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18111. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18112. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18113. protected _applyFilterValues(): void;
  18114. /**
  18115. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18116. * @param onCompiled Callback triggered at the and of the effects compilation
  18117. * @param options Sets of optional options forcing the compilation with different modes
  18118. */
  18119. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18120. useInstances: boolean;
  18121. }>): void;
  18122. /**
  18123. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18124. * @param options Sets of optional options forcing the compilation with different modes
  18125. * @returns A promise that resolves when the compilation completes
  18126. */
  18127. forceCompilationAsync(options?: Partial<{
  18128. useInstances: boolean;
  18129. }>): Promise<void>;
  18130. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18131. private _prepareShadowDefines;
  18132. /**
  18133. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18134. * @param subMesh The submesh we want to render in the shadow map
  18135. * @param useInstances Defines wether will draw in the map using instances
  18136. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18137. * @returns true if ready otherwise, false
  18138. */
  18139. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18140. /**
  18141. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18142. * @param defines Defines of the material we want to update
  18143. * @param lightIndex Index of the light in the enabled light list of the material
  18144. */
  18145. prepareDefines(defines: any, lightIndex: number): void;
  18146. /**
  18147. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18148. * defined in the generator but impacting the effect).
  18149. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18150. * @param effect The effect we are binfing the information for
  18151. */
  18152. bindShadowLight(lightIndex: string, effect: Effect): void;
  18153. /**
  18154. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18155. * (eq to shadow prjection matrix * light transform matrix)
  18156. * @returns The transform matrix used to create the shadow map
  18157. */
  18158. getTransformMatrix(): Matrix;
  18159. /**
  18160. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18161. * Cube and 2D textures for instance.
  18162. */
  18163. recreateShadowMap(): void;
  18164. protected _disposeBlurPostProcesses(): void;
  18165. protected _disposeRTTandPostProcesses(): void;
  18166. /**
  18167. * Disposes the ShadowGenerator.
  18168. * Returns nothing.
  18169. */
  18170. dispose(): void;
  18171. /**
  18172. * Serializes the shadow generator setup to a json object.
  18173. * @returns The serialized JSON object
  18174. */
  18175. serialize(): any;
  18176. /**
  18177. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18178. * @param parsedShadowGenerator The JSON object to parse
  18179. * @param scene The scene to create the shadow map for
  18180. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18181. * @returns The parsed shadow generator
  18182. */
  18183. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18184. }
  18185. }
  18186. declare module "babylonjs/Lights/light" {
  18187. import { Nullable } from "babylonjs/types";
  18188. import { Scene } from "babylonjs/scene";
  18189. import { Vector3 } from "babylonjs/Maths/math.vector";
  18190. import { Color3 } from "babylonjs/Maths/math.color";
  18191. import { Node } from "babylonjs/node";
  18192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18195. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18196. /**
  18197. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18198. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18199. * 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.
  18200. */
  18201. export abstract class Light extends Node {
  18202. /**
  18203. * Falloff Default: light is falling off following the material specification:
  18204. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18205. */
  18206. static readonly FALLOFF_DEFAULT: number;
  18207. /**
  18208. * Falloff Physical: light is falling off following the inverse squared distance law.
  18209. */
  18210. static readonly FALLOFF_PHYSICAL: number;
  18211. /**
  18212. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18213. * to enhance interoperability with other engines.
  18214. */
  18215. static readonly FALLOFF_GLTF: number;
  18216. /**
  18217. * Falloff Standard: light is falling off like in the standard material
  18218. * to enhance interoperability with other materials.
  18219. */
  18220. static readonly FALLOFF_STANDARD: number;
  18221. /**
  18222. * If every light affecting the material is in this lightmapMode,
  18223. * material.lightmapTexture adds or multiplies
  18224. * (depends on material.useLightmapAsShadowmap)
  18225. * after every other light calculations.
  18226. */
  18227. static readonly LIGHTMAP_DEFAULT: number;
  18228. /**
  18229. * material.lightmapTexture as only diffuse lighting from this light
  18230. * adds only specular lighting from this light
  18231. * adds dynamic shadows
  18232. */
  18233. static readonly LIGHTMAP_SPECULAR: number;
  18234. /**
  18235. * material.lightmapTexture as only lighting
  18236. * no light calculation from this light
  18237. * only adds dynamic shadows from this light
  18238. */
  18239. static readonly LIGHTMAP_SHADOWSONLY: number;
  18240. /**
  18241. * Each light type uses the default quantity according to its type:
  18242. * point/spot lights use luminous intensity
  18243. * directional lights use illuminance
  18244. */
  18245. static readonly INTENSITYMODE_AUTOMATIC: number;
  18246. /**
  18247. * lumen (lm)
  18248. */
  18249. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18250. /**
  18251. * candela (lm/sr)
  18252. */
  18253. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18254. /**
  18255. * lux (lm/m^2)
  18256. */
  18257. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18258. /**
  18259. * nit (cd/m^2)
  18260. */
  18261. static readonly INTENSITYMODE_LUMINANCE: number;
  18262. /**
  18263. * Light type const id of the point light.
  18264. */
  18265. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18266. /**
  18267. * Light type const id of the directional light.
  18268. */
  18269. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18270. /**
  18271. * Light type const id of the spot light.
  18272. */
  18273. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18274. /**
  18275. * Light type const id of the hemispheric light.
  18276. */
  18277. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18278. /**
  18279. * Diffuse gives the basic color to an object.
  18280. */
  18281. diffuse: Color3;
  18282. /**
  18283. * Specular produces a highlight color on an object.
  18284. * Note: This is note affecting PBR materials.
  18285. */
  18286. specular: Color3;
  18287. /**
  18288. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18289. * falling off base on range or angle.
  18290. * This can be set to any values in Light.FALLOFF_x.
  18291. *
  18292. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18293. * other types of materials.
  18294. */
  18295. falloffType: number;
  18296. /**
  18297. * Strength of the light.
  18298. * Note: By default it is define in the framework own unit.
  18299. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18300. */
  18301. intensity: number;
  18302. private _range;
  18303. protected _inverseSquaredRange: number;
  18304. /**
  18305. * Defines how far from the source the light is impacting in scene units.
  18306. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18307. */
  18308. get range(): number;
  18309. /**
  18310. * Defines how far from the source the light is impacting in scene units.
  18311. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18312. */
  18313. set range(value: number);
  18314. /**
  18315. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18316. * of light.
  18317. */
  18318. private _photometricScale;
  18319. private _intensityMode;
  18320. /**
  18321. * Gets the photometric scale used to interpret the intensity.
  18322. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18323. */
  18324. get intensityMode(): number;
  18325. /**
  18326. * Sets the photometric scale used to interpret the intensity.
  18327. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18328. */
  18329. set intensityMode(value: number);
  18330. private _radius;
  18331. /**
  18332. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18333. */
  18334. get radius(): number;
  18335. /**
  18336. * sets the light radius used by PBR Materials to simulate soft area lights.
  18337. */
  18338. set radius(value: number);
  18339. private _renderPriority;
  18340. /**
  18341. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18342. * exceeding the number allowed of the materials.
  18343. */
  18344. renderPriority: number;
  18345. private _shadowEnabled;
  18346. /**
  18347. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18348. * the current shadow generator.
  18349. */
  18350. get shadowEnabled(): boolean;
  18351. /**
  18352. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18353. * the current shadow generator.
  18354. */
  18355. set shadowEnabled(value: boolean);
  18356. private _includedOnlyMeshes;
  18357. /**
  18358. * Gets the only meshes impacted by this light.
  18359. */
  18360. get includedOnlyMeshes(): AbstractMesh[];
  18361. /**
  18362. * Sets the only meshes impacted by this light.
  18363. */
  18364. set includedOnlyMeshes(value: AbstractMesh[]);
  18365. private _excludedMeshes;
  18366. /**
  18367. * Gets the meshes not impacted by this light.
  18368. */
  18369. get excludedMeshes(): AbstractMesh[];
  18370. /**
  18371. * Sets the meshes not impacted by this light.
  18372. */
  18373. set excludedMeshes(value: AbstractMesh[]);
  18374. private _excludeWithLayerMask;
  18375. /**
  18376. * Gets the layer id use to find what meshes are not impacted by the light.
  18377. * Inactive if 0
  18378. */
  18379. get excludeWithLayerMask(): number;
  18380. /**
  18381. * Sets the layer id use to find what meshes are not impacted by the light.
  18382. * Inactive if 0
  18383. */
  18384. set excludeWithLayerMask(value: number);
  18385. private _includeOnlyWithLayerMask;
  18386. /**
  18387. * Gets the layer id use to find what meshes are impacted by the light.
  18388. * Inactive if 0
  18389. */
  18390. get includeOnlyWithLayerMask(): number;
  18391. /**
  18392. * Sets the layer id use to find what meshes are impacted by the light.
  18393. * Inactive if 0
  18394. */
  18395. set includeOnlyWithLayerMask(value: number);
  18396. private _lightmapMode;
  18397. /**
  18398. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18399. */
  18400. get lightmapMode(): number;
  18401. /**
  18402. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18403. */
  18404. set lightmapMode(value: number);
  18405. /**
  18406. * Shadow generator associted to the light.
  18407. * @hidden Internal use only.
  18408. */
  18409. _shadowGenerator: Nullable<IShadowGenerator>;
  18410. /**
  18411. * @hidden Internal use only.
  18412. */
  18413. _excludedMeshesIds: string[];
  18414. /**
  18415. * @hidden Internal use only.
  18416. */
  18417. _includedOnlyMeshesIds: string[];
  18418. /**
  18419. * The current light unifom buffer.
  18420. * @hidden Internal use only.
  18421. */
  18422. _uniformBuffer: UniformBuffer;
  18423. /** @hidden */
  18424. _renderId: number;
  18425. /**
  18426. * Creates a Light object in the scene.
  18427. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18428. * @param name The firendly name of the light
  18429. * @param scene The scene the light belongs too
  18430. */
  18431. constructor(name: string, scene: Scene);
  18432. protected abstract _buildUniformLayout(): void;
  18433. /**
  18434. * Sets the passed Effect "effect" with the Light information.
  18435. * @param effect The effect to update
  18436. * @param lightIndex The index of the light in the effect to update
  18437. * @returns The light
  18438. */
  18439. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18440. /**
  18441. * Sets the passed Effect "effect" with the Light textures.
  18442. * @param effect The effect to update
  18443. * @param lightIndex The index of the light in the effect to update
  18444. * @returns The light
  18445. */
  18446. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18447. /**
  18448. * Binds the lights information from the scene to the effect for the given mesh.
  18449. * @param lightIndex Light index
  18450. * @param scene The scene where the light belongs to
  18451. * @param effect The effect we are binding the data to
  18452. * @param useSpecular Defines if specular is supported
  18453. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18454. */
  18455. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18456. /**
  18457. * Sets the passed Effect "effect" with the Light information.
  18458. * @param effect The effect to update
  18459. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18460. * @returns The light
  18461. */
  18462. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18463. /**
  18464. * Returns the string "Light".
  18465. * @returns the class name
  18466. */
  18467. getClassName(): string;
  18468. /** @hidden */
  18469. readonly _isLight: boolean;
  18470. /**
  18471. * Converts the light information to a readable string for debug purpose.
  18472. * @param fullDetails Supports for multiple levels of logging within scene loading
  18473. * @returns the human readable light info
  18474. */
  18475. toString(fullDetails?: boolean): string;
  18476. /** @hidden */
  18477. protected _syncParentEnabledState(): void;
  18478. /**
  18479. * Set the enabled state of this node.
  18480. * @param value - the new enabled state
  18481. */
  18482. setEnabled(value: boolean): void;
  18483. /**
  18484. * Returns the Light associated shadow generator if any.
  18485. * @return the associated shadow generator.
  18486. */
  18487. getShadowGenerator(): Nullable<IShadowGenerator>;
  18488. /**
  18489. * Returns a Vector3, the absolute light position in the World.
  18490. * @returns the world space position of the light
  18491. */
  18492. getAbsolutePosition(): Vector3;
  18493. /**
  18494. * Specifies if the light will affect the passed mesh.
  18495. * @param mesh The mesh to test against the light
  18496. * @return true the mesh is affected otherwise, false.
  18497. */
  18498. canAffectMesh(mesh: AbstractMesh): boolean;
  18499. /**
  18500. * Sort function to order lights for rendering.
  18501. * @param a First Light object to compare to second.
  18502. * @param b Second Light object to compare first.
  18503. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18504. */
  18505. static CompareLightsPriority(a: Light, b: Light): number;
  18506. /**
  18507. * Releases resources associated with this node.
  18508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18510. */
  18511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18512. /**
  18513. * Returns the light type ID (integer).
  18514. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18515. */
  18516. getTypeID(): number;
  18517. /**
  18518. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18519. * @returns the scaled intensity in intensity mode unit
  18520. */
  18521. getScaledIntensity(): number;
  18522. /**
  18523. * Returns a new Light object, named "name", from the current one.
  18524. * @param name The name of the cloned light
  18525. * @param newParent The parent of this light, if it has one
  18526. * @returns the new created light
  18527. */
  18528. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18529. /**
  18530. * Serializes the current light into a Serialization object.
  18531. * @returns the serialized object.
  18532. */
  18533. serialize(): any;
  18534. /**
  18535. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18536. * This new light is named "name" and added to the passed scene.
  18537. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18538. * @param name The friendly name of the light
  18539. * @param scene The scene the new light will belong to
  18540. * @returns the constructor function
  18541. */
  18542. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18543. /**
  18544. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18545. * @param parsedLight The JSON representation of the light
  18546. * @param scene The scene to create the parsed light in
  18547. * @returns the created light after parsing
  18548. */
  18549. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18550. private _hookArrayForExcluded;
  18551. private _hookArrayForIncludedOnly;
  18552. private _resyncMeshes;
  18553. /**
  18554. * Forces the meshes to update their light related information in their rendering used effects
  18555. * @hidden Internal Use Only
  18556. */
  18557. _markMeshesAsLightDirty(): void;
  18558. /**
  18559. * Recomputes the cached photometric scale if needed.
  18560. */
  18561. private _computePhotometricScale;
  18562. /**
  18563. * Returns the Photometric Scale according to the light type and intensity mode.
  18564. */
  18565. private _getPhotometricScale;
  18566. /**
  18567. * Reorder the light in the scene according to their defined priority.
  18568. * @hidden Internal Use Only
  18569. */
  18570. _reorderLightsInScene(): void;
  18571. /**
  18572. * Prepares the list of defines specific to the light type.
  18573. * @param defines the list of defines
  18574. * @param lightIndex defines the index of the light for the effect
  18575. */
  18576. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18577. }
  18578. }
  18579. declare module "babylonjs/Cameras/targetCamera" {
  18580. import { Nullable } from "babylonjs/types";
  18581. import { Camera } from "babylonjs/Cameras/camera";
  18582. import { Scene } from "babylonjs/scene";
  18583. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18584. /**
  18585. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18586. * This is the base of the follow, arc rotate cameras and Free camera
  18587. * @see http://doc.babylonjs.com/features/cameras
  18588. */
  18589. export class TargetCamera extends Camera {
  18590. private static _RigCamTransformMatrix;
  18591. private static _TargetTransformMatrix;
  18592. private static _TargetFocalPoint;
  18593. private _tmpUpVector;
  18594. private _tmpTargetVector;
  18595. /**
  18596. * Define the current direction the camera is moving to
  18597. */
  18598. cameraDirection: Vector3;
  18599. /**
  18600. * Define the current rotation the camera is rotating to
  18601. */
  18602. cameraRotation: Vector2;
  18603. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18604. ignoreParentScaling: boolean;
  18605. /**
  18606. * When set, the up vector of the camera will be updated by the rotation of the camera
  18607. */
  18608. updateUpVectorFromRotation: boolean;
  18609. private _tmpQuaternion;
  18610. /**
  18611. * Define the current rotation of the camera
  18612. */
  18613. rotation: Vector3;
  18614. /**
  18615. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18616. */
  18617. rotationQuaternion: Quaternion;
  18618. /**
  18619. * Define the current speed of the camera
  18620. */
  18621. speed: number;
  18622. /**
  18623. * Add constraint to the camera to prevent it to move freely in all directions and
  18624. * around all axis.
  18625. */
  18626. noRotationConstraint: boolean;
  18627. /**
  18628. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18629. * panning
  18630. */
  18631. invertRotation: boolean;
  18632. /**
  18633. * Speed multiplier for inverse camera panning
  18634. */
  18635. inverseRotationSpeed: number;
  18636. /**
  18637. * Define the current target of the camera as an object or a position.
  18638. */
  18639. lockedTarget: any;
  18640. /** @hidden */
  18641. _currentTarget: Vector3;
  18642. /** @hidden */
  18643. _initialFocalDistance: number;
  18644. /** @hidden */
  18645. _viewMatrix: Matrix;
  18646. /** @hidden */
  18647. _camMatrix: Matrix;
  18648. /** @hidden */
  18649. _cameraTransformMatrix: Matrix;
  18650. /** @hidden */
  18651. _cameraRotationMatrix: Matrix;
  18652. /** @hidden */
  18653. _referencePoint: Vector3;
  18654. /** @hidden */
  18655. _transformedReferencePoint: Vector3;
  18656. /** @hidden */
  18657. _reset: () => void;
  18658. private _defaultUp;
  18659. /**
  18660. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18661. * This is the base of the follow, arc rotate cameras and Free camera
  18662. * @see http://doc.babylonjs.com/features/cameras
  18663. * @param name Defines the name of the camera in the scene
  18664. * @param position Defines the start position of the camera in the scene
  18665. * @param scene Defines the scene the camera belongs to
  18666. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18667. */
  18668. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18669. /**
  18670. * Gets the position in front of the camera at a given distance.
  18671. * @param distance The distance from the camera we want the position to be
  18672. * @returns the position
  18673. */
  18674. getFrontPosition(distance: number): Vector3;
  18675. /** @hidden */
  18676. _getLockedTargetPosition(): Nullable<Vector3>;
  18677. private _storedPosition;
  18678. private _storedRotation;
  18679. private _storedRotationQuaternion;
  18680. /**
  18681. * Store current camera state of the camera (fov, position, rotation, etc..)
  18682. * @returns the camera
  18683. */
  18684. storeState(): Camera;
  18685. /**
  18686. * Restored camera state. You must call storeState() first
  18687. * @returns whether it was successful or not
  18688. * @hidden
  18689. */
  18690. _restoreStateValues(): boolean;
  18691. /** @hidden */
  18692. _initCache(): void;
  18693. /** @hidden */
  18694. _updateCache(ignoreParentClass?: boolean): void;
  18695. /** @hidden */
  18696. _isSynchronizedViewMatrix(): boolean;
  18697. /** @hidden */
  18698. _computeLocalCameraSpeed(): number;
  18699. /**
  18700. * Defines the target the camera should look at.
  18701. * @param target Defines the new target as a Vector or a mesh
  18702. */
  18703. setTarget(target: Vector3): void;
  18704. /**
  18705. * Return the current target position of the camera. This value is expressed in local space.
  18706. * @returns the target position
  18707. */
  18708. getTarget(): Vector3;
  18709. /** @hidden */
  18710. _decideIfNeedsToMove(): boolean;
  18711. /** @hidden */
  18712. _updatePosition(): void;
  18713. /** @hidden */
  18714. _checkInputs(): void;
  18715. protected _updateCameraRotationMatrix(): void;
  18716. /**
  18717. * 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)
  18718. * @returns the current camera
  18719. */
  18720. private _rotateUpVectorWithCameraRotationMatrix;
  18721. private _cachedRotationZ;
  18722. private _cachedQuaternionRotationZ;
  18723. /** @hidden */
  18724. _getViewMatrix(): Matrix;
  18725. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18726. /**
  18727. * @hidden
  18728. */
  18729. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18730. /**
  18731. * @hidden
  18732. */
  18733. _updateRigCameras(): void;
  18734. private _getRigCamPositionAndTarget;
  18735. /**
  18736. * Gets the current object class name.
  18737. * @return the class name
  18738. */
  18739. getClassName(): string;
  18740. }
  18741. }
  18742. declare module "babylonjs/Events/keyboardEvents" {
  18743. /**
  18744. * Gather the list of keyboard event types as constants.
  18745. */
  18746. export class KeyboardEventTypes {
  18747. /**
  18748. * The keydown event is fired when a key becomes active (pressed).
  18749. */
  18750. static readonly KEYDOWN: number;
  18751. /**
  18752. * The keyup event is fired when a key has been released.
  18753. */
  18754. static readonly KEYUP: number;
  18755. }
  18756. /**
  18757. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18758. */
  18759. export class KeyboardInfo {
  18760. /**
  18761. * Defines the type of event (KeyboardEventTypes)
  18762. */
  18763. type: number;
  18764. /**
  18765. * Defines the related dom event
  18766. */
  18767. event: KeyboardEvent;
  18768. /**
  18769. * Instantiates a new keyboard info.
  18770. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18771. * @param type Defines the type of event (KeyboardEventTypes)
  18772. * @param event Defines the related dom event
  18773. */
  18774. constructor(
  18775. /**
  18776. * Defines the type of event (KeyboardEventTypes)
  18777. */
  18778. type: number,
  18779. /**
  18780. * Defines the related dom event
  18781. */
  18782. event: KeyboardEvent);
  18783. }
  18784. /**
  18785. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18786. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18787. */
  18788. export class KeyboardInfoPre extends KeyboardInfo {
  18789. /**
  18790. * Defines the type of event (KeyboardEventTypes)
  18791. */
  18792. type: number;
  18793. /**
  18794. * Defines the related dom event
  18795. */
  18796. event: KeyboardEvent;
  18797. /**
  18798. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18799. */
  18800. skipOnPointerObservable: boolean;
  18801. /**
  18802. * Instantiates a new keyboard pre info.
  18803. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18804. * @param type Defines the type of event (KeyboardEventTypes)
  18805. * @param event Defines the related dom event
  18806. */
  18807. constructor(
  18808. /**
  18809. * Defines the type of event (KeyboardEventTypes)
  18810. */
  18811. type: number,
  18812. /**
  18813. * Defines the related dom event
  18814. */
  18815. event: KeyboardEvent);
  18816. }
  18817. }
  18818. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18819. import { Nullable } from "babylonjs/types";
  18820. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18821. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18822. /**
  18823. * Manage the keyboard inputs to control the movement of a free camera.
  18824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18825. */
  18826. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18827. /**
  18828. * Defines the camera the input is attached to.
  18829. */
  18830. camera: FreeCamera;
  18831. /**
  18832. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18833. */
  18834. keysUp: number[];
  18835. /**
  18836. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18837. */
  18838. keysUpward: number[];
  18839. /**
  18840. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18841. */
  18842. keysDown: number[];
  18843. /**
  18844. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18845. */
  18846. keysDownward: number[];
  18847. /**
  18848. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18849. */
  18850. keysLeft: number[];
  18851. /**
  18852. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18853. */
  18854. keysRight: number[];
  18855. private _keys;
  18856. private _onCanvasBlurObserver;
  18857. private _onKeyboardObserver;
  18858. private _engine;
  18859. private _scene;
  18860. /**
  18861. * Attach the input controls to a specific dom element to get the input from.
  18862. * @param element Defines the element the controls should be listened from
  18863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18864. */
  18865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18866. /**
  18867. * Detach the current controls from the specified dom element.
  18868. * @param element Defines the element to stop listening the inputs from
  18869. */
  18870. detachControl(element: Nullable<HTMLElement>): void;
  18871. /**
  18872. * Update the current camera state depending on the inputs that have been used this frame.
  18873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18874. */
  18875. checkInputs(): void;
  18876. /**
  18877. * Gets the class name of the current intput.
  18878. * @returns the class name
  18879. */
  18880. getClassName(): string;
  18881. /** @hidden */
  18882. _onLostFocus(): void;
  18883. /**
  18884. * Get the friendly name associated with the input class.
  18885. * @returns the input friendly name
  18886. */
  18887. getSimpleName(): string;
  18888. }
  18889. }
  18890. declare module "babylonjs/Events/pointerEvents" {
  18891. import { Nullable } from "babylonjs/types";
  18892. import { Vector2 } from "babylonjs/Maths/math.vector";
  18893. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18894. import { Ray } from "babylonjs/Culling/ray";
  18895. /**
  18896. * Gather the list of pointer event types as constants.
  18897. */
  18898. export class PointerEventTypes {
  18899. /**
  18900. * 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.
  18901. */
  18902. static readonly POINTERDOWN: number;
  18903. /**
  18904. * The pointerup event is fired when a pointer is no longer active.
  18905. */
  18906. static readonly POINTERUP: number;
  18907. /**
  18908. * The pointermove event is fired when a pointer changes coordinates.
  18909. */
  18910. static readonly POINTERMOVE: number;
  18911. /**
  18912. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18913. */
  18914. static readonly POINTERWHEEL: number;
  18915. /**
  18916. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18917. */
  18918. static readonly POINTERPICK: number;
  18919. /**
  18920. * The pointertap event is fired when a the object has been touched and released without drag.
  18921. */
  18922. static readonly POINTERTAP: number;
  18923. /**
  18924. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18925. */
  18926. static readonly POINTERDOUBLETAP: number;
  18927. }
  18928. /**
  18929. * Base class of pointer info types.
  18930. */
  18931. export class PointerInfoBase {
  18932. /**
  18933. * Defines the type of event (PointerEventTypes)
  18934. */
  18935. type: number;
  18936. /**
  18937. * Defines the related dom event
  18938. */
  18939. event: PointerEvent | MouseWheelEvent;
  18940. /**
  18941. * Instantiates the base class of pointers info.
  18942. * @param type Defines the type of event (PointerEventTypes)
  18943. * @param event Defines the related dom event
  18944. */
  18945. constructor(
  18946. /**
  18947. * Defines the type of event (PointerEventTypes)
  18948. */
  18949. type: number,
  18950. /**
  18951. * Defines the related dom event
  18952. */
  18953. event: PointerEvent | MouseWheelEvent);
  18954. }
  18955. /**
  18956. * This class is used to store pointer related info for the onPrePointerObservable event.
  18957. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18958. */
  18959. export class PointerInfoPre extends PointerInfoBase {
  18960. /**
  18961. * Ray from a pointer if availible (eg. 6dof controller)
  18962. */
  18963. ray: Nullable<Ray>;
  18964. /**
  18965. * Defines the local position of the pointer on the canvas.
  18966. */
  18967. localPosition: Vector2;
  18968. /**
  18969. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18970. */
  18971. skipOnPointerObservable: boolean;
  18972. /**
  18973. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18974. * @param type Defines the type of event (PointerEventTypes)
  18975. * @param event Defines the related dom event
  18976. * @param localX Defines the local x coordinates of the pointer when the event occured
  18977. * @param localY Defines the local y coordinates of the pointer when the event occured
  18978. */
  18979. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18980. }
  18981. /**
  18982. * This type contains all the data related to a pointer event in Babylon.js.
  18983. * 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.
  18984. */
  18985. export class PointerInfo extends PointerInfoBase {
  18986. /**
  18987. * Defines the picking info associated to the info (if any)\
  18988. */
  18989. pickInfo: Nullable<PickingInfo>;
  18990. /**
  18991. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18992. * @param type Defines the type of event (PointerEventTypes)
  18993. * @param event Defines the related dom event
  18994. * @param pickInfo Defines the picking info associated to the info (if any)\
  18995. */
  18996. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18997. /**
  18998. * Defines the picking info associated to the info (if any)\
  18999. */
  19000. pickInfo: Nullable<PickingInfo>);
  19001. }
  19002. /**
  19003. * Data relating to a touch event on the screen.
  19004. */
  19005. export interface PointerTouch {
  19006. /**
  19007. * X coordinate of touch.
  19008. */
  19009. x: number;
  19010. /**
  19011. * Y coordinate of touch.
  19012. */
  19013. y: number;
  19014. /**
  19015. * Id of touch. Unique for each finger.
  19016. */
  19017. pointerId: number;
  19018. /**
  19019. * Event type passed from DOM.
  19020. */
  19021. type: any;
  19022. }
  19023. }
  19024. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19025. import { Observable } from "babylonjs/Misc/observable";
  19026. import { Nullable } from "babylonjs/types";
  19027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19029. /**
  19030. * Manage the mouse inputs to control the movement of a free camera.
  19031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19032. */
  19033. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19034. /**
  19035. * Define if touch is enabled in the mouse input
  19036. */
  19037. touchEnabled: boolean;
  19038. /**
  19039. * Defines the camera the input is attached to.
  19040. */
  19041. camera: FreeCamera;
  19042. /**
  19043. * Defines the buttons associated with the input to handle camera move.
  19044. */
  19045. buttons: number[];
  19046. /**
  19047. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19048. */
  19049. angularSensibility: number;
  19050. private _pointerInput;
  19051. private _onMouseMove;
  19052. private _observer;
  19053. private previousPosition;
  19054. /**
  19055. * Observable for when a pointer move event occurs containing the move offset
  19056. */
  19057. onPointerMovedObservable: Observable<{
  19058. offsetX: number;
  19059. offsetY: number;
  19060. }>;
  19061. /**
  19062. * @hidden
  19063. * If the camera should be rotated automatically based on pointer movement
  19064. */
  19065. _allowCameraRotation: boolean;
  19066. /**
  19067. * Manage the mouse inputs to control the movement of a free camera.
  19068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19069. * @param touchEnabled Defines if touch is enabled or not
  19070. */
  19071. constructor(
  19072. /**
  19073. * Define if touch is enabled in the mouse input
  19074. */
  19075. touchEnabled?: boolean);
  19076. /**
  19077. * Attach the input controls to a specific dom element to get the input from.
  19078. * @param element Defines the element the controls should be listened from
  19079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19080. */
  19081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19082. /**
  19083. * Called on JS contextmenu event.
  19084. * Override this method to provide functionality.
  19085. */
  19086. protected onContextMenu(evt: PointerEvent): void;
  19087. /**
  19088. * Detach the current controls from the specified dom element.
  19089. * @param element Defines the element to stop listening the inputs from
  19090. */
  19091. detachControl(element: Nullable<HTMLElement>): void;
  19092. /**
  19093. * Gets the class name of the current intput.
  19094. * @returns the class name
  19095. */
  19096. getClassName(): string;
  19097. /**
  19098. * Get the friendly name associated with the input class.
  19099. * @returns the input friendly name
  19100. */
  19101. getSimpleName(): string;
  19102. }
  19103. }
  19104. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19105. import { Nullable } from "babylonjs/types";
  19106. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19107. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19108. /**
  19109. * Manage the touch inputs to control the movement of a free camera.
  19110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19111. */
  19112. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19113. /**
  19114. * Defines the camera the input is attached to.
  19115. */
  19116. camera: FreeCamera;
  19117. /**
  19118. * Defines the touch sensibility for rotation.
  19119. * The higher the faster.
  19120. */
  19121. touchAngularSensibility: number;
  19122. /**
  19123. * Defines the touch sensibility for move.
  19124. * The higher the faster.
  19125. */
  19126. touchMoveSensibility: number;
  19127. private _offsetX;
  19128. private _offsetY;
  19129. private _pointerPressed;
  19130. private _pointerInput;
  19131. private _observer;
  19132. private _onLostFocus;
  19133. /**
  19134. * Attach the input controls to a specific dom element to get the input from.
  19135. * @param element Defines the element the controls should be listened from
  19136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19137. */
  19138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19139. /**
  19140. * Detach the current controls from the specified dom element.
  19141. * @param element Defines the element to stop listening the inputs from
  19142. */
  19143. detachControl(element: Nullable<HTMLElement>): void;
  19144. /**
  19145. * Update the current camera state depending on the inputs that have been used this frame.
  19146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19147. */
  19148. checkInputs(): void;
  19149. /**
  19150. * Gets the class name of the current intput.
  19151. * @returns the class name
  19152. */
  19153. getClassName(): string;
  19154. /**
  19155. * Get the friendly name associated with the input class.
  19156. * @returns the input friendly name
  19157. */
  19158. getSimpleName(): string;
  19159. }
  19160. }
  19161. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19162. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19163. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19164. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19165. import { Nullable } from "babylonjs/types";
  19166. /**
  19167. * Default Inputs manager for the FreeCamera.
  19168. * It groups all the default supported inputs for ease of use.
  19169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19170. */
  19171. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19172. /**
  19173. * @hidden
  19174. */
  19175. _mouseInput: Nullable<FreeCameraMouseInput>;
  19176. /**
  19177. * Instantiates a new FreeCameraInputsManager.
  19178. * @param camera Defines the camera the inputs belong to
  19179. */
  19180. constructor(camera: FreeCamera);
  19181. /**
  19182. * Add keyboard input support to the input manager.
  19183. * @returns the current input manager
  19184. */
  19185. addKeyboard(): FreeCameraInputsManager;
  19186. /**
  19187. * Add mouse input support to the input manager.
  19188. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19189. * @returns the current input manager
  19190. */
  19191. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19192. /**
  19193. * Removes the mouse input support from the manager
  19194. * @returns the current input manager
  19195. */
  19196. removeMouse(): FreeCameraInputsManager;
  19197. /**
  19198. * Add touch input support to the input manager.
  19199. * @returns the current input manager
  19200. */
  19201. addTouch(): FreeCameraInputsManager;
  19202. /**
  19203. * Remove all attached input methods from a camera
  19204. */
  19205. clear(): void;
  19206. }
  19207. }
  19208. declare module "babylonjs/Cameras/freeCamera" {
  19209. import { Vector3 } from "babylonjs/Maths/math.vector";
  19210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19211. import { Scene } from "babylonjs/scene";
  19212. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19213. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19214. /**
  19215. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19216. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19217. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19218. */
  19219. export class FreeCamera extends TargetCamera {
  19220. /**
  19221. * Define the collision ellipsoid of the camera.
  19222. * This is helpful to simulate a camera body like the player body around the camera
  19223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19224. */
  19225. ellipsoid: Vector3;
  19226. /**
  19227. * Define an offset for the position of the ellipsoid around the camera.
  19228. * This can be helpful to determine the center of the body near the gravity center of the body
  19229. * instead of its head.
  19230. */
  19231. ellipsoidOffset: Vector3;
  19232. /**
  19233. * Enable or disable collisions of the camera with the rest of the scene objects.
  19234. */
  19235. checkCollisions: boolean;
  19236. /**
  19237. * Enable or disable gravity on the camera.
  19238. */
  19239. applyGravity: boolean;
  19240. /**
  19241. * Define the input manager associated to the camera.
  19242. */
  19243. inputs: FreeCameraInputsManager;
  19244. /**
  19245. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19246. * Higher values reduce sensitivity.
  19247. */
  19248. get angularSensibility(): number;
  19249. /**
  19250. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19251. * Higher values reduce sensitivity.
  19252. */
  19253. set angularSensibility(value: number);
  19254. /**
  19255. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19256. */
  19257. get keysUp(): number[];
  19258. set keysUp(value: number[]);
  19259. /**
  19260. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19261. */
  19262. get keysUpward(): number[];
  19263. set keysUpward(value: number[]);
  19264. /**
  19265. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19266. */
  19267. get keysDown(): number[];
  19268. set keysDown(value: number[]);
  19269. /**
  19270. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19271. */
  19272. get keysDownward(): number[];
  19273. set keysDownward(value: number[]);
  19274. /**
  19275. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19276. */
  19277. get keysLeft(): number[];
  19278. set keysLeft(value: number[]);
  19279. /**
  19280. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19281. */
  19282. get keysRight(): number[];
  19283. set keysRight(value: number[]);
  19284. /**
  19285. * Event raised when the camera collide with a mesh in the scene.
  19286. */
  19287. onCollide: (collidedMesh: AbstractMesh) => void;
  19288. private _collider;
  19289. private _needMoveForGravity;
  19290. private _oldPosition;
  19291. private _diffPosition;
  19292. private _newPosition;
  19293. /** @hidden */
  19294. _localDirection: Vector3;
  19295. /** @hidden */
  19296. _transformedDirection: Vector3;
  19297. /**
  19298. * Instantiates a Free Camera.
  19299. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19300. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19302. * @param name Define the name of the camera in the scene
  19303. * @param position Define the start position of the camera in the scene
  19304. * @param scene Define the scene the camera belongs to
  19305. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19306. */
  19307. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19308. /**
  19309. * Attached controls to the current camera.
  19310. * @param element Defines the element the controls should be listened from
  19311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19312. */
  19313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19314. /**
  19315. * Detach the current controls from the camera.
  19316. * The camera will stop reacting to inputs.
  19317. * @param element Defines the element to stop listening the inputs from
  19318. */
  19319. detachControl(element: HTMLElement): void;
  19320. private _collisionMask;
  19321. /**
  19322. * Define a collision mask to limit the list of object the camera can collide with
  19323. */
  19324. get collisionMask(): number;
  19325. set collisionMask(mask: number);
  19326. /** @hidden */
  19327. _collideWithWorld(displacement: Vector3): void;
  19328. private _onCollisionPositionChange;
  19329. /** @hidden */
  19330. _checkInputs(): void;
  19331. /** @hidden */
  19332. _decideIfNeedsToMove(): boolean;
  19333. /** @hidden */
  19334. _updatePosition(): void;
  19335. /**
  19336. * Destroy the camera and release the current resources hold by it.
  19337. */
  19338. dispose(): void;
  19339. /**
  19340. * Gets the current object class name.
  19341. * @return the class name
  19342. */
  19343. getClassName(): string;
  19344. }
  19345. }
  19346. declare module "babylonjs/Gamepads/gamepad" {
  19347. import { Observable } from "babylonjs/Misc/observable";
  19348. /**
  19349. * Represents a gamepad control stick position
  19350. */
  19351. export class StickValues {
  19352. /**
  19353. * The x component of the control stick
  19354. */
  19355. x: number;
  19356. /**
  19357. * The y component of the control stick
  19358. */
  19359. y: number;
  19360. /**
  19361. * Initializes the gamepad x and y control stick values
  19362. * @param x The x component of the gamepad control stick value
  19363. * @param y The y component of the gamepad control stick value
  19364. */
  19365. constructor(
  19366. /**
  19367. * The x component of the control stick
  19368. */
  19369. x: number,
  19370. /**
  19371. * The y component of the control stick
  19372. */
  19373. y: number);
  19374. }
  19375. /**
  19376. * An interface which manages callbacks for gamepad button changes
  19377. */
  19378. export interface GamepadButtonChanges {
  19379. /**
  19380. * Called when a gamepad has been changed
  19381. */
  19382. changed: boolean;
  19383. /**
  19384. * Called when a gamepad press event has been triggered
  19385. */
  19386. pressChanged: boolean;
  19387. /**
  19388. * Called when a touch event has been triggered
  19389. */
  19390. touchChanged: boolean;
  19391. /**
  19392. * Called when a value has changed
  19393. */
  19394. valueChanged: boolean;
  19395. }
  19396. /**
  19397. * Represents a gamepad
  19398. */
  19399. export class Gamepad {
  19400. /**
  19401. * The id of the gamepad
  19402. */
  19403. id: string;
  19404. /**
  19405. * The index of the gamepad
  19406. */
  19407. index: number;
  19408. /**
  19409. * The browser gamepad
  19410. */
  19411. browserGamepad: any;
  19412. /**
  19413. * Specifies what type of gamepad this represents
  19414. */
  19415. type: number;
  19416. private _leftStick;
  19417. private _rightStick;
  19418. /** @hidden */
  19419. _isConnected: boolean;
  19420. private _leftStickAxisX;
  19421. private _leftStickAxisY;
  19422. private _rightStickAxisX;
  19423. private _rightStickAxisY;
  19424. /**
  19425. * Triggered when the left control stick has been changed
  19426. */
  19427. private _onleftstickchanged;
  19428. /**
  19429. * Triggered when the right control stick has been changed
  19430. */
  19431. private _onrightstickchanged;
  19432. /**
  19433. * Represents a gamepad controller
  19434. */
  19435. static GAMEPAD: number;
  19436. /**
  19437. * Represents a generic controller
  19438. */
  19439. static GENERIC: number;
  19440. /**
  19441. * Represents an XBox controller
  19442. */
  19443. static XBOX: number;
  19444. /**
  19445. * Represents a pose-enabled controller
  19446. */
  19447. static POSE_ENABLED: number;
  19448. /**
  19449. * Represents an Dual Shock controller
  19450. */
  19451. static DUALSHOCK: number;
  19452. /**
  19453. * Specifies whether the left control stick should be Y-inverted
  19454. */
  19455. protected _invertLeftStickY: boolean;
  19456. /**
  19457. * Specifies if the gamepad has been connected
  19458. */
  19459. get isConnected(): boolean;
  19460. /**
  19461. * Initializes the gamepad
  19462. * @param id The id of the gamepad
  19463. * @param index The index of the gamepad
  19464. * @param browserGamepad The browser gamepad
  19465. * @param leftStickX The x component of the left joystick
  19466. * @param leftStickY The y component of the left joystick
  19467. * @param rightStickX The x component of the right joystick
  19468. * @param rightStickY The y component of the right joystick
  19469. */
  19470. constructor(
  19471. /**
  19472. * The id of the gamepad
  19473. */
  19474. id: string,
  19475. /**
  19476. * The index of the gamepad
  19477. */
  19478. index: number,
  19479. /**
  19480. * The browser gamepad
  19481. */
  19482. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19483. /**
  19484. * Callback triggered when the left joystick has changed
  19485. * @param callback
  19486. */
  19487. onleftstickchanged(callback: (values: StickValues) => void): void;
  19488. /**
  19489. * Callback triggered when the right joystick has changed
  19490. * @param callback
  19491. */
  19492. onrightstickchanged(callback: (values: StickValues) => void): void;
  19493. /**
  19494. * Gets the left joystick
  19495. */
  19496. get leftStick(): StickValues;
  19497. /**
  19498. * Sets the left joystick values
  19499. */
  19500. set leftStick(newValues: StickValues);
  19501. /**
  19502. * Gets the right joystick
  19503. */
  19504. get rightStick(): StickValues;
  19505. /**
  19506. * Sets the right joystick value
  19507. */
  19508. set rightStick(newValues: StickValues);
  19509. /**
  19510. * Updates the gamepad joystick positions
  19511. */
  19512. update(): void;
  19513. /**
  19514. * Disposes the gamepad
  19515. */
  19516. dispose(): void;
  19517. }
  19518. /**
  19519. * Represents a generic gamepad
  19520. */
  19521. export class GenericPad extends Gamepad {
  19522. private _buttons;
  19523. private _onbuttondown;
  19524. private _onbuttonup;
  19525. /**
  19526. * Observable triggered when a button has been pressed
  19527. */
  19528. onButtonDownObservable: Observable<number>;
  19529. /**
  19530. * Observable triggered when a button has been released
  19531. */
  19532. onButtonUpObservable: Observable<number>;
  19533. /**
  19534. * Callback triggered when a button has been pressed
  19535. * @param callback Called when a button has been pressed
  19536. */
  19537. onbuttondown(callback: (buttonPressed: number) => void): void;
  19538. /**
  19539. * Callback triggered when a button has been released
  19540. * @param callback Called when a button has been released
  19541. */
  19542. onbuttonup(callback: (buttonReleased: number) => void): void;
  19543. /**
  19544. * Initializes the generic gamepad
  19545. * @param id The id of the generic gamepad
  19546. * @param index The index of the generic gamepad
  19547. * @param browserGamepad The browser gamepad
  19548. */
  19549. constructor(id: string, index: number, browserGamepad: any);
  19550. private _setButtonValue;
  19551. /**
  19552. * Updates the generic gamepad
  19553. */
  19554. update(): void;
  19555. /**
  19556. * Disposes the generic gamepad
  19557. */
  19558. dispose(): void;
  19559. }
  19560. }
  19561. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19562. import { Observable } from "babylonjs/Misc/observable";
  19563. import { Nullable } from "babylonjs/types";
  19564. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19567. import { Ray } from "babylonjs/Culling/ray";
  19568. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19569. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19570. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19571. /**
  19572. * Defines the types of pose enabled controllers that are supported
  19573. */
  19574. export enum PoseEnabledControllerType {
  19575. /**
  19576. * HTC Vive
  19577. */
  19578. VIVE = 0,
  19579. /**
  19580. * Oculus Rift
  19581. */
  19582. OCULUS = 1,
  19583. /**
  19584. * Windows mixed reality
  19585. */
  19586. WINDOWS = 2,
  19587. /**
  19588. * Samsung gear VR
  19589. */
  19590. GEAR_VR = 3,
  19591. /**
  19592. * Google Daydream
  19593. */
  19594. DAYDREAM = 4,
  19595. /**
  19596. * Generic
  19597. */
  19598. GENERIC = 5
  19599. }
  19600. /**
  19601. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19602. */
  19603. export interface MutableGamepadButton {
  19604. /**
  19605. * Value of the button/trigger
  19606. */
  19607. value: number;
  19608. /**
  19609. * If the button/trigger is currently touched
  19610. */
  19611. touched: boolean;
  19612. /**
  19613. * If the button/trigger is currently pressed
  19614. */
  19615. pressed: boolean;
  19616. }
  19617. /**
  19618. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19619. * @hidden
  19620. */
  19621. export interface ExtendedGamepadButton extends GamepadButton {
  19622. /**
  19623. * If the button/trigger is currently pressed
  19624. */
  19625. readonly pressed: boolean;
  19626. /**
  19627. * If the button/trigger is currently touched
  19628. */
  19629. readonly touched: boolean;
  19630. /**
  19631. * Value of the button/trigger
  19632. */
  19633. readonly value: number;
  19634. }
  19635. /** @hidden */
  19636. export interface _GamePadFactory {
  19637. /**
  19638. * Returns whether or not the current gamepad can be created for this type of controller.
  19639. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19640. * @returns true if it can be created, otherwise false
  19641. */
  19642. canCreate(gamepadInfo: any): boolean;
  19643. /**
  19644. * Creates a new instance of the Gamepad.
  19645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19646. * @returns the new gamepad instance
  19647. */
  19648. create(gamepadInfo: any): Gamepad;
  19649. }
  19650. /**
  19651. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19652. */
  19653. export class PoseEnabledControllerHelper {
  19654. /** @hidden */
  19655. static _ControllerFactories: _GamePadFactory[];
  19656. /** @hidden */
  19657. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19658. /**
  19659. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19660. * @param vrGamepad the gamepad to initialized
  19661. * @returns a vr controller of the type the gamepad identified as
  19662. */
  19663. static InitiateController(vrGamepad: any): Gamepad;
  19664. }
  19665. /**
  19666. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19667. */
  19668. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19669. /**
  19670. * If the controller is used in a webXR session
  19671. */
  19672. isXR: boolean;
  19673. private _deviceRoomPosition;
  19674. private _deviceRoomRotationQuaternion;
  19675. /**
  19676. * The device position in babylon space
  19677. */
  19678. devicePosition: Vector3;
  19679. /**
  19680. * The device rotation in babylon space
  19681. */
  19682. deviceRotationQuaternion: Quaternion;
  19683. /**
  19684. * The scale factor of the device in babylon space
  19685. */
  19686. deviceScaleFactor: number;
  19687. /**
  19688. * (Likely devicePosition should be used instead) The device position in its room space
  19689. */
  19690. position: Vector3;
  19691. /**
  19692. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19693. */
  19694. rotationQuaternion: Quaternion;
  19695. /**
  19696. * The type of controller (Eg. Windows mixed reality)
  19697. */
  19698. controllerType: PoseEnabledControllerType;
  19699. protected _calculatedPosition: Vector3;
  19700. private _calculatedRotation;
  19701. /**
  19702. * The raw pose from the device
  19703. */
  19704. rawPose: DevicePose;
  19705. private _trackPosition;
  19706. private _maxRotationDistFromHeadset;
  19707. private _draggedRoomRotation;
  19708. /**
  19709. * @hidden
  19710. */
  19711. _disableTrackPosition(fixedPosition: Vector3): void;
  19712. /**
  19713. * Internal, the mesh attached to the controller
  19714. * @hidden
  19715. */
  19716. _mesh: Nullable<AbstractMesh>;
  19717. private _poseControlledCamera;
  19718. private _leftHandSystemQuaternion;
  19719. /**
  19720. * Internal, matrix used to convert room space to babylon space
  19721. * @hidden
  19722. */
  19723. _deviceToWorld: Matrix;
  19724. /**
  19725. * Node to be used when casting a ray from the controller
  19726. * @hidden
  19727. */
  19728. _pointingPoseNode: Nullable<TransformNode>;
  19729. /**
  19730. * Name of the child mesh that can be used to cast a ray from the controller
  19731. */
  19732. static readonly POINTING_POSE: string;
  19733. /**
  19734. * Creates a new PoseEnabledController from a gamepad
  19735. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19736. */
  19737. constructor(browserGamepad: any);
  19738. private _workingMatrix;
  19739. /**
  19740. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19741. */
  19742. update(): void;
  19743. /**
  19744. * Updates only the pose device and mesh without doing any button event checking
  19745. */
  19746. protected _updatePoseAndMesh(): void;
  19747. /**
  19748. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19749. * @param poseData raw pose fromthe device
  19750. */
  19751. updateFromDevice(poseData: DevicePose): void;
  19752. /**
  19753. * @hidden
  19754. */
  19755. _meshAttachedObservable: Observable<AbstractMesh>;
  19756. /**
  19757. * Attaches a mesh to the controller
  19758. * @param mesh the mesh to be attached
  19759. */
  19760. attachToMesh(mesh: AbstractMesh): void;
  19761. /**
  19762. * Attaches the controllers mesh to a camera
  19763. * @param camera the camera the mesh should be attached to
  19764. */
  19765. attachToPoseControlledCamera(camera: TargetCamera): void;
  19766. /**
  19767. * Disposes of the controller
  19768. */
  19769. dispose(): void;
  19770. /**
  19771. * The mesh that is attached to the controller
  19772. */
  19773. get mesh(): Nullable<AbstractMesh>;
  19774. /**
  19775. * Gets the ray of the controller in the direction the controller is pointing
  19776. * @param length the length the resulting ray should be
  19777. * @returns a ray in the direction the controller is pointing
  19778. */
  19779. getForwardRay(length?: number): Ray;
  19780. }
  19781. }
  19782. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19783. import { Observable } from "babylonjs/Misc/observable";
  19784. import { Scene } from "babylonjs/scene";
  19785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19786. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19787. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19788. import { Nullable } from "babylonjs/types";
  19789. /**
  19790. * Defines the WebVRController object that represents controllers tracked in 3D space
  19791. */
  19792. export abstract class WebVRController extends PoseEnabledController {
  19793. /**
  19794. * Internal, the default controller model for the controller
  19795. */
  19796. protected _defaultModel: Nullable<AbstractMesh>;
  19797. /**
  19798. * Fired when the trigger state has changed
  19799. */
  19800. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19801. /**
  19802. * Fired when the main button state has changed
  19803. */
  19804. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19805. /**
  19806. * Fired when the secondary button state has changed
  19807. */
  19808. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19809. /**
  19810. * Fired when the pad state has changed
  19811. */
  19812. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19813. /**
  19814. * Fired when controllers stick values have changed
  19815. */
  19816. onPadValuesChangedObservable: Observable<StickValues>;
  19817. /**
  19818. * Array of button availible on the controller
  19819. */
  19820. protected _buttons: Array<MutableGamepadButton>;
  19821. private _onButtonStateChange;
  19822. /**
  19823. * Fired when a controller button's state has changed
  19824. * @param callback the callback containing the button that was modified
  19825. */
  19826. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19827. /**
  19828. * X and Y axis corresponding to the controllers joystick
  19829. */
  19830. pad: StickValues;
  19831. /**
  19832. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19833. */
  19834. hand: string;
  19835. /**
  19836. * The default controller model for the controller
  19837. */
  19838. get defaultModel(): Nullable<AbstractMesh>;
  19839. /**
  19840. * Creates a new WebVRController from a gamepad
  19841. * @param vrGamepad the gamepad that the WebVRController should be created from
  19842. */
  19843. constructor(vrGamepad: any);
  19844. /**
  19845. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19846. */
  19847. update(): void;
  19848. /**
  19849. * Function to be called when a button is modified
  19850. */
  19851. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19852. /**
  19853. * Loads a mesh and attaches it to the controller
  19854. * @param scene the scene the mesh should be added to
  19855. * @param meshLoaded callback for when the mesh has been loaded
  19856. */
  19857. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19858. private _setButtonValue;
  19859. private _changes;
  19860. private _checkChanges;
  19861. /**
  19862. * Disposes of th webVRCOntroller
  19863. */
  19864. dispose(): void;
  19865. }
  19866. }
  19867. declare module "babylonjs/Lights/hemisphericLight" {
  19868. import { Nullable } from "babylonjs/types";
  19869. import { Scene } from "babylonjs/scene";
  19870. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19871. import { Color3 } from "babylonjs/Maths/math.color";
  19872. import { Effect } from "babylonjs/Materials/effect";
  19873. import { Light } from "babylonjs/Lights/light";
  19874. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19875. /**
  19876. * The HemisphericLight simulates the ambient environment light,
  19877. * so the passed direction is the light reflection direction, not the incoming direction.
  19878. */
  19879. export class HemisphericLight extends Light {
  19880. /**
  19881. * The groundColor is the light in the opposite direction to the one specified during creation.
  19882. * 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.
  19883. */
  19884. groundColor: Color3;
  19885. /**
  19886. * The light reflection direction, not the incoming direction.
  19887. */
  19888. direction: Vector3;
  19889. /**
  19890. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19891. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19892. * The HemisphericLight can't cast shadows.
  19893. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19894. * @param name The friendly name of the light
  19895. * @param direction The direction of the light reflection
  19896. * @param scene The scene the light belongs to
  19897. */
  19898. constructor(name: string, direction: Vector3, scene: Scene);
  19899. protected _buildUniformLayout(): void;
  19900. /**
  19901. * Returns the string "HemisphericLight".
  19902. * @return The class name
  19903. */
  19904. getClassName(): string;
  19905. /**
  19906. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19907. * Returns the updated direction.
  19908. * @param target The target the direction should point to
  19909. * @return The computed direction
  19910. */
  19911. setDirectionToTarget(target: Vector3): Vector3;
  19912. /**
  19913. * Returns the shadow generator associated to the light.
  19914. * @returns Always null for hemispheric lights because it does not support shadows.
  19915. */
  19916. getShadowGenerator(): Nullable<IShadowGenerator>;
  19917. /**
  19918. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19919. * @param effect The effect to update
  19920. * @param lightIndex The index of the light in the effect to update
  19921. * @returns The hemispheric light
  19922. */
  19923. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19924. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19925. /**
  19926. * Computes the world matrix of the node
  19927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19928. * @param useWasUpdatedFlag defines a reserved property
  19929. * @returns the world matrix
  19930. */
  19931. computeWorldMatrix(): Matrix;
  19932. /**
  19933. * Returns the integer 3.
  19934. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19935. */
  19936. getTypeID(): number;
  19937. /**
  19938. * Prepares the list of defines specific to the light type.
  19939. * @param defines the list of defines
  19940. * @param lightIndex defines the index of the light for the effect
  19941. */
  19942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19943. }
  19944. }
  19945. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19946. /** @hidden */
  19947. export var vrMultiviewToSingleviewPixelShader: {
  19948. name: string;
  19949. shader: string;
  19950. };
  19951. }
  19952. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19954. import { Scene } from "babylonjs/scene";
  19955. /**
  19956. * Renders to multiple views with a single draw call
  19957. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19958. */
  19959. export class MultiviewRenderTarget extends RenderTargetTexture {
  19960. /**
  19961. * Creates a multiview render target
  19962. * @param scene scene used with the render target
  19963. * @param size the size of the render target (used for each view)
  19964. */
  19965. constructor(scene: Scene, size?: number | {
  19966. width: number;
  19967. height: number;
  19968. } | {
  19969. ratio: number;
  19970. });
  19971. /**
  19972. * @hidden
  19973. * @param faceIndex the face index, if its a cube texture
  19974. */
  19975. _bindFrameBuffer(faceIndex?: number): void;
  19976. /**
  19977. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19978. * @returns the view count
  19979. */
  19980. getViewCount(): number;
  19981. }
  19982. }
  19983. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19984. import { Camera } from "babylonjs/Cameras/camera";
  19985. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19986. import { Nullable } from "babylonjs/types";
  19987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19988. import { Matrix } from "babylonjs/Maths/math.vector";
  19989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19990. module "babylonjs/Engines/engine" {
  19991. interface Engine {
  19992. /**
  19993. * Creates a new multiview render target
  19994. * @param width defines the width of the texture
  19995. * @param height defines the height of the texture
  19996. * @returns the created multiview texture
  19997. */
  19998. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19999. /**
  20000. * Binds a multiview framebuffer to be drawn to
  20001. * @param multiviewTexture texture to bind
  20002. */
  20003. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20004. }
  20005. }
  20006. module "babylonjs/Cameras/camera" {
  20007. interface Camera {
  20008. /**
  20009. * @hidden
  20010. * 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)
  20011. */
  20012. _useMultiviewToSingleView: boolean;
  20013. /**
  20014. * @hidden
  20015. * 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)
  20016. */
  20017. _multiviewTexture: Nullable<RenderTargetTexture>;
  20018. /**
  20019. * @hidden
  20020. * ensures the multiview texture of the camera exists and has the specified width/height
  20021. * @param width height to set on the multiview texture
  20022. * @param height width to set on the multiview texture
  20023. */
  20024. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20025. }
  20026. }
  20027. module "babylonjs/scene" {
  20028. interface Scene {
  20029. /** @hidden */
  20030. _transformMatrixR: Matrix;
  20031. /** @hidden */
  20032. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20033. /** @hidden */
  20034. _createMultiviewUbo(): void;
  20035. /** @hidden */
  20036. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20037. /** @hidden */
  20038. _renderMultiviewToSingleView(camera: Camera): void;
  20039. }
  20040. }
  20041. }
  20042. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20043. import { Camera } from "babylonjs/Cameras/camera";
  20044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20045. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20046. import "babylonjs/Engines/Extensions/engine.multiview";
  20047. /**
  20048. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20049. * This will not be used for webXR as it supports displaying texture arrays directly
  20050. */
  20051. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20052. /**
  20053. * Initializes a VRMultiviewToSingleview
  20054. * @param name name of the post process
  20055. * @param camera camera to be applied to
  20056. * @param scaleFactor scaling factor to the size of the output texture
  20057. */
  20058. constructor(name: string, camera: Camera, scaleFactor: number);
  20059. }
  20060. }
  20061. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20062. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20063. import { Nullable } from "babylonjs/types";
  20064. import { Size } from "babylonjs/Maths/math.size";
  20065. import { Observable } from "babylonjs/Misc/observable";
  20066. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20067. /**
  20068. * Interface used to define additional presentation attributes
  20069. */
  20070. export interface IVRPresentationAttributes {
  20071. /**
  20072. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20073. */
  20074. highRefreshRate: boolean;
  20075. /**
  20076. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20077. */
  20078. foveationLevel: number;
  20079. }
  20080. module "babylonjs/Engines/engine" {
  20081. interface Engine {
  20082. /** @hidden */
  20083. _vrDisplay: any;
  20084. /** @hidden */
  20085. _vrSupported: boolean;
  20086. /** @hidden */
  20087. _oldSize: Size;
  20088. /** @hidden */
  20089. _oldHardwareScaleFactor: number;
  20090. /** @hidden */
  20091. _vrExclusivePointerMode: boolean;
  20092. /** @hidden */
  20093. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20094. /** @hidden */
  20095. _onVRDisplayPointerRestricted: () => void;
  20096. /** @hidden */
  20097. _onVRDisplayPointerUnrestricted: () => void;
  20098. /** @hidden */
  20099. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20100. /** @hidden */
  20101. _onVrDisplayDisconnect: Nullable<() => void>;
  20102. /** @hidden */
  20103. _onVrDisplayPresentChange: Nullable<() => void>;
  20104. /**
  20105. * Observable signaled when VR display mode changes
  20106. */
  20107. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20108. /**
  20109. * Observable signaled when VR request present is complete
  20110. */
  20111. onVRRequestPresentComplete: Observable<boolean>;
  20112. /**
  20113. * Observable signaled when VR request present starts
  20114. */
  20115. onVRRequestPresentStart: Observable<Engine>;
  20116. /**
  20117. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20118. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20119. */
  20120. isInVRExclusivePointerMode: boolean;
  20121. /**
  20122. * Gets a boolean indicating if a webVR device was detected
  20123. * @returns true if a webVR device was detected
  20124. */
  20125. isVRDevicePresent(): boolean;
  20126. /**
  20127. * Gets the current webVR device
  20128. * @returns the current webVR device (or null)
  20129. */
  20130. getVRDevice(): any;
  20131. /**
  20132. * Initializes a webVR display and starts listening to display change events
  20133. * The onVRDisplayChangedObservable will be notified upon these changes
  20134. * @returns A promise containing a VRDisplay and if vr is supported
  20135. */
  20136. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20137. /** @hidden */
  20138. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20139. /**
  20140. * Gets or sets the presentation attributes used to configure VR rendering
  20141. */
  20142. vrPresentationAttributes?: IVRPresentationAttributes;
  20143. /**
  20144. * Call this function to switch to webVR mode
  20145. * Will do nothing if webVR is not supported or if there is no webVR device
  20146. * @param options the webvr options provided to the camera. mainly used for multiview
  20147. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20148. */
  20149. enableVR(options: WebVROptions): void;
  20150. /** @hidden */
  20151. _onVRFullScreenTriggered(): void;
  20152. }
  20153. }
  20154. }
  20155. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20156. import { Nullable } from "babylonjs/types";
  20157. import { Observable } from "babylonjs/Misc/observable";
  20158. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20159. import { Scene } from "babylonjs/scene";
  20160. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20161. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20162. import { Node } from "babylonjs/node";
  20163. import { Ray } from "babylonjs/Culling/ray";
  20164. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20165. import "babylonjs/Engines/Extensions/engine.webVR";
  20166. /**
  20167. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20168. * IMPORTANT!! The data is right-hand data.
  20169. * @export
  20170. * @interface DevicePose
  20171. */
  20172. export interface DevicePose {
  20173. /**
  20174. * The position of the device, values in array are [x,y,z].
  20175. */
  20176. readonly position: Nullable<Float32Array>;
  20177. /**
  20178. * The linearVelocity of the device, values in array are [x,y,z].
  20179. */
  20180. readonly linearVelocity: Nullable<Float32Array>;
  20181. /**
  20182. * The linearAcceleration of the device, values in array are [x,y,z].
  20183. */
  20184. readonly linearAcceleration: Nullable<Float32Array>;
  20185. /**
  20186. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20187. */
  20188. readonly orientation: Nullable<Float32Array>;
  20189. /**
  20190. * The angularVelocity of the device, values in array are [x,y,z].
  20191. */
  20192. readonly angularVelocity: Nullable<Float32Array>;
  20193. /**
  20194. * The angularAcceleration of the device, values in array are [x,y,z].
  20195. */
  20196. readonly angularAcceleration: Nullable<Float32Array>;
  20197. }
  20198. /**
  20199. * Interface representing a pose controlled object in Babylon.
  20200. * A pose controlled object has both regular pose values as well as pose values
  20201. * from an external device such as a VR head mounted display
  20202. */
  20203. export interface PoseControlled {
  20204. /**
  20205. * The position of the object in babylon space.
  20206. */
  20207. position: Vector3;
  20208. /**
  20209. * The rotation quaternion of the object in babylon space.
  20210. */
  20211. rotationQuaternion: Quaternion;
  20212. /**
  20213. * The position of the device in babylon space.
  20214. */
  20215. devicePosition?: Vector3;
  20216. /**
  20217. * The rotation quaternion of the device in babylon space.
  20218. */
  20219. deviceRotationQuaternion: Quaternion;
  20220. /**
  20221. * The raw pose coming from the device.
  20222. */
  20223. rawPose: Nullable<DevicePose>;
  20224. /**
  20225. * The scale of the device to be used when translating from device space to babylon space.
  20226. */
  20227. deviceScaleFactor: number;
  20228. /**
  20229. * Updates the poseControlled values based on the input device pose.
  20230. * @param poseData the pose data to update the object with
  20231. */
  20232. updateFromDevice(poseData: DevicePose): void;
  20233. }
  20234. /**
  20235. * Set of options to customize the webVRCamera
  20236. */
  20237. export interface WebVROptions {
  20238. /**
  20239. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20240. */
  20241. trackPosition?: boolean;
  20242. /**
  20243. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20244. */
  20245. positionScale?: number;
  20246. /**
  20247. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20248. */
  20249. displayName?: string;
  20250. /**
  20251. * Should the native controller meshes be initialized. (default: true)
  20252. */
  20253. controllerMeshes?: boolean;
  20254. /**
  20255. * Creating a default HemiLight only on controllers. (default: true)
  20256. */
  20257. defaultLightingOnControllers?: boolean;
  20258. /**
  20259. * If you don't want to use the default VR button of the helper. (default: false)
  20260. */
  20261. useCustomVRButton?: boolean;
  20262. /**
  20263. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20264. */
  20265. customVRButton?: HTMLButtonElement;
  20266. /**
  20267. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20268. */
  20269. rayLength?: number;
  20270. /**
  20271. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20272. */
  20273. defaultHeight?: number;
  20274. /**
  20275. * If multiview should be used if availible (default: false)
  20276. */
  20277. useMultiview?: boolean;
  20278. }
  20279. /**
  20280. * This represents a WebVR camera.
  20281. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20282. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20283. */
  20284. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20285. private webVROptions;
  20286. /**
  20287. * @hidden
  20288. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20289. */
  20290. _vrDevice: any;
  20291. /**
  20292. * The rawPose of the vrDevice.
  20293. */
  20294. rawPose: Nullable<DevicePose>;
  20295. private _onVREnabled;
  20296. private _specsVersion;
  20297. private _attached;
  20298. private _frameData;
  20299. protected _descendants: Array<Node>;
  20300. private _deviceRoomPosition;
  20301. /** @hidden */
  20302. _deviceRoomRotationQuaternion: Quaternion;
  20303. private _standingMatrix;
  20304. /**
  20305. * Represents device position in babylon space.
  20306. */
  20307. devicePosition: Vector3;
  20308. /**
  20309. * Represents device rotation in babylon space.
  20310. */
  20311. deviceRotationQuaternion: Quaternion;
  20312. /**
  20313. * The scale of the device to be used when translating from device space to babylon space.
  20314. */
  20315. deviceScaleFactor: number;
  20316. private _deviceToWorld;
  20317. private _worldToDevice;
  20318. /**
  20319. * References to the webVR controllers for the vrDevice.
  20320. */
  20321. controllers: Array<WebVRController>;
  20322. /**
  20323. * Emits an event when a controller is attached.
  20324. */
  20325. onControllersAttachedObservable: Observable<WebVRController[]>;
  20326. /**
  20327. * Emits an event when a controller's mesh has been loaded;
  20328. */
  20329. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20330. /**
  20331. * Emits an event when the HMD's pose has been updated.
  20332. */
  20333. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20334. private _poseSet;
  20335. /**
  20336. * If the rig cameras be used as parent instead of this camera.
  20337. */
  20338. rigParenting: boolean;
  20339. private _lightOnControllers;
  20340. private _defaultHeight?;
  20341. /**
  20342. * Instantiates a WebVRFreeCamera.
  20343. * @param name The name of the WebVRFreeCamera
  20344. * @param position The starting anchor position for the camera
  20345. * @param scene The scene the camera belongs to
  20346. * @param webVROptions a set of customizable options for the webVRCamera
  20347. */
  20348. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20349. /**
  20350. * Gets the device distance from the ground in meters.
  20351. * @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.
  20352. */
  20353. deviceDistanceToRoomGround(): number;
  20354. /**
  20355. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20356. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20357. */
  20358. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20359. /**
  20360. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20361. * @returns A promise with a boolean set to if the standing matrix is supported.
  20362. */
  20363. useStandingMatrixAsync(): Promise<boolean>;
  20364. /**
  20365. * Disposes the camera
  20366. */
  20367. dispose(): void;
  20368. /**
  20369. * Gets a vrController by name.
  20370. * @param name The name of the controller to retreive
  20371. * @returns the controller matching the name specified or null if not found
  20372. */
  20373. getControllerByName(name: string): Nullable<WebVRController>;
  20374. private _leftController;
  20375. /**
  20376. * The controller corresponding to the users left hand.
  20377. */
  20378. get leftController(): Nullable<WebVRController>;
  20379. private _rightController;
  20380. /**
  20381. * The controller corresponding to the users right hand.
  20382. */
  20383. get rightController(): Nullable<WebVRController>;
  20384. /**
  20385. * Casts a ray forward from the vrCamera's gaze.
  20386. * @param length Length of the ray (default: 100)
  20387. * @returns the ray corresponding to the gaze
  20388. */
  20389. getForwardRay(length?: number): Ray;
  20390. /**
  20391. * @hidden
  20392. * Updates the camera based on device's frame data
  20393. */
  20394. _checkInputs(): void;
  20395. /**
  20396. * Updates the poseControlled values based on the input device pose.
  20397. * @param poseData Pose coming from the device
  20398. */
  20399. updateFromDevice(poseData: DevicePose): void;
  20400. private _htmlElementAttached;
  20401. private _detachIfAttached;
  20402. /**
  20403. * WebVR's attach control will start broadcasting frames to the device.
  20404. * Note that in certain browsers (chrome for example) this function must be called
  20405. * within a user-interaction callback. Example:
  20406. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20407. *
  20408. * @param element html element to attach the vrDevice to
  20409. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20410. */
  20411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20412. /**
  20413. * Detaches the camera from the html element and disables VR
  20414. *
  20415. * @param element html element to detach from
  20416. */
  20417. detachControl(element: HTMLElement): void;
  20418. /**
  20419. * @returns the name of this class
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * Calls resetPose on the vrDisplay
  20424. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20425. */
  20426. resetToCurrentRotation(): void;
  20427. /**
  20428. * @hidden
  20429. * Updates the rig cameras (left and right eye)
  20430. */
  20431. _updateRigCameras(): void;
  20432. private _workingVector;
  20433. private _oneVector;
  20434. private _workingMatrix;
  20435. private updateCacheCalled;
  20436. private _correctPositionIfNotTrackPosition;
  20437. /**
  20438. * @hidden
  20439. * Updates the cached values of the camera
  20440. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20441. */
  20442. _updateCache(ignoreParentClass?: boolean): void;
  20443. /**
  20444. * @hidden
  20445. * Get current device position in babylon world
  20446. */
  20447. _computeDevicePosition(): void;
  20448. /**
  20449. * Updates the current device position and rotation in the babylon world
  20450. */
  20451. update(): void;
  20452. /**
  20453. * @hidden
  20454. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20455. * @returns an identity matrix
  20456. */
  20457. _getViewMatrix(): Matrix;
  20458. private _tmpMatrix;
  20459. /**
  20460. * This function is called by the two RIG cameras.
  20461. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20462. * @hidden
  20463. */
  20464. _getWebVRViewMatrix(): Matrix;
  20465. /** @hidden */
  20466. _getWebVRProjectionMatrix(): Matrix;
  20467. private _onGamepadConnectedObserver;
  20468. private _onGamepadDisconnectedObserver;
  20469. private _updateCacheWhenTrackingDisabledObserver;
  20470. /**
  20471. * Initializes the controllers and their meshes
  20472. */
  20473. initControllers(): void;
  20474. }
  20475. }
  20476. declare module "babylonjs/Materials/materialHelper" {
  20477. import { Nullable } from "babylonjs/types";
  20478. import { Scene } from "babylonjs/scene";
  20479. import { Engine } from "babylonjs/Engines/engine";
  20480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20481. import { Light } from "babylonjs/Lights/light";
  20482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20483. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20485. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20486. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20487. /**
  20488. * "Static Class" containing the most commonly used helper while dealing with material for
  20489. * rendering purpose.
  20490. *
  20491. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20492. *
  20493. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20494. */
  20495. export class MaterialHelper {
  20496. /**
  20497. * Bind the current view position to an effect.
  20498. * @param effect The effect to be bound
  20499. * @param scene The scene the eyes position is used from
  20500. * @param variableName name of the shader variable that will hold the eye position
  20501. */
  20502. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20503. /**
  20504. * Helps preparing the defines values about the UVs in used in the effect.
  20505. * UVs are shared as much as we can accross channels in the shaders.
  20506. * @param texture The texture we are preparing the UVs for
  20507. * @param defines The defines to update
  20508. * @param key The channel key "diffuse", "specular"... used in the shader
  20509. */
  20510. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20511. /**
  20512. * Binds a texture matrix value to its corrsponding uniform
  20513. * @param texture The texture to bind the matrix for
  20514. * @param uniformBuffer The uniform buffer receivin the data
  20515. * @param key The channel key "diffuse", "specular"... used in the shader
  20516. */
  20517. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20518. /**
  20519. * Gets the current status of the fog (should it be enabled?)
  20520. * @param mesh defines the mesh to evaluate for fog support
  20521. * @param scene defines the hosting scene
  20522. * @returns true if fog must be enabled
  20523. */
  20524. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20525. /**
  20526. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20527. * @param mesh defines the current mesh
  20528. * @param scene defines the current scene
  20529. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20530. * @param pointsCloud defines if point cloud rendering has to be turned on
  20531. * @param fogEnabled defines if fog has to be turned on
  20532. * @param alphaTest defines if alpha testing has to be turned on
  20533. * @param defines defines the current list of defines
  20534. */
  20535. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20536. /**
  20537. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20538. * @param scene defines the current scene
  20539. * @param engine defines the current engine
  20540. * @param defines specifies the list of active defines
  20541. * @param useInstances defines if instances have to be turned on
  20542. * @param useClipPlane defines if clip plane have to be turned on
  20543. * @param useInstances defines if instances have to be turned on
  20544. * @param useThinInstances defines if thin instances have to be turned on
  20545. */
  20546. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20547. /**
  20548. * Prepares the defines for bones
  20549. * @param mesh The mesh containing the geometry data we will draw
  20550. * @param defines The defines to update
  20551. */
  20552. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20553. /**
  20554. * Prepares the defines for morph targets
  20555. * @param mesh The mesh containing the geometry data we will draw
  20556. * @param defines The defines to update
  20557. */
  20558. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20559. /**
  20560. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20561. * @param mesh The mesh containing the geometry data we will draw
  20562. * @param defines The defines to update
  20563. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20564. * @param useBones Precise whether bones should be used or not (override mesh info)
  20565. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20566. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20567. * @returns false if defines are considered not dirty and have not been checked
  20568. */
  20569. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20570. /**
  20571. * Prepares the defines related to multiview
  20572. * @param scene The scene we are intending to draw
  20573. * @param defines The defines to update
  20574. */
  20575. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20576. /**
  20577. * Prepares the defines related to the light information passed in parameter
  20578. * @param scene The scene we are intending to draw
  20579. * @param mesh The mesh the effect is compiling for
  20580. * @param light The light the effect is compiling for
  20581. * @param lightIndex The index of the light
  20582. * @param defines The defines to update
  20583. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20584. * @param state Defines the current state regarding what is needed (normals, etc...)
  20585. */
  20586. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20587. needNormals: boolean;
  20588. needRebuild: boolean;
  20589. shadowEnabled: boolean;
  20590. specularEnabled: boolean;
  20591. lightmapMode: boolean;
  20592. }): void;
  20593. /**
  20594. * Prepares the defines related to the light information passed in parameter
  20595. * @param scene The scene we are intending to draw
  20596. * @param mesh The mesh the effect is compiling for
  20597. * @param defines The defines to update
  20598. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20599. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20600. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20601. * @returns true if normals will be required for the rest of the effect
  20602. */
  20603. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20604. /**
  20605. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20606. * @param lightIndex defines the light index
  20607. * @param uniformsList The uniform list
  20608. * @param samplersList The sampler list
  20609. * @param projectedLightTexture defines if projected texture must be used
  20610. * @param uniformBuffersList defines an optional list of uniform buffers
  20611. */
  20612. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20613. /**
  20614. * Prepares the uniforms and samplers list to be used in the effect
  20615. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20616. * @param samplersList The sampler list
  20617. * @param defines The defines helping in the list generation
  20618. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20619. */
  20620. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20621. /**
  20622. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20623. * @param defines The defines to update while falling back
  20624. * @param fallbacks The authorized effect fallbacks
  20625. * @param maxSimultaneousLights The maximum number of lights allowed
  20626. * @param rank the current rank of the Effect
  20627. * @returns The newly affected rank
  20628. */
  20629. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20630. private static _TmpMorphInfluencers;
  20631. /**
  20632. * Prepares the list of attributes required for morph targets according to the effect defines.
  20633. * @param attribs The current list of supported attribs
  20634. * @param mesh The mesh to prepare the morph targets attributes for
  20635. * @param influencers The number of influencers
  20636. */
  20637. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20638. /**
  20639. * Prepares the list of attributes required for morph targets according to the effect defines.
  20640. * @param attribs The current list of supported attribs
  20641. * @param mesh The mesh to prepare the morph targets attributes for
  20642. * @param defines The current Defines of the effect
  20643. */
  20644. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20645. /**
  20646. * Prepares the list of attributes required for bones according to the effect defines.
  20647. * @param attribs The current list of supported attribs
  20648. * @param mesh The mesh to prepare the bones attributes for
  20649. * @param defines The current Defines of the effect
  20650. * @param fallbacks The current efffect fallback strategy
  20651. */
  20652. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20653. /**
  20654. * Check and prepare the list of attributes required for instances according to the effect defines.
  20655. * @param attribs The current list of supported attribs
  20656. * @param defines The current MaterialDefines of the effect
  20657. */
  20658. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20659. /**
  20660. * Add the list of attributes required for instances to the attribs array.
  20661. * @param attribs The current list of supported attribs
  20662. */
  20663. static PushAttributesForInstances(attribs: string[]): void;
  20664. /**
  20665. * Binds the light information to the effect.
  20666. * @param light The light containing the generator
  20667. * @param effect The effect we are binding the data to
  20668. * @param lightIndex The light index in the effect used to render
  20669. */
  20670. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20671. /**
  20672. * Binds the lights information from the scene to the effect for the given mesh.
  20673. * @param light Light to bind
  20674. * @param lightIndex Light index
  20675. * @param scene The scene where the light belongs to
  20676. * @param effect The effect we are binding the data to
  20677. * @param useSpecular Defines if specular is supported
  20678. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20679. */
  20680. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20681. /**
  20682. * Binds the lights information from the scene to the effect for the given mesh.
  20683. * @param scene The scene the lights belongs to
  20684. * @param mesh The mesh we are binding the information to render
  20685. * @param effect The effect we are binding the data to
  20686. * @param defines The generated defines for the effect
  20687. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20688. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20689. */
  20690. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20691. private static _tempFogColor;
  20692. /**
  20693. * Binds the fog information from the scene to the effect for the given mesh.
  20694. * @param scene The scene the lights belongs to
  20695. * @param mesh The mesh we are binding the information to render
  20696. * @param effect The effect we are binding the data to
  20697. * @param linearSpace Defines if the fog effect is applied in linear space
  20698. */
  20699. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20700. /**
  20701. * Binds the bones information from the mesh to the effect.
  20702. * @param mesh The mesh we are binding the information to render
  20703. * @param effect The effect we are binding the data to
  20704. */
  20705. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20706. /**
  20707. * Binds the morph targets information from the mesh to the effect.
  20708. * @param abstractMesh The mesh we are binding the information to render
  20709. * @param effect The effect we are binding the data to
  20710. */
  20711. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20712. /**
  20713. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20714. * @param defines The generated defines used in the effect
  20715. * @param effect The effect we are binding the data to
  20716. * @param scene The scene we are willing to render with logarithmic scale for
  20717. */
  20718. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20719. /**
  20720. * Binds the clip plane information from the scene to the effect.
  20721. * @param scene The scene the clip plane information are extracted from
  20722. * @param effect The effect we are binding the data to
  20723. */
  20724. static BindClipPlane(effect: Effect, scene: Scene): void;
  20725. }
  20726. }
  20727. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20729. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20730. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20731. import { Nullable } from "babylonjs/types";
  20732. import { Effect } from "babylonjs/Materials/effect";
  20733. import { Matrix } from "babylonjs/Maths/math.vector";
  20734. import { Scene } from "babylonjs/scene";
  20735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20737. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20738. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20739. import { Observable } from "babylonjs/Misc/observable";
  20740. /**
  20741. * Block used to expose an input value
  20742. */
  20743. export class InputBlock extends NodeMaterialBlock {
  20744. private _mode;
  20745. private _associatedVariableName;
  20746. private _storedValue;
  20747. private _valueCallback;
  20748. private _type;
  20749. private _animationType;
  20750. /** Gets or set a value used to limit the range of float values */
  20751. min: number;
  20752. /** Gets or set a value used to limit the range of float values */
  20753. max: number;
  20754. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20755. isBoolean: boolean;
  20756. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20757. matrixMode: number;
  20758. /** @hidden */
  20759. _systemValue: Nullable<NodeMaterialSystemValues>;
  20760. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20761. visibleInInspector: boolean;
  20762. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20763. isConstant: boolean;
  20764. /** Gets or sets the group to use to display this block in the Inspector */
  20765. groupInInspector: string;
  20766. /** Gets an observable raised when the value is changed */
  20767. onValueChangedObservable: Observable<InputBlock>;
  20768. /**
  20769. * Gets or sets the connection point type (default is float)
  20770. */
  20771. get type(): NodeMaterialBlockConnectionPointTypes;
  20772. /**
  20773. * Creates a new InputBlock
  20774. * @param name defines the block name
  20775. * @param target defines the target of that block (Vertex by default)
  20776. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20777. */
  20778. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20779. /**
  20780. * Gets the output component
  20781. */
  20782. get output(): NodeMaterialConnectionPoint;
  20783. /**
  20784. * Set the source of this connection point to a vertex attribute
  20785. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20786. * @returns the current connection point
  20787. */
  20788. setAsAttribute(attributeName?: string): InputBlock;
  20789. /**
  20790. * Set the source of this connection point to a system value
  20791. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20792. * @returns the current connection point
  20793. */
  20794. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20795. /**
  20796. * Gets or sets the value of that point.
  20797. * Please note that this value will be ignored if valueCallback is defined
  20798. */
  20799. get value(): any;
  20800. set value(value: any);
  20801. /**
  20802. * Gets or sets a callback used to get the value of that point.
  20803. * Please note that setting this value will force the connection point to ignore the value property
  20804. */
  20805. get valueCallback(): () => any;
  20806. set valueCallback(value: () => any);
  20807. /**
  20808. * Gets or sets the associated variable name in the shader
  20809. */
  20810. get associatedVariableName(): string;
  20811. set associatedVariableName(value: string);
  20812. /** Gets or sets the type of animation applied to the input */
  20813. get animationType(): AnimatedInputBlockTypes;
  20814. set animationType(value: AnimatedInputBlockTypes);
  20815. /**
  20816. * Gets a boolean indicating that this connection point not defined yet
  20817. */
  20818. get isUndefined(): boolean;
  20819. /**
  20820. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20821. * In this case the connection point name must be the name of the uniform to use.
  20822. * Can only be set on inputs
  20823. */
  20824. get isUniform(): boolean;
  20825. set isUniform(value: boolean);
  20826. /**
  20827. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20828. * In this case the connection point name must be the name of the attribute to use
  20829. * Can only be set on inputs
  20830. */
  20831. get isAttribute(): boolean;
  20832. set isAttribute(value: boolean);
  20833. /**
  20834. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20835. * Can only be set on exit points
  20836. */
  20837. get isVarying(): boolean;
  20838. set isVarying(value: boolean);
  20839. /**
  20840. * Gets a boolean indicating that the current connection point is a system value
  20841. */
  20842. get isSystemValue(): boolean;
  20843. /**
  20844. * Gets or sets the current well known value or null if not defined as a system value
  20845. */
  20846. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20847. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20848. /**
  20849. * Gets the current class name
  20850. * @returns the class name
  20851. */
  20852. getClassName(): string;
  20853. /**
  20854. * Animate the input if animationType !== None
  20855. * @param scene defines the rendering scene
  20856. */
  20857. animate(scene: Scene): void;
  20858. private _emitDefine;
  20859. initialize(state: NodeMaterialBuildState): void;
  20860. /**
  20861. * Set the input block to its default value (based on its type)
  20862. */
  20863. setDefaultValue(): void;
  20864. private _emitConstant;
  20865. /** @hidden */
  20866. get _noContextSwitch(): boolean;
  20867. private _emit;
  20868. /** @hidden */
  20869. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20870. /** @hidden */
  20871. _transmit(effect: Effect, scene: Scene): void;
  20872. protected _buildBlock(state: NodeMaterialBuildState): void;
  20873. protected _dumpPropertiesCode(): string;
  20874. dispose(): void;
  20875. serialize(): any;
  20876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20877. }
  20878. }
  20879. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20880. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20881. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20882. import { Nullable } from "babylonjs/types";
  20883. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20884. import { Observable } from "babylonjs/Misc/observable";
  20885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20886. /**
  20887. * Enum used to define the compatibility state between two connection points
  20888. */
  20889. export enum NodeMaterialConnectionPointCompatibilityStates {
  20890. /** Points are compatibles */
  20891. Compatible = 0,
  20892. /** Points are incompatible because of their types */
  20893. TypeIncompatible = 1,
  20894. /** Points are incompatible because of their targets (vertex vs fragment) */
  20895. TargetIncompatible = 2
  20896. }
  20897. /**
  20898. * Defines the direction of a connection point
  20899. */
  20900. export enum NodeMaterialConnectionPointDirection {
  20901. /** Input */
  20902. Input = 0,
  20903. /** Output */
  20904. Output = 1
  20905. }
  20906. /**
  20907. * Defines a connection point for a block
  20908. */
  20909. export class NodeMaterialConnectionPoint {
  20910. /** @hidden */
  20911. _ownerBlock: NodeMaterialBlock;
  20912. /** @hidden */
  20913. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20914. private _endpoints;
  20915. private _associatedVariableName;
  20916. private _direction;
  20917. /** @hidden */
  20918. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20919. /** @hidden */
  20920. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20921. private _type;
  20922. /** @hidden */
  20923. _enforceAssociatedVariableName: boolean;
  20924. /** Gets the direction of the point */
  20925. get direction(): NodeMaterialConnectionPointDirection;
  20926. /** Indicates that this connection point needs dual validation before being connected to another point */
  20927. needDualDirectionValidation: boolean;
  20928. /**
  20929. * Gets or sets the additional types supported by this connection point
  20930. */
  20931. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20932. /**
  20933. * Gets or sets the additional types excluded by this connection point
  20934. */
  20935. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20936. /**
  20937. * Observable triggered when this point is connected
  20938. */
  20939. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20940. /**
  20941. * Gets or sets the associated variable name in the shader
  20942. */
  20943. get associatedVariableName(): string;
  20944. set associatedVariableName(value: string);
  20945. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20946. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20947. /**
  20948. * Gets or sets the connection point type (default is float)
  20949. */
  20950. get type(): NodeMaterialBlockConnectionPointTypes;
  20951. set type(value: NodeMaterialBlockConnectionPointTypes);
  20952. /**
  20953. * Gets or sets the connection point name
  20954. */
  20955. name: string;
  20956. /**
  20957. * Gets or sets the connection point name
  20958. */
  20959. displayName: string;
  20960. /**
  20961. * Gets or sets a boolean indicating that this connection point can be omitted
  20962. */
  20963. isOptional: boolean;
  20964. /**
  20965. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20966. */
  20967. isExposedOnFrame: boolean;
  20968. /**
  20969. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20970. */
  20971. define: string;
  20972. /** @hidden */
  20973. _prioritizeVertex: boolean;
  20974. private _target;
  20975. /** Gets or sets the target of that connection point */
  20976. get target(): NodeMaterialBlockTargets;
  20977. set target(value: NodeMaterialBlockTargets);
  20978. /**
  20979. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20980. */
  20981. get isConnected(): boolean;
  20982. /**
  20983. * Gets a boolean indicating that the current point is connected to an input block
  20984. */
  20985. get isConnectedToInputBlock(): boolean;
  20986. /**
  20987. * Gets a the connected input block (if any)
  20988. */
  20989. get connectInputBlock(): Nullable<InputBlock>;
  20990. /** Get the other side of the connection (if any) */
  20991. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20992. /** Get the block that owns this connection point */
  20993. get ownerBlock(): NodeMaterialBlock;
  20994. /** Get the block connected on the other side of this connection (if any) */
  20995. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20996. /** Get the block connected on the endpoints of this connection (if any) */
  20997. get connectedBlocks(): Array<NodeMaterialBlock>;
  20998. /** Gets the list of connected endpoints */
  20999. get endpoints(): NodeMaterialConnectionPoint[];
  21000. /** Gets a boolean indicating if that output point is connected to at least one input */
  21001. get hasEndpoints(): boolean;
  21002. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21003. get isConnectedInVertexShader(): boolean;
  21004. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21005. get isConnectedInFragmentShader(): boolean;
  21006. /**
  21007. * Creates a block suitable to be used as an input for this input point.
  21008. * If null is returned, a block based on the point type will be created.
  21009. * @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
  21010. */
  21011. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21012. /**
  21013. * Creates a new connection point
  21014. * @param name defines the connection point name
  21015. * @param ownerBlock defines the block hosting this connection point
  21016. * @param direction defines the direction of the connection point
  21017. */
  21018. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21019. /**
  21020. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21021. * @returns the class name
  21022. */
  21023. getClassName(): string;
  21024. /**
  21025. * Gets a boolean indicating if the current point can be connected to another point
  21026. * @param connectionPoint defines the other connection point
  21027. * @returns a boolean
  21028. */
  21029. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21030. /**
  21031. * Gets a number indicating if the current point can be connected to another point
  21032. * @param connectionPoint defines the other connection point
  21033. * @returns a number defining the compatibility state
  21034. */
  21035. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21036. /**
  21037. * Connect this point to another connection point
  21038. * @param connectionPoint defines the other connection point
  21039. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21040. * @returns the current connection point
  21041. */
  21042. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Disconnect this point from one of his endpoint
  21045. * @param endpoint defines the other connection point
  21046. * @returns the current connection point
  21047. */
  21048. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21049. /**
  21050. * Serializes this point in a JSON representation
  21051. * @param isInput defines if the connection point is an input (default is true)
  21052. * @returns the serialized point object
  21053. */
  21054. serialize(isInput?: boolean): any;
  21055. /**
  21056. * Release resources
  21057. */
  21058. dispose(): void;
  21059. }
  21060. }
  21061. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21062. /**
  21063. * Enum used to define the material modes
  21064. */
  21065. export enum NodeMaterialModes {
  21066. /** Regular material */
  21067. Material = 0,
  21068. /** For post process */
  21069. PostProcess = 1,
  21070. /** For particle system */
  21071. Particle = 2
  21072. }
  21073. }
  21074. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21077. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21081. import { Effect } from "babylonjs/Materials/effect";
  21082. import { Mesh } from "babylonjs/Meshes/mesh";
  21083. import { Nullable } from "babylonjs/types";
  21084. import { Texture } from "babylonjs/Materials/Textures/texture";
  21085. import { Scene } from "babylonjs/scene";
  21086. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21087. /**
  21088. * Block used to read a texture from a sampler
  21089. */
  21090. export class TextureBlock extends NodeMaterialBlock {
  21091. private _defineName;
  21092. private _linearDefineName;
  21093. private _gammaDefineName;
  21094. private _tempTextureRead;
  21095. private _samplerName;
  21096. private _transformedUVName;
  21097. private _textureTransformName;
  21098. private _textureInfoName;
  21099. private _mainUVName;
  21100. private _mainUVDefineName;
  21101. private _fragmentOnly;
  21102. /**
  21103. * Gets or sets the texture associated with the node
  21104. */
  21105. texture: Nullable<Texture>;
  21106. /**
  21107. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21108. */
  21109. convertToGammaSpace: boolean;
  21110. /**
  21111. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21112. */
  21113. convertToLinearSpace: boolean;
  21114. /**
  21115. * Create a new TextureBlock
  21116. * @param name defines the block name
  21117. */
  21118. constructor(name: string, fragmentOnly?: boolean);
  21119. /**
  21120. * Gets the current class name
  21121. * @returns the class name
  21122. */
  21123. getClassName(): string;
  21124. /**
  21125. * Gets the uv input component
  21126. */
  21127. get uv(): NodeMaterialConnectionPoint;
  21128. /**
  21129. * Gets the rgba output component
  21130. */
  21131. get rgba(): NodeMaterialConnectionPoint;
  21132. /**
  21133. * Gets the rgb output component
  21134. */
  21135. get rgb(): NodeMaterialConnectionPoint;
  21136. /**
  21137. * Gets the r output component
  21138. */
  21139. get r(): NodeMaterialConnectionPoint;
  21140. /**
  21141. * Gets the g output component
  21142. */
  21143. get g(): NodeMaterialConnectionPoint;
  21144. /**
  21145. * Gets the b output component
  21146. */
  21147. get b(): NodeMaterialConnectionPoint;
  21148. /**
  21149. * Gets the a output component
  21150. */
  21151. get a(): NodeMaterialConnectionPoint;
  21152. get target(): NodeMaterialBlockTargets;
  21153. autoConfigure(material: NodeMaterial): void;
  21154. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21156. isReady(): boolean;
  21157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21158. private get _isMixed();
  21159. private _injectVertexCode;
  21160. private _writeTextureRead;
  21161. private _writeOutput;
  21162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21163. protected _dumpPropertiesCode(): string;
  21164. serialize(): any;
  21165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21166. }
  21167. }
  21168. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21169. /** @hidden */
  21170. export var reflectionFunction: {
  21171. name: string;
  21172. shader: string;
  21173. };
  21174. }
  21175. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21181. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21182. import { Effect } from "babylonjs/Materials/effect";
  21183. import { Mesh } from "babylonjs/Meshes/mesh";
  21184. import { Nullable } from "babylonjs/types";
  21185. import { Scene } from "babylonjs/scene";
  21186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21187. /**
  21188. * Base block used to read a reflection texture from a sampler
  21189. */
  21190. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21191. /** @hidden */
  21192. _define3DName: string;
  21193. /** @hidden */
  21194. _defineCubicName: string;
  21195. /** @hidden */
  21196. _defineExplicitName: string;
  21197. /** @hidden */
  21198. _defineProjectionName: string;
  21199. /** @hidden */
  21200. _defineLocalCubicName: string;
  21201. /** @hidden */
  21202. _defineSphericalName: string;
  21203. /** @hidden */
  21204. _definePlanarName: string;
  21205. /** @hidden */
  21206. _defineEquirectangularName: string;
  21207. /** @hidden */
  21208. _defineMirroredEquirectangularFixedName: string;
  21209. /** @hidden */
  21210. _defineEquirectangularFixedName: string;
  21211. /** @hidden */
  21212. _defineSkyboxName: string;
  21213. /** @hidden */
  21214. _defineOppositeZ: string;
  21215. /** @hidden */
  21216. _cubeSamplerName: string;
  21217. /** @hidden */
  21218. _2DSamplerName: string;
  21219. protected _positionUVWName: string;
  21220. protected _directionWName: string;
  21221. protected _reflectionVectorName: string;
  21222. /** @hidden */
  21223. _reflectionCoordsName: string;
  21224. /** @hidden */
  21225. _reflectionMatrixName: string;
  21226. protected _reflectionColorName: string;
  21227. /**
  21228. * Gets or sets the texture associated with the node
  21229. */
  21230. texture: Nullable<BaseTexture>;
  21231. /**
  21232. * Create a new ReflectionTextureBaseBlock
  21233. * @param name defines the block name
  21234. */
  21235. constructor(name: string);
  21236. /**
  21237. * Gets the current class name
  21238. * @returns the class name
  21239. */
  21240. getClassName(): string;
  21241. /**
  21242. * Gets the world position input component
  21243. */
  21244. abstract get position(): NodeMaterialConnectionPoint;
  21245. /**
  21246. * Gets the world position input component
  21247. */
  21248. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21249. /**
  21250. * Gets the world normal input component
  21251. */
  21252. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21253. /**
  21254. * Gets the world input component
  21255. */
  21256. abstract get world(): NodeMaterialConnectionPoint;
  21257. /**
  21258. * Gets the camera (or eye) position component
  21259. */
  21260. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21261. /**
  21262. * Gets the view input component
  21263. */
  21264. abstract get view(): NodeMaterialConnectionPoint;
  21265. protected _getTexture(): Nullable<BaseTexture>;
  21266. autoConfigure(material: NodeMaterial): void;
  21267. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21268. isReady(): boolean;
  21269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21270. /**
  21271. * Gets the code to inject in the vertex shader
  21272. * @param state current state of the node material building
  21273. * @returns the shader code
  21274. */
  21275. handleVertexSide(state: NodeMaterialBuildState): string;
  21276. /**
  21277. * Handles the inits for the fragment code path
  21278. * @param state node material build state
  21279. */
  21280. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21281. /**
  21282. * Generates the reflection coords code for the fragment code path
  21283. * @param worldNormalVarName name of the world normal variable
  21284. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21285. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21286. * @returns the shader code
  21287. */
  21288. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21289. /**
  21290. * Generates the reflection color code for the fragment code path
  21291. * @param lodVarName name of the lod variable
  21292. * @param swizzleLookupTexture swizzle to use for the final color variable
  21293. * @returns the shader code
  21294. */
  21295. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21296. /**
  21297. * Generates the code corresponding to the connected output points
  21298. * @param state node material build state
  21299. * @param varName name of the variable to output
  21300. * @returns the shader code
  21301. */
  21302. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21303. protected _buildBlock(state: NodeMaterialBuildState): this;
  21304. protected _dumpPropertiesCode(): string;
  21305. serialize(): any;
  21306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21307. }
  21308. }
  21309. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21311. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21312. import { Nullable } from "babylonjs/types";
  21313. /**
  21314. * Defines a connection point to be used for points with a custom object type
  21315. */
  21316. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21317. private _blockType;
  21318. private _blockName;
  21319. private _nameForCheking?;
  21320. /**
  21321. * Creates a new connection point
  21322. * @param name defines the connection point name
  21323. * @param ownerBlock defines the block hosting this connection point
  21324. * @param direction defines the direction of the connection point
  21325. */
  21326. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21327. /**
  21328. * Gets a number indicating if the current point can be connected to another point
  21329. * @param connectionPoint defines the other connection point
  21330. * @returns a number defining the compatibility state
  21331. */
  21332. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21333. /**
  21334. * Creates a block suitable to be used as an input for this input point.
  21335. * If null is returned, a block based on the point type will be created.
  21336. * @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
  21337. */
  21338. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21339. }
  21340. }
  21341. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21342. /**
  21343. * Enum defining the type of properties that can be edited in the property pages in the NME
  21344. */
  21345. export enum PropertyTypeForEdition {
  21346. /** property is a boolean */
  21347. Boolean = 0,
  21348. /** property is a float */
  21349. Float = 1,
  21350. /** property is a Vector2 */
  21351. Vector2 = 2,
  21352. /** property is a list of values */
  21353. List = 3
  21354. }
  21355. /**
  21356. * Interface that defines an option in a variable of type list
  21357. */
  21358. export interface IEditablePropertyListOption {
  21359. /** label of the option */
  21360. "label": string;
  21361. /** value of the option */
  21362. "value": number;
  21363. }
  21364. /**
  21365. * Interface that defines the options available for an editable property
  21366. */
  21367. export interface IEditablePropertyOption {
  21368. /** min value */
  21369. "min"?: number;
  21370. /** max value */
  21371. "max"?: number;
  21372. /** notifiers: indicates which actions to take when the property is changed */
  21373. "notifiers"?: {
  21374. /** the material should be rebuilt */
  21375. "rebuild"?: boolean;
  21376. /** the preview should be updated */
  21377. "update"?: boolean;
  21378. };
  21379. /** list of the options for a variable of type list */
  21380. "options"?: IEditablePropertyListOption[];
  21381. }
  21382. /**
  21383. * Interface that describes an editable property
  21384. */
  21385. export interface IPropertyDescriptionForEdition {
  21386. /** name of the property */
  21387. "propertyName": string;
  21388. /** display name of the property */
  21389. "displayName": string;
  21390. /** type of the property */
  21391. "type": PropertyTypeForEdition;
  21392. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21393. "groupName": string;
  21394. /** options for the property */
  21395. "options": IEditablePropertyOption;
  21396. }
  21397. /**
  21398. * Decorator that flags a property in a node material block as being editable
  21399. */
  21400. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21401. }
  21402. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21405. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21407. import { Nullable } from "babylonjs/types";
  21408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21409. import { Mesh } from "babylonjs/Meshes/mesh";
  21410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21411. import { Effect } from "babylonjs/Materials/effect";
  21412. import { Scene } from "babylonjs/scene";
  21413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21414. /**
  21415. * Block used to implement the refraction part of the sub surface module of the PBR material
  21416. */
  21417. export class RefractionBlock extends NodeMaterialBlock {
  21418. /** @hidden */
  21419. _define3DName: string;
  21420. /** @hidden */
  21421. _refractionMatrixName: string;
  21422. /** @hidden */
  21423. _defineLODRefractionAlpha: string;
  21424. /** @hidden */
  21425. _defineLinearSpecularRefraction: string;
  21426. /** @hidden */
  21427. _defineOppositeZ: string;
  21428. /** @hidden */
  21429. _cubeSamplerName: string;
  21430. /** @hidden */
  21431. _2DSamplerName: string;
  21432. /** @hidden */
  21433. _vRefractionMicrosurfaceInfosName: string;
  21434. /** @hidden */
  21435. _vRefractionInfosName: string;
  21436. private _scene;
  21437. /**
  21438. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21439. * Materials half opaque for instance using refraction could benefit from this control.
  21440. */
  21441. linkRefractionWithTransparency: boolean;
  21442. /**
  21443. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21444. */
  21445. invertRefractionY: boolean;
  21446. /**
  21447. * Gets or sets the texture associated with the node
  21448. */
  21449. texture: Nullable<BaseTexture>;
  21450. /**
  21451. * Create a new RefractionBlock
  21452. * @param name defines the block name
  21453. */
  21454. constructor(name: string);
  21455. /**
  21456. * Gets the current class name
  21457. * @returns the class name
  21458. */
  21459. getClassName(): string;
  21460. /**
  21461. * Gets the intensity input component
  21462. */
  21463. get intensity(): NodeMaterialConnectionPoint;
  21464. /**
  21465. * Gets the index of refraction input component
  21466. */
  21467. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21468. /**
  21469. * Gets the tint at distance input component
  21470. */
  21471. get tintAtDistance(): NodeMaterialConnectionPoint;
  21472. /**
  21473. * Gets the view input component
  21474. */
  21475. get view(): NodeMaterialConnectionPoint;
  21476. /**
  21477. * Gets the refraction object output component
  21478. */
  21479. get refraction(): NodeMaterialConnectionPoint;
  21480. /**
  21481. * Returns true if the block has a texture
  21482. */
  21483. get hasTexture(): boolean;
  21484. protected _getTexture(): Nullable<BaseTexture>;
  21485. autoConfigure(material: NodeMaterial): void;
  21486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21487. isReady(): boolean;
  21488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21489. /**
  21490. * Gets the main code of the block (fragment side)
  21491. * @param state current state of the node material building
  21492. * @returns the shader code
  21493. */
  21494. getCode(state: NodeMaterialBuildState): string;
  21495. protected _buildBlock(state: NodeMaterialBuildState): this;
  21496. protected _dumpPropertiesCode(): string;
  21497. serialize(): any;
  21498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21499. }
  21500. }
  21501. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21504. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21507. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21509. import { Nullable } from "babylonjs/types";
  21510. import { Scene } from "babylonjs/scene";
  21511. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21512. /**
  21513. * Base block used as input for post process
  21514. */
  21515. export class CurrentScreenBlock extends NodeMaterialBlock {
  21516. private _samplerName;
  21517. private _linearDefineName;
  21518. private _gammaDefineName;
  21519. private _mainUVName;
  21520. private _tempTextureRead;
  21521. /**
  21522. * Gets or sets the texture associated with the node
  21523. */
  21524. texture: Nullable<BaseTexture>;
  21525. /**
  21526. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21527. */
  21528. convertToGammaSpace: boolean;
  21529. /**
  21530. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21531. */
  21532. convertToLinearSpace: boolean;
  21533. /**
  21534. * Create a new CurrentScreenBlock
  21535. * @param name defines the block name
  21536. */
  21537. constructor(name: string);
  21538. /**
  21539. * Gets the current class name
  21540. * @returns the class name
  21541. */
  21542. getClassName(): string;
  21543. /**
  21544. * Gets the uv input component
  21545. */
  21546. get uv(): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Gets the rgba output component
  21549. */
  21550. get rgba(): NodeMaterialConnectionPoint;
  21551. /**
  21552. * Gets the rgb output component
  21553. */
  21554. get rgb(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the r output component
  21557. */
  21558. get r(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the g output component
  21561. */
  21562. get g(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the b output component
  21565. */
  21566. get b(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Gets the a output component
  21569. */
  21570. get a(): NodeMaterialConnectionPoint;
  21571. /**
  21572. * Initialize the block and prepare the context for build
  21573. * @param state defines the state that will be used for the build
  21574. */
  21575. initialize(state: NodeMaterialBuildState): void;
  21576. get target(): NodeMaterialBlockTargets;
  21577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21578. isReady(): boolean;
  21579. private _injectVertexCode;
  21580. private _writeTextureRead;
  21581. private _writeOutput;
  21582. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21583. serialize(): any;
  21584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21585. }
  21586. }
  21587. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21592. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21594. import { Nullable } from "babylonjs/types";
  21595. import { Scene } from "babylonjs/scene";
  21596. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21597. /**
  21598. * Base block used for the particle texture
  21599. */
  21600. export class ParticleTextureBlock extends NodeMaterialBlock {
  21601. private _samplerName;
  21602. private _linearDefineName;
  21603. private _gammaDefineName;
  21604. private _tempTextureRead;
  21605. /**
  21606. * Gets or sets the texture associated with the node
  21607. */
  21608. texture: Nullable<BaseTexture>;
  21609. /**
  21610. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21611. */
  21612. convertToGammaSpace: boolean;
  21613. /**
  21614. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21615. */
  21616. convertToLinearSpace: boolean;
  21617. /**
  21618. * Create a new ParticleTextureBlock
  21619. * @param name defines the block name
  21620. */
  21621. constructor(name: string);
  21622. /**
  21623. * Gets the current class name
  21624. * @returns the class name
  21625. */
  21626. getClassName(): string;
  21627. /**
  21628. * Gets the uv input component
  21629. */
  21630. get uv(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the rgba output component
  21633. */
  21634. get rgba(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the rgb output component
  21637. */
  21638. get rgb(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Gets the r output component
  21641. */
  21642. get r(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the g output component
  21645. */
  21646. get g(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the b output component
  21649. */
  21650. get b(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the a output component
  21653. */
  21654. get a(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Initialize the block and prepare the context for build
  21657. * @param state defines the state that will be used for the build
  21658. */
  21659. initialize(state: NodeMaterialBuildState): void;
  21660. autoConfigure(material: NodeMaterial): void;
  21661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21662. isReady(): boolean;
  21663. private _writeOutput;
  21664. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21665. serialize(): any;
  21666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21667. }
  21668. }
  21669. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21672. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21673. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21674. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21675. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21676. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21677. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21678. import { Scene } from "babylonjs/scene";
  21679. /**
  21680. * Class used to store shared data between 2 NodeMaterialBuildState
  21681. */
  21682. export class NodeMaterialBuildStateSharedData {
  21683. /**
  21684. * Gets the list of emitted varyings
  21685. */
  21686. temps: string[];
  21687. /**
  21688. * Gets the list of emitted varyings
  21689. */
  21690. varyings: string[];
  21691. /**
  21692. * Gets the varying declaration string
  21693. */
  21694. varyingDeclaration: string;
  21695. /**
  21696. * Input blocks
  21697. */
  21698. inputBlocks: InputBlock[];
  21699. /**
  21700. * Input blocks
  21701. */
  21702. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21703. /**
  21704. * Bindable blocks (Blocks that need to set data to the effect)
  21705. */
  21706. bindableBlocks: NodeMaterialBlock[];
  21707. /**
  21708. * List of blocks that can provide a compilation fallback
  21709. */
  21710. blocksWithFallbacks: NodeMaterialBlock[];
  21711. /**
  21712. * List of blocks that can provide a define update
  21713. */
  21714. blocksWithDefines: NodeMaterialBlock[];
  21715. /**
  21716. * List of blocks that can provide a repeatable content
  21717. */
  21718. repeatableContentBlocks: NodeMaterialBlock[];
  21719. /**
  21720. * List of blocks that can provide a dynamic list of uniforms
  21721. */
  21722. dynamicUniformBlocks: NodeMaterialBlock[];
  21723. /**
  21724. * List of blocks that can block the isReady function for the material
  21725. */
  21726. blockingBlocks: NodeMaterialBlock[];
  21727. /**
  21728. * Gets the list of animated inputs
  21729. */
  21730. animatedInputs: InputBlock[];
  21731. /**
  21732. * Build Id used to avoid multiple recompilations
  21733. */
  21734. buildId: number;
  21735. /** List of emitted variables */
  21736. variableNames: {
  21737. [key: string]: number;
  21738. };
  21739. /** List of emitted defines */
  21740. defineNames: {
  21741. [key: string]: number;
  21742. };
  21743. /** Should emit comments? */
  21744. emitComments: boolean;
  21745. /** Emit build activity */
  21746. verbose: boolean;
  21747. /** Gets or sets the hosting scene */
  21748. scene: Scene;
  21749. /**
  21750. * Gets the compilation hints emitted at compilation time
  21751. */
  21752. hints: {
  21753. needWorldViewMatrix: boolean;
  21754. needWorldViewProjectionMatrix: boolean;
  21755. needAlphaBlending: boolean;
  21756. needAlphaTesting: boolean;
  21757. };
  21758. /**
  21759. * List of compilation checks
  21760. */
  21761. checks: {
  21762. emitVertex: boolean;
  21763. emitFragment: boolean;
  21764. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21765. };
  21766. /**
  21767. * Is vertex program allowed to be empty?
  21768. */
  21769. allowEmptyVertexProgram: boolean;
  21770. /** Creates a new shared data */
  21771. constructor();
  21772. /**
  21773. * Emits console errors and exceptions if there is a failing check
  21774. */
  21775. emitErrors(): void;
  21776. }
  21777. }
  21778. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21779. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21780. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21781. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21782. /**
  21783. * Class used to store node based material build state
  21784. */
  21785. export class NodeMaterialBuildState {
  21786. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21787. supportUniformBuffers: boolean;
  21788. /**
  21789. * Gets the list of emitted attributes
  21790. */
  21791. attributes: string[];
  21792. /**
  21793. * Gets the list of emitted uniforms
  21794. */
  21795. uniforms: string[];
  21796. /**
  21797. * Gets the list of emitted constants
  21798. */
  21799. constants: string[];
  21800. /**
  21801. * Gets the list of emitted samplers
  21802. */
  21803. samplers: string[];
  21804. /**
  21805. * Gets the list of emitted functions
  21806. */
  21807. functions: {
  21808. [key: string]: string;
  21809. };
  21810. /**
  21811. * Gets the list of emitted extensions
  21812. */
  21813. extensions: {
  21814. [key: string]: string;
  21815. };
  21816. /**
  21817. * Gets the target of the compilation state
  21818. */
  21819. target: NodeMaterialBlockTargets;
  21820. /**
  21821. * Gets the list of emitted counters
  21822. */
  21823. counters: {
  21824. [key: string]: number;
  21825. };
  21826. /**
  21827. * Shared data between multiple NodeMaterialBuildState instances
  21828. */
  21829. sharedData: NodeMaterialBuildStateSharedData;
  21830. /** @hidden */
  21831. _vertexState: NodeMaterialBuildState;
  21832. /** @hidden */
  21833. _attributeDeclaration: string;
  21834. /** @hidden */
  21835. _uniformDeclaration: string;
  21836. /** @hidden */
  21837. _constantDeclaration: string;
  21838. /** @hidden */
  21839. _samplerDeclaration: string;
  21840. /** @hidden */
  21841. _varyingTransfer: string;
  21842. /** @hidden */
  21843. _injectAtEnd: string;
  21844. private _repeatableContentAnchorIndex;
  21845. /** @hidden */
  21846. _builtCompilationString: string;
  21847. /**
  21848. * Gets the emitted compilation strings
  21849. */
  21850. compilationString: string;
  21851. /**
  21852. * Finalize the compilation strings
  21853. * @param state defines the current compilation state
  21854. */
  21855. finalize(state: NodeMaterialBuildState): void;
  21856. /** @hidden */
  21857. get _repeatableContentAnchor(): string;
  21858. /** @hidden */
  21859. _getFreeVariableName(prefix: string): string;
  21860. /** @hidden */
  21861. _getFreeDefineName(prefix: string): string;
  21862. /** @hidden */
  21863. _excludeVariableName(name: string): void;
  21864. /** @hidden */
  21865. _emit2DSampler(name: string): void;
  21866. /** @hidden */
  21867. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21868. /** @hidden */
  21869. _emitExtension(name: string, extension: string, define?: string): void;
  21870. /** @hidden */
  21871. _emitFunction(name: string, code: string, comments: string): void;
  21872. /** @hidden */
  21873. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21874. replaceStrings?: {
  21875. search: RegExp;
  21876. replace: string;
  21877. }[];
  21878. repeatKey?: string;
  21879. }): string;
  21880. /** @hidden */
  21881. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21882. repeatKey?: string;
  21883. removeAttributes?: boolean;
  21884. removeUniforms?: boolean;
  21885. removeVaryings?: boolean;
  21886. removeIfDef?: boolean;
  21887. replaceStrings?: {
  21888. search: RegExp;
  21889. replace: string;
  21890. }[];
  21891. }, storeKey?: string): void;
  21892. /** @hidden */
  21893. _registerTempVariable(name: string): boolean;
  21894. /** @hidden */
  21895. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21896. /** @hidden */
  21897. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21898. /** @hidden */
  21899. _emitFloat(value: number): string;
  21900. }
  21901. }
  21902. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21903. /**
  21904. * Helper class used to generate session unique ID
  21905. */
  21906. export class UniqueIdGenerator {
  21907. private static _UniqueIdCounter;
  21908. /**
  21909. * Gets an unique (relatively to the current scene) Id
  21910. */
  21911. static get UniqueId(): number;
  21912. }
  21913. }
  21914. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21915. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21917. import { Nullable } from "babylonjs/types";
  21918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21919. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21920. import { Effect } from "babylonjs/Materials/effect";
  21921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21922. import { Mesh } from "babylonjs/Meshes/mesh";
  21923. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21925. import { Scene } from "babylonjs/scene";
  21926. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21927. /**
  21928. * Defines a block that can be used inside a node based material
  21929. */
  21930. export class NodeMaterialBlock {
  21931. private _buildId;
  21932. private _buildTarget;
  21933. private _target;
  21934. private _isFinalMerger;
  21935. private _isInput;
  21936. protected _isUnique: boolean;
  21937. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21938. inputsAreExclusive: boolean;
  21939. /** @hidden */
  21940. _codeVariableName: string;
  21941. /** @hidden */
  21942. _inputs: NodeMaterialConnectionPoint[];
  21943. /** @hidden */
  21944. _outputs: NodeMaterialConnectionPoint[];
  21945. /** @hidden */
  21946. _preparationId: number;
  21947. /**
  21948. * Gets or sets the name of the block
  21949. */
  21950. name: string;
  21951. /**
  21952. * Gets or sets the unique id of the node
  21953. */
  21954. uniqueId: number;
  21955. /**
  21956. * Gets or sets the comments associated with this block
  21957. */
  21958. comments: string;
  21959. /**
  21960. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21961. */
  21962. get isUnique(): boolean;
  21963. /**
  21964. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21965. */
  21966. get isFinalMerger(): boolean;
  21967. /**
  21968. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21969. */
  21970. get isInput(): boolean;
  21971. /**
  21972. * Gets or sets the build Id
  21973. */
  21974. get buildId(): number;
  21975. set buildId(value: number);
  21976. /**
  21977. * Gets or sets the target of the block
  21978. */
  21979. get target(): NodeMaterialBlockTargets;
  21980. set target(value: NodeMaterialBlockTargets);
  21981. /**
  21982. * Gets the list of input points
  21983. */
  21984. get inputs(): NodeMaterialConnectionPoint[];
  21985. /** Gets the list of output points */
  21986. get outputs(): NodeMaterialConnectionPoint[];
  21987. /**
  21988. * Find an input by its name
  21989. * @param name defines the name of the input to look for
  21990. * @returns the input or null if not found
  21991. */
  21992. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21993. /**
  21994. * Find an output by its name
  21995. * @param name defines the name of the outputto look for
  21996. * @returns the output or null if not found
  21997. */
  21998. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21999. /**
  22000. * Creates a new NodeMaterialBlock
  22001. * @param name defines the block name
  22002. * @param target defines the target of that block (Vertex by default)
  22003. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22004. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22005. */
  22006. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22007. /**
  22008. * Initialize the block and prepare the context for build
  22009. * @param state defines the state that will be used for the build
  22010. */
  22011. initialize(state: NodeMaterialBuildState): void;
  22012. /**
  22013. * Bind data to effect. Will only be called for blocks with isBindable === true
  22014. * @param effect defines the effect to bind data to
  22015. * @param nodeMaterial defines the hosting NodeMaterial
  22016. * @param mesh defines the mesh that will be rendered
  22017. * @param subMesh defines the submesh that will be rendered
  22018. */
  22019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22020. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22021. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22022. protected _writeFloat(value: number): string;
  22023. /**
  22024. * Gets the current class name e.g. "NodeMaterialBlock"
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Register a new input. Must be called inside a block constructor
  22030. * @param name defines the connection point name
  22031. * @param type defines the connection point type
  22032. * @param isOptional defines a boolean indicating that this input can be omitted
  22033. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22034. * @param point an already created connection point. If not provided, create a new one
  22035. * @returns the current block
  22036. */
  22037. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22038. /**
  22039. * Register a new output. Must be called inside a block constructor
  22040. * @param name defines the connection point name
  22041. * @param type defines the connection point type
  22042. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22043. * @param point an already created connection point. If not provided, create a new one
  22044. * @returns the current block
  22045. */
  22046. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22047. /**
  22048. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22049. * @param forOutput defines an optional connection point to check compatibility with
  22050. * @returns the first available input or null
  22051. */
  22052. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22053. /**
  22054. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22055. * @param forBlock defines an optional block to check compatibility with
  22056. * @returns the first available input or null
  22057. */
  22058. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22059. /**
  22060. * Gets the sibling of the given output
  22061. * @param current defines the current output
  22062. * @returns the next output in the list or null
  22063. */
  22064. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22065. /**
  22066. * Connect current block with another block
  22067. * @param other defines the block to connect with
  22068. * @param options define the various options to help pick the right connections
  22069. * @returns the current block
  22070. */
  22071. connectTo(other: NodeMaterialBlock, options?: {
  22072. input?: string;
  22073. output?: string;
  22074. outputSwizzle?: string;
  22075. }): this | undefined;
  22076. protected _buildBlock(state: NodeMaterialBuildState): void;
  22077. /**
  22078. * Add uniforms, samplers and uniform buffers at compilation time
  22079. * @param state defines the state to update
  22080. * @param nodeMaterial defines the node material requesting the update
  22081. * @param defines defines the material defines to update
  22082. * @param uniformBuffers defines the list of uniform buffer names
  22083. */
  22084. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22085. /**
  22086. * Add potential fallbacks if shader compilation fails
  22087. * @param mesh defines the mesh to be rendered
  22088. * @param fallbacks defines the current prioritized list of fallbacks
  22089. */
  22090. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22091. /**
  22092. * Initialize defines for shader compilation
  22093. * @param mesh defines the mesh to be rendered
  22094. * @param nodeMaterial defines the node material requesting the update
  22095. * @param defines defines the material defines to update
  22096. * @param useInstances specifies that instances should be used
  22097. */
  22098. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22099. /**
  22100. * Update defines for shader compilation
  22101. * @param mesh defines the mesh to be rendered
  22102. * @param nodeMaterial defines the node material requesting the update
  22103. * @param defines defines the material defines to update
  22104. * @param useInstances specifies that instances should be used
  22105. * @param subMesh defines which submesh to render
  22106. */
  22107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22108. /**
  22109. * Lets the block try to connect some inputs automatically
  22110. * @param material defines the hosting NodeMaterial
  22111. */
  22112. autoConfigure(material: NodeMaterial): void;
  22113. /**
  22114. * Function called when a block is declared as repeatable content generator
  22115. * @param vertexShaderState defines the current compilation state for the vertex shader
  22116. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22117. * @param mesh defines the mesh to be rendered
  22118. * @param defines defines the material defines to update
  22119. */
  22120. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22121. /**
  22122. * Checks if the block is ready
  22123. * @param mesh defines the mesh to be rendered
  22124. * @param nodeMaterial defines the node material requesting the update
  22125. * @param defines defines the material defines to update
  22126. * @param useInstances specifies that instances should be used
  22127. * @returns true if the block is ready
  22128. */
  22129. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22130. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22131. private _processBuild;
  22132. /**
  22133. * Compile the current node and generate the shader code
  22134. * @param state defines the current compilation state (uniforms, samplers, current string)
  22135. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22136. * @returns true if already built
  22137. */
  22138. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22139. protected _inputRename(name: string): string;
  22140. protected _outputRename(name: string): string;
  22141. protected _dumpPropertiesCode(): string;
  22142. /** @hidden */
  22143. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22144. /** @hidden */
  22145. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22146. /**
  22147. * Clone the current block to a new identical block
  22148. * @param scene defines the hosting scene
  22149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22150. * @returns a copy of the current block
  22151. */
  22152. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22153. /**
  22154. * Serializes this block in a JSON representation
  22155. * @returns the serialized block object
  22156. */
  22157. serialize(): any;
  22158. /** @hidden */
  22159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22160. private _deserializePortDisplayNamesAndExposedOnFrame;
  22161. /**
  22162. * Release resources
  22163. */
  22164. dispose(): void;
  22165. }
  22166. }
  22167. declare module "babylonjs/Materials/pushMaterial" {
  22168. import { Nullable } from "babylonjs/types";
  22169. import { Scene } from "babylonjs/scene";
  22170. import { Matrix } from "babylonjs/Maths/math.vector";
  22171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22172. import { Mesh } from "babylonjs/Meshes/mesh";
  22173. import { Material } from "babylonjs/Materials/material";
  22174. import { Effect } from "babylonjs/Materials/effect";
  22175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22176. /**
  22177. * Base class of materials working in push mode in babylon JS
  22178. * @hidden
  22179. */
  22180. export class PushMaterial extends Material {
  22181. protected _activeEffect: Effect;
  22182. protected _normalMatrix: Matrix;
  22183. constructor(name: string, scene: Scene);
  22184. getEffect(): Effect;
  22185. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22186. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22187. /**
  22188. * Binds the given world matrix to the active effect
  22189. *
  22190. * @param world the matrix to bind
  22191. */
  22192. bindOnlyWorldMatrix(world: Matrix): void;
  22193. /**
  22194. * Binds the given normal matrix to the active effect
  22195. *
  22196. * @param normalMatrix the matrix to bind
  22197. */
  22198. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22199. bind(world: Matrix, mesh?: Mesh): void;
  22200. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22201. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22202. }
  22203. }
  22204. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22206. /**
  22207. * Root class for all node material optimizers
  22208. */
  22209. export class NodeMaterialOptimizer {
  22210. /**
  22211. * Function used to optimize a NodeMaterial graph
  22212. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22213. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22214. */
  22215. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22216. }
  22217. }
  22218. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22222. import { Scene } from "babylonjs/scene";
  22223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22224. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22226. /**
  22227. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22228. */
  22229. export class TransformBlock extends NodeMaterialBlock {
  22230. /**
  22231. * Defines the value to use to complement W value to transform it to a Vector4
  22232. */
  22233. complementW: number;
  22234. /**
  22235. * Defines the value to use to complement z value to transform it to a Vector4
  22236. */
  22237. complementZ: number;
  22238. /**
  22239. * Creates a new TransformBlock
  22240. * @param name defines the block name
  22241. */
  22242. constructor(name: string);
  22243. /**
  22244. * Gets the current class name
  22245. * @returns the class name
  22246. */
  22247. getClassName(): string;
  22248. /**
  22249. * Gets the vector input
  22250. */
  22251. get vector(): NodeMaterialConnectionPoint;
  22252. /**
  22253. * Gets the output component
  22254. */
  22255. get output(): NodeMaterialConnectionPoint;
  22256. /**
  22257. * Gets the xyz output component
  22258. */
  22259. get xyz(): NodeMaterialConnectionPoint;
  22260. /**
  22261. * Gets the matrix transform input
  22262. */
  22263. get transform(): NodeMaterialConnectionPoint;
  22264. protected _buildBlock(state: NodeMaterialBuildState): this;
  22265. /**
  22266. * Update defines for shader compilation
  22267. * @param mesh defines the mesh to be rendered
  22268. * @param nodeMaterial defines the node material requesting the update
  22269. * @param defines defines the material defines to update
  22270. * @param useInstances specifies that instances should be used
  22271. * @param subMesh defines which submesh to render
  22272. */
  22273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22274. serialize(): any;
  22275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22276. protected _dumpPropertiesCode(): string;
  22277. }
  22278. }
  22279. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22283. /**
  22284. * Block used to output the vertex position
  22285. */
  22286. export class VertexOutputBlock extends NodeMaterialBlock {
  22287. /**
  22288. * Creates a new VertexOutputBlock
  22289. * @param name defines the block name
  22290. */
  22291. constructor(name: string);
  22292. /**
  22293. * Gets the current class name
  22294. * @returns the class name
  22295. */
  22296. getClassName(): string;
  22297. /**
  22298. * Gets the vector input component
  22299. */
  22300. get vector(): NodeMaterialConnectionPoint;
  22301. protected _buildBlock(state: NodeMaterialBuildState): this;
  22302. }
  22303. }
  22304. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22308. /**
  22309. * Block used to output the final color
  22310. */
  22311. export class FragmentOutputBlock extends NodeMaterialBlock {
  22312. /**
  22313. * Create a new FragmentOutputBlock
  22314. * @param name defines the block name
  22315. */
  22316. constructor(name: string);
  22317. /**
  22318. * Gets the current class name
  22319. * @returns the class name
  22320. */
  22321. getClassName(): string;
  22322. /**
  22323. * Gets the rgba input component
  22324. */
  22325. get rgba(): NodeMaterialConnectionPoint;
  22326. /**
  22327. * Gets the rgb input component
  22328. */
  22329. get rgb(): NodeMaterialConnectionPoint;
  22330. /**
  22331. * Gets the a input component
  22332. */
  22333. get a(): NodeMaterialConnectionPoint;
  22334. protected _buildBlock(state: NodeMaterialBuildState): this;
  22335. }
  22336. }
  22337. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22341. /**
  22342. * Block used for the particle ramp gradient section
  22343. */
  22344. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22345. /**
  22346. * Create a new ParticleRampGradientBlock
  22347. * @param name defines the block name
  22348. */
  22349. constructor(name: string);
  22350. /**
  22351. * Gets the current class name
  22352. * @returns the class name
  22353. */
  22354. getClassName(): string;
  22355. /**
  22356. * Gets the color input component
  22357. */
  22358. get color(): NodeMaterialConnectionPoint;
  22359. /**
  22360. * Gets the rampColor output component
  22361. */
  22362. get rampColor(): NodeMaterialConnectionPoint;
  22363. /**
  22364. * Initialize the block and prepare the context for build
  22365. * @param state defines the state that will be used for the build
  22366. */
  22367. initialize(state: NodeMaterialBuildState): void;
  22368. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22369. }
  22370. }
  22371. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22375. /**
  22376. * Block used for the particle blend multiply section
  22377. */
  22378. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22379. /**
  22380. * Create a new ParticleBlendMultiplyBlock
  22381. * @param name defines the block name
  22382. */
  22383. constructor(name: string);
  22384. /**
  22385. * Gets the current class name
  22386. * @returns the class name
  22387. */
  22388. getClassName(): string;
  22389. /**
  22390. * Gets the color input component
  22391. */
  22392. get color(): NodeMaterialConnectionPoint;
  22393. /**
  22394. * Gets the alphaTexture input component
  22395. */
  22396. get alphaTexture(): NodeMaterialConnectionPoint;
  22397. /**
  22398. * Gets the alphaColor input component
  22399. */
  22400. get alphaColor(): NodeMaterialConnectionPoint;
  22401. /**
  22402. * Gets the blendColor output component
  22403. */
  22404. get blendColor(): NodeMaterialConnectionPoint;
  22405. /**
  22406. * Initialize the block and prepare the context for build
  22407. * @param state defines the state that will be used for the build
  22408. */
  22409. initialize(state: NodeMaterialBuildState): void;
  22410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22411. }
  22412. }
  22413. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22417. /**
  22418. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22419. */
  22420. export class VectorMergerBlock extends NodeMaterialBlock {
  22421. /**
  22422. * Create a new VectorMergerBlock
  22423. * @param name defines the block name
  22424. */
  22425. constructor(name: string);
  22426. /**
  22427. * Gets the current class name
  22428. * @returns the class name
  22429. */
  22430. getClassName(): string;
  22431. /**
  22432. * Gets the xyz component (input)
  22433. */
  22434. get xyzIn(): NodeMaterialConnectionPoint;
  22435. /**
  22436. * Gets the xy component (input)
  22437. */
  22438. get xyIn(): NodeMaterialConnectionPoint;
  22439. /**
  22440. * Gets the x component (input)
  22441. */
  22442. get x(): NodeMaterialConnectionPoint;
  22443. /**
  22444. * Gets the y component (input)
  22445. */
  22446. get y(): NodeMaterialConnectionPoint;
  22447. /**
  22448. * Gets the z component (input)
  22449. */
  22450. get z(): NodeMaterialConnectionPoint;
  22451. /**
  22452. * Gets the w component (input)
  22453. */
  22454. get w(): NodeMaterialConnectionPoint;
  22455. /**
  22456. * Gets the xyzw component (output)
  22457. */
  22458. get xyzw(): NodeMaterialConnectionPoint;
  22459. /**
  22460. * Gets the xyz component (output)
  22461. */
  22462. get xyzOut(): NodeMaterialConnectionPoint;
  22463. /**
  22464. * Gets the xy component (output)
  22465. */
  22466. get xyOut(): NodeMaterialConnectionPoint;
  22467. /**
  22468. * Gets the xy component (output)
  22469. * @deprecated Please use xyOut instead.
  22470. */
  22471. get xy(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the xyz component (output)
  22474. * @deprecated Please use xyzOut instead.
  22475. */
  22476. get xyz(): NodeMaterialConnectionPoint;
  22477. protected _buildBlock(state: NodeMaterialBuildState): this;
  22478. }
  22479. }
  22480. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22484. import { Vector2 } from "babylonjs/Maths/math.vector";
  22485. import { Scene } from "babylonjs/scene";
  22486. /**
  22487. * Block used to remap a float from a range to a new one
  22488. */
  22489. export class RemapBlock extends NodeMaterialBlock {
  22490. /**
  22491. * Gets or sets the source range
  22492. */
  22493. sourceRange: Vector2;
  22494. /**
  22495. * Gets or sets the target range
  22496. */
  22497. targetRange: Vector2;
  22498. /**
  22499. * Creates a new RemapBlock
  22500. * @param name defines the block name
  22501. */
  22502. constructor(name: string);
  22503. /**
  22504. * Gets the current class name
  22505. * @returns the class name
  22506. */
  22507. getClassName(): string;
  22508. /**
  22509. * Gets the input component
  22510. */
  22511. get input(): NodeMaterialConnectionPoint;
  22512. /**
  22513. * Gets the source min input component
  22514. */
  22515. get sourceMin(): NodeMaterialConnectionPoint;
  22516. /**
  22517. * Gets the source max input component
  22518. */
  22519. get sourceMax(): NodeMaterialConnectionPoint;
  22520. /**
  22521. * Gets the target min input component
  22522. */
  22523. get targetMin(): NodeMaterialConnectionPoint;
  22524. /**
  22525. * Gets the target max input component
  22526. */
  22527. get targetMax(): NodeMaterialConnectionPoint;
  22528. /**
  22529. * Gets the output component
  22530. */
  22531. get output(): NodeMaterialConnectionPoint;
  22532. protected _buildBlock(state: NodeMaterialBuildState): this;
  22533. protected _dumpPropertiesCode(): string;
  22534. serialize(): any;
  22535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22536. }
  22537. }
  22538. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22542. /**
  22543. * Block used to multiply 2 values
  22544. */
  22545. export class MultiplyBlock extends NodeMaterialBlock {
  22546. /**
  22547. * Creates a new MultiplyBlock
  22548. * @param name defines the block name
  22549. */
  22550. constructor(name: string);
  22551. /**
  22552. * Gets the current class name
  22553. * @returns the class name
  22554. */
  22555. getClassName(): string;
  22556. /**
  22557. * Gets the left operand input component
  22558. */
  22559. get left(): NodeMaterialConnectionPoint;
  22560. /**
  22561. * Gets the right operand input component
  22562. */
  22563. get right(): NodeMaterialConnectionPoint;
  22564. /**
  22565. * Gets the output component
  22566. */
  22567. get output(): NodeMaterialConnectionPoint;
  22568. protected _buildBlock(state: NodeMaterialBuildState): this;
  22569. }
  22570. }
  22571. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22575. /**
  22576. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22577. */
  22578. export class ColorSplitterBlock extends NodeMaterialBlock {
  22579. /**
  22580. * Create a new ColorSplitterBlock
  22581. * @param name defines the block name
  22582. */
  22583. constructor(name: string);
  22584. /**
  22585. * Gets the current class name
  22586. * @returns the class name
  22587. */
  22588. getClassName(): string;
  22589. /**
  22590. * Gets the rgba component (input)
  22591. */
  22592. get rgba(): NodeMaterialConnectionPoint;
  22593. /**
  22594. * Gets the rgb component (input)
  22595. */
  22596. get rgbIn(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the rgb component (output)
  22599. */
  22600. get rgbOut(): NodeMaterialConnectionPoint;
  22601. /**
  22602. * Gets the r component (output)
  22603. */
  22604. get r(): NodeMaterialConnectionPoint;
  22605. /**
  22606. * Gets the g component (output)
  22607. */
  22608. get g(): NodeMaterialConnectionPoint;
  22609. /**
  22610. * Gets the b component (output)
  22611. */
  22612. get b(): NodeMaterialConnectionPoint;
  22613. /**
  22614. * Gets the a component (output)
  22615. */
  22616. get a(): NodeMaterialConnectionPoint;
  22617. protected _inputRename(name: string): string;
  22618. protected _outputRename(name: string): string;
  22619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22620. }
  22621. }
  22622. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22624. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22625. import { Scene } from "babylonjs/scene";
  22626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22627. import { Matrix } from "babylonjs/Maths/math.vector";
  22628. import { Mesh } from "babylonjs/Meshes/mesh";
  22629. import { Engine } from "babylonjs/Engines/engine";
  22630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22631. import { Observable } from "babylonjs/Misc/observable";
  22632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22633. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22634. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22635. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22636. import { Nullable } from "babylonjs/types";
  22637. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22638. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22639. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22640. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22641. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22642. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22643. import { Effect } from "babylonjs/Materials/effect";
  22644. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22645. import { Camera } from "babylonjs/Cameras/camera";
  22646. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22647. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22648. /**
  22649. * Interface used to configure the node material editor
  22650. */
  22651. export interface INodeMaterialEditorOptions {
  22652. /** Define the URl to load node editor script */
  22653. editorURL?: string;
  22654. }
  22655. /** @hidden */
  22656. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22657. NORMAL: boolean;
  22658. TANGENT: boolean;
  22659. UV1: boolean;
  22660. /** BONES */
  22661. NUM_BONE_INFLUENCERS: number;
  22662. BonesPerMesh: number;
  22663. BONETEXTURE: boolean;
  22664. /** MORPH TARGETS */
  22665. MORPHTARGETS: boolean;
  22666. MORPHTARGETS_NORMAL: boolean;
  22667. MORPHTARGETS_TANGENT: boolean;
  22668. MORPHTARGETS_UV: boolean;
  22669. NUM_MORPH_INFLUENCERS: number;
  22670. /** IMAGE PROCESSING */
  22671. IMAGEPROCESSING: boolean;
  22672. VIGNETTE: boolean;
  22673. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22674. VIGNETTEBLENDMODEOPAQUE: boolean;
  22675. TONEMAPPING: boolean;
  22676. TONEMAPPING_ACES: boolean;
  22677. CONTRAST: boolean;
  22678. EXPOSURE: boolean;
  22679. COLORCURVES: boolean;
  22680. COLORGRADING: boolean;
  22681. COLORGRADING3D: boolean;
  22682. SAMPLER3DGREENDEPTH: boolean;
  22683. SAMPLER3DBGRMAP: boolean;
  22684. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22685. /** MISC. */
  22686. BUMPDIRECTUV: number;
  22687. constructor();
  22688. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22689. }
  22690. /**
  22691. * Class used to configure NodeMaterial
  22692. */
  22693. export interface INodeMaterialOptions {
  22694. /**
  22695. * Defines if blocks should emit comments
  22696. */
  22697. emitComments: boolean;
  22698. }
  22699. /**
  22700. * Class used to create a node based material built by assembling shader blocks
  22701. */
  22702. export class NodeMaterial extends PushMaterial {
  22703. private static _BuildIdGenerator;
  22704. private _options;
  22705. private _vertexCompilationState;
  22706. private _fragmentCompilationState;
  22707. private _sharedData;
  22708. private _buildId;
  22709. private _buildWasSuccessful;
  22710. private _cachedWorldViewMatrix;
  22711. private _cachedWorldViewProjectionMatrix;
  22712. private _optimizers;
  22713. private _animationFrame;
  22714. /** Define the Url to load node editor script */
  22715. static EditorURL: string;
  22716. /** Define the Url to load snippets */
  22717. static SnippetUrl: string;
  22718. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22719. static IgnoreTexturesAtLoadTime: boolean;
  22720. private BJSNODEMATERIALEDITOR;
  22721. /** Get the inspector from bundle or global */
  22722. private _getGlobalNodeMaterialEditor;
  22723. /**
  22724. * Snippet ID if the material was created from the snippet server
  22725. */
  22726. snippetId: string;
  22727. /**
  22728. * Gets or sets data used by visual editor
  22729. * @see https://nme.babylonjs.com
  22730. */
  22731. editorData: any;
  22732. /**
  22733. * 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)
  22734. */
  22735. ignoreAlpha: boolean;
  22736. /**
  22737. * Defines the maximum number of lights that can be used in the material
  22738. */
  22739. maxSimultaneousLights: number;
  22740. /**
  22741. * Observable raised when the material is built
  22742. */
  22743. onBuildObservable: Observable<NodeMaterial>;
  22744. /**
  22745. * Gets or sets the root nodes of the material vertex shader
  22746. */
  22747. _vertexOutputNodes: NodeMaterialBlock[];
  22748. /**
  22749. * Gets or sets the root nodes of the material fragment (pixel) shader
  22750. */
  22751. _fragmentOutputNodes: NodeMaterialBlock[];
  22752. /** Gets or sets options to control the node material overall behavior */
  22753. get options(): INodeMaterialOptions;
  22754. set options(options: INodeMaterialOptions);
  22755. /**
  22756. * Default configuration related to image processing available in the standard Material.
  22757. */
  22758. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22759. /**
  22760. * Gets the image processing configuration used either in this material.
  22761. */
  22762. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22763. /**
  22764. * Sets the Default image processing configuration used either in the this material.
  22765. *
  22766. * If sets to null, the scene one is in use.
  22767. */
  22768. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22769. /**
  22770. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22771. */
  22772. attachedBlocks: NodeMaterialBlock[];
  22773. /**
  22774. * Specifies the mode of the node material
  22775. * @hidden
  22776. */
  22777. _mode: NodeMaterialModes;
  22778. /**
  22779. * Gets the mode property
  22780. */
  22781. get mode(): NodeMaterialModes;
  22782. /**
  22783. * Create a new node based material
  22784. * @param name defines the material name
  22785. * @param scene defines the hosting scene
  22786. * @param options defines creation option
  22787. */
  22788. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22789. /**
  22790. * Gets the current class name of the material e.g. "NodeMaterial"
  22791. * @returns the class name
  22792. */
  22793. getClassName(): string;
  22794. /**
  22795. * Keep track of the image processing observer to allow dispose and replace.
  22796. */
  22797. private _imageProcessingObserver;
  22798. /**
  22799. * Attaches a new image processing configuration to the Standard Material.
  22800. * @param configuration
  22801. */
  22802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22803. /**
  22804. * Get a block by its name
  22805. * @param name defines the name of the block to retrieve
  22806. * @returns the required block or null if not found
  22807. */
  22808. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22809. /**
  22810. * Get a block by its name
  22811. * @param predicate defines the predicate used to find the good candidate
  22812. * @returns the required block or null if not found
  22813. */
  22814. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22815. /**
  22816. * Get an input block by its name
  22817. * @param predicate defines the predicate used to find the good candidate
  22818. * @returns the required input block or null if not found
  22819. */
  22820. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22821. /**
  22822. * Gets the list of input blocks attached to this material
  22823. * @returns an array of InputBlocks
  22824. */
  22825. getInputBlocks(): InputBlock[];
  22826. /**
  22827. * Adds a new optimizer to the list of optimizers
  22828. * @param optimizer defines the optimizers to add
  22829. * @returns the current material
  22830. */
  22831. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22832. /**
  22833. * Remove an optimizer from the list of optimizers
  22834. * @param optimizer defines the optimizers to remove
  22835. * @returns the current material
  22836. */
  22837. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22838. /**
  22839. * Add a new block to the list of output nodes
  22840. * @param node defines the node to add
  22841. * @returns the current material
  22842. */
  22843. addOutputNode(node: NodeMaterialBlock): this;
  22844. /**
  22845. * Remove a block from the list of root nodes
  22846. * @param node defines the node to remove
  22847. * @returns the current material
  22848. */
  22849. removeOutputNode(node: NodeMaterialBlock): this;
  22850. private _addVertexOutputNode;
  22851. private _removeVertexOutputNode;
  22852. private _addFragmentOutputNode;
  22853. private _removeFragmentOutputNode;
  22854. /**
  22855. * Specifies if the material will require alpha blending
  22856. * @returns a boolean specifying if alpha blending is needed
  22857. */
  22858. needAlphaBlending(): boolean;
  22859. /**
  22860. * Specifies if this material should be rendered in alpha test mode
  22861. * @returns a boolean specifying if an alpha test is needed.
  22862. */
  22863. needAlphaTesting(): boolean;
  22864. private _initializeBlock;
  22865. private _resetDualBlocks;
  22866. /**
  22867. * Remove a block from the current node material
  22868. * @param block defines the block to remove
  22869. */
  22870. removeBlock(block: NodeMaterialBlock): void;
  22871. /**
  22872. * Build the material and generates the inner effect
  22873. * @param verbose defines if the build should log activity
  22874. */
  22875. build(verbose?: boolean): void;
  22876. /**
  22877. * Runs an otpimization phase to try to improve the shader code
  22878. */
  22879. optimize(): void;
  22880. private _prepareDefinesForAttributes;
  22881. /**
  22882. * Create a post process from the material
  22883. * @param camera The camera to apply the render pass to.
  22884. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22886. * @param engine The engine which the post process will be applied. (default: current engine)
  22887. * @param reusable If the post process can be reused on the same frame. (default: false)
  22888. * @param textureType Type of textures used when performing the post process. (default: 0)
  22889. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22890. * @returns the post process created
  22891. */
  22892. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22893. /**
  22894. * Create the post process effect from the material
  22895. * @param postProcess The post process to create the effect for
  22896. */
  22897. createEffectForPostProcess(postProcess: PostProcess): void;
  22898. private _createEffectOrPostProcess;
  22899. private _createEffectForParticles;
  22900. /**
  22901. * Create the effect to be used as the custom effect for a particle system
  22902. * @param particleSystem Particle system to create the effect for
  22903. * @param onCompiled defines a function to call when the effect creation is successful
  22904. * @param onError defines a function to call when the effect creation has failed
  22905. */
  22906. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22907. private _processDefines;
  22908. /**
  22909. * Get if the submesh is ready to be used and all its information available.
  22910. * Child classes can use it to update shaders
  22911. * @param mesh defines the mesh to check
  22912. * @param subMesh defines which submesh to check
  22913. * @param useInstances specifies that instances should be used
  22914. * @returns a boolean indicating that the submesh is ready or not
  22915. */
  22916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22917. /**
  22918. * Get a string representing the shaders built by the current node graph
  22919. */
  22920. get compiledShaders(): string;
  22921. /**
  22922. * Binds the world matrix to the material
  22923. * @param world defines the world transformation matrix
  22924. */
  22925. bindOnlyWorldMatrix(world: Matrix): void;
  22926. /**
  22927. * Binds the submesh to this material by preparing the effect and shader to draw
  22928. * @param world defines the world transformation matrix
  22929. * @param mesh defines the mesh containing the submesh
  22930. * @param subMesh defines the submesh to bind the material to
  22931. */
  22932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22933. /**
  22934. * Gets the active textures from the material
  22935. * @returns an array of textures
  22936. */
  22937. getActiveTextures(): BaseTexture[];
  22938. /**
  22939. * Gets the list of texture blocks
  22940. * @returns an array of texture blocks
  22941. */
  22942. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22943. /**
  22944. * Specifies if the material uses a texture
  22945. * @param texture defines the texture to check against the material
  22946. * @returns a boolean specifying if the material uses the texture
  22947. */
  22948. hasTexture(texture: BaseTexture): boolean;
  22949. /**
  22950. * Disposes the material
  22951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22954. */
  22955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22956. /** Creates the node editor window. */
  22957. private _createNodeEditor;
  22958. /**
  22959. * Launch the node material editor
  22960. * @param config Define the configuration of the editor
  22961. * @return a promise fulfilled when the node editor is visible
  22962. */
  22963. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22964. /**
  22965. * Clear the current material
  22966. */
  22967. clear(): void;
  22968. /**
  22969. * Clear the current material and set it to a default state
  22970. */
  22971. setToDefault(): void;
  22972. /**
  22973. * Clear the current material and set it to a default state for post process
  22974. */
  22975. setToDefaultPostProcess(): void;
  22976. /**
  22977. * Clear the current material and set it to a default state for particle
  22978. */
  22979. setToDefaultParticle(): void;
  22980. /**
  22981. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22982. * @param url defines the url to load from
  22983. * @returns a promise that will fullfil when the material is fully loaded
  22984. */
  22985. loadAsync(url: string): Promise<void>;
  22986. private _gatherBlocks;
  22987. /**
  22988. * Generate a string containing the code declaration required to create an equivalent of this material
  22989. * @returns a string
  22990. */
  22991. generateCode(): string;
  22992. /**
  22993. * Serializes this material in a JSON representation
  22994. * @returns the serialized material object
  22995. */
  22996. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22997. private _restoreConnections;
  22998. /**
  22999. * Clear the current graph and load a new one from a serialization object
  23000. * @param source defines the JSON representation of the material
  23001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23002. * @param merge defines whether or not the source must be merged or replace the current content
  23003. */
  23004. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23005. /**
  23006. * Makes a duplicate of the current material.
  23007. * @param name - name to use for the new material.
  23008. */
  23009. clone(name: string): NodeMaterial;
  23010. /**
  23011. * Creates a node material from parsed material data
  23012. * @param source defines the JSON representation of the material
  23013. * @param scene defines the hosting scene
  23014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23015. * @returns a new node material
  23016. */
  23017. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23018. /**
  23019. * Creates a node material from a snippet saved in a remote file
  23020. * @param name defines the name of the material to create
  23021. * @param url defines the url to load from
  23022. * @param scene defines the hosting scene
  23023. * @returns a promise that will resolve to the new node material
  23024. */
  23025. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23026. /**
  23027. * Creates a node material from a snippet saved by the node material editor
  23028. * @param snippetId defines the snippet to load
  23029. * @param scene defines the hosting scene
  23030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23031. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23032. * @returns a promise that will resolve to the new node material
  23033. */
  23034. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23035. /**
  23036. * Creates a new node material set to default basic configuration
  23037. * @param name defines the name of the material
  23038. * @param scene defines the hosting scene
  23039. * @returns a new NodeMaterial
  23040. */
  23041. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23042. }
  23043. }
  23044. declare module "babylonjs/PostProcesses/postProcess" {
  23045. import { Nullable } from "babylonjs/types";
  23046. import { SmartArray } from "babylonjs/Misc/smartArray";
  23047. import { Observable } from "babylonjs/Misc/observable";
  23048. import { Vector2 } from "babylonjs/Maths/math.vector";
  23049. import { Camera } from "babylonjs/Cameras/camera";
  23050. import { Effect } from "babylonjs/Materials/effect";
  23051. import "babylonjs/Shaders/postprocess.vertex";
  23052. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23053. import { Engine } from "babylonjs/Engines/engine";
  23054. import { Color4 } from "babylonjs/Maths/math.color";
  23055. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23056. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23058. /**
  23059. * Size options for a post process
  23060. */
  23061. export type PostProcessOptions = {
  23062. width: number;
  23063. height: number;
  23064. };
  23065. /**
  23066. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23067. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23068. */
  23069. export class PostProcess {
  23070. /** Name of the PostProcess. */
  23071. name: string;
  23072. /**
  23073. * Gets or sets the unique id of the post process
  23074. */
  23075. uniqueId: number;
  23076. /**
  23077. * Width of the texture to apply the post process on
  23078. */
  23079. width: number;
  23080. /**
  23081. * Height of the texture to apply the post process on
  23082. */
  23083. height: number;
  23084. /**
  23085. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23086. */
  23087. nodeMaterialSource: Nullable<NodeMaterial>;
  23088. /**
  23089. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23090. * @hidden
  23091. */
  23092. _outputTexture: Nullable<InternalTexture>;
  23093. /**
  23094. * Sampling mode used by the shader
  23095. * See https://doc.babylonjs.com/classes/3.1/texture
  23096. */
  23097. renderTargetSamplingMode: number;
  23098. /**
  23099. * Clear color to use when screen clearing
  23100. */
  23101. clearColor: Color4;
  23102. /**
  23103. * If the buffer needs to be cleared before applying the post process. (default: true)
  23104. * Should be set to false if shader will overwrite all previous pixels.
  23105. */
  23106. autoClear: boolean;
  23107. /**
  23108. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23109. */
  23110. alphaMode: number;
  23111. /**
  23112. * Sets the setAlphaBlendConstants of the babylon engine
  23113. */
  23114. alphaConstants: Color4;
  23115. /**
  23116. * Animations to be used for the post processing
  23117. */
  23118. animations: import("babylonjs/Animations/animation").Animation[];
  23119. /**
  23120. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23121. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23122. */
  23123. enablePixelPerfectMode: boolean;
  23124. /**
  23125. * Force the postprocess to be applied without taking in account viewport
  23126. */
  23127. forceFullscreenViewport: boolean;
  23128. /**
  23129. * List of inspectable custom properties (used by the Inspector)
  23130. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23131. */
  23132. inspectableCustomProperties: IInspectable[];
  23133. /**
  23134. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23135. *
  23136. * | Value | Type | Description |
  23137. * | ----- | ----------------------------------- | ----------- |
  23138. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23139. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23140. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23141. *
  23142. */
  23143. scaleMode: number;
  23144. /**
  23145. * Force textures to be a power of two (default: false)
  23146. */
  23147. alwaysForcePOT: boolean;
  23148. private _samples;
  23149. /**
  23150. * Number of sample textures (default: 1)
  23151. */
  23152. get samples(): number;
  23153. set samples(n: number);
  23154. /**
  23155. * Modify the scale of the post process to be the same as the viewport (default: false)
  23156. */
  23157. adaptScaleToCurrentViewport: boolean;
  23158. private _camera;
  23159. private _scene;
  23160. private _engine;
  23161. private _options;
  23162. private _reusable;
  23163. private _textureType;
  23164. private _textureFormat;
  23165. /**
  23166. * Smart array of input and output textures for the post process.
  23167. * @hidden
  23168. */
  23169. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23170. /**
  23171. * The index in _textures that corresponds to the output texture.
  23172. * @hidden
  23173. */
  23174. _currentRenderTextureInd: number;
  23175. private _effect;
  23176. private _samplers;
  23177. private _fragmentUrl;
  23178. private _vertexUrl;
  23179. private _parameters;
  23180. private _scaleRatio;
  23181. protected _indexParameters: any;
  23182. private _shareOutputWithPostProcess;
  23183. private _texelSize;
  23184. private _forcedOutputTexture;
  23185. /**
  23186. * Returns the fragment url or shader name used in the post process.
  23187. * @returns the fragment url or name in the shader store.
  23188. */
  23189. getEffectName(): string;
  23190. /**
  23191. * An event triggered when the postprocess is activated.
  23192. */
  23193. onActivateObservable: Observable<Camera>;
  23194. private _onActivateObserver;
  23195. /**
  23196. * A function that is added to the onActivateObservable
  23197. */
  23198. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23199. /**
  23200. * An event triggered when the postprocess changes its size.
  23201. */
  23202. onSizeChangedObservable: Observable<PostProcess>;
  23203. private _onSizeChangedObserver;
  23204. /**
  23205. * A function that is added to the onSizeChangedObservable
  23206. */
  23207. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23208. /**
  23209. * An event triggered when the postprocess applies its effect.
  23210. */
  23211. onApplyObservable: Observable<Effect>;
  23212. private _onApplyObserver;
  23213. /**
  23214. * A function that is added to the onApplyObservable
  23215. */
  23216. set onApply(callback: (effect: Effect) => void);
  23217. /**
  23218. * An event triggered before rendering the postprocess
  23219. */
  23220. onBeforeRenderObservable: Observable<Effect>;
  23221. private _onBeforeRenderObserver;
  23222. /**
  23223. * A function that is added to the onBeforeRenderObservable
  23224. */
  23225. set onBeforeRender(callback: (effect: Effect) => void);
  23226. /**
  23227. * An event triggered after rendering the postprocess
  23228. */
  23229. onAfterRenderObservable: Observable<Effect>;
  23230. private _onAfterRenderObserver;
  23231. /**
  23232. * A function that is added to the onAfterRenderObservable
  23233. */
  23234. set onAfterRender(callback: (efect: Effect) => void);
  23235. /**
  23236. * 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
  23237. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23238. */
  23239. get inputTexture(): InternalTexture;
  23240. set inputTexture(value: InternalTexture);
  23241. /**
  23242. * Gets the camera which post process is applied to.
  23243. * @returns The camera the post process is applied to.
  23244. */
  23245. getCamera(): Camera;
  23246. /**
  23247. * Gets the texel size of the postprocess.
  23248. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23249. */
  23250. get texelSize(): Vector2;
  23251. /**
  23252. * Creates a new instance PostProcess
  23253. * @param name The name of the PostProcess.
  23254. * @param fragmentUrl The url of the fragment shader to be used.
  23255. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23256. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23257. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23258. * @param camera The camera to apply the render pass to.
  23259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23260. * @param engine The engine which the post process will be applied. (default: current engine)
  23261. * @param reusable If the post process can be reused on the same frame. (default: false)
  23262. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23263. * @param textureType Type of textures used when performing the post process. (default: 0)
  23264. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23265. * @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
  23266. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23267. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23268. */
  23269. constructor(
  23270. /** Name of the PostProcess. */
  23271. 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);
  23272. /**
  23273. * Gets a string idenfifying the name of the class
  23274. * @returns "PostProcess" string
  23275. */
  23276. getClassName(): string;
  23277. /**
  23278. * Gets the engine which this post process belongs to.
  23279. * @returns The engine the post process was enabled with.
  23280. */
  23281. getEngine(): Engine;
  23282. /**
  23283. * The effect that is created when initializing the post process.
  23284. * @returns The created effect corresponding the the postprocess.
  23285. */
  23286. getEffect(): Effect;
  23287. /**
  23288. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23289. * @param postProcess The post process to share the output with.
  23290. * @returns This post process.
  23291. */
  23292. shareOutputWith(postProcess: PostProcess): PostProcess;
  23293. /**
  23294. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23295. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23296. */
  23297. useOwnOutput(): void;
  23298. /**
  23299. * Updates the effect with the current post process compile time values and recompiles the shader.
  23300. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23301. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23302. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23303. * @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
  23304. * @param onCompiled Called when the shader has been compiled.
  23305. * @param onError Called if there is an error when compiling a shader.
  23306. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23307. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23308. */
  23309. 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;
  23310. /**
  23311. * The post process is reusable if it can be used multiple times within one frame.
  23312. * @returns If the post process is reusable
  23313. */
  23314. isReusable(): boolean;
  23315. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23316. markTextureDirty(): void;
  23317. /**
  23318. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23319. * 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.
  23320. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23321. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23322. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23323. * @returns The target texture that was bound to be written to.
  23324. */
  23325. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23326. /**
  23327. * If the post process is supported.
  23328. */
  23329. get isSupported(): boolean;
  23330. /**
  23331. * The aspect ratio of the output texture.
  23332. */
  23333. get aspectRatio(): number;
  23334. /**
  23335. * Get a value indicating if the post-process is ready to be used
  23336. * @returns true if the post-process is ready (shader is compiled)
  23337. */
  23338. isReady(): boolean;
  23339. /**
  23340. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23341. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23342. */
  23343. apply(): Nullable<Effect>;
  23344. private _disposeTextures;
  23345. /**
  23346. * Disposes the post process.
  23347. * @param camera The camera to dispose the post process on.
  23348. */
  23349. dispose(camera?: Camera): void;
  23350. }
  23351. }
  23352. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23353. /** @hidden */
  23354. export var kernelBlurVaryingDeclaration: {
  23355. name: string;
  23356. shader: string;
  23357. };
  23358. }
  23359. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23360. /** @hidden */
  23361. export var kernelBlurFragment: {
  23362. name: string;
  23363. shader: string;
  23364. };
  23365. }
  23366. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23367. /** @hidden */
  23368. export var kernelBlurFragment2: {
  23369. name: string;
  23370. shader: string;
  23371. };
  23372. }
  23373. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23374. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23375. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23376. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23377. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23378. /** @hidden */
  23379. export var kernelBlurPixelShader: {
  23380. name: string;
  23381. shader: string;
  23382. };
  23383. }
  23384. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23385. /** @hidden */
  23386. export var kernelBlurVertex: {
  23387. name: string;
  23388. shader: string;
  23389. };
  23390. }
  23391. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23392. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23393. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23394. /** @hidden */
  23395. export var kernelBlurVertexShader: {
  23396. name: string;
  23397. shader: string;
  23398. };
  23399. }
  23400. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23401. import { Vector2 } from "babylonjs/Maths/math.vector";
  23402. import { Nullable } from "babylonjs/types";
  23403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23404. import { Camera } from "babylonjs/Cameras/camera";
  23405. import { Effect } from "babylonjs/Materials/effect";
  23406. import { Engine } from "babylonjs/Engines/engine";
  23407. import "babylonjs/Shaders/kernelBlur.fragment";
  23408. import "babylonjs/Shaders/kernelBlur.vertex";
  23409. /**
  23410. * The Blur Post Process which blurs an image based on a kernel and direction.
  23411. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23412. */
  23413. export class BlurPostProcess extends PostProcess {
  23414. /** The direction in which to blur the image. */
  23415. direction: Vector2;
  23416. private blockCompilation;
  23417. protected _kernel: number;
  23418. protected _idealKernel: number;
  23419. protected _packedFloat: boolean;
  23420. private _staticDefines;
  23421. /**
  23422. * Sets the length in pixels of the blur sample region
  23423. */
  23424. set kernel(v: number);
  23425. /**
  23426. * Gets the length in pixels of the blur sample region
  23427. */
  23428. get kernel(): number;
  23429. /**
  23430. * Sets wether or not the blur needs to unpack/repack floats
  23431. */
  23432. set packedFloat(v: boolean);
  23433. /**
  23434. * Gets wether or not the blur is unpacking/repacking floats
  23435. */
  23436. get packedFloat(): boolean;
  23437. /**
  23438. * Creates a new instance BlurPostProcess
  23439. * @param name The name of the effect.
  23440. * @param direction The direction in which to blur the image.
  23441. * @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.
  23442. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23443. * @param camera The camera to apply the render pass to.
  23444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23445. * @param engine The engine which the post process will be applied. (default: current engine)
  23446. * @param reusable If the post process can be reused on the same frame. (default: false)
  23447. * @param textureType Type of textures used when performing the post process. (default: 0)
  23448. * @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)
  23449. */
  23450. constructor(name: string,
  23451. /** The direction in which to blur the image. */
  23452. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23453. /**
  23454. * Updates the effect with the current post process compile time values and recompiles the shader.
  23455. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23456. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23457. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23458. * @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
  23459. * @param onCompiled Called when the shader has been compiled.
  23460. * @param onError Called if there is an error when compiling a shader.
  23461. */
  23462. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23463. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23464. /**
  23465. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23466. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23467. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23468. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23469. * The gaps between physical kernels are compensated for in the weighting of the samples
  23470. * @param idealKernel Ideal blur kernel.
  23471. * @return Nearest best kernel.
  23472. */
  23473. protected _nearestBestKernel(idealKernel: number): number;
  23474. /**
  23475. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23476. * @param x The point on the Gaussian distribution to sample.
  23477. * @return the value of the Gaussian function at x.
  23478. */
  23479. protected _gaussianWeight(x: number): number;
  23480. /**
  23481. * Generates a string that can be used as a floating point number in GLSL.
  23482. * @param x Value to print.
  23483. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23484. * @return GLSL float string.
  23485. */
  23486. protected _glslFloat(x: number, decimalFigures?: number): string;
  23487. }
  23488. }
  23489. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23490. import { Scene } from "babylonjs/scene";
  23491. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23492. import { Plane } from "babylonjs/Maths/math.plane";
  23493. /**
  23494. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23495. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23496. * You can then easily use it as a reflectionTexture on a flat surface.
  23497. * In case the surface is not a plane, please consider relying on reflection probes.
  23498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23499. */
  23500. export class MirrorTexture extends RenderTargetTexture {
  23501. private scene;
  23502. /**
  23503. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23504. * 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.
  23505. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23506. */
  23507. mirrorPlane: Plane;
  23508. /**
  23509. * Define the blur ratio used to blur the reflection if needed.
  23510. */
  23511. set blurRatio(value: number);
  23512. get blurRatio(): number;
  23513. /**
  23514. * Define the adaptive blur kernel used to blur the reflection if needed.
  23515. * This will autocompute the closest best match for the `blurKernel`
  23516. */
  23517. set adaptiveBlurKernel(value: number);
  23518. /**
  23519. * Define the blur kernel used to blur the reflection if needed.
  23520. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23521. */
  23522. set blurKernel(value: number);
  23523. /**
  23524. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23525. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23526. */
  23527. set blurKernelX(value: number);
  23528. get blurKernelX(): number;
  23529. /**
  23530. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23531. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23532. */
  23533. set blurKernelY(value: number);
  23534. get blurKernelY(): number;
  23535. private _autoComputeBlurKernel;
  23536. protected _onRatioRescale(): void;
  23537. private _updateGammaSpace;
  23538. private _imageProcessingConfigChangeObserver;
  23539. private _transformMatrix;
  23540. private _mirrorMatrix;
  23541. private _savedViewMatrix;
  23542. private _blurX;
  23543. private _blurY;
  23544. private _adaptiveBlurKernel;
  23545. private _blurKernelX;
  23546. private _blurKernelY;
  23547. private _blurRatio;
  23548. /**
  23549. * Instantiates a Mirror Texture.
  23550. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23551. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23552. * You can then easily use it as a reflectionTexture on a flat surface.
  23553. * In case the surface is not a plane, please consider relying on reflection probes.
  23554. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23555. * @param name
  23556. * @param size
  23557. * @param scene
  23558. * @param generateMipMaps
  23559. * @param type
  23560. * @param samplingMode
  23561. * @param generateDepthBuffer
  23562. */
  23563. constructor(name: string, size: number | {
  23564. width: number;
  23565. height: number;
  23566. } | {
  23567. ratio: number;
  23568. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23569. private _preparePostProcesses;
  23570. /**
  23571. * Clone the mirror texture.
  23572. * @returns the cloned texture
  23573. */
  23574. clone(): MirrorTexture;
  23575. /**
  23576. * Serialize the texture to a JSON representation you could use in Parse later on
  23577. * @returns the serialized JSON representation
  23578. */
  23579. serialize(): any;
  23580. /**
  23581. * Dispose the texture and release its associated resources.
  23582. */
  23583. dispose(): void;
  23584. }
  23585. }
  23586. declare module "babylonjs/Materials/Textures/texture" {
  23587. import { Observable } from "babylonjs/Misc/observable";
  23588. import { Nullable } from "babylonjs/types";
  23589. import { Matrix } from "babylonjs/Maths/math.vector";
  23590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23591. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23592. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23593. import { Scene } from "babylonjs/scene";
  23594. /**
  23595. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23596. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23597. */
  23598. export class Texture extends BaseTexture {
  23599. /**
  23600. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23601. */
  23602. static SerializeBuffers: boolean;
  23603. /** @hidden */
  23604. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23605. /** @hidden */
  23606. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23607. /** @hidden */
  23608. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23609. /** nearest is mag = nearest and min = nearest and mip = linear */
  23610. static readonly NEAREST_SAMPLINGMODE: number;
  23611. /** nearest is mag = nearest and min = nearest and mip = linear */
  23612. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23613. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23614. static readonly BILINEAR_SAMPLINGMODE: number;
  23615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23616. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23617. /** Trilinear is mag = linear and min = linear and mip = linear */
  23618. static readonly TRILINEAR_SAMPLINGMODE: number;
  23619. /** Trilinear is mag = linear and min = linear and mip = linear */
  23620. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23621. /** mag = nearest and min = nearest and mip = nearest */
  23622. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23623. /** mag = nearest and min = linear and mip = nearest */
  23624. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23625. /** mag = nearest and min = linear and mip = linear */
  23626. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23627. /** mag = nearest and min = linear and mip = none */
  23628. static readonly NEAREST_LINEAR: number;
  23629. /** mag = nearest and min = nearest and mip = none */
  23630. static readonly NEAREST_NEAREST: number;
  23631. /** mag = linear and min = nearest and mip = nearest */
  23632. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23633. /** mag = linear and min = nearest and mip = linear */
  23634. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23635. /** mag = linear and min = linear and mip = none */
  23636. static readonly LINEAR_LINEAR: number;
  23637. /** mag = linear and min = nearest and mip = none */
  23638. static readonly LINEAR_NEAREST: number;
  23639. /** Explicit coordinates mode */
  23640. static readonly EXPLICIT_MODE: number;
  23641. /** Spherical coordinates mode */
  23642. static readonly SPHERICAL_MODE: number;
  23643. /** Planar coordinates mode */
  23644. static readonly PLANAR_MODE: number;
  23645. /** Cubic coordinates mode */
  23646. static readonly CUBIC_MODE: number;
  23647. /** Projection coordinates mode */
  23648. static readonly PROJECTION_MODE: number;
  23649. /** Inverse Cubic coordinates mode */
  23650. static readonly SKYBOX_MODE: number;
  23651. /** Inverse Cubic coordinates mode */
  23652. static readonly INVCUBIC_MODE: number;
  23653. /** Equirectangular coordinates mode */
  23654. static readonly EQUIRECTANGULAR_MODE: number;
  23655. /** Equirectangular Fixed coordinates mode */
  23656. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23657. /** Equirectangular Fixed Mirrored coordinates mode */
  23658. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23659. /** Texture is not repeating outside of 0..1 UVs */
  23660. static readonly CLAMP_ADDRESSMODE: number;
  23661. /** Texture is repeating outside of 0..1 UVs */
  23662. static readonly WRAP_ADDRESSMODE: number;
  23663. /** Texture is repeating and mirrored */
  23664. static readonly MIRROR_ADDRESSMODE: number;
  23665. /**
  23666. * 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
  23667. */
  23668. static UseSerializedUrlIfAny: boolean;
  23669. /**
  23670. * Define the url of the texture.
  23671. */
  23672. url: Nullable<string>;
  23673. /**
  23674. * Define an offset on the texture to offset the u coordinates of the UVs
  23675. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23676. */
  23677. uOffset: number;
  23678. /**
  23679. * Define an offset on the texture to offset the v coordinates of the UVs
  23680. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23681. */
  23682. vOffset: number;
  23683. /**
  23684. * Define an offset on the texture to scale the u coordinates of the UVs
  23685. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23686. */
  23687. uScale: number;
  23688. /**
  23689. * Define an offset on the texture to scale the v coordinates of the UVs
  23690. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23691. */
  23692. vScale: number;
  23693. /**
  23694. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23695. * @see http://doc.babylonjs.com/how_to/more_materials
  23696. */
  23697. uAng: number;
  23698. /**
  23699. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23700. * @see http://doc.babylonjs.com/how_to/more_materials
  23701. */
  23702. vAng: number;
  23703. /**
  23704. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23705. * @see http://doc.babylonjs.com/how_to/more_materials
  23706. */
  23707. wAng: number;
  23708. /**
  23709. * Defines the center of rotation (U)
  23710. */
  23711. uRotationCenter: number;
  23712. /**
  23713. * Defines the center of rotation (V)
  23714. */
  23715. vRotationCenter: number;
  23716. /**
  23717. * Defines the center of rotation (W)
  23718. */
  23719. wRotationCenter: number;
  23720. /**
  23721. * Are mip maps generated for this texture or not.
  23722. */
  23723. get noMipmap(): boolean;
  23724. /**
  23725. * List of inspectable custom properties (used by the Inspector)
  23726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23727. */
  23728. inspectableCustomProperties: Nullable<IInspectable[]>;
  23729. private _noMipmap;
  23730. /** @hidden */
  23731. _invertY: boolean;
  23732. private _rowGenerationMatrix;
  23733. private _cachedTextureMatrix;
  23734. private _projectionModeMatrix;
  23735. private _t0;
  23736. private _t1;
  23737. private _t2;
  23738. private _cachedUOffset;
  23739. private _cachedVOffset;
  23740. private _cachedUScale;
  23741. private _cachedVScale;
  23742. private _cachedUAng;
  23743. private _cachedVAng;
  23744. private _cachedWAng;
  23745. private _cachedProjectionMatrixId;
  23746. private _cachedCoordinatesMode;
  23747. /** @hidden */
  23748. protected _initialSamplingMode: number;
  23749. /** @hidden */
  23750. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23751. private _deleteBuffer;
  23752. protected _format: Nullable<number>;
  23753. private _delayedOnLoad;
  23754. private _delayedOnError;
  23755. private _mimeType?;
  23756. /**
  23757. * Observable triggered once the texture has been loaded.
  23758. */
  23759. onLoadObservable: Observable<Texture>;
  23760. protected _isBlocking: boolean;
  23761. /**
  23762. * Is the texture preventing material to render while loading.
  23763. * If false, a default texture will be used instead of the loading one during the preparation step.
  23764. */
  23765. set isBlocking(value: boolean);
  23766. get isBlocking(): boolean;
  23767. /**
  23768. * Get the current sampling mode associated with the texture.
  23769. */
  23770. get samplingMode(): number;
  23771. /**
  23772. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23773. */
  23774. get invertY(): boolean;
  23775. /**
  23776. * Instantiates a new texture.
  23777. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23778. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23779. * @param url defines the url of the picture to load as a texture
  23780. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23781. * @param noMipmap defines if the texture will require mip maps or not
  23782. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23783. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23784. * @param onLoad defines a callback triggered when the texture has been loaded
  23785. * @param onError defines a callback triggered when an error occurred during the loading session
  23786. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23787. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23788. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23789. * @param mimeType defines an optional mime type information
  23790. */
  23791. 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);
  23792. /**
  23793. * Update the url (and optional buffer) of this texture if url was null during construction.
  23794. * @param url the url of the texture
  23795. * @param buffer the buffer of the texture (defaults to null)
  23796. * @param onLoad callback called when the texture is loaded (defaults to null)
  23797. */
  23798. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23799. /**
  23800. * Finish the loading sequence of a texture flagged as delayed load.
  23801. * @hidden
  23802. */
  23803. delayLoad(): void;
  23804. private _prepareRowForTextureGeneration;
  23805. /**
  23806. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23807. * @returns the transform matrix of the texture.
  23808. */
  23809. getTextureMatrix(uBase?: number): Matrix;
  23810. /**
  23811. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23812. * @returns The reflection texture transform
  23813. */
  23814. getReflectionTextureMatrix(): Matrix;
  23815. /**
  23816. * Clones the texture.
  23817. * @returns the cloned texture
  23818. */
  23819. clone(): Texture;
  23820. /**
  23821. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23822. * @returns The JSON representation of the texture
  23823. */
  23824. serialize(): any;
  23825. /**
  23826. * Get the current class name of the texture useful for serialization or dynamic coding.
  23827. * @returns "Texture"
  23828. */
  23829. getClassName(): string;
  23830. /**
  23831. * Dispose the texture and release its associated resources.
  23832. */
  23833. dispose(): void;
  23834. /**
  23835. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23836. * @param parsedTexture Define the JSON representation of the texture
  23837. * @param scene Define the scene the parsed texture should be instantiated in
  23838. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23839. * @returns The parsed texture if successful
  23840. */
  23841. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23842. /**
  23843. * Creates a texture from its base 64 representation.
  23844. * @param data Define the base64 payload without the data: prefix
  23845. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23846. * @param scene Define the scene the texture should belong to
  23847. * @param noMipmap Forces the texture to not create mip map information if true
  23848. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23849. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23850. * @param onLoad define a callback triggered when the texture has been loaded
  23851. * @param onError define a callback triggered when an error occurred during the loading session
  23852. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23853. * @returns the created texture
  23854. */
  23855. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23856. /**
  23857. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23858. * @param data Define the base64 payload without the data: prefix
  23859. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23860. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23861. * @param scene Define the scene the texture should belong to
  23862. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23863. * @param noMipmap Forces the texture to not create mip map information if true
  23864. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23865. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23866. * @param onLoad define a callback triggered when the texture has been loaded
  23867. * @param onError define a callback triggered when an error occurred during the loading session
  23868. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23869. * @returns the created texture
  23870. */
  23871. 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;
  23872. }
  23873. }
  23874. declare module "babylonjs/PostProcesses/postProcessManager" {
  23875. import { Nullable } from "babylonjs/types";
  23876. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23877. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23878. import { Scene } from "babylonjs/scene";
  23879. /**
  23880. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23881. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23882. */
  23883. export class PostProcessManager {
  23884. private _scene;
  23885. private _indexBuffer;
  23886. private _vertexBuffers;
  23887. /**
  23888. * Creates a new instance PostProcess
  23889. * @param scene The scene that the post process is associated with.
  23890. */
  23891. constructor(scene: Scene);
  23892. private _prepareBuffers;
  23893. private _buildIndexBuffer;
  23894. /**
  23895. * Rebuilds the vertex buffers of the manager.
  23896. * @hidden
  23897. */
  23898. _rebuild(): void;
  23899. /**
  23900. * Prepares a frame to be run through a post process.
  23901. * @param sourceTexture The input texture to the post procesess. (default: null)
  23902. * @param postProcesses An array of post processes to be run. (default: null)
  23903. * @returns True if the post processes were able to be run.
  23904. * @hidden
  23905. */
  23906. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23907. /**
  23908. * Manually render a set of post processes to a texture.
  23909. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23910. * @param postProcesses An array of post processes to be run.
  23911. * @param targetTexture The target texture to render to.
  23912. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23913. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23914. * @param lodLevel defines which lod of the texture to render to
  23915. */
  23916. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23917. /**
  23918. * Finalize the result of the output of the postprocesses.
  23919. * @param doNotPresent If true the result will not be displayed to the screen.
  23920. * @param targetTexture The target texture to render to.
  23921. * @param faceIndex The index of the face to bind the target texture to.
  23922. * @param postProcesses The array of post processes to render.
  23923. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23924. * @hidden
  23925. */
  23926. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23927. /**
  23928. * Disposes of the post process manager.
  23929. */
  23930. dispose(): void;
  23931. }
  23932. }
  23933. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23934. import { Observable } from "babylonjs/Misc/observable";
  23935. import { SmartArray } from "babylonjs/Misc/smartArray";
  23936. import { Nullable, Immutable } from "babylonjs/types";
  23937. import { Camera } from "babylonjs/Cameras/camera";
  23938. import { Scene } from "babylonjs/scene";
  23939. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23940. import { Color4 } from "babylonjs/Maths/math.color";
  23941. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23943. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23945. import { Texture } from "babylonjs/Materials/Textures/texture";
  23946. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23947. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23948. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23949. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23950. import { Engine } from "babylonjs/Engines/engine";
  23951. /**
  23952. * This Helps creating a texture that will be created from a camera in your scene.
  23953. * It is basically a dynamic texture that could be used to create special effects for instance.
  23954. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23955. */
  23956. export class RenderTargetTexture extends Texture {
  23957. isCube: boolean;
  23958. /**
  23959. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23960. */
  23961. static readonly REFRESHRATE_RENDER_ONCE: number;
  23962. /**
  23963. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23964. */
  23965. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23966. /**
  23967. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23968. * the central point of your effect and can save a lot of performances.
  23969. */
  23970. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23971. /**
  23972. * Use this predicate to dynamically define the list of mesh you want to render.
  23973. * If set, the renderList property will be overwritten.
  23974. */
  23975. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23976. private _renderList;
  23977. /**
  23978. * Use this list to define the list of mesh you want to render.
  23979. */
  23980. get renderList(): Nullable<Array<AbstractMesh>>;
  23981. set renderList(value: Nullable<Array<AbstractMesh>>);
  23982. /**
  23983. * Use this function to overload the renderList array at rendering time.
  23984. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23985. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23986. * the cube (if the RTT is a cube, else layerOrFace=0).
  23987. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23988. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23989. * hold dummy elements!
  23990. */
  23991. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23992. private _hookArray;
  23993. /**
  23994. * Define if particles should be rendered in your texture.
  23995. */
  23996. renderParticles: boolean;
  23997. /**
  23998. * Define if sprites should be rendered in your texture.
  23999. */
  24000. renderSprites: boolean;
  24001. /**
  24002. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24003. */
  24004. coordinatesMode: number;
  24005. /**
  24006. * Define the camera used to render the texture.
  24007. */
  24008. activeCamera: Nullable<Camera>;
  24009. /**
  24010. * Override the mesh isReady function with your own one.
  24011. */
  24012. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24013. /**
  24014. * Override the render function of the texture with your own one.
  24015. */
  24016. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24017. /**
  24018. * Define if camera post processes should be use while rendering the texture.
  24019. */
  24020. useCameraPostProcesses: boolean;
  24021. /**
  24022. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24023. */
  24024. ignoreCameraViewport: boolean;
  24025. private _postProcessManager;
  24026. private _postProcesses;
  24027. private _resizeObserver;
  24028. /**
  24029. * An event triggered when the texture is unbind.
  24030. */
  24031. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24032. /**
  24033. * An event triggered when the texture is unbind.
  24034. */
  24035. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24036. private _onAfterUnbindObserver;
  24037. /**
  24038. * Set a after unbind callback in the texture.
  24039. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24040. */
  24041. set onAfterUnbind(callback: () => void);
  24042. /**
  24043. * An event triggered before rendering the texture
  24044. */
  24045. onBeforeRenderObservable: Observable<number>;
  24046. private _onBeforeRenderObserver;
  24047. /**
  24048. * Set a before render callback in the texture.
  24049. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24050. */
  24051. set onBeforeRender(callback: (faceIndex: number) => void);
  24052. /**
  24053. * An event triggered after rendering the texture
  24054. */
  24055. onAfterRenderObservable: Observable<number>;
  24056. private _onAfterRenderObserver;
  24057. /**
  24058. * Set a after render callback in the texture.
  24059. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24060. */
  24061. set onAfterRender(callback: (faceIndex: number) => void);
  24062. /**
  24063. * An event triggered after the texture clear
  24064. */
  24065. onClearObservable: Observable<Engine>;
  24066. private _onClearObserver;
  24067. /**
  24068. * Set a clear callback in the texture.
  24069. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24070. */
  24071. set onClear(callback: (Engine: Engine) => void);
  24072. /**
  24073. * An event triggered when the texture is resized.
  24074. */
  24075. onResizeObservable: Observable<RenderTargetTexture>;
  24076. /**
  24077. * Define the clear color of the Render Target if it should be different from the scene.
  24078. */
  24079. clearColor: Color4;
  24080. protected _size: number | {
  24081. width: number;
  24082. height: number;
  24083. layers?: number;
  24084. };
  24085. protected _initialSizeParameter: number | {
  24086. width: number;
  24087. height: number;
  24088. } | {
  24089. ratio: number;
  24090. };
  24091. protected _sizeRatio: Nullable<number>;
  24092. /** @hidden */
  24093. _generateMipMaps: boolean;
  24094. protected _renderingManager: RenderingManager;
  24095. /** @hidden */
  24096. _waitingRenderList: string[];
  24097. protected _doNotChangeAspectRatio: boolean;
  24098. protected _currentRefreshId: number;
  24099. protected _refreshRate: number;
  24100. protected _textureMatrix: Matrix;
  24101. protected _samples: number;
  24102. protected _renderTargetOptions: RenderTargetCreationOptions;
  24103. /**
  24104. * Gets render target creation options that were used.
  24105. */
  24106. get renderTargetOptions(): RenderTargetCreationOptions;
  24107. protected _onRatioRescale(): void;
  24108. /**
  24109. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24110. * It must define where the camera used to render the texture is set
  24111. */
  24112. boundingBoxPosition: Vector3;
  24113. private _boundingBoxSize;
  24114. /**
  24115. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24116. * When defined, the cubemap will switch to local mode
  24117. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24118. * @example https://www.babylonjs-playground.com/#RNASML
  24119. */
  24120. set boundingBoxSize(value: Vector3);
  24121. get boundingBoxSize(): Vector3;
  24122. /**
  24123. * In case the RTT has been created with a depth texture, get the associated
  24124. * depth texture.
  24125. * Otherwise, return null.
  24126. */
  24127. get depthStencilTexture(): Nullable<InternalTexture>;
  24128. /**
  24129. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24130. * or used a shadow, depth texture...
  24131. * @param name The friendly name of the texture
  24132. * @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)
  24133. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24134. * @param generateMipMaps True if mip maps need to be generated after render.
  24135. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24136. * @param type The type of the buffer in the RTT (int, half float, float...)
  24137. * @param isCube True if a cube texture needs to be created
  24138. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24139. * @param generateDepthBuffer True to generate a depth buffer
  24140. * @param generateStencilBuffer True to generate a stencil buffer
  24141. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24142. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24143. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24144. */
  24145. constructor(name: string, size: number | {
  24146. width: number;
  24147. height: number;
  24148. layers?: number;
  24149. } | {
  24150. ratio: number;
  24151. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24152. /**
  24153. * Creates a depth stencil texture.
  24154. * This is only available in WebGL 2 or with the depth texture extension available.
  24155. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24156. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24157. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24158. */
  24159. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24160. private _processSizeParameter;
  24161. /**
  24162. * Define the number of samples to use in case of MSAA.
  24163. * It defaults to one meaning no MSAA has been enabled.
  24164. */
  24165. get samples(): number;
  24166. set samples(value: number);
  24167. /**
  24168. * Resets the refresh counter of the texture and start bak from scratch.
  24169. * Could be useful to regenerate the texture if it is setup to render only once.
  24170. */
  24171. resetRefreshCounter(): void;
  24172. /**
  24173. * Define the refresh rate of the texture or the rendering frequency.
  24174. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24175. */
  24176. get refreshRate(): number;
  24177. set refreshRate(value: number);
  24178. /**
  24179. * Adds a post process to the render target rendering passes.
  24180. * @param postProcess define the post process to add
  24181. */
  24182. addPostProcess(postProcess: PostProcess): void;
  24183. /**
  24184. * Clear all the post processes attached to the render target
  24185. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24186. */
  24187. clearPostProcesses(dispose?: boolean): void;
  24188. /**
  24189. * Remove one of the post process from the list of attached post processes to the texture
  24190. * @param postProcess define the post process to remove from the list
  24191. */
  24192. removePostProcess(postProcess: PostProcess): void;
  24193. /** @hidden */
  24194. _shouldRender(): boolean;
  24195. /**
  24196. * Gets the actual render size of the texture.
  24197. * @returns the width of the render size
  24198. */
  24199. getRenderSize(): number;
  24200. /**
  24201. * Gets the actual render width of the texture.
  24202. * @returns the width of the render size
  24203. */
  24204. getRenderWidth(): number;
  24205. /**
  24206. * Gets the actual render height of the texture.
  24207. * @returns the height of the render size
  24208. */
  24209. getRenderHeight(): number;
  24210. /**
  24211. * Gets the actual number of layers of the texture.
  24212. * @returns the number of layers
  24213. */
  24214. getRenderLayers(): number;
  24215. /**
  24216. * Get if the texture can be rescaled or not.
  24217. */
  24218. get canRescale(): boolean;
  24219. /**
  24220. * Resize the texture using a ratio.
  24221. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24222. */
  24223. scale(ratio: number): void;
  24224. /**
  24225. * Get the texture reflection matrix used to rotate/transform the reflection.
  24226. * @returns the reflection matrix
  24227. */
  24228. getReflectionTextureMatrix(): Matrix;
  24229. /**
  24230. * Resize the texture to a new desired size.
  24231. * Be carrefull as it will recreate all the data in the new texture.
  24232. * @param size Define the new size. It can be:
  24233. * - a number for squared texture,
  24234. * - an object containing { width: number, height: number }
  24235. * - or an object containing a ratio { ratio: number }
  24236. */
  24237. resize(size: number | {
  24238. width: number;
  24239. height: number;
  24240. } | {
  24241. ratio: number;
  24242. }): void;
  24243. private _defaultRenderListPrepared;
  24244. /**
  24245. * Renders all the objects from the render list into the texture.
  24246. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24247. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24248. */
  24249. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24250. private _bestReflectionRenderTargetDimension;
  24251. private _prepareRenderingManager;
  24252. /**
  24253. * @hidden
  24254. * @param faceIndex face index to bind to if this is a cubetexture
  24255. * @param layer defines the index of the texture to bind in the array
  24256. */
  24257. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24258. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24259. private renderToTarget;
  24260. /**
  24261. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24262. * This allowed control for front to back rendering or reversly depending of the special needs.
  24263. *
  24264. * @param renderingGroupId The rendering group id corresponding to its index
  24265. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24266. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24267. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24268. */
  24269. 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;
  24270. /**
  24271. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24272. *
  24273. * @param renderingGroupId The rendering group id corresponding to its index
  24274. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24275. */
  24276. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24277. /**
  24278. * Clones the texture.
  24279. * @returns the cloned texture
  24280. */
  24281. clone(): RenderTargetTexture;
  24282. /**
  24283. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24284. * @returns The JSON representation of the texture
  24285. */
  24286. serialize(): any;
  24287. /**
  24288. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24289. */
  24290. disposeFramebufferObjects(): void;
  24291. /**
  24292. * Dispose the texture and release its associated resources.
  24293. */
  24294. dispose(): void;
  24295. /** @hidden */
  24296. _rebuild(): void;
  24297. /**
  24298. * Clear the info related to rendering groups preventing retention point in material dispose.
  24299. */
  24300. freeRenderingGroups(): void;
  24301. /**
  24302. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24303. * @returns the view count
  24304. */
  24305. getViewCount(): number;
  24306. }
  24307. }
  24308. declare module "babylonjs/Misc/guid" {
  24309. /**
  24310. * Class used to manipulate GUIDs
  24311. */
  24312. export class GUID {
  24313. /**
  24314. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24315. * Be aware Math.random() could cause collisions, but:
  24316. * "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"
  24317. * @returns a pseudo random id
  24318. */
  24319. static RandomId(): string;
  24320. }
  24321. }
  24322. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24323. import { Nullable } from "babylonjs/types";
  24324. import { Scene } from "babylonjs/scene";
  24325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24326. import { Material } from "babylonjs/Materials/material";
  24327. import { Effect } from "babylonjs/Materials/effect";
  24328. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24329. /**
  24330. * Options to be used when creating a shadow depth material
  24331. */
  24332. export interface IIOptionShadowDepthMaterial {
  24333. /** Variables in the vertex shader code that need to have their names remapped.
  24334. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24335. * "var_name" should be either: worldPos or vNormalW
  24336. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24337. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24338. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24339. */
  24340. remappedVariables?: string[];
  24341. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24342. standalone?: boolean;
  24343. }
  24344. /**
  24345. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24346. */
  24347. export class ShadowDepthWrapper {
  24348. private _scene;
  24349. private _options?;
  24350. private _baseMaterial;
  24351. private _onEffectCreatedObserver;
  24352. private _subMeshToEffect;
  24353. private _subMeshToDepthEffect;
  24354. private _meshes;
  24355. /** @hidden */
  24356. _matriceNames: any;
  24357. /** Gets the standalone status of the wrapper */
  24358. get standalone(): boolean;
  24359. /** Gets the base material the wrapper is built upon */
  24360. get baseMaterial(): Material;
  24361. /**
  24362. * Instantiate a new shadow depth wrapper.
  24363. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24364. * generate the shadow depth map. For more information, please refer to the documentation:
  24365. * https://doc.babylonjs.com/babylon101/shadows
  24366. * @param baseMaterial Material to wrap
  24367. * @param scene Define the scene the material belongs to
  24368. * @param options Options used to create the wrapper
  24369. */
  24370. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24371. /**
  24372. * Gets the effect to use to generate the depth map
  24373. * @param subMesh subMesh to get the effect for
  24374. * @param shadowGenerator shadow generator to get the effect for
  24375. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24376. */
  24377. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24378. /**
  24379. * Specifies that the submesh is ready to be used for depth rendering
  24380. * @param subMesh submesh to check
  24381. * @param defines the list of defines to take into account when checking the effect
  24382. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24383. * @param useInstances specifies that instances should be used
  24384. * @returns a boolean indicating that the submesh is ready or not
  24385. */
  24386. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24387. /**
  24388. * Disposes the resources
  24389. */
  24390. dispose(): void;
  24391. private _makeEffect;
  24392. }
  24393. }
  24394. declare module "babylonjs/Materials/material" {
  24395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24396. import { SmartArray } from "babylonjs/Misc/smartArray";
  24397. import { Observable } from "babylonjs/Misc/observable";
  24398. import { Nullable } from "babylonjs/types";
  24399. import { Scene } from "babylonjs/scene";
  24400. import { Matrix } from "babylonjs/Maths/math.vector";
  24401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24404. import { Effect } from "babylonjs/Materials/effect";
  24405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24407. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24408. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24409. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24410. import { Mesh } from "babylonjs/Meshes/mesh";
  24411. import { Animation } from "babylonjs/Animations/animation";
  24412. /**
  24413. * Options for compiling materials.
  24414. */
  24415. export interface IMaterialCompilationOptions {
  24416. /**
  24417. * Defines whether clip planes are enabled.
  24418. */
  24419. clipPlane: boolean;
  24420. /**
  24421. * Defines whether instances are enabled.
  24422. */
  24423. useInstances: boolean;
  24424. }
  24425. /**
  24426. * Options passed when calling customShaderNameResolve
  24427. */
  24428. export interface ICustomShaderNameResolveOptions {
  24429. /**
  24430. * 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
  24431. */
  24432. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24433. }
  24434. /**
  24435. * Base class for the main features of a material in Babylon.js
  24436. */
  24437. export class Material implements IAnimatable {
  24438. /**
  24439. * Returns the triangle fill mode
  24440. */
  24441. static readonly TriangleFillMode: number;
  24442. /**
  24443. * Returns the wireframe mode
  24444. */
  24445. static readonly WireFrameFillMode: number;
  24446. /**
  24447. * Returns the point fill mode
  24448. */
  24449. static readonly PointFillMode: number;
  24450. /**
  24451. * Returns the point list draw mode
  24452. */
  24453. static readonly PointListDrawMode: number;
  24454. /**
  24455. * Returns the line list draw mode
  24456. */
  24457. static readonly LineListDrawMode: number;
  24458. /**
  24459. * Returns the line loop draw mode
  24460. */
  24461. static readonly LineLoopDrawMode: number;
  24462. /**
  24463. * Returns the line strip draw mode
  24464. */
  24465. static readonly LineStripDrawMode: number;
  24466. /**
  24467. * Returns the triangle strip draw mode
  24468. */
  24469. static readonly TriangleStripDrawMode: number;
  24470. /**
  24471. * Returns the triangle fan draw mode
  24472. */
  24473. static readonly TriangleFanDrawMode: number;
  24474. /**
  24475. * Stores the clock-wise side orientation
  24476. */
  24477. static readonly ClockWiseSideOrientation: number;
  24478. /**
  24479. * Stores the counter clock-wise side orientation
  24480. */
  24481. static readonly CounterClockWiseSideOrientation: number;
  24482. /**
  24483. * The dirty texture flag value
  24484. */
  24485. static readonly TextureDirtyFlag: number;
  24486. /**
  24487. * The dirty light flag value
  24488. */
  24489. static readonly LightDirtyFlag: number;
  24490. /**
  24491. * The dirty fresnel flag value
  24492. */
  24493. static readonly FresnelDirtyFlag: number;
  24494. /**
  24495. * The dirty attribute flag value
  24496. */
  24497. static readonly AttributesDirtyFlag: number;
  24498. /**
  24499. * The dirty misc flag value
  24500. */
  24501. static readonly MiscDirtyFlag: number;
  24502. /**
  24503. * The all dirty flag value
  24504. */
  24505. static readonly AllDirtyFlag: number;
  24506. /**
  24507. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24508. */
  24509. static readonly MATERIAL_OPAQUE: number;
  24510. /**
  24511. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24512. */
  24513. static readonly MATERIAL_ALPHATEST: number;
  24514. /**
  24515. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24516. */
  24517. static readonly MATERIAL_ALPHABLEND: number;
  24518. /**
  24519. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24520. * They are also discarded below the alpha cutoff threshold to improve performances.
  24521. */
  24522. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24523. /**
  24524. * The Whiteout method is used to blend normals.
  24525. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24526. */
  24527. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24528. /**
  24529. * The Reoriented Normal Mapping method is used to blend normals.
  24530. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24531. */
  24532. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24533. /**
  24534. * Custom callback helping to override the default shader used in the material.
  24535. */
  24536. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24537. /**
  24538. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24539. */
  24540. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24541. /**
  24542. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24543. * This means that the material can keep using a previous shader while a new one is being compiled.
  24544. * This is mostly used when shader parallel compilation is supported (true by default)
  24545. */
  24546. allowShaderHotSwapping: boolean;
  24547. /**
  24548. * The ID of the material
  24549. */
  24550. id: string;
  24551. /**
  24552. * Gets or sets the unique id of the material
  24553. */
  24554. uniqueId: number;
  24555. /**
  24556. * The name of the material
  24557. */
  24558. name: string;
  24559. /**
  24560. * Gets or sets user defined metadata
  24561. */
  24562. metadata: any;
  24563. /**
  24564. * For internal use only. Please do not use.
  24565. */
  24566. reservedDataStore: any;
  24567. /**
  24568. * Specifies if the ready state should be checked on each call
  24569. */
  24570. checkReadyOnEveryCall: boolean;
  24571. /**
  24572. * Specifies if the ready state should be checked once
  24573. */
  24574. checkReadyOnlyOnce: boolean;
  24575. /**
  24576. * The state of the material
  24577. */
  24578. state: string;
  24579. /**
  24580. * The alpha value of the material
  24581. */
  24582. protected _alpha: number;
  24583. /**
  24584. * List of inspectable custom properties (used by the Inspector)
  24585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24586. */
  24587. inspectableCustomProperties: IInspectable[];
  24588. /**
  24589. * Sets the alpha value of the material
  24590. */
  24591. set alpha(value: number);
  24592. /**
  24593. * Gets the alpha value of the material
  24594. */
  24595. get alpha(): number;
  24596. /**
  24597. * Specifies if back face culling is enabled
  24598. */
  24599. protected _backFaceCulling: boolean;
  24600. /**
  24601. * Sets the back-face culling state
  24602. */
  24603. set backFaceCulling(value: boolean);
  24604. /**
  24605. * Gets the back-face culling state
  24606. */
  24607. get backFaceCulling(): boolean;
  24608. /**
  24609. * Stores the value for side orientation
  24610. */
  24611. sideOrientation: number;
  24612. /**
  24613. * Callback triggered when the material is compiled
  24614. */
  24615. onCompiled: Nullable<(effect: Effect) => void>;
  24616. /**
  24617. * Callback triggered when an error occurs
  24618. */
  24619. onError: Nullable<(effect: Effect, errors: string) => void>;
  24620. /**
  24621. * Callback triggered to get the render target textures
  24622. */
  24623. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24624. /**
  24625. * Gets a boolean indicating that current material needs to register RTT
  24626. */
  24627. get hasRenderTargetTextures(): boolean;
  24628. /**
  24629. * Specifies if the material should be serialized
  24630. */
  24631. doNotSerialize: boolean;
  24632. /**
  24633. * @hidden
  24634. */
  24635. _storeEffectOnSubMeshes: boolean;
  24636. /**
  24637. * Stores the animations for the material
  24638. */
  24639. animations: Nullable<Array<Animation>>;
  24640. /**
  24641. * An event triggered when the material is disposed
  24642. */
  24643. onDisposeObservable: Observable<Material>;
  24644. /**
  24645. * An observer which watches for dispose events
  24646. */
  24647. private _onDisposeObserver;
  24648. private _onUnBindObservable;
  24649. /**
  24650. * Called during a dispose event
  24651. */
  24652. set onDispose(callback: () => void);
  24653. private _onBindObservable;
  24654. /**
  24655. * An event triggered when the material is bound
  24656. */
  24657. get onBindObservable(): Observable<AbstractMesh>;
  24658. /**
  24659. * An observer which watches for bind events
  24660. */
  24661. private _onBindObserver;
  24662. /**
  24663. * Called during a bind event
  24664. */
  24665. set onBind(callback: (Mesh: AbstractMesh) => void);
  24666. /**
  24667. * An event triggered when the material is unbound
  24668. */
  24669. get onUnBindObservable(): Observable<Material>;
  24670. protected _onEffectCreatedObservable: Nullable<Observable<{
  24671. effect: Effect;
  24672. subMesh: Nullable<SubMesh>;
  24673. }>>;
  24674. /**
  24675. * An event triggered when the effect is (re)created
  24676. */
  24677. get onEffectCreatedObservable(): Observable<{
  24678. effect: Effect;
  24679. subMesh: Nullable<SubMesh>;
  24680. }>;
  24681. /**
  24682. * Stores the value of the alpha mode
  24683. */
  24684. private _alphaMode;
  24685. /**
  24686. * Sets the value of the alpha mode.
  24687. *
  24688. * | Value | Type | Description |
  24689. * | --- | --- | --- |
  24690. * | 0 | ALPHA_DISABLE | |
  24691. * | 1 | ALPHA_ADD | |
  24692. * | 2 | ALPHA_COMBINE | |
  24693. * | 3 | ALPHA_SUBTRACT | |
  24694. * | 4 | ALPHA_MULTIPLY | |
  24695. * | 5 | ALPHA_MAXIMIZED | |
  24696. * | 6 | ALPHA_ONEONE | |
  24697. * | 7 | ALPHA_PREMULTIPLIED | |
  24698. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24699. * | 9 | ALPHA_INTERPOLATE | |
  24700. * | 10 | ALPHA_SCREENMODE | |
  24701. *
  24702. */
  24703. set alphaMode(value: number);
  24704. /**
  24705. * Gets the value of the alpha mode
  24706. */
  24707. get alphaMode(): number;
  24708. /**
  24709. * Stores the state of the need depth pre-pass value
  24710. */
  24711. private _needDepthPrePass;
  24712. /**
  24713. * Sets the need depth pre-pass value
  24714. */
  24715. set needDepthPrePass(value: boolean);
  24716. /**
  24717. * Gets the depth pre-pass value
  24718. */
  24719. get needDepthPrePass(): boolean;
  24720. /**
  24721. * Specifies if depth writing should be disabled
  24722. */
  24723. disableDepthWrite: boolean;
  24724. /**
  24725. * Specifies if color writing should be disabled
  24726. */
  24727. disableColorWrite: boolean;
  24728. /**
  24729. * Specifies if depth writing should be forced
  24730. */
  24731. forceDepthWrite: boolean;
  24732. /**
  24733. * Specifies the depth function that should be used. 0 means the default engine function
  24734. */
  24735. depthFunction: number;
  24736. /**
  24737. * Specifies if there should be a separate pass for culling
  24738. */
  24739. separateCullingPass: boolean;
  24740. /**
  24741. * Stores the state specifing if fog should be enabled
  24742. */
  24743. private _fogEnabled;
  24744. /**
  24745. * Sets the state for enabling fog
  24746. */
  24747. set fogEnabled(value: boolean);
  24748. /**
  24749. * Gets the value of the fog enabled state
  24750. */
  24751. get fogEnabled(): boolean;
  24752. /**
  24753. * Stores the size of points
  24754. */
  24755. pointSize: number;
  24756. /**
  24757. * Stores the z offset value
  24758. */
  24759. zOffset: number;
  24760. get wireframe(): boolean;
  24761. /**
  24762. * Sets the state of wireframe mode
  24763. */
  24764. set wireframe(value: boolean);
  24765. /**
  24766. * Gets the value specifying if point clouds are enabled
  24767. */
  24768. get pointsCloud(): boolean;
  24769. /**
  24770. * Sets the state of point cloud mode
  24771. */
  24772. set pointsCloud(value: boolean);
  24773. /**
  24774. * Gets the material fill mode
  24775. */
  24776. get fillMode(): number;
  24777. /**
  24778. * Sets the material fill mode
  24779. */
  24780. set fillMode(value: number);
  24781. /**
  24782. * @hidden
  24783. * Stores the effects for the material
  24784. */
  24785. _effect: Nullable<Effect>;
  24786. /**
  24787. * Specifies if uniform buffers should be used
  24788. */
  24789. private _useUBO;
  24790. /**
  24791. * Stores a reference to the scene
  24792. */
  24793. private _scene;
  24794. /**
  24795. * Stores the fill mode state
  24796. */
  24797. private _fillMode;
  24798. /**
  24799. * Specifies if the depth write state should be cached
  24800. */
  24801. private _cachedDepthWriteState;
  24802. /**
  24803. * Specifies if the color write state should be cached
  24804. */
  24805. private _cachedColorWriteState;
  24806. /**
  24807. * Specifies if the depth function state should be cached
  24808. */
  24809. private _cachedDepthFunctionState;
  24810. /**
  24811. * Stores the uniform buffer
  24812. */
  24813. protected _uniformBuffer: UniformBuffer;
  24814. /** @hidden */
  24815. _indexInSceneMaterialArray: number;
  24816. /** @hidden */
  24817. meshMap: Nullable<{
  24818. [id: string]: AbstractMesh | undefined;
  24819. }>;
  24820. /**
  24821. * Creates a material instance
  24822. * @param name defines the name of the material
  24823. * @param scene defines the scene to reference
  24824. * @param doNotAdd specifies if the material should be added to the scene
  24825. */
  24826. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24827. /**
  24828. * Returns a string representation of the current material
  24829. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24830. * @returns a string with material information
  24831. */
  24832. toString(fullDetails?: boolean): string;
  24833. /**
  24834. * Gets the class name of the material
  24835. * @returns a string with the class name of the material
  24836. */
  24837. getClassName(): string;
  24838. /**
  24839. * Specifies if updates for the material been locked
  24840. */
  24841. get isFrozen(): boolean;
  24842. /**
  24843. * Locks updates for the material
  24844. */
  24845. freeze(): void;
  24846. /**
  24847. * Unlocks updates for the material
  24848. */
  24849. unfreeze(): void;
  24850. /**
  24851. * Specifies if the material is ready to be used
  24852. * @param mesh defines the mesh to check
  24853. * @param useInstances specifies if instances should be used
  24854. * @returns a boolean indicating if the material is ready to be used
  24855. */
  24856. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24857. /**
  24858. * Specifies that the submesh is ready to be used
  24859. * @param mesh defines the mesh to check
  24860. * @param subMesh defines which submesh to check
  24861. * @param useInstances specifies that instances should be used
  24862. * @returns a boolean indicating that the submesh is ready or not
  24863. */
  24864. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24865. /**
  24866. * Returns the material effect
  24867. * @returns the effect associated with the material
  24868. */
  24869. getEffect(): Nullable<Effect>;
  24870. /**
  24871. * Returns the current scene
  24872. * @returns a Scene
  24873. */
  24874. getScene(): Scene;
  24875. /**
  24876. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24877. */
  24878. protected _forceAlphaTest: boolean;
  24879. /**
  24880. * The transparency mode of the material.
  24881. */
  24882. protected _transparencyMode: Nullable<number>;
  24883. /**
  24884. * Gets the current transparency mode.
  24885. */
  24886. get transparencyMode(): Nullable<number>;
  24887. /**
  24888. * Sets the transparency mode of the material.
  24889. *
  24890. * | Value | Type | Description |
  24891. * | ----- | ----------------------------------- | ----------- |
  24892. * | 0 | OPAQUE | |
  24893. * | 1 | ALPHATEST | |
  24894. * | 2 | ALPHABLEND | |
  24895. * | 3 | ALPHATESTANDBLEND | |
  24896. *
  24897. */
  24898. set transparencyMode(value: Nullable<number>);
  24899. /**
  24900. * Returns true if alpha blending should be disabled.
  24901. */
  24902. protected get _disableAlphaBlending(): boolean;
  24903. /**
  24904. * Specifies whether or not this material should be rendered in alpha blend mode.
  24905. * @returns a boolean specifying if alpha blending is needed
  24906. */
  24907. needAlphaBlending(): boolean;
  24908. /**
  24909. * Specifies if the mesh will require alpha blending
  24910. * @param mesh defines the mesh to check
  24911. * @returns a boolean specifying if alpha blending is needed for the mesh
  24912. */
  24913. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24914. /**
  24915. * Specifies whether or not this material should be rendered in alpha test mode.
  24916. * @returns a boolean specifying if an alpha test is needed.
  24917. */
  24918. needAlphaTesting(): boolean;
  24919. /**
  24920. * Specifies if material alpha testing should be turned on for the mesh
  24921. * @param mesh defines the mesh to check
  24922. */
  24923. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24924. /**
  24925. * Gets the texture used for the alpha test
  24926. * @returns the texture to use for alpha testing
  24927. */
  24928. getAlphaTestTexture(): Nullable<BaseTexture>;
  24929. /**
  24930. * Marks the material to indicate that it needs to be re-calculated
  24931. */
  24932. markDirty(): void;
  24933. /** @hidden */
  24934. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24935. /**
  24936. * Binds the material to the mesh
  24937. * @param world defines the world transformation matrix
  24938. * @param mesh defines the mesh to bind the material to
  24939. */
  24940. bind(world: Matrix, mesh?: Mesh): void;
  24941. /**
  24942. * Binds the submesh to the material
  24943. * @param world defines the world transformation matrix
  24944. * @param mesh defines the mesh containing the submesh
  24945. * @param subMesh defines the submesh to bind the material to
  24946. */
  24947. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24948. /**
  24949. * Binds the world matrix to the material
  24950. * @param world defines the world transformation matrix
  24951. */
  24952. bindOnlyWorldMatrix(world: Matrix): void;
  24953. /**
  24954. * Binds the scene's uniform buffer to the effect.
  24955. * @param effect defines the effect to bind to the scene uniform buffer
  24956. * @param sceneUbo defines the uniform buffer storing scene data
  24957. */
  24958. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24959. /**
  24960. * Binds the view matrix to the effect
  24961. * @param effect defines the effect to bind the view matrix to
  24962. */
  24963. bindView(effect: Effect): void;
  24964. /**
  24965. * Binds the view projection matrix to the effect
  24966. * @param effect defines the effect to bind the view projection matrix to
  24967. */
  24968. bindViewProjection(effect: Effect): void;
  24969. /**
  24970. * Processes to execute after binding the material to a mesh
  24971. * @param mesh defines the rendered mesh
  24972. */
  24973. protected _afterBind(mesh?: Mesh): void;
  24974. /**
  24975. * Unbinds the material from the mesh
  24976. */
  24977. unbind(): void;
  24978. /**
  24979. * Gets the active textures from the material
  24980. * @returns an array of textures
  24981. */
  24982. getActiveTextures(): BaseTexture[];
  24983. /**
  24984. * Specifies if the material uses a texture
  24985. * @param texture defines the texture to check against the material
  24986. * @returns a boolean specifying if the material uses the texture
  24987. */
  24988. hasTexture(texture: BaseTexture): boolean;
  24989. /**
  24990. * Makes a duplicate of the material, and gives it a new name
  24991. * @param name defines the new name for the duplicated material
  24992. * @returns the cloned material
  24993. */
  24994. clone(name: string): Nullable<Material>;
  24995. /**
  24996. * Gets the meshes bound to the material
  24997. * @returns an array of meshes bound to the material
  24998. */
  24999. getBindedMeshes(): AbstractMesh[];
  25000. /**
  25001. * Force shader compilation
  25002. * @param mesh defines the mesh associated with this material
  25003. * @param onCompiled defines a function to execute once the material is compiled
  25004. * @param options defines the options to configure the compilation
  25005. * @param onError defines a function to execute if the material fails compiling
  25006. */
  25007. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25008. /**
  25009. * Force shader compilation
  25010. * @param mesh defines the mesh that will use this material
  25011. * @param options defines additional options for compiling the shaders
  25012. * @returns a promise that resolves when the compilation completes
  25013. */
  25014. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25015. private static readonly _AllDirtyCallBack;
  25016. private static readonly _ImageProcessingDirtyCallBack;
  25017. private static readonly _TextureDirtyCallBack;
  25018. private static readonly _FresnelDirtyCallBack;
  25019. private static readonly _MiscDirtyCallBack;
  25020. private static readonly _LightsDirtyCallBack;
  25021. private static readonly _AttributeDirtyCallBack;
  25022. private static _FresnelAndMiscDirtyCallBack;
  25023. private static _TextureAndMiscDirtyCallBack;
  25024. private static readonly _DirtyCallbackArray;
  25025. private static readonly _RunDirtyCallBacks;
  25026. /**
  25027. * Marks a define in the material to indicate that it needs to be re-computed
  25028. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25029. */
  25030. markAsDirty(flag: number): void;
  25031. /**
  25032. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25033. * @param func defines a function which checks material defines against the submeshes
  25034. */
  25035. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25036. /**
  25037. * Indicates that we need to re-calculated for all submeshes
  25038. */
  25039. protected _markAllSubMeshesAsAllDirty(): void;
  25040. /**
  25041. * Indicates that image processing needs to be re-calculated for all submeshes
  25042. */
  25043. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25044. /**
  25045. * Indicates that textures need to be re-calculated for all submeshes
  25046. */
  25047. protected _markAllSubMeshesAsTexturesDirty(): void;
  25048. /**
  25049. * Indicates that fresnel needs to be re-calculated for all submeshes
  25050. */
  25051. protected _markAllSubMeshesAsFresnelDirty(): void;
  25052. /**
  25053. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25054. */
  25055. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25056. /**
  25057. * Indicates that lights need to be re-calculated for all submeshes
  25058. */
  25059. protected _markAllSubMeshesAsLightsDirty(): void;
  25060. /**
  25061. * Indicates that attributes need to be re-calculated for all submeshes
  25062. */
  25063. protected _markAllSubMeshesAsAttributesDirty(): void;
  25064. /**
  25065. * Indicates that misc needs to be re-calculated for all submeshes
  25066. */
  25067. protected _markAllSubMeshesAsMiscDirty(): void;
  25068. /**
  25069. * Indicates that textures and misc need to be re-calculated for all submeshes
  25070. */
  25071. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25072. /**
  25073. * Disposes the material
  25074. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25075. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25076. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25077. */
  25078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25079. /** @hidden */
  25080. private releaseVertexArrayObject;
  25081. /**
  25082. * Serializes this material
  25083. * @returns the serialized material object
  25084. */
  25085. serialize(): any;
  25086. /**
  25087. * Creates a material from parsed material data
  25088. * @param parsedMaterial defines parsed material data
  25089. * @param scene defines the hosting scene
  25090. * @param rootUrl defines the root URL to use to load textures
  25091. * @returns a new material
  25092. */
  25093. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25094. }
  25095. }
  25096. declare module "babylonjs/Materials/multiMaterial" {
  25097. import { Nullable } from "babylonjs/types";
  25098. import { Scene } from "babylonjs/scene";
  25099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25102. import { Material } from "babylonjs/Materials/material";
  25103. /**
  25104. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25105. * separate meshes. This can be use to improve performances.
  25106. * @see http://doc.babylonjs.com/how_to/multi_materials
  25107. */
  25108. export class MultiMaterial extends Material {
  25109. private _subMaterials;
  25110. /**
  25111. * Gets or Sets the list of Materials used within the multi material.
  25112. * They need to be ordered according to the submeshes order in the associated mesh
  25113. */
  25114. get subMaterials(): Nullable<Material>[];
  25115. set subMaterials(value: Nullable<Material>[]);
  25116. /**
  25117. * Function used to align with Node.getChildren()
  25118. * @returns the list of Materials used within the multi material
  25119. */
  25120. getChildren(): Nullable<Material>[];
  25121. /**
  25122. * Instantiates a new Multi Material
  25123. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25124. * separate meshes. This can be use to improve performances.
  25125. * @see http://doc.babylonjs.com/how_to/multi_materials
  25126. * @param name Define the name in the scene
  25127. * @param scene Define the scene the material belongs to
  25128. */
  25129. constructor(name: string, scene: Scene);
  25130. private _hookArray;
  25131. /**
  25132. * Get one of the submaterial by its index in the submaterials array
  25133. * @param index The index to look the sub material at
  25134. * @returns The Material if the index has been defined
  25135. */
  25136. getSubMaterial(index: number): Nullable<Material>;
  25137. /**
  25138. * Get the list of active textures for the whole sub materials list.
  25139. * @returns All the textures that will be used during the rendering
  25140. */
  25141. getActiveTextures(): BaseTexture[];
  25142. /**
  25143. * Gets the current class name of the material e.g. "MultiMaterial"
  25144. * Mainly use in serialization.
  25145. * @returns the class name
  25146. */
  25147. getClassName(): string;
  25148. /**
  25149. * Checks if the material is ready to render the requested sub mesh
  25150. * @param mesh Define the mesh the submesh belongs to
  25151. * @param subMesh Define the sub mesh to look readyness for
  25152. * @param useInstances Define whether or not the material is used with instances
  25153. * @returns true if ready, otherwise false
  25154. */
  25155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25156. /**
  25157. * Clones the current material and its related sub materials
  25158. * @param name Define the name of the newly cloned material
  25159. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25160. * @returns the cloned material
  25161. */
  25162. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25163. /**
  25164. * Serializes the materials into a JSON representation.
  25165. * @returns the JSON representation
  25166. */
  25167. serialize(): any;
  25168. /**
  25169. * Dispose the material and release its associated resources
  25170. * @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)
  25171. * @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)
  25172. * @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)
  25173. */
  25174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25175. /**
  25176. * Creates a MultiMaterial from parsed MultiMaterial data.
  25177. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25178. * @param scene defines the hosting scene
  25179. * @returns a new MultiMaterial
  25180. */
  25181. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25182. }
  25183. }
  25184. declare module "babylonjs/Meshes/subMesh" {
  25185. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25187. import { Engine } from "babylonjs/Engines/engine";
  25188. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25189. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25190. import { Effect } from "babylonjs/Materials/effect";
  25191. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25192. import { Plane } from "babylonjs/Maths/math.plane";
  25193. import { Collider } from "babylonjs/Collisions/collider";
  25194. import { Material } from "babylonjs/Materials/material";
  25195. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25197. import { Mesh } from "babylonjs/Meshes/mesh";
  25198. import { Ray } from "babylonjs/Culling/ray";
  25199. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25200. /**
  25201. * Defines a subdivision inside a mesh
  25202. */
  25203. export class SubMesh implements ICullable {
  25204. /** the material index to use */
  25205. materialIndex: number;
  25206. /** vertex index start */
  25207. verticesStart: number;
  25208. /** vertices count */
  25209. verticesCount: number;
  25210. /** index start */
  25211. indexStart: number;
  25212. /** indices count */
  25213. indexCount: number;
  25214. /** @hidden */
  25215. _materialDefines: Nullable<MaterialDefines>;
  25216. /** @hidden */
  25217. _materialEffect: Nullable<Effect>;
  25218. /** @hidden */
  25219. _effectOverride: Nullable<Effect>;
  25220. /**
  25221. * Gets material defines used by the effect associated to the sub mesh
  25222. */
  25223. get materialDefines(): Nullable<MaterialDefines>;
  25224. /**
  25225. * Sets material defines used by the effect associated to the sub mesh
  25226. */
  25227. set materialDefines(defines: Nullable<MaterialDefines>);
  25228. /**
  25229. * Gets associated effect
  25230. */
  25231. get effect(): Nullable<Effect>;
  25232. /**
  25233. * Sets associated effect (effect used to render this submesh)
  25234. * @param effect defines the effect to associate with
  25235. * @param defines defines the set of defines used to compile this effect
  25236. */
  25237. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25238. /** @hidden */
  25239. _linesIndexCount: number;
  25240. private _mesh;
  25241. private _renderingMesh;
  25242. private _boundingInfo;
  25243. private _linesIndexBuffer;
  25244. /** @hidden */
  25245. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25246. /** @hidden */
  25247. _trianglePlanes: Plane[];
  25248. /** @hidden */
  25249. _lastColliderTransformMatrix: Nullable<Matrix>;
  25250. /** @hidden */
  25251. _renderId: number;
  25252. /** @hidden */
  25253. _alphaIndex: number;
  25254. /** @hidden */
  25255. _distanceToCamera: number;
  25256. /** @hidden */
  25257. _id: number;
  25258. private _currentMaterial;
  25259. /**
  25260. * Add a new submesh to a mesh
  25261. * @param materialIndex defines the material index to use
  25262. * @param verticesStart defines vertex index start
  25263. * @param verticesCount defines vertices count
  25264. * @param indexStart defines index start
  25265. * @param indexCount defines indices count
  25266. * @param mesh defines the parent mesh
  25267. * @param renderingMesh defines an optional rendering mesh
  25268. * @param createBoundingBox defines if bounding box should be created for this submesh
  25269. * @returns the new submesh
  25270. */
  25271. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25272. /**
  25273. * Creates a new submesh
  25274. * @param materialIndex defines the material index to use
  25275. * @param verticesStart defines vertex index start
  25276. * @param verticesCount defines vertices count
  25277. * @param indexStart defines index start
  25278. * @param indexCount defines indices count
  25279. * @param mesh defines the parent mesh
  25280. * @param renderingMesh defines an optional rendering mesh
  25281. * @param createBoundingBox defines if bounding box should be created for this submesh
  25282. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25283. */
  25284. constructor(
  25285. /** the material index to use */
  25286. materialIndex: number,
  25287. /** vertex index start */
  25288. verticesStart: number,
  25289. /** vertices count */
  25290. verticesCount: number,
  25291. /** index start */
  25292. indexStart: number,
  25293. /** indices count */
  25294. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25295. /**
  25296. * Returns true if this submesh covers the entire parent mesh
  25297. * @ignorenaming
  25298. */
  25299. get IsGlobal(): boolean;
  25300. /**
  25301. * Returns the submesh BoudingInfo object
  25302. * @returns current bounding info (or mesh's one if the submesh is global)
  25303. */
  25304. getBoundingInfo(): BoundingInfo;
  25305. /**
  25306. * Sets the submesh BoundingInfo
  25307. * @param boundingInfo defines the new bounding info to use
  25308. * @returns the SubMesh
  25309. */
  25310. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25311. /**
  25312. * Returns the mesh of the current submesh
  25313. * @return the parent mesh
  25314. */
  25315. getMesh(): AbstractMesh;
  25316. /**
  25317. * Returns the rendering mesh of the submesh
  25318. * @returns the rendering mesh (could be different from parent mesh)
  25319. */
  25320. getRenderingMesh(): Mesh;
  25321. /**
  25322. * Returns the replacement mesh of the submesh
  25323. * @returns the replacement mesh (could be different from parent mesh)
  25324. */
  25325. getReplacementMesh(): Nullable<AbstractMesh>;
  25326. /**
  25327. * Returns the effective mesh of the submesh
  25328. * @returns the effective mesh (could be different from parent mesh)
  25329. */
  25330. getEffectiveMesh(): AbstractMesh;
  25331. /**
  25332. * Returns the submesh material
  25333. * @returns null or the current material
  25334. */
  25335. getMaterial(): Nullable<Material>;
  25336. private _IsMultiMaterial;
  25337. /**
  25338. * Sets a new updated BoundingInfo object to the submesh
  25339. * @param data defines an optional position array to use to determine the bounding info
  25340. * @returns the SubMesh
  25341. */
  25342. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25343. /** @hidden */
  25344. _checkCollision(collider: Collider): boolean;
  25345. /**
  25346. * Updates the submesh BoundingInfo
  25347. * @param world defines the world matrix to use to update the bounding info
  25348. * @returns the submesh
  25349. */
  25350. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25351. /**
  25352. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25353. * @param frustumPlanes defines the frustum planes
  25354. * @returns true if the submesh is intersecting with the frustum
  25355. */
  25356. isInFrustum(frustumPlanes: Plane[]): boolean;
  25357. /**
  25358. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25359. * @param frustumPlanes defines the frustum planes
  25360. * @returns true if the submesh is inside the frustum
  25361. */
  25362. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25363. /**
  25364. * Renders the submesh
  25365. * @param enableAlphaMode defines if alpha needs to be used
  25366. * @returns the submesh
  25367. */
  25368. render(enableAlphaMode: boolean): SubMesh;
  25369. /**
  25370. * @hidden
  25371. */
  25372. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25373. /**
  25374. * Checks if the submesh intersects with a ray
  25375. * @param ray defines the ray to test
  25376. * @returns true is the passed ray intersects the submesh bounding box
  25377. */
  25378. canIntersects(ray: Ray): boolean;
  25379. /**
  25380. * Intersects current submesh with a ray
  25381. * @param ray defines the ray to test
  25382. * @param positions defines mesh's positions array
  25383. * @param indices defines mesh's indices array
  25384. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25385. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25386. * @returns intersection info or null if no intersection
  25387. */
  25388. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25389. /** @hidden */
  25390. private _intersectLines;
  25391. /** @hidden */
  25392. private _intersectUnIndexedLines;
  25393. /** @hidden */
  25394. private _intersectTriangles;
  25395. /** @hidden */
  25396. private _intersectUnIndexedTriangles;
  25397. /** @hidden */
  25398. _rebuild(): void;
  25399. /**
  25400. * Creates a new submesh from the passed mesh
  25401. * @param newMesh defines the new hosting mesh
  25402. * @param newRenderingMesh defines an optional rendering mesh
  25403. * @returns the new submesh
  25404. */
  25405. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25406. /**
  25407. * Release associated resources
  25408. */
  25409. dispose(): void;
  25410. /**
  25411. * Gets the class name
  25412. * @returns the string "SubMesh".
  25413. */
  25414. getClassName(): string;
  25415. /**
  25416. * Creates a new submesh from indices data
  25417. * @param materialIndex the index of the main mesh material
  25418. * @param startIndex the index where to start the copy in the mesh indices array
  25419. * @param indexCount the number of indices to copy then from the startIndex
  25420. * @param mesh the main mesh to create the submesh from
  25421. * @param renderingMesh the optional rendering mesh
  25422. * @returns a new submesh
  25423. */
  25424. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25425. }
  25426. }
  25427. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25428. /**
  25429. * Class used to represent data loading progression
  25430. */
  25431. export class SceneLoaderFlags {
  25432. private static _ForceFullSceneLoadingForIncremental;
  25433. private static _ShowLoadingScreen;
  25434. private static _CleanBoneMatrixWeights;
  25435. private static _loggingLevel;
  25436. /**
  25437. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25438. */
  25439. static get ForceFullSceneLoadingForIncremental(): boolean;
  25440. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25441. /**
  25442. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25443. */
  25444. static get ShowLoadingScreen(): boolean;
  25445. static set ShowLoadingScreen(value: boolean);
  25446. /**
  25447. * Defines the current logging level (while loading the scene)
  25448. * @ignorenaming
  25449. */
  25450. static get loggingLevel(): number;
  25451. static set loggingLevel(value: number);
  25452. /**
  25453. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25454. */
  25455. static get CleanBoneMatrixWeights(): boolean;
  25456. static set CleanBoneMatrixWeights(value: boolean);
  25457. }
  25458. }
  25459. declare module "babylonjs/Meshes/geometry" {
  25460. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25461. import { Scene } from "babylonjs/scene";
  25462. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25463. import { Engine } from "babylonjs/Engines/engine";
  25464. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25465. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25466. import { Effect } from "babylonjs/Materials/effect";
  25467. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25468. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25469. import { Mesh } from "babylonjs/Meshes/mesh";
  25470. /**
  25471. * Class used to store geometry data (vertex buffers + index buffer)
  25472. */
  25473. export class Geometry implements IGetSetVerticesData {
  25474. /**
  25475. * Gets or sets the ID of the geometry
  25476. */
  25477. id: string;
  25478. /**
  25479. * Gets or sets the unique ID of the geometry
  25480. */
  25481. uniqueId: number;
  25482. /**
  25483. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25484. */
  25485. delayLoadState: number;
  25486. /**
  25487. * Gets the file containing the data to load when running in delay load state
  25488. */
  25489. delayLoadingFile: Nullable<string>;
  25490. /**
  25491. * Callback called when the geometry is updated
  25492. */
  25493. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25494. private _scene;
  25495. private _engine;
  25496. private _meshes;
  25497. private _totalVertices;
  25498. /** @hidden */
  25499. _indices: IndicesArray;
  25500. /** @hidden */
  25501. _vertexBuffers: {
  25502. [key: string]: VertexBuffer;
  25503. };
  25504. private _isDisposed;
  25505. private _extend;
  25506. private _boundingBias;
  25507. /** @hidden */
  25508. _delayInfo: Array<string>;
  25509. private _indexBuffer;
  25510. private _indexBufferIsUpdatable;
  25511. /** @hidden */
  25512. _boundingInfo: Nullable<BoundingInfo>;
  25513. /** @hidden */
  25514. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25515. /** @hidden */
  25516. _softwareSkinningFrameId: number;
  25517. private _vertexArrayObjects;
  25518. private _updatable;
  25519. /** @hidden */
  25520. _positions: Nullable<Vector3[]>;
  25521. /**
  25522. * 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
  25523. */
  25524. get boundingBias(): Vector2;
  25525. /**
  25526. * 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
  25527. */
  25528. set boundingBias(value: Vector2);
  25529. /**
  25530. * Static function used to attach a new empty geometry to a mesh
  25531. * @param mesh defines the mesh to attach the geometry to
  25532. * @returns the new Geometry
  25533. */
  25534. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25535. /** Get the list of meshes using this geometry */
  25536. get meshes(): Mesh[];
  25537. /**
  25538. * Creates a new geometry
  25539. * @param id defines the unique ID
  25540. * @param scene defines the hosting scene
  25541. * @param vertexData defines the VertexData used to get geometry data
  25542. * @param updatable defines if geometry must be updatable (false by default)
  25543. * @param mesh defines the mesh that will be associated with the geometry
  25544. */
  25545. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25546. /**
  25547. * Gets the current extend of the geometry
  25548. */
  25549. get extend(): {
  25550. minimum: Vector3;
  25551. maximum: Vector3;
  25552. };
  25553. /**
  25554. * Gets the hosting scene
  25555. * @returns the hosting Scene
  25556. */
  25557. getScene(): Scene;
  25558. /**
  25559. * Gets the hosting engine
  25560. * @returns the hosting Engine
  25561. */
  25562. getEngine(): Engine;
  25563. /**
  25564. * Defines if the geometry is ready to use
  25565. * @returns true if the geometry is ready to be used
  25566. */
  25567. isReady(): boolean;
  25568. /**
  25569. * Gets a value indicating that the geometry should not be serialized
  25570. */
  25571. get doNotSerialize(): boolean;
  25572. /** @hidden */
  25573. _rebuild(): void;
  25574. /**
  25575. * Affects all geometry data in one call
  25576. * @param vertexData defines the geometry data
  25577. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25578. */
  25579. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25580. /**
  25581. * Set specific vertex data
  25582. * @param kind defines the data kind (Position, normal, etc...)
  25583. * @param data defines the vertex data to use
  25584. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25585. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25586. */
  25587. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25588. /**
  25589. * Removes a specific vertex data
  25590. * @param kind defines the data kind (Position, normal, etc...)
  25591. */
  25592. removeVerticesData(kind: string): void;
  25593. /**
  25594. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25595. * @param buffer defines the vertex buffer to use
  25596. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25597. */
  25598. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25599. /**
  25600. * Update a specific vertex buffer
  25601. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25602. * It will do nothing if the buffer is not updatable
  25603. * @param kind defines the data kind (Position, normal, etc...)
  25604. * @param data defines the data to use
  25605. * @param offset defines the offset in the target buffer where to store the data
  25606. * @param useBytes set to true if the offset is in bytes
  25607. */
  25608. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25609. /**
  25610. * Update a specific vertex buffer
  25611. * This function will create a new buffer if the current one is not updatable
  25612. * @param kind defines the data kind (Position, normal, etc...)
  25613. * @param data defines the data to use
  25614. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25615. */
  25616. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25617. private _updateBoundingInfo;
  25618. /** @hidden */
  25619. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25620. /**
  25621. * Gets total number of vertices
  25622. * @returns the total number of vertices
  25623. */
  25624. getTotalVertices(): number;
  25625. /**
  25626. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25627. * @param kind defines the data kind (Position, normal, etc...)
  25628. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25629. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25630. * @returns a float array containing vertex data
  25631. */
  25632. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25633. /**
  25634. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25635. * @param kind defines the data kind (Position, normal, etc...)
  25636. * @returns true if the vertex buffer with the specified kind is updatable
  25637. */
  25638. isVertexBufferUpdatable(kind: string): boolean;
  25639. /**
  25640. * Gets a specific vertex buffer
  25641. * @param kind defines the data kind (Position, normal, etc...)
  25642. * @returns a VertexBuffer
  25643. */
  25644. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25645. /**
  25646. * Returns all vertex buffers
  25647. * @return an object holding all vertex buffers indexed by kind
  25648. */
  25649. getVertexBuffers(): Nullable<{
  25650. [key: string]: VertexBuffer;
  25651. }>;
  25652. /**
  25653. * Gets a boolean indicating if specific vertex buffer is present
  25654. * @param kind defines the data kind (Position, normal, etc...)
  25655. * @returns true if data is present
  25656. */
  25657. isVerticesDataPresent(kind: string): boolean;
  25658. /**
  25659. * Gets a list of all attached data kinds (Position, normal, etc...)
  25660. * @returns a list of string containing all kinds
  25661. */
  25662. getVerticesDataKinds(): string[];
  25663. /**
  25664. * Update index buffer
  25665. * @param indices defines the indices to store in the index buffer
  25666. * @param offset defines the offset in the target buffer where to store the data
  25667. * @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)
  25668. */
  25669. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25670. /**
  25671. * Creates a new index buffer
  25672. * @param indices defines the indices to store in the index buffer
  25673. * @param totalVertices defines the total number of vertices (could be null)
  25674. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25675. */
  25676. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25677. /**
  25678. * Return the total number of indices
  25679. * @returns the total number of indices
  25680. */
  25681. getTotalIndices(): number;
  25682. /**
  25683. * Gets the index buffer array
  25684. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25686. * @returns the index buffer array
  25687. */
  25688. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25689. /**
  25690. * Gets the index buffer
  25691. * @return the index buffer
  25692. */
  25693. getIndexBuffer(): Nullable<DataBuffer>;
  25694. /** @hidden */
  25695. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25696. /**
  25697. * Release the associated resources for a specific mesh
  25698. * @param mesh defines the source mesh
  25699. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25700. */
  25701. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25702. /**
  25703. * Apply current geometry to a given mesh
  25704. * @param mesh defines the mesh to apply geometry to
  25705. */
  25706. applyToMesh(mesh: Mesh): void;
  25707. private _updateExtend;
  25708. private _applyToMesh;
  25709. private notifyUpdate;
  25710. /**
  25711. * Load the geometry if it was flagged as delay loaded
  25712. * @param scene defines the hosting scene
  25713. * @param onLoaded defines a callback called when the geometry is loaded
  25714. */
  25715. load(scene: Scene, onLoaded?: () => void): void;
  25716. private _queueLoad;
  25717. /**
  25718. * Invert the geometry to move from a right handed system to a left handed one.
  25719. */
  25720. toLeftHanded(): void;
  25721. /** @hidden */
  25722. _resetPointsArrayCache(): void;
  25723. /** @hidden */
  25724. _generatePointsArray(): boolean;
  25725. /**
  25726. * Gets a value indicating if the geometry is disposed
  25727. * @returns true if the geometry was disposed
  25728. */
  25729. isDisposed(): boolean;
  25730. private _disposeVertexArrayObjects;
  25731. /**
  25732. * Free all associated resources
  25733. */
  25734. dispose(): void;
  25735. /**
  25736. * Clone the current geometry into a new geometry
  25737. * @param id defines the unique ID of the new geometry
  25738. * @returns a new geometry object
  25739. */
  25740. copy(id: string): Geometry;
  25741. /**
  25742. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25743. * @return a JSON representation of the current geometry data (without the vertices data)
  25744. */
  25745. serialize(): any;
  25746. private toNumberArray;
  25747. /**
  25748. * Serialize all vertices data into a JSON oject
  25749. * @returns a JSON representation of the current geometry data
  25750. */
  25751. serializeVerticeData(): any;
  25752. /**
  25753. * Extracts a clone of a mesh geometry
  25754. * @param mesh defines the source mesh
  25755. * @param id defines the unique ID of the new geometry object
  25756. * @returns the new geometry object
  25757. */
  25758. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25759. /**
  25760. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25761. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25762. * Be aware Math.random() could cause collisions, but:
  25763. * "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"
  25764. * @returns a string containing a new GUID
  25765. */
  25766. static RandomId(): string;
  25767. /** @hidden */
  25768. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25769. private static _CleanMatricesWeights;
  25770. /**
  25771. * Create a new geometry from persisted data (Using .babylon file format)
  25772. * @param parsedVertexData defines the persisted data
  25773. * @param scene defines the hosting scene
  25774. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25775. * @returns the new geometry object
  25776. */
  25777. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25778. }
  25779. }
  25780. declare module "babylonjs/Meshes/mesh.vertexData" {
  25781. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25782. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25783. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25784. import { Geometry } from "babylonjs/Meshes/geometry";
  25785. import { Mesh } from "babylonjs/Meshes/mesh";
  25786. /**
  25787. * Define an interface for all classes that will get and set the data on vertices
  25788. */
  25789. export interface IGetSetVerticesData {
  25790. /**
  25791. * Gets a boolean indicating if specific vertex data is present
  25792. * @param kind defines the vertex data kind to use
  25793. * @returns true is data kind is present
  25794. */
  25795. isVerticesDataPresent(kind: string): boolean;
  25796. /**
  25797. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25798. * @param kind defines the data kind (Position, normal, etc...)
  25799. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25801. * @returns a float array containing vertex data
  25802. */
  25803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25804. /**
  25805. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25806. * @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.
  25807. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25808. * @returns the indices array or an empty array if the mesh has no geometry
  25809. */
  25810. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25811. /**
  25812. * Set specific vertex data
  25813. * @param kind defines the data kind (Position, normal, etc...)
  25814. * @param data defines the vertex data to use
  25815. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25816. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25817. */
  25818. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25819. /**
  25820. * Update a specific associated vertex buffer
  25821. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25822. * - VertexBuffer.PositionKind
  25823. * - VertexBuffer.UVKind
  25824. * - VertexBuffer.UV2Kind
  25825. * - VertexBuffer.UV3Kind
  25826. * - VertexBuffer.UV4Kind
  25827. * - VertexBuffer.UV5Kind
  25828. * - VertexBuffer.UV6Kind
  25829. * - VertexBuffer.ColorKind
  25830. * - VertexBuffer.MatricesIndicesKind
  25831. * - VertexBuffer.MatricesIndicesExtraKind
  25832. * - VertexBuffer.MatricesWeightsKind
  25833. * - VertexBuffer.MatricesWeightsExtraKind
  25834. * @param data defines the data source
  25835. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25836. * @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)
  25837. */
  25838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25839. /**
  25840. * Creates a new index buffer
  25841. * @param indices defines the indices to store in the index buffer
  25842. * @param totalVertices defines the total number of vertices (could be null)
  25843. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25844. */
  25845. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25846. }
  25847. /**
  25848. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25849. */
  25850. export class VertexData {
  25851. /**
  25852. * Mesh side orientation : usually the external or front surface
  25853. */
  25854. static readonly FRONTSIDE: number;
  25855. /**
  25856. * Mesh side orientation : usually the internal or back surface
  25857. */
  25858. static readonly BACKSIDE: number;
  25859. /**
  25860. * Mesh side orientation : both internal and external or front and back surfaces
  25861. */
  25862. static readonly DOUBLESIDE: number;
  25863. /**
  25864. * Mesh side orientation : by default, `FRONTSIDE`
  25865. */
  25866. static readonly DEFAULTSIDE: number;
  25867. /**
  25868. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25869. */
  25870. positions: Nullable<FloatArray>;
  25871. /**
  25872. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25873. */
  25874. normals: Nullable<FloatArray>;
  25875. /**
  25876. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25877. */
  25878. tangents: Nullable<FloatArray>;
  25879. /**
  25880. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25881. */
  25882. uvs: Nullable<FloatArray>;
  25883. /**
  25884. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25885. */
  25886. uvs2: Nullable<FloatArray>;
  25887. /**
  25888. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25889. */
  25890. uvs3: Nullable<FloatArray>;
  25891. /**
  25892. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25893. */
  25894. uvs4: Nullable<FloatArray>;
  25895. /**
  25896. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25897. */
  25898. uvs5: Nullable<FloatArray>;
  25899. /**
  25900. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25901. */
  25902. uvs6: Nullable<FloatArray>;
  25903. /**
  25904. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25905. */
  25906. colors: Nullable<FloatArray>;
  25907. /**
  25908. * 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).
  25909. */
  25910. matricesIndices: Nullable<FloatArray>;
  25911. /**
  25912. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25913. */
  25914. matricesWeights: Nullable<FloatArray>;
  25915. /**
  25916. * An array extending the number of possible indices
  25917. */
  25918. matricesIndicesExtra: Nullable<FloatArray>;
  25919. /**
  25920. * An array extending the number of possible weights when the number of indices is extended
  25921. */
  25922. matricesWeightsExtra: Nullable<FloatArray>;
  25923. /**
  25924. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25925. */
  25926. indices: Nullable<IndicesArray>;
  25927. /**
  25928. * Uses the passed data array to set the set the values for the specified kind of data
  25929. * @param data a linear array of floating numbers
  25930. * @param kind the type of data that is being set, eg positions, colors etc
  25931. */
  25932. set(data: FloatArray, kind: string): void;
  25933. /**
  25934. * Associates the vertexData to the passed Mesh.
  25935. * Sets it as updatable or not (default `false`)
  25936. * @param mesh the mesh the vertexData is applied to
  25937. * @param updatable when used and having the value true allows new data to update the vertexData
  25938. * @returns the VertexData
  25939. */
  25940. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25941. /**
  25942. * Associates the vertexData to the passed Geometry.
  25943. * Sets it as updatable or not (default `false`)
  25944. * @param geometry the geometry the vertexData is applied to
  25945. * @param updatable when used and having the value true allows new data to update the vertexData
  25946. * @returns VertexData
  25947. */
  25948. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25949. /**
  25950. * Updates the associated mesh
  25951. * @param mesh the mesh to be updated
  25952. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25953. * @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
  25954. * @returns VertexData
  25955. */
  25956. updateMesh(mesh: Mesh): VertexData;
  25957. /**
  25958. * Updates the associated geometry
  25959. * @param geometry the geometry to be updated
  25960. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25961. * @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
  25962. * @returns VertexData.
  25963. */
  25964. updateGeometry(geometry: Geometry): VertexData;
  25965. private _applyTo;
  25966. private _update;
  25967. /**
  25968. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25969. * @param matrix the transforming matrix
  25970. * @returns the VertexData
  25971. */
  25972. transform(matrix: Matrix): VertexData;
  25973. /**
  25974. * Merges the passed VertexData into the current one
  25975. * @param other the VertexData to be merged into the current one
  25976. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25977. * @returns the modified VertexData
  25978. */
  25979. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25980. private _mergeElement;
  25981. private _validate;
  25982. /**
  25983. * Serializes the VertexData
  25984. * @returns a serialized object
  25985. */
  25986. serialize(): any;
  25987. /**
  25988. * Extracts the vertexData from a mesh
  25989. * @param mesh the mesh from which to extract the VertexData
  25990. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25992. * @returns the object VertexData associated to the passed mesh
  25993. */
  25994. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25995. /**
  25996. * Extracts the vertexData from the geometry
  25997. * @param geometry the geometry from which to extract the VertexData
  25998. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25999. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26000. * @returns the object VertexData associated to the passed mesh
  26001. */
  26002. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26003. private static _ExtractFrom;
  26004. /**
  26005. * Creates the VertexData for a Ribbon
  26006. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26007. * * pathArray array of paths, each of which an array of successive Vector3
  26008. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26009. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26010. * * 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
  26011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26012. * * 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)
  26013. * * 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)
  26014. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26015. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26016. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26017. * @returns the VertexData of the ribbon
  26018. */
  26019. static CreateRibbon(options: {
  26020. pathArray: Vector3[][];
  26021. closeArray?: boolean;
  26022. closePath?: boolean;
  26023. offset?: number;
  26024. sideOrientation?: number;
  26025. frontUVs?: Vector4;
  26026. backUVs?: Vector4;
  26027. invertUV?: boolean;
  26028. uvs?: Vector2[];
  26029. colors?: Color4[];
  26030. }): VertexData;
  26031. /**
  26032. * Creates the VertexData for a box
  26033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26034. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26035. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26036. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26037. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26038. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26039. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26041. * * 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)
  26042. * * 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)
  26043. * @returns the VertexData of the box
  26044. */
  26045. static CreateBox(options: {
  26046. size?: number;
  26047. width?: number;
  26048. height?: number;
  26049. depth?: number;
  26050. faceUV?: Vector4[];
  26051. faceColors?: Color4[];
  26052. sideOrientation?: number;
  26053. frontUVs?: Vector4;
  26054. backUVs?: Vector4;
  26055. }): VertexData;
  26056. /**
  26057. * Creates the VertexData for a tiled box
  26058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26059. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26060. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26061. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26063. * @returns the VertexData of the box
  26064. */
  26065. static CreateTiledBox(options: {
  26066. pattern?: number;
  26067. width?: number;
  26068. height?: number;
  26069. depth?: number;
  26070. tileSize?: number;
  26071. tileWidth?: number;
  26072. tileHeight?: number;
  26073. alignHorizontal?: number;
  26074. alignVertical?: number;
  26075. faceUV?: Vector4[];
  26076. faceColors?: Color4[];
  26077. sideOrientation?: number;
  26078. }): VertexData;
  26079. /**
  26080. * Creates the VertexData for a tiled plane
  26081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26082. * * pattern a limited pattern arrangement depending on the number
  26083. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26084. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26085. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26087. * * 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)
  26088. * * 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)
  26089. * @returns the VertexData of the tiled plane
  26090. */
  26091. static CreateTiledPlane(options: {
  26092. pattern?: number;
  26093. tileSize?: number;
  26094. tileWidth?: number;
  26095. tileHeight?: number;
  26096. size?: number;
  26097. width?: number;
  26098. height?: number;
  26099. alignHorizontal?: number;
  26100. alignVertical?: number;
  26101. sideOrientation?: number;
  26102. frontUVs?: Vector4;
  26103. backUVs?: Vector4;
  26104. }): VertexData;
  26105. /**
  26106. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26108. * * segments sets the number of horizontal strips optional, default 32
  26109. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26110. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26111. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26112. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26113. * * 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
  26114. * * 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
  26115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26116. * * 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)
  26117. * * 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)
  26118. * @returns the VertexData of the ellipsoid
  26119. */
  26120. static CreateSphere(options: {
  26121. segments?: number;
  26122. diameter?: number;
  26123. diameterX?: number;
  26124. diameterY?: number;
  26125. diameterZ?: number;
  26126. arc?: number;
  26127. slice?: number;
  26128. sideOrientation?: number;
  26129. frontUVs?: Vector4;
  26130. backUVs?: Vector4;
  26131. }): VertexData;
  26132. /**
  26133. * Creates the VertexData for a cylinder, cone or prism
  26134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26135. * * height sets the height (y direction) of the cylinder, optional, default 2
  26136. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26137. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26138. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26139. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26140. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26141. * * 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
  26142. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26144. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26145. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26147. * * 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)
  26148. * * 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)
  26149. * @returns the VertexData of the cylinder, cone or prism
  26150. */
  26151. static CreateCylinder(options: {
  26152. height?: number;
  26153. diameterTop?: number;
  26154. diameterBottom?: number;
  26155. diameter?: number;
  26156. tessellation?: number;
  26157. subdivisions?: number;
  26158. arc?: number;
  26159. faceColors?: Color4[];
  26160. faceUV?: Vector4[];
  26161. hasRings?: boolean;
  26162. enclose?: boolean;
  26163. sideOrientation?: number;
  26164. frontUVs?: Vector4;
  26165. backUVs?: Vector4;
  26166. }): VertexData;
  26167. /**
  26168. * Creates the VertexData for a torus
  26169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26170. * * diameter the diameter of the torus, optional default 1
  26171. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26172. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26174. * * 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)
  26175. * * 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)
  26176. * @returns the VertexData of the torus
  26177. */
  26178. static CreateTorus(options: {
  26179. diameter?: number;
  26180. thickness?: number;
  26181. tessellation?: number;
  26182. sideOrientation?: number;
  26183. frontUVs?: Vector4;
  26184. backUVs?: Vector4;
  26185. }): VertexData;
  26186. /**
  26187. * Creates the VertexData of the LineSystem
  26188. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26189. * - lines an array of lines, each line being an array of successive Vector3
  26190. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26191. * @returns the VertexData of the LineSystem
  26192. */
  26193. static CreateLineSystem(options: {
  26194. lines: Vector3[][];
  26195. colors?: Nullable<Color4[][]>;
  26196. }): VertexData;
  26197. /**
  26198. * Create the VertexData for a DashedLines
  26199. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26200. * - points an array successive Vector3
  26201. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26202. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26203. * - dashNb the intended total number of dashes, optional, default 200
  26204. * @returns the VertexData for the DashedLines
  26205. */
  26206. static CreateDashedLines(options: {
  26207. points: Vector3[];
  26208. dashSize?: number;
  26209. gapSize?: number;
  26210. dashNb?: number;
  26211. }): VertexData;
  26212. /**
  26213. * Creates the VertexData for a Ground
  26214. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26215. * - width the width (x direction) of the ground, optional, default 1
  26216. * - height the height (z direction) of the ground, optional, default 1
  26217. * - subdivisions the number of subdivisions per side, optional, default 1
  26218. * @returns the VertexData of the Ground
  26219. */
  26220. static CreateGround(options: {
  26221. width?: number;
  26222. height?: number;
  26223. subdivisions?: number;
  26224. subdivisionsX?: number;
  26225. subdivisionsY?: number;
  26226. }): VertexData;
  26227. /**
  26228. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26229. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26230. * * xmin the ground minimum X coordinate, optional, default -1
  26231. * * zmin the ground minimum Z coordinate, optional, default -1
  26232. * * xmax the ground maximum X coordinate, optional, default 1
  26233. * * zmax the ground maximum Z coordinate, optional, default 1
  26234. * * 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}
  26235. * * 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}
  26236. * @returns the VertexData of the TiledGround
  26237. */
  26238. static CreateTiledGround(options: {
  26239. xmin: number;
  26240. zmin: number;
  26241. xmax: number;
  26242. zmax: number;
  26243. subdivisions?: {
  26244. w: number;
  26245. h: number;
  26246. };
  26247. precision?: {
  26248. w: number;
  26249. h: number;
  26250. };
  26251. }): VertexData;
  26252. /**
  26253. * Creates the VertexData of the Ground designed from a heightmap
  26254. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26255. * * width the width (x direction) of the ground
  26256. * * height the height (z direction) of the ground
  26257. * * subdivisions the number of subdivisions per side
  26258. * * minHeight the minimum altitude on the ground, optional, default 0
  26259. * * maxHeight the maximum altitude on the ground, optional default 1
  26260. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26261. * * buffer the array holding the image color data
  26262. * * bufferWidth the width of image
  26263. * * bufferHeight the height of image
  26264. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26265. * @returns the VertexData of the Ground designed from a heightmap
  26266. */
  26267. static CreateGroundFromHeightMap(options: {
  26268. width: number;
  26269. height: number;
  26270. subdivisions: number;
  26271. minHeight: number;
  26272. maxHeight: number;
  26273. colorFilter: Color3;
  26274. buffer: Uint8Array;
  26275. bufferWidth: number;
  26276. bufferHeight: number;
  26277. alphaFilter: number;
  26278. }): VertexData;
  26279. /**
  26280. * Creates the VertexData for a Plane
  26281. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26282. * * size sets the width and height of the plane to the value of size, optional default 1
  26283. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26284. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26286. * * 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)
  26287. * * 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)
  26288. * @returns the VertexData of the box
  26289. */
  26290. static CreatePlane(options: {
  26291. size?: number;
  26292. width?: number;
  26293. height?: number;
  26294. sideOrientation?: number;
  26295. frontUVs?: Vector4;
  26296. backUVs?: Vector4;
  26297. }): VertexData;
  26298. /**
  26299. * Creates the VertexData of the Disc or regular Polygon
  26300. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26301. * * radius the radius of the disc, optional default 0.5
  26302. * * tessellation the number of polygon sides, optional, default 64
  26303. * * 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
  26304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26305. * * 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)
  26306. * * 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)
  26307. * @returns the VertexData of the box
  26308. */
  26309. static CreateDisc(options: {
  26310. radius?: number;
  26311. tessellation?: number;
  26312. arc?: number;
  26313. sideOrientation?: number;
  26314. frontUVs?: Vector4;
  26315. backUVs?: Vector4;
  26316. }): VertexData;
  26317. /**
  26318. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26319. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26320. * @param polygon a mesh built from polygonTriangulation.build()
  26321. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26323. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26324. * @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)
  26325. * @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)
  26326. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26327. * @returns the VertexData of the Polygon
  26328. */
  26329. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26330. /**
  26331. * Creates the VertexData of the IcoSphere
  26332. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26333. * * radius the radius of the IcoSphere, optional default 1
  26334. * * radiusX allows stretching in the x direction, optional, default radius
  26335. * * radiusY allows stretching in the y direction, optional, default radius
  26336. * * radiusZ allows stretching in the z direction, optional, default radius
  26337. * * flat when true creates a flat shaded mesh, optional, default true
  26338. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26340. * * 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)
  26341. * * 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)
  26342. * @returns the VertexData of the IcoSphere
  26343. */
  26344. static CreateIcoSphere(options: {
  26345. radius?: number;
  26346. radiusX?: number;
  26347. radiusY?: number;
  26348. radiusZ?: number;
  26349. flat?: boolean;
  26350. subdivisions?: number;
  26351. sideOrientation?: number;
  26352. frontUVs?: Vector4;
  26353. backUVs?: Vector4;
  26354. }): VertexData;
  26355. /**
  26356. * Creates the VertexData for a Polyhedron
  26357. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26358. * * type provided types are:
  26359. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26360. * * 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)
  26361. * * size the size of the IcoSphere, optional default 1
  26362. * * sizeX allows stretching in the x direction, optional, default size
  26363. * * sizeY allows stretching in the y direction, optional, default size
  26364. * * sizeZ allows stretching in the z direction, optional, default size
  26365. * * 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
  26366. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26367. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26368. * * flat when true creates a flat shaded mesh, optional, default true
  26369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26371. * * 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)
  26372. * * 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)
  26373. * @returns the VertexData of the Polyhedron
  26374. */
  26375. static CreatePolyhedron(options: {
  26376. type?: number;
  26377. size?: number;
  26378. sizeX?: number;
  26379. sizeY?: number;
  26380. sizeZ?: number;
  26381. custom?: any;
  26382. faceUV?: Vector4[];
  26383. faceColors?: Color4[];
  26384. flat?: boolean;
  26385. sideOrientation?: number;
  26386. frontUVs?: Vector4;
  26387. backUVs?: Vector4;
  26388. }): VertexData;
  26389. /**
  26390. * Creates the VertexData for a TorusKnot
  26391. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26392. * * radius the radius of the torus knot, optional, default 2
  26393. * * tube the thickness of the tube, optional, default 0.5
  26394. * * radialSegments the number of sides on each tube segments, optional, default 32
  26395. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26396. * * p the number of windings around the z axis, optional, default 2
  26397. * * q the number of windings around the x axis, optional, default 3
  26398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26399. * * 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)
  26400. * * 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)
  26401. * @returns the VertexData of the Torus Knot
  26402. */
  26403. static CreateTorusKnot(options: {
  26404. radius?: number;
  26405. tube?: number;
  26406. radialSegments?: number;
  26407. tubularSegments?: number;
  26408. p?: number;
  26409. q?: number;
  26410. sideOrientation?: number;
  26411. frontUVs?: Vector4;
  26412. backUVs?: Vector4;
  26413. }): VertexData;
  26414. /**
  26415. * Compute normals for given positions and indices
  26416. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26417. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26418. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26419. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26420. * * facetNormals : optional array of facet normals (vector3)
  26421. * * facetPositions : optional array of facet positions (vector3)
  26422. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26423. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26424. * * bInfo : optional bounding info, required for facetPartitioning computation
  26425. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26426. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26427. * * useRightHandedSystem: optional boolean to for right handed system computation
  26428. * * depthSort : optional boolean to enable the facet depth sort computation
  26429. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26430. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26431. */
  26432. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26433. facetNormals?: any;
  26434. facetPositions?: any;
  26435. facetPartitioning?: any;
  26436. ratio?: number;
  26437. bInfo?: any;
  26438. bbSize?: Vector3;
  26439. subDiv?: any;
  26440. useRightHandedSystem?: boolean;
  26441. depthSort?: boolean;
  26442. distanceTo?: Vector3;
  26443. depthSortedFacets?: any;
  26444. }): void;
  26445. /** @hidden */
  26446. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26447. /**
  26448. * Applies VertexData created from the imported parameters to the geometry
  26449. * @param parsedVertexData the parsed data from an imported file
  26450. * @param geometry the geometry to apply the VertexData to
  26451. */
  26452. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26453. }
  26454. }
  26455. declare module "babylonjs/Morph/morphTarget" {
  26456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26457. import { Observable } from "babylonjs/Misc/observable";
  26458. import { Nullable, FloatArray } from "babylonjs/types";
  26459. import { Scene } from "babylonjs/scene";
  26460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26461. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26462. /**
  26463. * Defines a target to use with MorphTargetManager
  26464. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26465. */
  26466. export class MorphTarget implements IAnimatable {
  26467. /** defines the name of the target */
  26468. name: string;
  26469. /**
  26470. * Gets or sets the list of animations
  26471. */
  26472. animations: import("babylonjs/Animations/animation").Animation[];
  26473. private _scene;
  26474. private _positions;
  26475. private _normals;
  26476. private _tangents;
  26477. private _uvs;
  26478. private _influence;
  26479. private _uniqueId;
  26480. /**
  26481. * Observable raised when the influence changes
  26482. */
  26483. onInfluenceChanged: Observable<boolean>;
  26484. /** @hidden */
  26485. _onDataLayoutChanged: Observable<void>;
  26486. /**
  26487. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26488. */
  26489. get influence(): number;
  26490. set influence(influence: number);
  26491. /**
  26492. * Gets or sets the id of the morph Target
  26493. */
  26494. id: string;
  26495. private _animationPropertiesOverride;
  26496. /**
  26497. * Gets or sets the animation properties override
  26498. */
  26499. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26500. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26501. /**
  26502. * Creates a new MorphTarget
  26503. * @param name defines the name of the target
  26504. * @param influence defines the influence to use
  26505. * @param scene defines the scene the morphtarget belongs to
  26506. */
  26507. constructor(
  26508. /** defines the name of the target */
  26509. name: string, influence?: number, scene?: Nullable<Scene>);
  26510. /**
  26511. * Gets the unique ID of this manager
  26512. */
  26513. get uniqueId(): number;
  26514. /**
  26515. * Gets a boolean defining if the target contains position data
  26516. */
  26517. get hasPositions(): boolean;
  26518. /**
  26519. * Gets a boolean defining if the target contains normal data
  26520. */
  26521. get hasNormals(): boolean;
  26522. /**
  26523. * Gets a boolean defining if the target contains tangent data
  26524. */
  26525. get hasTangents(): boolean;
  26526. /**
  26527. * Gets a boolean defining if the target contains texture coordinates data
  26528. */
  26529. get hasUVs(): boolean;
  26530. /**
  26531. * Affects position data to this target
  26532. * @param data defines the position data to use
  26533. */
  26534. setPositions(data: Nullable<FloatArray>): void;
  26535. /**
  26536. * Gets the position data stored in this target
  26537. * @returns a FloatArray containing the position data (or null if not present)
  26538. */
  26539. getPositions(): Nullable<FloatArray>;
  26540. /**
  26541. * Affects normal data to this target
  26542. * @param data defines the normal data to use
  26543. */
  26544. setNormals(data: Nullable<FloatArray>): void;
  26545. /**
  26546. * Gets the normal data stored in this target
  26547. * @returns a FloatArray containing the normal data (or null if not present)
  26548. */
  26549. getNormals(): Nullable<FloatArray>;
  26550. /**
  26551. * Affects tangent data to this target
  26552. * @param data defines the tangent data to use
  26553. */
  26554. setTangents(data: Nullable<FloatArray>): void;
  26555. /**
  26556. * Gets the tangent data stored in this target
  26557. * @returns a FloatArray containing the tangent data (or null if not present)
  26558. */
  26559. getTangents(): Nullable<FloatArray>;
  26560. /**
  26561. * Affects texture coordinates data to this target
  26562. * @param data defines the texture coordinates data to use
  26563. */
  26564. setUVs(data: Nullable<FloatArray>): void;
  26565. /**
  26566. * Gets the texture coordinates data stored in this target
  26567. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26568. */
  26569. getUVs(): Nullable<FloatArray>;
  26570. /**
  26571. * Clone the current target
  26572. * @returns a new MorphTarget
  26573. */
  26574. clone(): MorphTarget;
  26575. /**
  26576. * Serializes the current target into a Serialization object
  26577. * @returns the serialized object
  26578. */
  26579. serialize(): any;
  26580. /**
  26581. * Returns the string "MorphTarget"
  26582. * @returns "MorphTarget"
  26583. */
  26584. getClassName(): string;
  26585. /**
  26586. * Creates a new target from serialized data
  26587. * @param serializationObject defines the serialized data to use
  26588. * @returns a new MorphTarget
  26589. */
  26590. static Parse(serializationObject: any): MorphTarget;
  26591. /**
  26592. * Creates a MorphTarget from mesh data
  26593. * @param mesh defines the source mesh
  26594. * @param name defines the name to use for the new target
  26595. * @param influence defines the influence to attach to the target
  26596. * @returns a new MorphTarget
  26597. */
  26598. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26599. }
  26600. }
  26601. declare module "babylonjs/Morph/morphTargetManager" {
  26602. import { Nullable } from "babylonjs/types";
  26603. import { Scene } from "babylonjs/scene";
  26604. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26605. /**
  26606. * This class is used to deform meshes using morphing between different targets
  26607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26608. */
  26609. export class MorphTargetManager {
  26610. private _targets;
  26611. private _targetInfluenceChangedObservers;
  26612. private _targetDataLayoutChangedObservers;
  26613. private _activeTargets;
  26614. private _scene;
  26615. private _influences;
  26616. private _supportsNormals;
  26617. private _supportsTangents;
  26618. private _supportsUVs;
  26619. private _vertexCount;
  26620. private _uniqueId;
  26621. private _tempInfluences;
  26622. /**
  26623. * Gets or sets a boolean indicating if normals must be morphed
  26624. */
  26625. enableNormalMorphing: boolean;
  26626. /**
  26627. * Gets or sets a boolean indicating if tangents must be morphed
  26628. */
  26629. enableTangentMorphing: boolean;
  26630. /**
  26631. * Gets or sets a boolean indicating if UV must be morphed
  26632. */
  26633. enableUVMorphing: boolean;
  26634. /**
  26635. * Creates a new MorphTargetManager
  26636. * @param scene defines the current scene
  26637. */
  26638. constructor(scene?: Nullable<Scene>);
  26639. /**
  26640. * Gets the unique ID of this manager
  26641. */
  26642. get uniqueId(): number;
  26643. /**
  26644. * Gets the number of vertices handled by this manager
  26645. */
  26646. get vertexCount(): number;
  26647. /**
  26648. * Gets a boolean indicating if this manager supports morphing of normals
  26649. */
  26650. get supportsNormals(): boolean;
  26651. /**
  26652. * Gets a boolean indicating if this manager supports morphing of tangents
  26653. */
  26654. get supportsTangents(): boolean;
  26655. /**
  26656. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26657. */
  26658. get supportsUVs(): boolean;
  26659. /**
  26660. * Gets the number of targets stored in this manager
  26661. */
  26662. get numTargets(): number;
  26663. /**
  26664. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26665. */
  26666. get numInfluencers(): number;
  26667. /**
  26668. * Gets the list of influences (one per target)
  26669. */
  26670. get influences(): Float32Array;
  26671. /**
  26672. * Gets the active target at specified index. An active target is a target with an influence > 0
  26673. * @param index defines the index to check
  26674. * @returns the requested target
  26675. */
  26676. getActiveTarget(index: number): MorphTarget;
  26677. /**
  26678. * Gets the target at specified index
  26679. * @param index defines the index to check
  26680. * @returns the requested target
  26681. */
  26682. getTarget(index: number): MorphTarget;
  26683. /**
  26684. * Add a new target to this manager
  26685. * @param target defines the target to add
  26686. */
  26687. addTarget(target: MorphTarget): void;
  26688. /**
  26689. * Removes a target from the manager
  26690. * @param target defines the target to remove
  26691. */
  26692. removeTarget(target: MorphTarget): void;
  26693. /**
  26694. * Clone the current manager
  26695. * @returns a new MorphTargetManager
  26696. */
  26697. clone(): MorphTargetManager;
  26698. /**
  26699. * Serializes the current manager into a Serialization object
  26700. * @returns the serialized object
  26701. */
  26702. serialize(): any;
  26703. private _syncActiveTargets;
  26704. /**
  26705. * Syncrhonize the targets with all the meshes using this morph target manager
  26706. */
  26707. synchronize(): void;
  26708. /**
  26709. * Creates a new MorphTargetManager from serialized data
  26710. * @param serializationObject defines the serialized data
  26711. * @param scene defines the hosting scene
  26712. * @returns the new MorphTargetManager
  26713. */
  26714. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26715. }
  26716. }
  26717. declare module "babylonjs/Meshes/meshLODLevel" {
  26718. import { Mesh } from "babylonjs/Meshes/mesh";
  26719. import { Nullable } from "babylonjs/types";
  26720. /**
  26721. * Class used to represent a specific level of detail of a mesh
  26722. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26723. */
  26724. export class MeshLODLevel {
  26725. /** Defines the distance where this level should start being displayed */
  26726. distance: number;
  26727. /** Defines the mesh to use to render this level */
  26728. mesh: Nullable<Mesh>;
  26729. /**
  26730. * Creates a new LOD level
  26731. * @param distance defines the distance where this level should star being displayed
  26732. * @param mesh defines the mesh to use to render this level
  26733. */
  26734. constructor(
  26735. /** Defines the distance where this level should start being displayed */
  26736. distance: number,
  26737. /** Defines the mesh to use to render this level */
  26738. mesh: Nullable<Mesh>);
  26739. }
  26740. }
  26741. declare module "babylonjs/Misc/canvasGenerator" {
  26742. /**
  26743. * Helper class used to generate a canvas to manipulate images
  26744. */
  26745. export class CanvasGenerator {
  26746. /**
  26747. * Create a new canvas (or offscreen canvas depending on the context)
  26748. * @param width defines the expected width
  26749. * @param height defines the expected height
  26750. * @return a new canvas or offscreen canvas
  26751. */
  26752. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26753. }
  26754. }
  26755. declare module "babylonjs/Meshes/groundMesh" {
  26756. import { Scene } from "babylonjs/scene";
  26757. import { Vector3 } from "babylonjs/Maths/math.vector";
  26758. import { Mesh } from "babylonjs/Meshes/mesh";
  26759. /**
  26760. * Mesh representing the gorund
  26761. */
  26762. export class GroundMesh extends Mesh {
  26763. /** If octree should be generated */
  26764. generateOctree: boolean;
  26765. private _heightQuads;
  26766. /** @hidden */
  26767. _subdivisionsX: number;
  26768. /** @hidden */
  26769. _subdivisionsY: number;
  26770. /** @hidden */
  26771. _width: number;
  26772. /** @hidden */
  26773. _height: number;
  26774. /** @hidden */
  26775. _minX: number;
  26776. /** @hidden */
  26777. _maxX: number;
  26778. /** @hidden */
  26779. _minZ: number;
  26780. /** @hidden */
  26781. _maxZ: number;
  26782. constructor(name: string, scene: Scene);
  26783. /**
  26784. * "GroundMesh"
  26785. * @returns "GroundMesh"
  26786. */
  26787. getClassName(): string;
  26788. /**
  26789. * The minimum of x and y subdivisions
  26790. */
  26791. get subdivisions(): number;
  26792. /**
  26793. * X subdivisions
  26794. */
  26795. get subdivisionsX(): number;
  26796. /**
  26797. * Y subdivisions
  26798. */
  26799. get subdivisionsY(): number;
  26800. /**
  26801. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26802. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26803. * @param chunksCount the number of subdivisions for x and y
  26804. * @param octreeBlocksSize (Default: 32)
  26805. */
  26806. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26807. /**
  26808. * Returns a height (y) value in the Worl system :
  26809. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26810. * @param x x coordinate
  26811. * @param z z coordinate
  26812. * @returns the ground y position if (x, z) are outside the ground surface.
  26813. */
  26814. getHeightAtCoordinates(x: number, z: number): number;
  26815. /**
  26816. * Returns a normalized vector (Vector3) orthogonal to the ground
  26817. * at the ground coordinates (x, z) expressed in the World system.
  26818. * @param x x coordinate
  26819. * @param z z coordinate
  26820. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26821. */
  26822. getNormalAtCoordinates(x: number, z: number): Vector3;
  26823. /**
  26824. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26825. * at the ground coordinates (x, z) expressed in the World system.
  26826. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26827. * @param x x coordinate
  26828. * @param z z coordinate
  26829. * @param ref vector to store the result
  26830. * @returns the GroundMesh.
  26831. */
  26832. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26833. /**
  26834. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26835. * if the ground has been updated.
  26836. * This can be used in the render loop.
  26837. * @returns the GroundMesh.
  26838. */
  26839. updateCoordinateHeights(): GroundMesh;
  26840. private _getFacetAt;
  26841. private _initHeightQuads;
  26842. private _computeHeightQuads;
  26843. /**
  26844. * Serializes this ground mesh
  26845. * @param serializationObject object to write serialization to
  26846. */
  26847. serialize(serializationObject: any): void;
  26848. /**
  26849. * Parses a serialized ground mesh
  26850. * @param parsedMesh the serialized mesh
  26851. * @param scene the scene to create the ground mesh in
  26852. * @returns the created ground mesh
  26853. */
  26854. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26855. }
  26856. }
  26857. declare module "babylonjs/Physics/physicsJoint" {
  26858. import { Vector3 } from "babylonjs/Maths/math.vector";
  26859. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26860. /**
  26861. * Interface for Physics-Joint data
  26862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26863. */
  26864. export interface PhysicsJointData {
  26865. /**
  26866. * The main pivot of the joint
  26867. */
  26868. mainPivot?: Vector3;
  26869. /**
  26870. * The connected pivot of the joint
  26871. */
  26872. connectedPivot?: Vector3;
  26873. /**
  26874. * The main axis of the joint
  26875. */
  26876. mainAxis?: Vector3;
  26877. /**
  26878. * The connected axis of the joint
  26879. */
  26880. connectedAxis?: Vector3;
  26881. /**
  26882. * The collision of the joint
  26883. */
  26884. collision?: boolean;
  26885. /**
  26886. * Native Oimo/Cannon/Energy data
  26887. */
  26888. nativeParams?: any;
  26889. }
  26890. /**
  26891. * This is a holder class for the physics joint created by the physics plugin
  26892. * It holds a set of functions to control the underlying joint
  26893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26894. */
  26895. export class PhysicsJoint {
  26896. /**
  26897. * The type of the physics joint
  26898. */
  26899. type: number;
  26900. /**
  26901. * The data for the physics joint
  26902. */
  26903. jointData: PhysicsJointData;
  26904. private _physicsJoint;
  26905. protected _physicsPlugin: IPhysicsEnginePlugin;
  26906. /**
  26907. * Initializes the physics joint
  26908. * @param type The type of the physics joint
  26909. * @param jointData The data for the physics joint
  26910. */
  26911. constructor(
  26912. /**
  26913. * The type of the physics joint
  26914. */
  26915. type: number,
  26916. /**
  26917. * The data for the physics joint
  26918. */
  26919. jointData: PhysicsJointData);
  26920. /**
  26921. * Gets the physics joint
  26922. */
  26923. get physicsJoint(): any;
  26924. /**
  26925. * Sets the physics joint
  26926. */
  26927. set physicsJoint(newJoint: any);
  26928. /**
  26929. * Sets the physics plugin
  26930. */
  26931. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26932. /**
  26933. * Execute a function that is physics-plugin specific.
  26934. * @param {Function} func the function that will be executed.
  26935. * It accepts two parameters: the physics world and the physics joint
  26936. */
  26937. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26938. /**
  26939. * Distance-Joint type
  26940. */
  26941. static DistanceJoint: number;
  26942. /**
  26943. * Hinge-Joint type
  26944. */
  26945. static HingeJoint: number;
  26946. /**
  26947. * Ball-and-Socket joint type
  26948. */
  26949. static BallAndSocketJoint: number;
  26950. /**
  26951. * Wheel-Joint type
  26952. */
  26953. static WheelJoint: number;
  26954. /**
  26955. * Slider-Joint type
  26956. */
  26957. static SliderJoint: number;
  26958. /**
  26959. * Prismatic-Joint type
  26960. */
  26961. static PrismaticJoint: number;
  26962. /**
  26963. * Universal-Joint type
  26964. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26965. */
  26966. static UniversalJoint: number;
  26967. /**
  26968. * Hinge-Joint 2 type
  26969. */
  26970. static Hinge2Joint: number;
  26971. /**
  26972. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26973. */
  26974. static PointToPointJoint: number;
  26975. /**
  26976. * Spring-Joint type
  26977. */
  26978. static SpringJoint: number;
  26979. /**
  26980. * Lock-Joint type
  26981. */
  26982. static LockJoint: number;
  26983. }
  26984. /**
  26985. * A class representing a physics distance joint
  26986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26987. */
  26988. export class DistanceJoint extends PhysicsJoint {
  26989. /**
  26990. *
  26991. * @param jointData The data for the Distance-Joint
  26992. */
  26993. constructor(jointData: DistanceJointData);
  26994. /**
  26995. * Update the predefined distance.
  26996. * @param maxDistance The maximum preferred distance
  26997. * @param minDistance The minimum preferred distance
  26998. */
  26999. updateDistance(maxDistance: number, minDistance?: number): void;
  27000. }
  27001. /**
  27002. * Represents a Motor-Enabled Joint
  27003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27004. */
  27005. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27006. /**
  27007. * Initializes the Motor-Enabled Joint
  27008. * @param type The type of the joint
  27009. * @param jointData The physica joint data for the joint
  27010. */
  27011. constructor(type: number, jointData: PhysicsJointData);
  27012. /**
  27013. * Set the motor values.
  27014. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27015. * @param force the force to apply
  27016. * @param maxForce max force for this motor.
  27017. */
  27018. setMotor(force?: number, maxForce?: number): void;
  27019. /**
  27020. * Set the motor's limits.
  27021. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27022. * @param upperLimit The upper limit of the motor
  27023. * @param lowerLimit The lower limit of the motor
  27024. */
  27025. setLimit(upperLimit: number, lowerLimit?: number): void;
  27026. }
  27027. /**
  27028. * This class represents a single physics Hinge-Joint
  27029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27030. */
  27031. export class HingeJoint extends MotorEnabledJoint {
  27032. /**
  27033. * Initializes the Hinge-Joint
  27034. * @param jointData The joint data for the Hinge-Joint
  27035. */
  27036. constructor(jointData: PhysicsJointData);
  27037. /**
  27038. * Set the motor values.
  27039. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27040. * @param {number} force the force to apply
  27041. * @param {number} maxForce max force for this motor.
  27042. */
  27043. setMotor(force?: number, maxForce?: number): void;
  27044. /**
  27045. * Set the motor's limits.
  27046. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27047. * @param upperLimit The upper limit of the motor
  27048. * @param lowerLimit The lower limit of the motor
  27049. */
  27050. setLimit(upperLimit: number, lowerLimit?: number): void;
  27051. }
  27052. /**
  27053. * This class represents a dual hinge physics joint (same as wheel joint)
  27054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27055. */
  27056. export class Hinge2Joint extends MotorEnabledJoint {
  27057. /**
  27058. * Initializes the Hinge2-Joint
  27059. * @param jointData The joint data for the Hinge2-Joint
  27060. */
  27061. constructor(jointData: PhysicsJointData);
  27062. /**
  27063. * Set the motor values.
  27064. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27065. * @param {number} targetSpeed the speed the motor is to reach
  27066. * @param {number} maxForce max force for this motor.
  27067. * @param {motorIndex} the motor's index, 0 or 1.
  27068. */
  27069. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27070. /**
  27071. * Set the motor limits.
  27072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27073. * @param {number} upperLimit the upper limit
  27074. * @param {number} lowerLimit lower limit
  27075. * @param {motorIndex} the motor's index, 0 or 1.
  27076. */
  27077. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27078. }
  27079. /**
  27080. * Interface for a motor enabled joint
  27081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27082. */
  27083. export interface IMotorEnabledJoint {
  27084. /**
  27085. * Physics joint
  27086. */
  27087. physicsJoint: any;
  27088. /**
  27089. * Sets the motor of the motor-enabled joint
  27090. * @param force The force of the motor
  27091. * @param maxForce The maximum force of the motor
  27092. * @param motorIndex The index of the motor
  27093. */
  27094. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27095. /**
  27096. * Sets the limit of the motor
  27097. * @param upperLimit The upper limit of the motor
  27098. * @param lowerLimit The lower limit of the motor
  27099. * @param motorIndex The index of the motor
  27100. */
  27101. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27102. }
  27103. /**
  27104. * Joint data for a Distance-Joint
  27105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27106. */
  27107. export interface DistanceJointData extends PhysicsJointData {
  27108. /**
  27109. * Max distance the 2 joint objects can be apart
  27110. */
  27111. maxDistance: number;
  27112. }
  27113. /**
  27114. * Joint data from a spring joint
  27115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27116. */
  27117. export interface SpringJointData extends PhysicsJointData {
  27118. /**
  27119. * Length of the spring
  27120. */
  27121. length: number;
  27122. /**
  27123. * Stiffness of the spring
  27124. */
  27125. stiffness: number;
  27126. /**
  27127. * Damping of the spring
  27128. */
  27129. damping: number;
  27130. /** this callback will be called when applying the force to the impostors. */
  27131. forceApplicationCallback: () => void;
  27132. }
  27133. }
  27134. declare module "babylonjs/Physics/physicsRaycastResult" {
  27135. import { Vector3 } from "babylonjs/Maths/math.vector";
  27136. /**
  27137. * Holds the data for the raycast result
  27138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27139. */
  27140. export class PhysicsRaycastResult {
  27141. private _hasHit;
  27142. private _hitDistance;
  27143. private _hitNormalWorld;
  27144. private _hitPointWorld;
  27145. private _rayFromWorld;
  27146. private _rayToWorld;
  27147. /**
  27148. * Gets if there was a hit
  27149. */
  27150. get hasHit(): boolean;
  27151. /**
  27152. * Gets the distance from the hit
  27153. */
  27154. get hitDistance(): number;
  27155. /**
  27156. * Gets the hit normal/direction in the world
  27157. */
  27158. get hitNormalWorld(): Vector3;
  27159. /**
  27160. * Gets the hit point in the world
  27161. */
  27162. get hitPointWorld(): Vector3;
  27163. /**
  27164. * Gets the ray "start point" of the ray in the world
  27165. */
  27166. get rayFromWorld(): Vector3;
  27167. /**
  27168. * Gets the ray "end point" of the ray in the world
  27169. */
  27170. get rayToWorld(): Vector3;
  27171. /**
  27172. * Sets the hit data (normal & point in world space)
  27173. * @param hitNormalWorld defines the normal in world space
  27174. * @param hitPointWorld defines the point in world space
  27175. */
  27176. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27177. /**
  27178. * Sets the distance from the start point to the hit point
  27179. * @param distance
  27180. */
  27181. setHitDistance(distance: number): void;
  27182. /**
  27183. * Calculates the distance manually
  27184. */
  27185. calculateHitDistance(): void;
  27186. /**
  27187. * Resets all the values to default
  27188. * @param from The from point on world space
  27189. * @param to The to point on world space
  27190. */
  27191. reset(from?: Vector3, to?: Vector3): void;
  27192. }
  27193. /**
  27194. * Interface for the size containing width and height
  27195. */
  27196. interface IXYZ {
  27197. /**
  27198. * X
  27199. */
  27200. x: number;
  27201. /**
  27202. * Y
  27203. */
  27204. y: number;
  27205. /**
  27206. * Z
  27207. */
  27208. z: number;
  27209. }
  27210. }
  27211. declare module "babylonjs/Physics/IPhysicsEngine" {
  27212. import { Nullable } from "babylonjs/types";
  27213. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27215. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27216. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27217. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27218. /**
  27219. * Interface used to describe a physics joint
  27220. */
  27221. export interface PhysicsImpostorJoint {
  27222. /** Defines the main impostor to which the joint is linked */
  27223. mainImpostor: PhysicsImpostor;
  27224. /** Defines the impostor that is connected to the main impostor using this joint */
  27225. connectedImpostor: PhysicsImpostor;
  27226. /** Defines the joint itself */
  27227. joint: PhysicsJoint;
  27228. }
  27229. /** @hidden */
  27230. export interface IPhysicsEnginePlugin {
  27231. world: any;
  27232. name: string;
  27233. setGravity(gravity: Vector3): void;
  27234. setTimeStep(timeStep: number): void;
  27235. getTimeStep(): number;
  27236. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27237. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27239. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27240. removePhysicsBody(impostor: PhysicsImpostor): void;
  27241. generateJoint(joint: PhysicsImpostorJoint): void;
  27242. removeJoint(joint: PhysicsImpostorJoint): void;
  27243. isSupported(): boolean;
  27244. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27245. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27246. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27247. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27248. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27249. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27250. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27251. getBodyMass(impostor: PhysicsImpostor): number;
  27252. getBodyFriction(impostor: PhysicsImpostor): number;
  27253. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27254. getBodyRestitution(impostor: PhysicsImpostor): number;
  27255. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27256. getBodyPressure?(impostor: PhysicsImpostor): number;
  27257. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27258. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27259. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27260. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27261. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27262. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27263. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27264. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27265. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27266. sleepBody(impostor: PhysicsImpostor): void;
  27267. wakeUpBody(impostor: PhysicsImpostor): void;
  27268. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27269. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27270. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27271. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27272. getRadius(impostor: PhysicsImpostor): number;
  27273. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27274. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27275. dispose(): void;
  27276. }
  27277. /**
  27278. * Interface used to define a physics engine
  27279. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27280. */
  27281. export interface IPhysicsEngine {
  27282. /**
  27283. * Gets the gravity vector used by the simulation
  27284. */
  27285. gravity: Vector3;
  27286. /**
  27287. * Sets the gravity vector used by the simulation
  27288. * @param gravity defines the gravity vector to use
  27289. */
  27290. setGravity(gravity: Vector3): void;
  27291. /**
  27292. * Set the time step of the physics engine.
  27293. * Default is 1/60.
  27294. * To slow it down, enter 1/600 for example.
  27295. * To speed it up, 1/30
  27296. * @param newTimeStep the new timestep to apply to this world.
  27297. */
  27298. setTimeStep(newTimeStep: number): void;
  27299. /**
  27300. * Get the time step of the physics engine.
  27301. * @returns the current time step
  27302. */
  27303. getTimeStep(): number;
  27304. /**
  27305. * Set the sub time step of the physics engine.
  27306. * Default is 0 meaning there is no sub steps
  27307. * To increase physics resolution precision, set a small value (like 1 ms)
  27308. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27309. */
  27310. setSubTimeStep(subTimeStep: number): void;
  27311. /**
  27312. * Get the sub time step of the physics engine.
  27313. * @returns the current sub time step
  27314. */
  27315. getSubTimeStep(): number;
  27316. /**
  27317. * Release all resources
  27318. */
  27319. dispose(): void;
  27320. /**
  27321. * Gets the name of the current physics plugin
  27322. * @returns the name of the plugin
  27323. */
  27324. getPhysicsPluginName(): string;
  27325. /**
  27326. * Adding a new impostor for the impostor tracking.
  27327. * This will be done by the impostor itself.
  27328. * @param impostor the impostor to add
  27329. */
  27330. addImpostor(impostor: PhysicsImpostor): void;
  27331. /**
  27332. * Remove an impostor from the engine.
  27333. * This impostor and its mesh will not longer be updated by the physics engine.
  27334. * @param impostor the impostor to remove
  27335. */
  27336. removeImpostor(impostor: PhysicsImpostor): void;
  27337. /**
  27338. * Add a joint to the physics engine
  27339. * @param mainImpostor defines the main impostor to which the joint is added.
  27340. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27341. * @param joint defines the joint that will connect both impostors.
  27342. */
  27343. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27344. /**
  27345. * Removes a joint from the simulation
  27346. * @param mainImpostor defines the impostor used with the joint
  27347. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27348. * @param joint defines the joint to remove
  27349. */
  27350. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27351. /**
  27352. * Gets the current plugin used to run the simulation
  27353. * @returns current plugin
  27354. */
  27355. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27356. /**
  27357. * Gets the list of physic impostors
  27358. * @returns an array of PhysicsImpostor
  27359. */
  27360. getImpostors(): Array<PhysicsImpostor>;
  27361. /**
  27362. * Gets the impostor for a physics enabled object
  27363. * @param object defines the object impersonated by the impostor
  27364. * @returns the PhysicsImpostor or null if not found
  27365. */
  27366. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27367. /**
  27368. * Gets the impostor for a physics body object
  27369. * @param body defines physics body used by the impostor
  27370. * @returns the PhysicsImpostor or null if not found
  27371. */
  27372. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27373. /**
  27374. * Does a raycast in the physics world
  27375. * @param from when should the ray start?
  27376. * @param to when should the ray end?
  27377. * @returns PhysicsRaycastResult
  27378. */
  27379. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27380. /**
  27381. * Called by the scene. No need to call it.
  27382. * @param delta defines the timespam between frames
  27383. */
  27384. _step(delta: number): void;
  27385. }
  27386. }
  27387. declare module "babylonjs/Physics/physicsImpostor" {
  27388. import { Nullable, IndicesArray } from "babylonjs/types";
  27389. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27390. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27392. import { Scene } from "babylonjs/scene";
  27393. import { Bone } from "babylonjs/Bones/bone";
  27394. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27395. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27396. import { Space } from "babylonjs/Maths/math.axis";
  27397. /**
  27398. * The interface for the physics imposter parameters
  27399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27400. */
  27401. export interface PhysicsImpostorParameters {
  27402. /**
  27403. * The mass of the physics imposter
  27404. */
  27405. mass: number;
  27406. /**
  27407. * The friction of the physics imposter
  27408. */
  27409. friction?: number;
  27410. /**
  27411. * The coefficient of restitution of the physics imposter
  27412. */
  27413. restitution?: number;
  27414. /**
  27415. * The native options of the physics imposter
  27416. */
  27417. nativeOptions?: any;
  27418. /**
  27419. * Specifies if the parent should be ignored
  27420. */
  27421. ignoreParent?: boolean;
  27422. /**
  27423. * Specifies if bi-directional transformations should be disabled
  27424. */
  27425. disableBidirectionalTransformation?: boolean;
  27426. /**
  27427. * The pressure inside the physics imposter, soft object only
  27428. */
  27429. pressure?: number;
  27430. /**
  27431. * The stiffness the physics imposter, soft object only
  27432. */
  27433. stiffness?: number;
  27434. /**
  27435. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27436. */
  27437. velocityIterations?: number;
  27438. /**
  27439. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27440. */
  27441. positionIterations?: number;
  27442. /**
  27443. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27444. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27445. * Add to fix multiple points
  27446. */
  27447. fixedPoints?: number;
  27448. /**
  27449. * The collision margin around a soft object
  27450. */
  27451. margin?: number;
  27452. /**
  27453. * The collision margin around a soft object
  27454. */
  27455. damping?: number;
  27456. /**
  27457. * The path for a rope based on an extrusion
  27458. */
  27459. path?: any;
  27460. /**
  27461. * The shape of an extrusion used for a rope based on an extrusion
  27462. */
  27463. shape?: any;
  27464. }
  27465. /**
  27466. * Interface for a physics-enabled object
  27467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27468. */
  27469. export interface IPhysicsEnabledObject {
  27470. /**
  27471. * The position of the physics-enabled object
  27472. */
  27473. position: Vector3;
  27474. /**
  27475. * The rotation of the physics-enabled object
  27476. */
  27477. rotationQuaternion: Nullable<Quaternion>;
  27478. /**
  27479. * The scale of the physics-enabled object
  27480. */
  27481. scaling: Vector3;
  27482. /**
  27483. * The rotation of the physics-enabled object
  27484. */
  27485. rotation?: Vector3;
  27486. /**
  27487. * The parent of the physics-enabled object
  27488. */
  27489. parent?: any;
  27490. /**
  27491. * The bounding info of the physics-enabled object
  27492. * @returns The bounding info of the physics-enabled object
  27493. */
  27494. getBoundingInfo(): BoundingInfo;
  27495. /**
  27496. * Computes the world matrix
  27497. * @param force Specifies if the world matrix should be computed by force
  27498. * @returns A world matrix
  27499. */
  27500. computeWorldMatrix(force: boolean): Matrix;
  27501. /**
  27502. * Gets the world matrix
  27503. * @returns A world matrix
  27504. */
  27505. getWorldMatrix?(): Matrix;
  27506. /**
  27507. * Gets the child meshes
  27508. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27509. * @returns An array of abstract meshes
  27510. */
  27511. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27512. /**
  27513. * Gets the vertex data
  27514. * @param kind The type of vertex data
  27515. * @returns A nullable array of numbers, or a float32 array
  27516. */
  27517. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27518. /**
  27519. * Gets the indices from the mesh
  27520. * @returns A nullable array of index arrays
  27521. */
  27522. getIndices?(): Nullable<IndicesArray>;
  27523. /**
  27524. * Gets the scene from the mesh
  27525. * @returns the indices array or null
  27526. */
  27527. getScene?(): Scene;
  27528. /**
  27529. * Gets the absolute position from the mesh
  27530. * @returns the absolute position
  27531. */
  27532. getAbsolutePosition(): Vector3;
  27533. /**
  27534. * Gets the absolute pivot point from the mesh
  27535. * @returns the absolute pivot point
  27536. */
  27537. getAbsolutePivotPoint(): Vector3;
  27538. /**
  27539. * Rotates the mesh
  27540. * @param axis The axis of rotation
  27541. * @param amount The amount of rotation
  27542. * @param space The space of the rotation
  27543. * @returns The rotation transform node
  27544. */
  27545. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27546. /**
  27547. * Translates the mesh
  27548. * @param axis The axis of translation
  27549. * @param distance The distance of translation
  27550. * @param space The space of the translation
  27551. * @returns The transform node
  27552. */
  27553. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27554. /**
  27555. * Sets the absolute position of the mesh
  27556. * @param absolutePosition The absolute position of the mesh
  27557. * @returns The transform node
  27558. */
  27559. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27560. /**
  27561. * Gets the class name of the mesh
  27562. * @returns The class name
  27563. */
  27564. getClassName(): string;
  27565. }
  27566. /**
  27567. * Represents a physics imposter
  27568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27569. */
  27570. export class PhysicsImpostor {
  27571. /**
  27572. * The physics-enabled object used as the physics imposter
  27573. */
  27574. object: IPhysicsEnabledObject;
  27575. /**
  27576. * The type of the physics imposter
  27577. */
  27578. type: number;
  27579. private _options;
  27580. private _scene?;
  27581. /**
  27582. * The default object size of the imposter
  27583. */
  27584. static DEFAULT_OBJECT_SIZE: Vector3;
  27585. /**
  27586. * The identity quaternion of the imposter
  27587. */
  27588. static IDENTITY_QUATERNION: Quaternion;
  27589. /** @hidden */
  27590. _pluginData: any;
  27591. private _physicsEngine;
  27592. private _physicsBody;
  27593. private _bodyUpdateRequired;
  27594. private _onBeforePhysicsStepCallbacks;
  27595. private _onAfterPhysicsStepCallbacks;
  27596. /** @hidden */
  27597. _onPhysicsCollideCallbacks: Array<{
  27598. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27599. otherImpostors: Array<PhysicsImpostor>;
  27600. }>;
  27601. private _deltaPosition;
  27602. private _deltaRotation;
  27603. private _deltaRotationConjugated;
  27604. /** @hidden */
  27605. _isFromLine: boolean;
  27606. private _parent;
  27607. private _isDisposed;
  27608. private static _tmpVecs;
  27609. private static _tmpQuat;
  27610. /**
  27611. * Specifies if the physics imposter is disposed
  27612. */
  27613. get isDisposed(): boolean;
  27614. /**
  27615. * Gets the mass of the physics imposter
  27616. */
  27617. get mass(): number;
  27618. set mass(value: number);
  27619. /**
  27620. * Gets the coefficient of friction
  27621. */
  27622. get friction(): number;
  27623. /**
  27624. * Sets the coefficient of friction
  27625. */
  27626. set friction(value: number);
  27627. /**
  27628. * Gets the coefficient of restitution
  27629. */
  27630. get restitution(): number;
  27631. /**
  27632. * Sets the coefficient of restitution
  27633. */
  27634. set restitution(value: number);
  27635. /**
  27636. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27637. */
  27638. get pressure(): number;
  27639. /**
  27640. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27641. */
  27642. set pressure(value: number);
  27643. /**
  27644. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27645. */
  27646. get stiffness(): number;
  27647. /**
  27648. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27649. */
  27650. set stiffness(value: number);
  27651. /**
  27652. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27653. */
  27654. get velocityIterations(): number;
  27655. /**
  27656. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27657. */
  27658. set velocityIterations(value: number);
  27659. /**
  27660. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27661. */
  27662. get positionIterations(): number;
  27663. /**
  27664. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27665. */
  27666. set positionIterations(value: number);
  27667. /**
  27668. * The unique id of the physics imposter
  27669. * set by the physics engine when adding this impostor to the array
  27670. */
  27671. uniqueId: number;
  27672. /**
  27673. * @hidden
  27674. */
  27675. soft: boolean;
  27676. /**
  27677. * @hidden
  27678. */
  27679. segments: number;
  27680. private _joints;
  27681. /**
  27682. * Initializes the physics imposter
  27683. * @param object The physics-enabled object used as the physics imposter
  27684. * @param type The type of the physics imposter
  27685. * @param _options The options for the physics imposter
  27686. * @param _scene The Babylon scene
  27687. */
  27688. constructor(
  27689. /**
  27690. * The physics-enabled object used as the physics imposter
  27691. */
  27692. object: IPhysicsEnabledObject,
  27693. /**
  27694. * The type of the physics imposter
  27695. */
  27696. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27697. /**
  27698. * This function will completly initialize this impostor.
  27699. * It will create a new body - but only if this mesh has no parent.
  27700. * If it has, this impostor will not be used other than to define the impostor
  27701. * of the child mesh.
  27702. * @hidden
  27703. */
  27704. _init(): void;
  27705. private _getPhysicsParent;
  27706. /**
  27707. * Should a new body be generated.
  27708. * @returns boolean specifying if body initialization is required
  27709. */
  27710. isBodyInitRequired(): boolean;
  27711. /**
  27712. * Sets the updated scaling
  27713. * @param updated Specifies if the scaling is updated
  27714. */
  27715. setScalingUpdated(): void;
  27716. /**
  27717. * Force a regeneration of this or the parent's impostor's body.
  27718. * Use under cautious - This will remove all joints already implemented.
  27719. */
  27720. forceUpdate(): void;
  27721. /**
  27722. * Gets the body that holds this impostor. Either its own, or its parent.
  27723. */
  27724. get physicsBody(): any;
  27725. /**
  27726. * Get the parent of the physics imposter
  27727. * @returns Physics imposter or null
  27728. */
  27729. get parent(): Nullable<PhysicsImpostor>;
  27730. /**
  27731. * Sets the parent of the physics imposter
  27732. */
  27733. set parent(value: Nullable<PhysicsImpostor>);
  27734. /**
  27735. * Set the physics body. Used mainly by the physics engine/plugin
  27736. */
  27737. set physicsBody(physicsBody: any);
  27738. /**
  27739. * Resets the update flags
  27740. */
  27741. resetUpdateFlags(): void;
  27742. /**
  27743. * Gets the object extend size
  27744. * @returns the object extend size
  27745. */
  27746. getObjectExtendSize(): Vector3;
  27747. /**
  27748. * Gets the object center
  27749. * @returns The object center
  27750. */
  27751. getObjectCenter(): Vector3;
  27752. /**
  27753. * Get a specific parameter from the options parameters
  27754. * @param paramName The object parameter name
  27755. * @returns The object parameter
  27756. */
  27757. getParam(paramName: string): any;
  27758. /**
  27759. * Sets a specific parameter in the options given to the physics plugin
  27760. * @param paramName The parameter name
  27761. * @param value The value of the parameter
  27762. */
  27763. setParam(paramName: string, value: number): void;
  27764. /**
  27765. * Specifically change the body's mass option. Won't recreate the physics body object
  27766. * @param mass The mass of the physics imposter
  27767. */
  27768. setMass(mass: number): void;
  27769. /**
  27770. * Gets the linear velocity
  27771. * @returns linear velocity or null
  27772. */
  27773. getLinearVelocity(): Nullable<Vector3>;
  27774. /**
  27775. * Sets the linear velocity
  27776. * @param velocity linear velocity or null
  27777. */
  27778. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27779. /**
  27780. * Gets the angular velocity
  27781. * @returns angular velocity or null
  27782. */
  27783. getAngularVelocity(): Nullable<Vector3>;
  27784. /**
  27785. * Sets the angular velocity
  27786. * @param velocity The velocity or null
  27787. */
  27788. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27789. /**
  27790. * Execute a function with the physics plugin native code
  27791. * Provide a function the will have two variables - the world object and the physics body object
  27792. * @param func The function to execute with the physics plugin native code
  27793. */
  27794. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27795. /**
  27796. * Register a function that will be executed before the physics world is stepping forward
  27797. * @param func The function to execute before the physics world is stepped forward
  27798. */
  27799. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27800. /**
  27801. * Unregister a function that will be executed before the physics world is stepping forward
  27802. * @param func The function to execute before the physics world is stepped forward
  27803. */
  27804. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27805. /**
  27806. * Register a function that will be executed after the physics step
  27807. * @param func The function to execute after physics step
  27808. */
  27809. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27810. /**
  27811. * Unregisters a function that will be executed after the physics step
  27812. * @param func The function to execute after physics step
  27813. */
  27814. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27815. /**
  27816. * register a function that will be executed when this impostor collides against a different body
  27817. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27818. * @param func Callback that is executed on collision
  27819. */
  27820. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27821. /**
  27822. * Unregisters the physics imposter on contact
  27823. * @param collideAgainst The physics object to collide against
  27824. * @param func Callback to execute on collision
  27825. */
  27826. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27827. private _tmpQuat;
  27828. private _tmpQuat2;
  27829. /**
  27830. * Get the parent rotation
  27831. * @returns The parent rotation
  27832. */
  27833. getParentsRotation(): Quaternion;
  27834. /**
  27835. * this function is executed by the physics engine.
  27836. */
  27837. beforeStep: () => void;
  27838. /**
  27839. * this function is executed by the physics engine
  27840. */
  27841. afterStep: () => void;
  27842. /**
  27843. * Legacy collision detection event support
  27844. */
  27845. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27846. /**
  27847. * event and body object due to cannon's event-based architecture.
  27848. */
  27849. onCollide: (e: {
  27850. body: any;
  27851. }) => void;
  27852. /**
  27853. * Apply a force
  27854. * @param force The force to apply
  27855. * @param contactPoint The contact point for the force
  27856. * @returns The physics imposter
  27857. */
  27858. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27859. /**
  27860. * Apply an impulse
  27861. * @param force The impulse force
  27862. * @param contactPoint The contact point for the impulse force
  27863. * @returns The physics imposter
  27864. */
  27865. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27866. /**
  27867. * A help function to create a joint
  27868. * @param otherImpostor A physics imposter used to create a joint
  27869. * @param jointType The type of joint
  27870. * @param jointData The data for the joint
  27871. * @returns The physics imposter
  27872. */
  27873. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27874. /**
  27875. * Add a joint to this impostor with a different impostor
  27876. * @param otherImpostor A physics imposter used to add a joint
  27877. * @param joint The joint to add
  27878. * @returns The physics imposter
  27879. */
  27880. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27881. /**
  27882. * Add an anchor to a cloth impostor
  27883. * @param otherImpostor rigid impostor to anchor to
  27884. * @param width ratio across width from 0 to 1
  27885. * @param height ratio up height from 0 to 1
  27886. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27887. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27888. * @returns impostor the soft imposter
  27889. */
  27890. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27891. /**
  27892. * Add a hook to a rope impostor
  27893. * @param otherImpostor rigid impostor to anchor to
  27894. * @param length ratio across rope from 0 to 1
  27895. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27896. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27897. * @returns impostor the rope imposter
  27898. */
  27899. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27900. /**
  27901. * Will keep this body still, in a sleep mode.
  27902. * @returns the physics imposter
  27903. */
  27904. sleep(): PhysicsImpostor;
  27905. /**
  27906. * Wake the body up.
  27907. * @returns The physics imposter
  27908. */
  27909. wakeUp(): PhysicsImpostor;
  27910. /**
  27911. * Clones the physics imposter
  27912. * @param newObject The physics imposter clones to this physics-enabled object
  27913. * @returns A nullable physics imposter
  27914. */
  27915. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27916. /**
  27917. * Disposes the physics imposter
  27918. */
  27919. dispose(): void;
  27920. /**
  27921. * Sets the delta position
  27922. * @param position The delta position amount
  27923. */
  27924. setDeltaPosition(position: Vector3): void;
  27925. /**
  27926. * Sets the delta rotation
  27927. * @param rotation The delta rotation amount
  27928. */
  27929. setDeltaRotation(rotation: Quaternion): void;
  27930. /**
  27931. * Gets the box size of the physics imposter and stores the result in the input parameter
  27932. * @param result Stores the box size
  27933. * @returns The physics imposter
  27934. */
  27935. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27936. /**
  27937. * Gets the radius of the physics imposter
  27938. * @returns Radius of the physics imposter
  27939. */
  27940. getRadius(): number;
  27941. /**
  27942. * Sync a bone with this impostor
  27943. * @param bone The bone to sync to the impostor.
  27944. * @param boneMesh The mesh that the bone is influencing.
  27945. * @param jointPivot The pivot of the joint / bone in local space.
  27946. * @param distToJoint Optional distance from the impostor to the joint.
  27947. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27948. */
  27949. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27950. /**
  27951. * Sync impostor to a bone
  27952. * @param bone The bone that the impostor will be synced to.
  27953. * @param boneMesh The mesh that the bone is influencing.
  27954. * @param jointPivot The pivot of the joint / bone in local space.
  27955. * @param distToJoint Optional distance from the impostor to the joint.
  27956. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27957. * @param boneAxis Optional vector3 axis the bone is aligned with
  27958. */
  27959. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27960. /**
  27961. * No-Imposter type
  27962. */
  27963. static NoImpostor: number;
  27964. /**
  27965. * Sphere-Imposter type
  27966. */
  27967. static SphereImpostor: number;
  27968. /**
  27969. * Box-Imposter type
  27970. */
  27971. static BoxImpostor: number;
  27972. /**
  27973. * Plane-Imposter type
  27974. */
  27975. static PlaneImpostor: number;
  27976. /**
  27977. * Mesh-imposter type
  27978. */
  27979. static MeshImpostor: number;
  27980. /**
  27981. * Capsule-Impostor type (Ammo.js plugin only)
  27982. */
  27983. static CapsuleImpostor: number;
  27984. /**
  27985. * Cylinder-Imposter type
  27986. */
  27987. static CylinderImpostor: number;
  27988. /**
  27989. * Particle-Imposter type
  27990. */
  27991. static ParticleImpostor: number;
  27992. /**
  27993. * Heightmap-Imposter type
  27994. */
  27995. static HeightmapImpostor: number;
  27996. /**
  27997. * ConvexHull-Impostor type (Ammo.js plugin only)
  27998. */
  27999. static ConvexHullImpostor: number;
  28000. /**
  28001. * Custom-Imposter type (Ammo.js plugin only)
  28002. */
  28003. static CustomImpostor: number;
  28004. /**
  28005. * Rope-Imposter type
  28006. */
  28007. static RopeImpostor: number;
  28008. /**
  28009. * Cloth-Imposter type
  28010. */
  28011. static ClothImpostor: number;
  28012. /**
  28013. * Softbody-Imposter type
  28014. */
  28015. static SoftbodyImpostor: number;
  28016. }
  28017. }
  28018. declare module "babylonjs/Meshes/mesh" {
  28019. import { Observable } from "babylonjs/Misc/observable";
  28020. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28021. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28022. import { Camera } from "babylonjs/Cameras/camera";
  28023. import { Scene } from "babylonjs/scene";
  28024. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28025. import { Color4 } from "babylonjs/Maths/math.color";
  28026. import { Engine } from "babylonjs/Engines/engine";
  28027. import { Node } from "babylonjs/node";
  28028. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28029. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28030. import { Buffer } from "babylonjs/Meshes/buffer";
  28031. import { Geometry } from "babylonjs/Meshes/geometry";
  28032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28034. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28035. import { Effect } from "babylonjs/Materials/effect";
  28036. import { Material } from "babylonjs/Materials/material";
  28037. import { Skeleton } from "babylonjs/Bones/skeleton";
  28038. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28039. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28040. import { Path3D } from "babylonjs/Maths/math.path";
  28041. import { Plane } from "babylonjs/Maths/math.plane";
  28042. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28043. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28044. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28045. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28046. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28047. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28048. /**
  28049. * @hidden
  28050. **/
  28051. export class _CreationDataStorage {
  28052. closePath?: boolean;
  28053. closeArray?: boolean;
  28054. idx: number[];
  28055. dashSize: number;
  28056. gapSize: number;
  28057. path3D: Path3D;
  28058. pathArray: Vector3[][];
  28059. arc: number;
  28060. radius: number;
  28061. cap: number;
  28062. tessellation: number;
  28063. }
  28064. /**
  28065. * @hidden
  28066. **/
  28067. class _InstanceDataStorage {
  28068. visibleInstances: any;
  28069. batchCache: _InstancesBatch;
  28070. instancesBufferSize: number;
  28071. instancesBuffer: Nullable<Buffer>;
  28072. instancesData: Float32Array;
  28073. overridenInstanceCount: number;
  28074. isFrozen: boolean;
  28075. previousBatch: Nullable<_InstancesBatch>;
  28076. hardwareInstancedRendering: boolean;
  28077. sideOrientation: number;
  28078. manualUpdate: boolean;
  28079. }
  28080. /**
  28081. * @hidden
  28082. **/
  28083. export class _InstancesBatch {
  28084. mustReturn: boolean;
  28085. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28086. renderSelf: boolean[];
  28087. hardwareInstancedRendering: boolean[];
  28088. }
  28089. /**
  28090. * @hidden
  28091. **/
  28092. class _ThinInstanceDataStorage {
  28093. instancesCount: number;
  28094. matrixBuffer: Nullable<Buffer>;
  28095. matrixBufferSize: number;
  28096. matrixData: Nullable<Float32Array>;
  28097. boundingVectors: Array<Vector3>;
  28098. }
  28099. /**
  28100. * Class used to represent renderable models
  28101. */
  28102. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28103. /**
  28104. * Mesh side orientation : usually the external or front surface
  28105. */
  28106. static readonly FRONTSIDE: number;
  28107. /**
  28108. * Mesh side orientation : usually the internal or back surface
  28109. */
  28110. static readonly BACKSIDE: number;
  28111. /**
  28112. * Mesh side orientation : both internal and external or front and back surfaces
  28113. */
  28114. static readonly DOUBLESIDE: number;
  28115. /**
  28116. * Mesh side orientation : by default, `FRONTSIDE`
  28117. */
  28118. static readonly DEFAULTSIDE: number;
  28119. /**
  28120. * Mesh cap setting : no cap
  28121. */
  28122. static readonly NO_CAP: number;
  28123. /**
  28124. * Mesh cap setting : one cap at the beginning of the mesh
  28125. */
  28126. static readonly CAP_START: number;
  28127. /**
  28128. * Mesh cap setting : one cap at the end of the mesh
  28129. */
  28130. static readonly CAP_END: number;
  28131. /**
  28132. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28133. */
  28134. static readonly CAP_ALL: number;
  28135. /**
  28136. * Mesh pattern setting : no flip or rotate
  28137. */
  28138. static readonly NO_FLIP: number;
  28139. /**
  28140. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28141. */
  28142. static readonly FLIP_TILE: number;
  28143. /**
  28144. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28145. */
  28146. static readonly ROTATE_TILE: number;
  28147. /**
  28148. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28149. */
  28150. static readonly FLIP_ROW: number;
  28151. /**
  28152. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28153. */
  28154. static readonly ROTATE_ROW: number;
  28155. /**
  28156. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28157. */
  28158. static readonly FLIP_N_ROTATE_TILE: number;
  28159. /**
  28160. * Mesh pattern setting : rotate pattern and rotate
  28161. */
  28162. static readonly FLIP_N_ROTATE_ROW: number;
  28163. /**
  28164. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28165. */
  28166. static readonly CENTER: number;
  28167. /**
  28168. * Mesh tile positioning : part tiles on left
  28169. */
  28170. static readonly LEFT: number;
  28171. /**
  28172. * Mesh tile positioning : part tiles on right
  28173. */
  28174. static readonly RIGHT: number;
  28175. /**
  28176. * Mesh tile positioning : part tiles on top
  28177. */
  28178. static readonly TOP: number;
  28179. /**
  28180. * Mesh tile positioning : part tiles on bottom
  28181. */
  28182. static readonly BOTTOM: number;
  28183. /**
  28184. * Gets the default side orientation.
  28185. * @param orientation the orientation to value to attempt to get
  28186. * @returns the default orientation
  28187. * @hidden
  28188. */
  28189. static _GetDefaultSideOrientation(orientation?: number): number;
  28190. private _internalMeshDataInfo;
  28191. /**
  28192. * An event triggered before rendering the mesh
  28193. */
  28194. get onBeforeRenderObservable(): Observable<Mesh>;
  28195. /**
  28196. * An event triggered before binding the mesh
  28197. */
  28198. get onBeforeBindObservable(): Observable<Mesh>;
  28199. /**
  28200. * An event triggered after rendering the mesh
  28201. */
  28202. get onAfterRenderObservable(): Observable<Mesh>;
  28203. /**
  28204. * An event triggered before drawing the mesh
  28205. */
  28206. get onBeforeDrawObservable(): Observable<Mesh>;
  28207. private _onBeforeDrawObserver;
  28208. /**
  28209. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28210. */
  28211. set onBeforeDraw(callback: () => void);
  28212. get hasInstances(): boolean;
  28213. get hasThinInstances(): boolean;
  28214. /**
  28215. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28216. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28217. */
  28218. delayLoadState: number;
  28219. /**
  28220. * Gets the list of instances created from this mesh
  28221. * it is not supposed to be modified manually.
  28222. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28223. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28224. */
  28225. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28226. /**
  28227. * Gets the file containing delay loading data for this mesh
  28228. */
  28229. delayLoadingFile: string;
  28230. /** @hidden */
  28231. _binaryInfo: any;
  28232. /**
  28233. * User defined function used to change how LOD level selection is done
  28234. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28235. */
  28236. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28237. /**
  28238. * Gets or sets the morph target manager
  28239. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28240. */
  28241. get morphTargetManager(): Nullable<MorphTargetManager>;
  28242. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28243. /** @hidden */
  28244. _creationDataStorage: Nullable<_CreationDataStorage>;
  28245. /** @hidden */
  28246. _geometry: Nullable<Geometry>;
  28247. /** @hidden */
  28248. _delayInfo: Array<string>;
  28249. /** @hidden */
  28250. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28251. /** @hidden */
  28252. _instanceDataStorage: _InstanceDataStorage;
  28253. /** @hidden */
  28254. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28255. private _effectiveMaterial;
  28256. /** @hidden */
  28257. _shouldGenerateFlatShading: boolean;
  28258. /** @hidden */
  28259. _originalBuilderSideOrientation: number;
  28260. /**
  28261. * Use this property to change the original side orientation defined at construction time
  28262. */
  28263. overrideMaterialSideOrientation: Nullable<number>;
  28264. /**
  28265. * Gets the source mesh (the one used to clone this one from)
  28266. */
  28267. get source(): Nullable<Mesh>;
  28268. /**
  28269. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28270. */
  28271. get isUnIndexed(): boolean;
  28272. set isUnIndexed(value: boolean);
  28273. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28274. get worldMatrixInstancedBuffer(): Float32Array;
  28275. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28276. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28277. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28278. /**
  28279. * @constructor
  28280. * @param name The value used by scene.getMeshByName() to do a lookup.
  28281. * @param scene The scene to add this mesh to.
  28282. * @param parent The parent of this mesh, if it has one
  28283. * @param source An optional Mesh from which geometry is shared, cloned.
  28284. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28285. * When false, achieved by calling a clone(), also passing False.
  28286. * This will make creation of children, recursive.
  28287. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28288. */
  28289. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28290. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28291. doNotInstantiate: boolean;
  28292. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28293. /**
  28294. * Gets the class name
  28295. * @returns the string "Mesh".
  28296. */
  28297. getClassName(): string;
  28298. /** @hidden */
  28299. get _isMesh(): boolean;
  28300. /**
  28301. * Returns a description of this mesh
  28302. * @param fullDetails define if full details about this mesh must be used
  28303. * @returns a descriptive string representing this mesh
  28304. */
  28305. toString(fullDetails?: boolean): string;
  28306. /** @hidden */
  28307. _unBindEffect(): void;
  28308. /**
  28309. * Gets a boolean indicating if this mesh has LOD
  28310. */
  28311. get hasLODLevels(): boolean;
  28312. /**
  28313. * Gets the list of MeshLODLevel associated with the current mesh
  28314. * @returns an array of MeshLODLevel
  28315. */
  28316. getLODLevels(): MeshLODLevel[];
  28317. private _sortLODLevels;
  28318. /**
  28319. * Add a mesh as LOD level triggered at the given distance.
  28320. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28321. * @param distance The distance from the center of the object to show this level
  28322. * @param mesh The mesh to be added as LOD level (can be null)
  28323. * @return This mesh (for chaining)
  28324. */
  28325. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28326. /**
  28327. * Returns the LOD level mesh at the passed distance or null if not found.
  28328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28329. * @param distance The distance from the center of the object to show this level
  28330. * @returns a Mesh or `null`
  28331. */
  28332. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28333. /**
  28334. * Remove a mesh from the LOD array
  28335. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28336. * @param mesh defines the mesh to be removed
  28337. * @return This mesh (for chaining)
  28338. */
  28339. removeLODLevel(mesh: Mesh): Mesh;
  28340. /**
  28341. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28343. * @param camera defines the camera to use to compute distance
  28344. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28345. * @return This mesh (for chaining)
  28346. */
  28347. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28348. /**
  28349. * Gets the mesh internal Geometry object
  28350. */
  28351. get geometry(): Nullable<Geometry>;
  28352. /**
  28353. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28354. * @returns the total number of vertices
  28355. */
  28356. getTotalVertices(): number;
  28357. /**
  28358. * Returns the content of an associated vertex buffer
  28359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28360. * - VertexBuffer.PositionKind
  28361. * - VertexBuffer.UVKind
  28362. * - VertexBuffer.UV2Kind
  28363. * - VertexBuffer.UV3Kind
  28364. * - VertexBuffer.UV4Kind
  28365. * - VertexBuffer.UV5Kind
  28366. * - VertexBuffer.UV6Kind
  28367. * - VertexBuffer.ColorKind
  28368. * - VertexBuffer.MatricesIndicesKind
  28369. * - VertexBuffer.MatricesIndicesExtraKind
  28370. * - VertexBuffer.MatricesWeightsKind
  28371. * - VertexBuffer.MatricesWeightsExtraKind
  28372. * @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
  28373. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28374. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28375. */
  28376. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28377. /**
  28378. * Returns the mesh VertexBuffer object from the requested `kind`
  28379. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28380. * - VertexBuffer.PositionKind
  28381. * - VertexBuffer.NormalKind
  28382. * - VertexBuffer.UVKind
  28383. * - VertexBuffer.UV2Kind
  28384. * - VertexBuffer.UV3Kind
  28385. * - VertexBuffer.UV4Kind
  28386. * - VertexBuffer.UV5Kind
  28387. * - VertexBuffer.UV6Kind
  28388. * - VertexBuffer.ColorKind
  28389. * - VertexBuffer.MatricesIndicesKind
  28390. * - VertexBuffer.MatricesIndicesExtraKind
  28391. * - VertexBuffer.MatricesWeightsKind
  28392. * - VertexBuffer.MatricesWeightsExtraKind
  28393. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28394. */
  28395. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28396. /**
  28397. * Tests if a specific vertex buffer is associated with this mesh
  28398. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28399. * - VertexBuffer.PositionKind
  28400. * - VertexBuffer.NormalKind
  28401. * - VertexBuffer.UVKind
  28402. * - VertexBuffer.UV2Kind
  28403. * - VertexBuffer.UV3Kind
  28404. * - VertexBuffer.UV4Kind
  28405. * - VertexBuffer.UV5Kind
  28406. * - VertexBuffer.UV6Kind
  28407. * - VertexBuffer.ColorKind
  28408. * - VertexBuffer.MatricesIndicesKind
  28409. * - VertexBuffer.MatricesIndicesExtraKind
  28410. * - VertexBuffer.MatricesWeightsKind
  28411. * - VertexBuffer.MatricesWeightsExtraKind
  28412. * @returns a boolean
  28413. */
  28414. isVerticesDataPresent(kind: string): boolean;
  28415. /**
  28416. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28417. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28418. * - VertexBuffer.PositionKind
  28419. * - VertexBuffer.UVKind
  28420. * - VertexBuffer.UV2Kind
  28421. * - VertexBuffer.UV3Kind
  28422. * - VertexBuffer.UV4Kind
  28423. * - VertexBuffer.UV5Kind
  28424. * - VertexBuffer.UV6Kind
  28425. * - VertexBuffer.ColorKind
  28426. * - VertexBuffer.MatricesIndicesKind
  28427. * - VertexBuffer.MatricesIndicesExtraKind
  28428. * - VertexBuffer.MatricesWeightsKind
  28429. * - VertexBuffer.MatricesWeightsExtraKind
  28430. * @returns a boolean
  28431. */
  28432. isVertexBufferUpdatable(kind: string): boolean;
  28433. /**
  28434. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28435. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28436. * - VertexBuffer.PositionKind
  28437. * - VertexBuffer.NormalKind
  28438. * - VertexBuffer.UVKind
  28439. * - VertexBuffer.UV2Kind
  28440. * - VertexBuffer.UV3Kind
  28441. * - VertexBuffer.UV4Kind
  28442. * - VertexBuffer.UV5Kind
  28443. * - VertexBuffer.UV6Kind
  28444. * - VertexBuffer.ColorKind
  28445. * - VertexBuffer.MatricesIndicesKind
  28446. * - VertexBuffer.MatricesIndicesExtraKind
  28447. * - VertexBuffer.MatricesWeightsKind
  28448. * - VertexBuffer.MatricesWeightsExtraKind
  28449. * @returns an array of strings
  28450. */
  28451. getVerticesDataKinds(): string[];
  28452. /**
  28453. * Returns a positive integer : the total number of indices in this mesh geometry.
  28454. * @returns the numner of indices or zero if the mesh has no geometry.
  28455. */
  28456. getTotalIndices(): number;
  28457. /**
  28458. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28459. * @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.
  28460. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28461. * @returns the indices array or an empty array if the mesh has no geometry
  28462. */
  28463. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28464. get isBlocked(): boolean;
  28465. /**
  28466. * Determine if the current mesh is ready to be rendered
  28467. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28468. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28469. * @returns true if all associated assets are ready (material, textures, shaders)
  28470. */
  28471. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28472. /**
  28473. * 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.
  28474. */
  28475. get areNormalsFrozen(): boolean;
  28476. /**
  28477. * 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.
  28478. * @returns the current mesh
  28479. */
  28480. freezeNormals(): Mesh;
  28481. /**
  28482. * 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
  28483. * @returns the current mesh
  28484. */
  28485. unfreezeNormals(): Mesh;
  28486. /**
  28487. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28488. */
  28489. set overridenInstanceCount(count: number);
  28490. /** @hidden */
  28491. _preActivate(): Mesh;
  28492. /** @hidden */
  28493. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28494. /** @hidden */
  28495. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28496. protected _afterComputeWorldMatrix(): void;
  28497. /** @hidden */
  28498. _postActivate(): void;
  28499. /**
  28500. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28501. * This means the mesh underlying bounding box and sphere are recomputed.
  28502. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28503. * @returns the current mesh
  28504. */
  28505. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28506. /** @hidden */
  28507. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28508. /**
  28509. * This function will subdivide the mesh into multiple submeshes
  28510. * @param count defines the expected number of submeshes
  28511. */
  28512. subdivide(count: number): void;
  28513. /**
  28514. * Copy a FloatArray into a specific associated vertex buffer
  28515. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28516. * - VertexBuffer.PositionKind
  28517. * - VertexBuffer.UVKind
  28518. * - VertexBuffer.UV2Kind
  28519. * - VertexBuffer.UV3Kind
  28520. * - VertexBuffer.UV4Kind
  28521. * - VertexBuffer.UV5Kind
  28522. * - VertexBuffer.UV6Kind
  28523. * - VertexBuffer.ColorKind
  28524. * - VertexBuffer.MatricesIndicesKind
  28525. * - VertexBuffer.MatricesIndicesExtraKind
  28526. * - VertexBuffer.MatricesWeightsKind
  28527. * - VertexBuffer.MatricesWeightsExtraKind
  28528. * @param data defines the data source
  28529. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28530. * @param stride defines the data stride size (can be null)
  28531. * @returns the current mesh
  28532. */
  28533. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28534. /**
  28535. * Delete a vertex buffer associated with this mesh
  28536. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28537. * - VertexBuffer.PositionKind
  28538. * - VertexBuffer.UVKind
  28539. * - VertexBuffer.UV2Kind
  28540. * - VertexBuffer.UV3Kind
  28541. * - VertexBuffer.UV4Kind
  28542. * - VertexBuffer.UV5Kind
  28543. * - VertexBuffer.UV6Kind
  28544. * - VertexBuffer.ColorKind
  28545. * - VertexBuffer.MatricesIndicesKind
  28546. * - VertexBuffer.MatricesIndicesExtraKind
  28547. * - VertexBuffer.MatricesWeightsKind
  28548. * - VertexBuffer.MatricesWeightsExtraKind
  28549. */
  28550. removeVerticesData(kind: string): void;
  28551. /**
  28552. * Flags an associated vertex buffer as updatable
  28553. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28554. * - VertexBuffer.PositionKind
  28555. * - VertexBuffer.UVKind
  28556. * - VertexBuffer.UV2Kind
  28557. * - VertexBuffer.UV3Kind
  28558. * - VertexBuffer.UV4Kind
  28559. * - VertexBuffer.UV5Kind
  28560. * - VertexBuffer.UV6Kind
  28561. * - VertexBuffer.ColorKind
  28562. * - VertexBuffer.MatricesIndicesKind
  28563. * - VertexBuffer.MatricesIndicesExtraKind
  28564. * - VertexBuffer.MatricesWeightsKind
  28565. * - VertexBuffer.MatricesWeightsExtraKind
  28566. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28567. */
  28568. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28569. /**
  28570. * Sets the mesh global Vertex Buffer
  28571. * @param buffer defines the buffer to use
  28572. * @returns the current mesh
  28573. */
  28574. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28575. /**
  28576. * Update a specific associated vertex buffer
  28577. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28578. * - VertexBuffer.PositionKind
  28579. * - VertexBuffer.UVKind
  28580. * - VertexBuffer.UV2Kind
  28581. * - VertexBuffer.UV3Kind
  28582. * - VertexBuffer.UV4Kind
  28583. * - VertexBuffer.UV5Kind
  28584. * - VertexBuffer.UV6Kind
  28585. * - VertexBuffer.ColorKind
  28586. * - VertexBuffer.MatricesIndicesKind
  28587. * - VertexBuffer.MatricesIndicesExtraKind
  28588. * - VertexBuffer.MatricesWeightsKind
  28589. * - VertexBuffer.MatricesWeightsExtraKind
  28590. * @param data defines the data source
  28591. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28592. * @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)
  28593. * @returns the current mesh
  28594. */
  28595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28596. /**
  28597. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28598. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28599. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28600. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28601. * @returns the current mesh
  28602. */
  28603. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28604. /**
  28605. * Creates a un-shared specific occurence of the geometry for the mesh.
  28606. * @returns the current mesh
  28607. */
  28608. makeGeometryUnique(): Mesh;
  28609. /**
  28610. * Set the index buffer of this mesh
  28611. * @param indices defines the source data
  28612. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28613. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28614. * @returns the current mesh
  28615. */
  28616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28617. /**
  28618. * Update the current index buffer
  28619. * @param indices defines the source data
  28620. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28621. * @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)
  28622. * @returns the current mesh
  28623. */
  28624. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28625. /**
  28626. * Invert the geometry to move from a right handed system to a left handed one.
  28627. * @returns the current mesh
  28628. */
  28629. toLeftHanded(): Mesh;
  28630. /** @hidden */
  28631. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28632. /** @hidden */
  28633. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28634. /**
  28635. * Registers for this mesh a javascript function called just before the rendering process
  28636. * @param func defines the function to call before rendering this mesh
  28637. * @returns the current mesh
  28638. */
  28639. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28640. /**
  28641. * Disposes a previously registered javascript function called before the rendering
  28642. * @param func defines the function to remove
  28643. * @returns the current mesh
  28644. */
  28645. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28646. /**
  28647. * Registers for this mesh a javascript function called just after the rendering is complete
  28648. * @param func defines the function to call after rendering this mesh
  28649. * @returns the current mesh
  28650. */
  28651. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28652. /**
  28653. * Disposes a previously registered javascript function called after the rendering.
  28654. * @param func defines the function to remove
  28655. * @returns the current mesh
  28656. */
  28657. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28658. /** @hidden */
  28659. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28660. /** @hidden */
  28661. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28662. /** @hidden */
  28663. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28664. /** @hidden */
  28665. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28666. /** @hidden */
  28667. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28668. /** @hidden */
  28669. _rebuild(): void;
  28670. /** @hidden */
  28671. _freeze(): void;
  28672. /** @hidden */
  28673. _unFreeze(): void;
  28674. /**
  28675. * 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
  28676. * @param subMesh defines the subMesh to render
  28677. * @param enableAlphaMode defines if alpha mode can be changed
  28678. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28679. * @returns the current mesh
  28680. */
  28681. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28682. private _onBeforeDraw;
  28683. /**
  28684. * Renormalize the mesh and patch it up if there are no weights
  28685. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28686. * However in the case of zero weights then we set just a single influence to 1.
  28687. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28688. */
  28689. cleanMatrixWeights(): void;
  28690. private normalizeSkinFourWeights;
  28691. private normalizeSkinWeightsAndExtra;
  28692. /**
  28693. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28694. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28695. * the user know there was an issue with importing the mesh
  28696. * @returns a validation object with skinned, valid and report string
  28697. */
  28698. validateSkinning(): {
  28699. skinned: boolean;
  28700. valid: boolean;
  28701. report: string;
  28702. };
  28703. /** @hidden */
  28704. _checkDelayState(): Mesh;
  28705. private _queueLoad;
  28706. /**
  28707. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28708. * A mesh is in the frustum if its bounding box intersects the frustum
  28709. * @param frustumPlanes defines the frustum to test
  28710. * @returns true if the mesh is in the frustum planes
  28711. */
  28712. isInFrustum(frustumPlanes: Plane[]): boolean;
  28713. /**
  28714. * Sets the mesh material by the material or multiMaterial `id` property
  28715. * @param id is a string identifying the material or the multiMaterial
  28716. * @returns the current mesh
  28717. */
  28718. setMaterialByID(id: string): Mesh;
  28719. /**
  28720. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28721. * @returns an array of IAnimatable
  28722. */
  28723. getAnimatables(): IAnimatable[];
  28724. /**
  28725. * Modifies the mesh geometry according to the passed transformation matrix.
  28726. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28727. * The mesh normals are modified using the same transformation.
  28728. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28729. * @param transform defines the transform matrix to use
  28730. * @see http://doc.babylonjs.com/resources/baking_transformations
  28731. * @returns the current mesh
  28732. */
  28733. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28734. /**
  28735. * Modifies the mesh geometry according to its own current World Matrix.
  28736. * The mesh World Matrix is then reset.
  28737. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28738. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28739. * @see http://doc.babylonjs.com/resources/baking_transformations
  28740. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28741. * @returns the current mesh
  28742. */
  28743. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28744. /** @hidden */
  28745. get _positions(): Nullable<Vector3[]>;
  28746. /** @hidden */
  28747. _resetPointsArrayCache(): Mesh;
  28748. /** @hidden */
  28749. _generatePointsArray(): boolean;
  28750. /**
  28751. * Returns a new Mesh object generated from the current mesh properties.
  28752. * This method must not get confused with createInstance()
  28753. * @param name is a string, the name given to the new mesh
  28754. * @param newParent can be any Node object (default `null`)
  28755. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28756. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28757. * @returns a new mesh
  28758. */
  28759. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28760. /**
  28761. * Releases resources associated with this mesh.
  28762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28764. */
  28765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28766. /** @hidden */
  28767. _disposeInstanceSpecificData(): void;
  28768. /** @hidden */
  28769. _disposeThinInstanceSpecificData(): void;
  28770. /**
  28771. * Modifies the mesh geometry according to a displacement map.
  28772. * 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.
  28773. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28774. * @param url is a string, the URL from the image file is to be downloaded.
  28775. * @param minHeight is the lower limit of the displacement.
  28776. * @param maxHeight is the upper limit of the displacement.
  28777. * @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.
  28778. * @param uvOffset is an optional vector2 used to offset UV.
  28779. * @param uvScale is an optional vector2 used to scale UV.
  28780. * @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.
  28781. * @returns the Mesh.
  28782. */
  28783. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28784. /**
  28785. * Modifies the mesh geometry according to a displacementMap buffer.
  28786. * 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.
  28787. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28788. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28789. * @param heightMapWidth is the width of the buffer image.
  28790. * @param heightMapHeight is the height of the buffer image.
  28791. * @param minHeight is the lower limit of the displacement.
  28792. * @param maxHeight is the upper limit of the displacement.
  28793. * @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.
  28794. * @param uvOffset is an optional vector2 used to offset UV.
  28795. * @param uvScale is an optional vector2 used to scale UV.
  28796. * @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.
  28797. * @returns the Mesh.
  28798. */
  28799. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28800. /**
  28801. * Modify the mesh to get a flat shading rendering.
  28802. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28803. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28804. * @returns current mesh
  28805. */
  28806. convertToFlatShadedMesh(): Mesh;
  28807. /**
  28808. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28809. * In other words, more vertices, no more indices and a single bigger VBO.
  28810. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28811. * @returns current mesh
  28812. */
  28813. convertToUnIndexedMesh(): Mesh;
  28814. /**
  28815. * Inverses facet orientations.
  28816. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28817. * @param flipNormals will also inverts the normals
  28818. * @returns current mesh
  28819. */
  28820. flipFaces(flipNormals?: boolean): Mesh;
  28821. /**
  28822. * Increase the number of facets and hence vertices in a mesh
  28823. * Vertex normals are interpolated from existing vertex normals
  28824. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28825. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28826. */
  28827. increaseVertices(numberPerEdge: number): void;
  28828. /**
  28829. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28830. * This will undo any application of covertToFlatShadedMesh
  28831. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28832. */
  28833. forceSharedVertices(): void;
  28834. /** @hidden */
  28835. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28836. /** @hidden */
  28837. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28838. /**
  28839. * Creates a new InstancedMesh object from the mesh model.
  28840. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28841. * @param name defines the name of the new instance
  28842. * @returns a new InstancedMesh
  28843. */
  28844. createInstance(name: string): InstancedMesh;
  28845. /**
  28846. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28847. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28848. * @returns the current mesh
  28849. */
  28850. synchronizeInstances(): Mesh;
  28851. /**
  28852. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28853. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28854. * This should be used together with the simplification to avoid disappearing triangles.
  28855. * @param successCallback an optional success callback to be called after the optimization finished.
  28856. * @returns the current mesh
  28857. */
  28858. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28859. /**
  28860. * Serialize current mesh
  28861. * @param serializationObject defines the object which will receive the serialization data
  28862. */
  28863. serialize(serializationObject: any): void;
  28864. /** @hidden */
  28865. _syncGeometryWithMorphTargetManager(): void;
  28866. /** @hidden */
  28867. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28868. /**
  28869. * Returns a new Mesh object parsed from the source provided.
  28870. * @param parsedMesh is the source
  28871. * @param scene defines the hosting scene
  28872. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28873. * @returns a new Mesh
  28874. */
  28875. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28876. /**
  28877. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28878. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28879. * @param name defines the name of the mesh to create
  28880. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28881. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28882. * @param closePath creates a seam between the first and the last points of each path of the path array
  28883. * @param offset is taken in account only if the `pathArray` is containing a single path
  28884. * @param scene defines the hosting scene
  28885. * @param updatable defines if the mesh must be flagged as updatable
  28886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28887. * @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)
  28888. * @returns a new Mesh
  28889. */
  28890. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28891. /**
  28892. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28893. * @param name defines the name of the mesh to create
  28894. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28895. * @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
  28896. * @param scene defines the hosting scene
  28897. * @param updatable defines if the mesh must be flagged as updatable
  28898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28899. * @returns a new Mesh
  28900. */
  28901. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28902. /**
  28903. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28904. * @param name defines the name of the mesh to create
  28905. * @param size sets the size (float) of each box side (default 1)
  28906. * @param scene defines the hosting scene
  28907. * @param updatable defines if the mesh must be flagged as updatable
  28908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28909. * @returns a new Mesh
  28910. */
  28911. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28912. /**
  28913. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28914. * @param name defines the name of the mesh to create
  28915. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28916. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28917. * @param scene defines the hosting scene
  28918. * @param updatable defines if the mesh must be flagged as updatable
  28919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28920. * @returns a new Mesh
  28921. */
  28922. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28923. /**
  28924. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28925. * @param name defines the name of the mesh to create
  28926. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28927. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28928. * @param scene defines the hosting scene
  28929. * @returns a new Mesh
  28930. */
  28931. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28932. /**
  28933. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28934. * @param name defines the name of the mesh to create
  28935. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28936. * @param diameterTop set the top cap diameter (floats, default 1)
  28937. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28938. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28939. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28940. * @param scene defines the hosting scene
  28941. * @param updatable defines if the mesh must be flagged as updatable
  28942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28943. * @returns a new Mesh
  28944. */
  28945. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28946. /**
  28947. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28948. * @param name defines the name of the mesh to create
  28949. * @param diameter sets the diameter size (float) of the torus (default 1)
  28950. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28951. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28952. * @param scene defines the hosting scene
  28953. * @param updatable defines if the mesh must be flagged as updatable
  28954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28955. * @returns a new Mesh
  28956. */
  28957. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28958. /**
  28959. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28960. * @param name defines the name of the mesh to create
  28961. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28962. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28963. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28964. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28965. * @param p the number of windings on X axis (positive integers, default 2)
  28966. * @param q the number of windings on Y axis (positive integers, default 3)
  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 CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28973. /**
  28974. * Creates a line 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 points is an array successive Vector3
  28977. * @param scene defines the hosting scene
  28978. * @param updatable defines if the mesh must be flagged as updatable
  28979. * @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).
  28980. * @returns a new Mesh
  28981. */
  28982. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28983. /**
  28984. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28985. * @param name defines the name of the mesh to create
  28986. * @param points is an array successive Vector3
  28987. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28988. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28989. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28990. * @param scene defines the hosting scene
  28991. * @param updatable defines if the mesh must be flagged as updatable
  28992. * @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)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28996. /**
  28997. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28998. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28999. * 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.
  29000. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29001. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29002. * Remember you can only change the shape positions, not their number when updating a polygon.
  29003. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29004. * @param name defines the name of the mesh to create
  29005. * @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
  29006. * @param scene defines the hosting scene
  29007. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29008. * @param updatable defines if the mesh must be flagged as updatable
  29009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29010. * @param earcutInjection can be used to inject your own earcut reference
  29011. * @returns a new Mesh
  29012. */
  29013. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29014. /**
  29015. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29016. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29017. * @param name defines the name of the mesh to create
  29018. * @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
  29019. * @param depth defines the height of extrusion
  29020. * @param scene defines the hosting scene
  29021. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29024. * @param earcutInjection can be used to inject your own earcut reference
  29025. * @returns a new Mesh
  29026. */
  29027. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29028. /**
  29029. * Creates an extruded shape mesh.
  29030. * 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
  29031. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29032. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29033. * @param name defines the name of the mesh to create
  29034. * @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
  29035. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29036. * @param scale is the value to scale the shape
  29037. * @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
  29038. * @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
  29039. * @param scene defines the hosting scene
  29040. * @param updatable defines if the mesh must be flagged as updatable
  29041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29042. * @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)
  29043. * @returns a new Mesh
  29044. */
  29045. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29046. /**
  29047. * Creates an custom extruded shape mesh.
  29048. * The custom extrusion is a parametric shape.
  29049. * It has no predefined shape. Its final shape will depend on the input parameters.
  29050. * Please consider using the same method from the MeshBuilder class instead
  29051. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29052. * @param name defines the name of the mesh to create
  29053. * @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
  29054. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29055. * @param scaleFunction is a custom Javascript function called on each path point
  29056. * @param rotationFunction is a custom Javascript function called on each path point
  29057. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29058. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29059. * @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
  29060. * @param scene defines the hosting scene
  29061. * @param updatable defines if the mesh must be flagged as updatable
  29062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29063. * @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)
  29064. * @returns a new Mesh
  29065. */
  29066. 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;
  29067. /**
  29068. * Creates lathe mesh.
  29069. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29070. * Please consider using the same method from the MeshBuilder class instead
  29071. * @param name defines the name of the mesh to create
  29072. * @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
  29073. * @param radius is the radius value of the lathe
  29074. * @param tessellation is the side number of the lathe.
  29075. * @param scene defines the hosting scene
  29076. * @param updatable defines if the mesh must be flagged as updatable
  29077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29078. * @returns a new Mesh
  29079. */
  29080. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29081. /**
  29082. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29083. * @param name defines the name of the mesh to create
  29084. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29085. * @param scene defines the hosting scene
  29086. * @param updatable defines if the mesh must be flagged as updatable
  29087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29088. * @returns a new Mesh
  29089. */
  29090. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29091. /**
  29092. * Creates a ground mesh.
  29093. * Please consider using the same method from the MeshBuilder class instead
  29094. * @param name defines the name of the mesh to create
  29095. * @param width set the width of the ground
  29096. * @param height set the height of the ground
  29097. * @param subdivisions sets the number of subdivisions per side
  29098. * @param scene defines the hosting scene
  29099. * @param updatable defines if the mesh must be flagged as updatable
  29100. * @returns a new Mesh
  29101. */
  29102. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29103. /**
  29104. * Creates a tiled ground mesh.
  29105. * Please consider using the same method from the MeshBuilder class instead
  29106. * @param name defines the name of the mesh to create
  29107. * @param xmin set the ground minimum X coordinate
  29108. * @param zmin set the ground minimum Y coordinate
  29109. * @param xmax set the ground maximum X coordinate
  29110. * @param zmax set the ground maximum Z coordinate
  29111. * @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
  29112. * @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
  29113. * @param scene defines the hosting scene
  29114. * @param updatable defines if the mesh must be flagged as updatable
  29115. * @returns a new Mesh
  29116. */
  29117. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29118. w: number;
  29119. h: number;
  29120. }, precision: {
  29121. w: number;
  29122. h: number;
  29123. }, scene: Scene, updatable?: boolean): Mesh;
  29124. /**
  29125. * Creates a ground mesh from a height map.
  29126. * Please consider using the same method from the MeshBuilder class instead
  29127. * @see http://doc.babylonjs.com/babylon101/height_map
  29128. * @param name defines the name of the mesh to create
  29129. * @param url sets the URL of the height map image resource
  29130. * @param width set the ground width size
  29131. * @param height set the ground height size
  29132. * @param subdivisions sets the number of subdivision per side
  29133. * @param minHeight is the minimum altitude on the ground
  29134. * @param maxHeight is the maximum altitude on the ground
  29135. * @param scene defines the hosting scene
  29136. * @param updatable defines if the mesh must be flagged as updatable
  29137. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29138. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29139. * @returns a new Mesh
  29140. */
  29141. 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;
  29142. /**
  29143. * Creates a tube mesh.
  29144. * The tube is a parametric shape.
  29145. * It has no predefined shape. Its final shape will depend on the input parameters.
  29146. * Please consider using the same method from the MeshBuilder class instead
  29147. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29148. * @param name defines the name of the mesh to create
  29149. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29150. * @param radius sets the tube radius size
  29151. * @param tessellation is the number of sides on the tubular surface
  29152. * @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
  29153. * @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
  29154. * @param scene defines the hosting scene
  29155. * @param updatable defines if the mesh must be flagged as updatable
  29156. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29157. * @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)
  29158. * @returns a new Mesh
  29159. */
  29160. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29161. (i: number, distance: number): number;
  29162. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29163. /**
  29164. * Creates a polyhedron mesh.
  29165. * Please consider using the same method from the MeshBuilder class instead.
  29166. * * 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
  29167. * * The parameter `size` (positive float, default 1) sets the polygon size
  29168. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29169. * * 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`
  29170. * * 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
  29171. * * 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)`)
  29172. * * 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
  29173. * * 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
  29174. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29175. * * If you create a double-sided mesh, you can choose what parts of 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
  29176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29177. * @param name defines the name of the mesh to create
  29178. * @param options defines the options used to create the mesh
  29179. * @param scene defines the hosting scene
  29180. * @returns a new Mesh
  29181. */
  29182. static CreatePolyhedron(name: string, options: {
  29183. type?: number;
  29184. size?: number;
  29185. sizeX?: number;
  29186. sizeY?: number;
  29187. sizeZ?: number;
  29188. custom?: any;
  29189. faceUV?: Vector4[];
  29190. faceColors?: Color4[];
  29191. updatable?: boolean;
  29192. sideOrientation?: number;
  29193. }, scene: Scene): Mesh;
  29194. /**
  29195. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29196. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29197. * * 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`)
  29198. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29199. * * 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
  29200. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29201. * * If you create a double-sided mesh, you can choose what parts of 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
  29202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29203. * @param name defines the name of the mesh
  29204. * @param options defines the options used to create the mesh
  29205. * @param scene defines the hosting scene
  29206. * @returns a new Mesh
  29207. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29208. */
  29209. static CreateIcoSphere(name: string, options: {
  29210. radius?: number;
  29211. flat?: boolean;
  29212. subdivisions?: number;
  29213. sideOrientation?: number;
  29214. updatable?: boolean;
  29215. }, scene: Scene): Mesh;
  29216. /**
  29217. * Creates a decal mesh.
  29218. * Please consider using the same method from the MeshBuilder class instead.
  29219. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29220. * @param name defines the name of the mesh
  29221. * @param sourceMesh defines the mesh receiving the decal
  29222. * @param position sets the position of the decal in world coordinates
  29223. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29224. * @param size sets the decal scaling
  29225. * @param angle sets the angle to rotate the decal
  29226. * @returns a new Mesh
  29227. */
  29228. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29229. /**
  29230. * Prepare internal position array for software CPU skinning
  29231. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29232. */
  29233. setPositionsForCPUSkinning(): Float32Array;
  29234. /**
  29235. * Prepare internal normal array for software CPU skinning
  29236. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29237. */
  29238. setNormalsForCPUSkinning(): Float32Array;
  29239. /**
  29240. * Updates the vertex buffer by applying transformation from the bones
  29241. * @param skeleton defines the skeleton to apply to current mesh
  29242. * @returns the current mesh
  29243. */
  29244. applySkeleton(skeleton: Skeleton): Mesh;
  29245. /**
  29246. * 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
  29247. * @param meshes defines the list of meshes to scan
  29248. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29249. */
  29250. static MinMax(meshes: AbstractMesh[]): {
  29251. min: Vector3;
  29252. max: Vector3;
  29253. };
  29254. /**
  29255. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29256. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29257. * @returns a vector3
  29258. */
  29259. static Center(meshesOrMinMaxVector: {
  29260. min: Vector3;
  29261. max: Vector3;
  29262. } | AbstractMesh[]): Vector3;
  29263. /**
  29264. * Merge the array of meshes into a single mesh for performance reasons.
  29265. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29266. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29267. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29268. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29269. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29270. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29271. * @returns a new mesh
  29272. */
  29273. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29274. /** @hidden */
  29275. addInstance(instance: InstancedMesh): void;
  29276. /** @hidden */
  29277. removeInstance(instance: InstancedMesh): void;
  29278. }
  29279. }
  29280. declare module "babylonjs/Cameras/camera" {
  29281. import { SmartArray } from "babylonjs/Misc/smartArray";
  29282. import { Observable } from "babylonjs/Misc/observable";
  29283. import { Nullable } from "babylonjs/types";
  29284. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29285. import { Scene } from "babylonjs/scene";
  29286. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29287. import { Node } from "babylonjs/node";
  29288. import { Mesh } from "babylonjs/Meshes/mesh";
  29289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29290. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29291. import { Viewport } from "babylonjs/Maths/math.viewport";
  29292. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29293. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29295. import { Ray } from "babylonjs/Culling/ray";
  29296. /**
  29297. * This is the base class of all the camera used in the application.
  29298. * @see http://doc.babylonjs.com/features/cameras
  29299. */
  29300. export class Camera extends Node {
  29301. /** @hidden */
  29302. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29303. /**
  29304. * This is the default projection mode used by the cameras.
  29305. * It helps recreating a feeling of perspective and better appreciate depth.
  29306. * This is the best way to simulate real life cameras.
  29307. */
  29308. static readonly PERSPECTIVE_CAMERA: number;
  29309. /**
  29310. * This helps creating camera with an orthographic mode.
  29311. * 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.
  29312. */
  29313. static readonly ORTHOGRAPHIC_CAMERA: number;
  29314. /**
  29315. * This is the default FOV mode for perspective cameras.
  29316. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29317. */
  29318. static readonly FOVMODE_VERTICAL_FIXED: number;
  29319. /**
  29320. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29321. */
  29322. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29323. /**
  29324. * This specifies ther is no need for a camera rig.
  29325. * Basically only one eye is rendered corresponding to the camera.
  29326. */
  29327. static readonly RIG_MODE_NONE: number;
  29328. /**
  29329. * Simulates a camera Rig with one blue eye and one red eye.
  29330. * This can be use with 3d blue and red glasses.
  29331. */
  29332. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29333. /**
  29334. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29335. */
  29336. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29337. /**
  29338. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29339. */
  29340. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29341. /**
  29342. * Defines that both eyes of the camera will be rendered over under each other.
  29343. */
  29344. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29345. /**
  29346. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29347. */
  29348. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29349. /**
  29350. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29351. */
  29352. static readonly RIG_MODE_VR: number;
  29353. /**
  29354. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29355. */
  29356. static readonly RIG_MODE_WEBVR: number;
  29357. /**
  29358. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29359. */
  29360. static readonly RIG_MODE_CUSTOM: number;
  29361. /**
  29362. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29363. */
  29364. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29365. /**
  29366. * Define the input manager associated with the camera.
  29367. */
  29368. inputs: CameraInputsManager<Camera>;
  29369. /** @hidden */
  29370. _position: Vector3;
  29371. /**
  29372. * Define the current local position of the camera in the scene
  29373. */
  29374. get position(): Vector3;
  29375. set position(newPosition: Vector3);
  29376. /**
  29377. * The vector the camera should consider as up.
  29378. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29379. */
  29380. upVector: Vector3;
  29381. /**
  29382. * Define the current limit on the left side for an orthographic camera
  29383. * In scene unit
  29384. */
  29385. orthoLeft: Nullable<number>;
  29386. /**
  29387. * Define the current limit on the right side for an orthographic camera
  29388. * In scene unit
  29389. */
  29390. orthoRight: Nullable<number>;
  29391. /**
  29392. * Define the current limit on the bottom side for an orthographic camera
  29393. * In scene unit
  29394. */
  29395. orthoBottom: Nullable<number>;
  29396. /**
  29397. * Define the current limit on the top side for an orthographic camera
  29398. * In scene unit
  29399. */
  29400. orthoTop: Nullable<number>;
  29401. /**
  29402. * Field Of View is set in Radians. (default is 0.8)
  29403. */
  29404. fov: number;
  29405. /**
  29406. * Define the minimum distance the camera can see from.
  29407. * This is important to note that the depth buffer are not infinite and the closer it starts
  29408. * the more your scene might encounter depth fighting issue.
  29409. */
  29410. minZ: number;
  29411. /**
  29412. * Define the maximum distance the camera can see to.
  29413. * This is important to note that the depth buffer are not infinite and the further it end
  29414. * the more your scene might encounter depth fighting issue.
  29415. */
  29416. maxZ: number;
  29417. /**
  29418. * Define the default inertia of the camera.
  29419. * This helps giving a smooth feeling to the camera movement.
  29420. */
  29421. inertia: number;
  29422. /**
  29423. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29424. */
  29425. mode: number;
  29426. /**
  29427. * Define whether the camera is intermediate.
  29428. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29429. */
  29430. isIntermediate: boolean;
  29431. /**
  29432. * Define the viewport of the camera.
  29433. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29434. */
  29435. viewport: Viewport;
  29436. /**
  29437. * Restricts the camera to viewing objects with the same layerMask.
  29438. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29439. */
  29440. layerMask: number;
  29441. /**
  29442. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29443. */
  29444. fovMode: number;
  29445. /**
  29446. * Rig mode of the camera.
  29447. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29448. * This is normally controlled byt the camera themselves as internal use.
  29449. */
  29450. cameraRigMode: number;
  29451. /**
  29452. * Defines the distance between both "eyes" in case of a RIG
  29453. */
  29454. interaxialDistance: number;
  29455. /**
  29456. * Defines if stereoscopic rendering is done side by side or over under.
  29457. */
  29458. isStereoscopicSideBySide: boolean;
  29459. /**
  29460. * 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
  29461. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29462. * else in the scene. (Eg. security camera)
  29463. *
  29464. * 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)
  29465. */
  29466. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29467. /**
  29468. * When set, the camera will render to this render target instead of the default canvas
  29469. *
  29470. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29471. */
  29472. outputRenderTarget: Nullable<RenderTargetTexture>;
  29473. /**
  29474. * Observable triggered when the camera view matrix has changed.
  29475. */
  29476. onViewMatrixChangedObservable: Observable<Camera>;
  29477. /**
  29478. * Observable triggered when the camera Projection matrix has changed.
  29479. */
  29480. onProjectionMatrixChangedObservable: Observable<Camera>;
  29481. /**
  29482. * Observable triggered when the inputs have been processed.
  29483. */
  29484. onAfterCheckInputsObservable: Observable<Camera>;
  29485. /**
  29486. * Observable triggered when reset has been called and applied to the camera.
  29487. */
  29488. onRestoreStateObservable: Observable<Camera>;
  29489. /**
  29490. * Is this camera a part of a rig system?
  29491. */
  29492. isRigCamera: boolean;
  29493. /**
  29494. * If isRigCamera set to true this will be set with the parent camera.
  29495. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29496. */
  29497. rigParent?: Camera;
  29498. /** @hidden */
  29499. _cameraRigParams: any;
  29500. /** @hidden */
  29501. _rigCameras: Camera[];
  29502. /** @hidden */
  29503. _rigPostProcess: Nullable<PostProcess>;
  29504. protected _webvrViewMatrix: Matrix;
  29505. /** @hidden */
  29506. _skipRendering: boolean;
  29507. /** @hidden */
  29508. _projectionMatrix: Matrix;
  29509. /** @hidden */
  29510. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29511. /** @hidden */
  29512. _activeMeshes: SmartArray<AbstractMesh>;
  29513. protected _globalPosition: Vector3;
  29514. /** @hidden */
  29515. _computedViewMatrix: Matrix;
  29516. private _doNotComputeProjectionMatrix;
  29517. private _transformMatrix;
  29518. private _frustumPlanes;
  29519. private _refreshFrustumPlanes;
  29520. private _storedFov;
  29521. private _stateStored;
  29522. /**
  29523. * Instantiates a new camera object.
  29524. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29525. * @see http://doc.babylonjs.com/features/cameras
  29526. * @param name Defines the name of the camera in the scene
  29527. * @param position Defines the position of the camera
  29528. * @param scene Defines the scene the camera belongs too
  29529. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29530. */
  29531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29532. /**
  29533. * Store current camera state (fov, position, etc..)
  29534. * @returns the camera
  29535. */
  29536. storeState(): Camera;
  29537. /**
  29538. * Restores the camera state values if it has been stored. You must call storeState() first
  29539. */
  29540. protected _restoreStateValues(): boolean;
  29541. /**
  29542. * Restored camera state. You must call storeState() first.
  29543. * @returns true if restored and false otherwise
  29544. */
  29545. restoreState(): boolean;
  29546. /**
  29547. * Gets the class name of the camera.
  29548. * @returns the class name
  29549. */
  29550. getClassName(): string;
  29551. /** @hidden */
  29552. readonly _isCamera: boolean;
  29553. /**
  29554. * Gets a string representation of the camera useful for debug purpose.
  29555. * @param fullDetails Defines that a more verboe level of logging is required
  29556. * @returns the string representation
  29557. */
  29558. toString(fullDetails?: boolean): string;
  29559. /**
  29560. * Gets the current world space position of the camera.
  29561. */
  29562. get globalPosition(): Vector3;
  29563. /**
  29564. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29565. * @returns the active meshe list
  29566. */
  29567. getActiveMeshes(): SmartArray<AbstractMesh>;
  29568. /**
  29569. * Check whether a mesh is part of the current active mesh list of the camera
  29570. * @param mesh Defines the mesh to check
  29571. * @returns true if active, false otherwise
  29572. */
  29573. isActiveMesh(mesh: Mesh): boolean;
  29574. /**
  29575. * Is this camera ready to be used/rendered
  29576. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29577. * @return true if the camera is ready
  29578. */
  29579. isReady(completeCheck?: boolean): boolean;
  29580. /** @hidden */
  29581. _initCache(): void;
  29582. /** @hidden */
  29583. _updateCache(ignoreParentClass?: boolean): void;
  29584. /** @hidden */
  29585. _isSynchronized(): boolean;
  29586. /** @hidden */
  29587. _isSynchronizedViewMatrix(): boolean;
  29588. /** @hidden */
  29589. _isSynchronizedProjectionMatrix(): boolean;
  29590. /**
  29591. * Attach the input controls to a specific dom element to get the input from.
  29592. * @param element Defines the element the controls should be listened from
  29593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29594. */
  29595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29596. /**
  29597. * Detach the current controls from the specified dom element.
  29598. * @param element Defines the element to stop listening the inputs from
  29599. */
  29600. detachControl(element: HTMLElement): void;
  29601. /**
  29602. * Update the camera state according to the different inputs gathered during the frame.
  29603. */
  29604. update(): void;
  29605. /** @hidden */
  29606. _checkInputs(): void;
  29607. /** @hidden */
  29608. get rigCameras(): Camera[];
  29609. /**
  29610. * Gets the post process used by the rig cameras
  29611. */
  29612. get rigPostProcess(): Nullable<PostProcess>;
  29613. /**
  29614. * Internal, gets the first post proces.
  29615. * @returns the first post process to be run on this camera.
  29616. */
  29617. _getFirstPostProcess(): Nullable<PostProcess>;
  29618. private _cascadePostProcessesToRigCams;
  29619. /**
  29620. * Attach a post process to the camera.
  29621. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29622. * @param postProcess The post process to attach to the camera
  29623. * @param insertAt The position of the post process in case several of them are in use in the scene
  29624. * @returns the position the post process has been inserted at
  29625. */
  29626. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29627. /**
  29628. * Detach a post process to the camera.
  29629. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29630. * @param postProcess The post process to detach from the camera
  29631. */
  29632. detachPostProcess(postProcess: PostProcess): void;
  29633. /**
  29634. * Gets the current world matrix of the camera
  29635. */
  29636. getWorldMatrix(): Matrix;
  29637. /** @hidden */
  29638. _getViewMatrix(): Matrix;
  29639. /**
  29640. * Gets the current view matrix of the camera.
  29641. * @param force forces the camera to recompute the matrix without looking at the cached state
  29642. * @returns the view matrix
  29643. */
  29644. getViewMatrix(force?: boolean): Matrix;
  29645. /**
  29646. * Freeze the projection matrix.
  29647. * It will prevent the cache check of the camera projection compute and can speed up perf
  29648. * if no parameter of the camera are meant to change
  29649. * @param projection Defines manually a projection if necessary
  29650. */
  29651. freezeProjectionMatrix(projection?: Matrix): void;
  29652. /**
  29653. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29654. */
  29655. unfreezeProjectionMatrix(): void;
  29656. /**
  29657. * Gets the current projection matrix of the camera.
  29658. * @param force forces the camera to recompute the matrix without looking at the cached state
  29659. * @returns the projection matrix
  29660. */
  29661. getProjectionMatrix(force?: boolean): Matrix;
  29662. /**
  29663. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29664. * @returns a Matrix
  29665. */
  29666. getTransformationMatrix(): Matrix;
  29667. private _updateFrustumPlanes;
  29668. /**
  29669. * Checks if a cullable object (mesh...) is in the camera frustum
  29670. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29671. * @param target The object to check
  29672. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29673. * @returns true if the object is in frustum otherwise false
  29674. */
  29675. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29676. /**
  29677. * Checks if a cullable object (mesh...) is in the camera frustum
  29678. * Unlike isInFrustum this cheks the full bounding box
  29679. * @param target The object to check
  29680. * @returns true if the object is in frustum otherwise false
  29681. */
  29682. isCompletelyInFrustum(target: ICullable): boolean;
  29683. /**
  29684. * Gets a ray in the forward direction from the camera.
  29685. * @param length Defines the length of the ray to create
  29686. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29687. * @param origin Defines the start point of the ray which defaults to the camera position
  29688. * @returns the forward ray
  29689. */
  29690. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29691. /**
  29692. * Releases resources associated with this node.
  29693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29695. */
  29696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29697. /** @hidden */
  29698. _isLeftCamera: boolean;
  29699. /**
  29700. * Gets the left camera of a rig setup in case of Rigged Camera
  29701. */
  29702. get isLeftCamera(): boolean;
  29703. /** @hidden */
  29704. _isRightCamera: boolean;
  29705. /**
  29706. * Gets the right camera of a rig setup in case of Rigged Camera
  29707. */
  29708. get isRightCamera(): boolean;
  29709. /**
  29710. * Gets the left camera of a rig setup in case of Rigged Camera
  29711. */
  29712. get leftCamera(): Nullable<FreeCamera>;
  29713. /**
  29714. * Gets the right camera of a rig setup in case of Rigged Camera
  29715. */
  29716. get rightCamera(): Nullable<FreeCamera>;
  29717. /**
  29718. * Gets the left camera target of a rig setup in case of Rigged Camera
  29719. * @returns the target position
  29720. */
  29721. getLeftTarget(): Nullable<Vector3>;
  29722. /**
  29723. * Gets the right camera target of a rig setup in case of Rigged Camera
  29724. * @returns the target position
  29725. */
  29726. getRightTarget(): Nullable<Vector3>;
  29727. /**
  29728. * @hidden
  29729. */
  29730. setCameraRigMode(mode: number, rigParams: any): void;
  29731. /** @hidden */
  29732. static _setStereoscopicRigMode(camera: Camera): void;
  29733. /** @hidden */
  29734. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29735. /** @hidden */
  29736. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29737. /** @hidden */
  29738. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29739. /** @hidden */
  29740. _getVRProjectionMatrix(): Matrix;
  29741. protected _updateCameraRotationMatrix(): void;
  29742. protected _updateWebVRCameraRotationMatrix(): void;
  29743. /**
  29744. * This function MUST be overwritten by the different WebVR cameras available.
  29745. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29746. * @hidden
  29747. */
  29748. _getWebVRProjectionMatrix(): Matrix;
  29749. /**
  29750. * This function MUST be overwritten by the different WebVR cameras available.
  29751. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29752. * @hidden
  29753. */
  29754. _getWebVRViewMatrix(): Matrix;
  29755. /** @hidden */
  29756. setCameraRigParameter(name: string, value: any): void;
  29757. /**
  29758. * needs to be overridden by children so sub has required properties to be copied
  29759. * @hidden
  29760. */
  29761. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29762. /**
  29763. * May need to be overridden by children
  29764. * @hidden
  29765. */
  29766. _updateRigCameras(): void;
  29767. /** @hidden */
  29768. _setupInputs(): void;
  29769. /**
  29770. * Serialiaze the camera setup to a json represention
  29771. * @returns the JSON representation
  29772. */
  29773. serialize(): any;
  29774. /**
  29775. * Clones the current camera.
  29776. * @param name The cloned camera name
  29777. * @returns the cloned camera
  29778. */
  29779. clone(name: string): Camera;
  29780. /**
  29781. * Gets the direction of the camera relative to a given local axis.
  29782. * @param localAxis Defines the reference axis to provide a relative direction.
  29783. * @return the direction
  29784. */
  29785. getDirection(localAxis: Vector3): Vector3;
  29786. /**
  29787. * Returns the current camera absolute rotation
  29788. */
  29789. get absoluteRotation(): Quaternion;
  29790. /**
  29791. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29792. * @param localAxis Defines the reference axis to provide a relative direction.
  29793. * @param result Defines the vector to store the result in
  29794. */
  29795. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29796. /**
  29797. * Gets a camera constructor for a given camera type
  29798. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29799. * @param name The name of the camera the result will be able to instantiate
  29800. * @param scene The scene the result will construct the camera in
  29801. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29802. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29803. * @returns a factory method to construc the camera
  29804. */
  29805. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29806. /**
  29807. * Compute the world matrix of the camera.
  29808. * @returns the camera world matrix
  29809. */
  29810. computeWorldMatrix(): Matrix;
  29811. /**
  29812. * Parse a JSON and creates the camera from the parsed information
  29813. * @param parsedCamera The JSON to parse
  29814. * @param scene The scene to instantiate the camera in
  29815. * @returns the newly constructed camera
  29816. */
  29817. static Parse(parsedCamera: any, scene: Scene): Camera;
  29818. }
  29819. }
  29820. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29821. import { Nullable } from "babylonjs/types";
  29822. import { Scene } from "babylonjs/scene";
  29823. import { Vector4 } from "babylonjs/Maths/math.vector";
  29824. import { Mesh } from "babylonjs/Meshes/mesh";
  29825. /**
  29826. * Class containing static functions to help procedurally build meshes
  29827. */
  29828. export class DiscBuilder {
  29829. /**
  29830. * Creates a plane polygonal mesh. By default, this is a disc
  29831. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29832. * * 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
  29833. * * 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
  29834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29837. * @param name defines the name of the mesh
  29838. * @param options defines the options used to create the mesh
  29839. * @param scene defines the hosting scene
  29840. * @returns the plane polygonal mesh
  29841. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29842. */
  29843. static CreateDisc(name: string, options: {
  29844. radius?: number;
  29845. tessellation?: number;
  29846. arc?: number;
  29847. updatable?: boolean;
  29848. sideOrientation?: number;
  29849. frontUVs?: Vector4;
  29850. backUVs?: Vector4;
  29851. }, scene?: Nullable<Scene>): Mesh;
  29852. }
  29853. }
  29854. declare module "babylonjs/Materials/fresnelParameters" {
  29855. import { DeepImmutable } from "babylonjs/types";
  29856. import { Color3 } from "babylonjs/Maths/math.color";
  29857. /**
  29858. * Options to be used when creating a FresnelParameters.
  29859. */
  29860. export type IFresnelParametersCreationOptions = {
  29861. /**
  29862. * Define the color used on edges (grazing angle)
  29863. */
  29864. leftColor?: Color3;
  29865. /**
  29866. * Define the color used on center
  29867. */
  29868. rightColor?: Color3;
  29869. /**
  29870. * Define bias applied to computed fresnel term
  29871. */
  29872. bias?: number;
  29873. /**
  29874. * Defined the power exponent applied to fresnel term
  29875. */
  29876. power?: number;
  29877. /**
  29878. * Define if the fresnel effect is enable or not.
  29879. */
  29880. isEnabled?: boolean;
  29881. };
  29882. /**
  29883. * Serialized format for FresnelParameters.
  29884. */
  29885. export type IFresnelParametersSerialized = {
  29886. /**
  29887. * Define the color used on edges (grazing angle) [as an array]
  29888. */
  29889. leftColor: number[];
  29890. /**
  29891. * Define the color used on center [as an array]
  29892. */
  29893. rightColor: number[];
  29894. /**
  29895. * Define bias applied to computed fresnel term
  29896. */
  29897. bias: number;
  29898. /**
  29899. * Defined the power exponent applied to fresnel term
  29900. */
  29901. power?: number;
  29902. /**
  29903. * Define if the fresnel effect is enable or not.
  29904. */
  29905. isEnabled: boolean;
  29906. };
  29907. /**
  29908. * This represents all the required information to add a fresnel effect on a material:
  29909. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29910. */
  29911. export class FresnelParameters {
  29912. private _isEnabled;
  29913. /**
  29914. * Define if the fresnel effect is enable or not.
  29915. */
  29916. get isEnabled(): boolean;
  29917. set isEnabled(value: boolean);
  29918. /**
  29919. * Define the color used on edges (grazing angle)
  29920. */
  29921. leftColor: Color3;
  29922. /**
  29923. * Define the color used on center
  29924. */
  29925. rightColor: Color3;
  29926. /**
  29927. * Define bias applied to computed fresnel term
  29928. */
  29929. bias: number;
  29930. /**
  29931. * Defined the power exponent applied to fresnel term
  29932. */
  29933. power: number;
  29934. /**
  29935. * Creates a new FresnelParameters object.
  29936. *
  29937. * @param options provide your own settings to optionally to override defaults
  29938. */
  29939. constructor(options?: IFresnelParametersCreationOptions);
  29940. /**
  29941. * Clones the current fresnel and its valuues
  29942. * @returns a clone fresnel configuration
  29943. */
  29944. clone(): FresnelParameters;
  29945. /**
  29946. * Determines equality between FresnelParameters objects
  29947. * @param otherFresnelParameters defines the second operand
  29948. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29949. */
  29950. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29951. /**
  29952. * Serializes the current fresnel parameters to a JSON representation.
  29953. * @return the JSON serialization
  29954. */
  29955. serialize(): IFresnelParametersSerialized;
  29956. /**
  29957. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29958. * @param parsedFresnelParameters Define the JSON representation
  29959. * @returns the parsed parameters
  29960. */
  29961. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29962. }
  29963. }
  29964. declare module "babylonjs/Materials/materialFlags" {
  29965. /**
  29966. * This groups all the flags used to control the materials channel.
  29967. */
  29968. export class MaterialFlags {
  29969. private static _DiffuseTextureEnabled;
  29970. /**
  29971. * Are diffuse textures enabled in the application.
  29972. */
  29973. static get DiffuseTextureEnabled(): boolean;
  29974. static set DiffuseTextureEnabled(value: boolean);
  29975. private static _DetailTextureEnabled;
  29976. /**
  29977. * Are detail textures enabled in the application.
  29978. */
  29979. static get DetailTextureEnabled(): boolean;
  29980. static set DetailTextureEnabled(value: boolean);
  29981. private static _AmbientTextureEnabled;
  29982. /**
  29983. * Are ambient textures enabled in the application.
  29984. */
  29985. static get AmbientTextureEnabled(): boolean;
  29986. static set AmbientTextureEnabled(value: boolean);
  29987. private static _OpacityTextureEnabled;
  29988. /**
  29989. * Are opacity textures enabled in the application.
  29990. */
  29991. static get OpacityTextureEnabled(): boolean;
  29992. static set OpacityTextureEnabled(value: boolean);
  29993. private static _ReflectionTextureEnabled;
  29994. /**
  29995. * Are reflection textures enabled in the application.
  29996. */
  29997. static get ReflectionTextureEnabled(): boolean;
  29998. static set ReflectionTextureEnabled(value: boolean);
  29999. private static _EmissiveTextureEnabled;
  30000. /**
  30001. * Are emissive textures enabled in the application.
  30002. */
  30003. static get EmissiveTextureEnabled(): boolean;
  30004. static set EmissiveTextureEnabled(value: boolean);
  30005. private static _SpecularTextureEnabled;
  30006. /**
  30007. * Are specular textures enabled in the application.
  30008. */
  30009. static get SpecularTextureEnabled(): boolean;
  30010. static set SpecularTextureEnabled(value: boolean);
  30011. private static _BumpTextureEnabled;
  30012. /**
  30013. * Are bump textures enabled in the application.
  30014. */
  30015. static get BumpTextureEnabled(): boolean;
  30016. static set BumpTextureEnabled(value: boolean);
  30017. private static _LightmapTextureEnabled;
  30018. /**
  30019. * Are lightmap textures enabled in the application.
  30020. */
  30021. static get LightmapTextureEnabled(): boolean;
  30022. static set LightmapTextureEnabled(value: boolean);
  30023. private static _RefractionTextureEnabled;
  30024. /**
  30025. * Are refraction textures enabled in the application.
  30026. */
  30027. static get RefractionTextureEnabled(): boolean;
  30028. static set RefractionTextureEnabled(value: boolean);
  30029. private static _ColorGradingTextureEnabled;
  30030. /**
  30031. * Are color grading textures enabled in the application.
  30032. */
  30033. static get ColorGradingTextureEnabled(): boolean;
  30034. static set ColorGradingTextureEnabled(value: boolean);
  30035. private static _FresnelEnabled;
  30036. /**
  30037. * Are fresnels enabled in the application.
  30038. */
  30039. static get FresnelEnabled(): boolean;
  30040. static set FresnelEnabled(value: boolean);
  30041. private static _ClearCoatTextureEnabled;
  30042. /**
  30043. * Are clear coat textures enabled in the application.
  30044. */
  30045. static get ClearCoatTextureEnabled(): boolean;
  30046. static set ClearCoatTextureEnabled(value: boolean);
  30047. private static _ClearCoatBumpTextureEnabled;
  30048. /**
  30049. * Are clear coat bump textures enabled in the application.
  30050. */
  30051. static get ClearCoatBumpTextureEnabled(): boolean;
  30052. static set ClearCoatBumpTextureEnabled(value: boolean);
  30053. private static _ClearCoatTintTextureEnabled;
  30054. /**
  30055. * Are clear coat tint textures enabled in the application.
  30056. */
  30057. static get ClearCoatTintTextureEnabled(): boolean;
  30058. static set ClearCoatTintTextureEnabled(value: boolean);
  30059. private static _SheenTextureEnabled;
  30060. /**
  30061. * Are sheen textures enabled in the application.
  30062. */
  30063. static get SheenTextureEnabled(): boolean;
  30064. static set SheenTextureEnabled(value: boolean);
  30065. private static _AnisotropicTextureEnabled;
  30066. /**
  30067. * Are anisotropic textures enabled in the application.
  30068. */
  30069. static get AnisotropicTextureEnabled(): boolean;
  30070. static set AnisotropicTextureEnabled(value: boolean);
  30071. private static _ThicknessTextureEnabled;
  30072. /**
  30073. * Are thickness textures enabled in the application.
  30074. */
  30075. static get ThicknessTextureEnabled(): boolean;
  30076. static set ThicknessTextureEnabled(value: boolean);
  30077. }
  30078. }
  30079. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30080. /** @hidden */
  30081. export var defaultFragmentDeclaration: {
  30082. name: string;
  30083. shader: string;
  30084. };
  30085. }
  30086. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30087. /** @hidden */
  30088. export var defaultUboDeclaration: {
  30089. name: string;
  30090. shader: string;
  30091. };
  30092. }
  30093. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30094. /** @hidden */
  30095. export var lightFragmentDeclaration: {
  30096. name: string;
  30097. shader: string;
  30098. };
  30099. }
  30100. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30101. /** @hidden */
  30102. export var lightUboDeclaration: {
  30103. name: string;
  30104. shader: string;
  30105. };
  30106. }
  30107. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30108. /** @hidden */
  30109. export var lightsFragmentFunctions: {
  30110. name: string;
  30111. shader: string;
  30112. };
  30113. }
  30114. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30115. /** @hidden */
  30116. export var shadowsFragmentFunctions: {
  30117. name: string;
  30118. shader: string;
  30119. };
  30120. }
  30121. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30122. /** @hidden */
  30123. export var fresnelFunction: {
  30124. name: string;
  30125. shader: string;
  30126. };
  30127. }
  30128. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30129. /** @hidden */
  30130. export var bumpFragmentMainFunctions: {
  30131. name: string;
  30132. shader: string;
  30133. };
  30134. }
  30135. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30136. /** @hidden */
  30137. export var bumpFragmentFunctions: {
  30138. name: string;
  30139. shader: string;
  30140. };
  30141. }
  30142. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30143. /** @hidden */
  30144. export var logDepthDeclaration: {
  30145. name: string;
  30146. shader: string;
  30147. };
  30148. }
  30149. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30150. /** @hidden */
  30151. export var bumpFragment: {
  30152. name: string;
  30153. shader: string;
  30154. };
  30155. }
  30156. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30157. /** @hidden */
  30158. export var depthPrePass: {
  30159. name: string;
  30160. shader: string;
  30161. };
  30162. }
  30163. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30164. /** @hidden */
  30165. export var lightFragment: {
  30166. name: string;
  30167. shader: string;
  30168. };
  30169. }
  30170. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30171. /** @hidden */
  30172. export var logDepthFragment: {
  30173. name: string;
  30174. shader: string;
  30175. };
  30176. }
  30177. declare module "babylonjs/Shaders/default.fragment" {
  30178. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30179. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30180. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30181. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30182. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30183. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30184. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30185. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30187. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30188. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30189. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30190. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30192. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30193. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30194. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30195. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30196. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30197. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30198. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30199. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30200. /** @hidden */
  30201. export var defaultPixelShader: {
  30202. name: string;
  30203. shader: string;
  30204. };
  30205. }
  30206. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30207. /** @hidden */
  30208. export var defaultVertexDeclaration: {
  30209. name: string;
  30210. shader: string;
  30211. };
  30212. }
  30213. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30214. /** @hidden */
  30215. export var bumpVertexDeclaration: {
  30216. name: string;
  30217. shader: string;
  30218. };
  30219. }
  30220. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30221. /** @hidden */
  30222. export var bumpVertex: {
  30223. name: string;
  30224. shader: string;
  30225. };
  30226. }
  30227. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30228. /** @hidden */
  30229. export var fogVertex: {
  30230. name: string;
  30231. shader: string;
  30232. };
  30233. }
  30234. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30235. /** @hidden */
  30236. export var shadowsVertex: {
  30237. name: string;
  30238. shader: string;
  30239. };
  30240. }
  30241. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30242. /** @hidden */
  30243. export var pointCloudVertex: {
  30244. name: string;
  30245. shader: string;
  30246. };
  30247. }
  30248. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30249. /** @hidden */
  30250. export var logDepthVertex: {
  30251. name: string;
  30252. shader: string;
  30253. };
  30254. }
  30255. declare module "babylonjs/Shaders/default.vertex" {
  30256. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30257. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30258. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30259. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30260. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30261. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30262. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30263. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30264. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30265. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30266. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30267. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30268. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30269. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30270. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30271. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30272. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30273. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30274. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30275. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30276. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30277. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30278. /** @hidden */
  30279. export var defaultVertexShader: {
  30280. name: string;
  30281. shader: string;
  30282. };
  30283. }
  30284. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30285. import { Nullable } from "babylonjs/types";
  30286. import { Scene } from "babylonjs/scene";
  30287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30288. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30289. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30290. /**
  30291. * @hidden
  30292. */
  30293. export interface IMaterialDetailMapDefines {
  30294. DETAIL: boolean;
  30295. DETAILDIRECTUV: number;
  30296. DETAIL_NORMALBLENDMETHOD: number;
  30297. /** @hidden */
  30298. _areTexturesDirty: boolean;
  30299. }
  30300. /**
  30301. * Define the code related to the detail map parameters of a material
  30302. *
  30303. * Inspired from:
  30304. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  30305. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30306. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30307. */
  30308. export class DetailMapConfiguration {
  30309. private _texture;
  30310. /**
  30311. * The detail texture of the material.
  30312. */
  30313. texture: Nullable<BaseTexture>;
  30314. /**
  30315. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30316. * Bigger values mean stronger blending
  30317. */
  30318. diffuseBlendLevel: number;
  30319. /**
  30320. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30321. * Bigger values mean stronger blending. Only used with PBR materials
  30322. */
  30323. roughnessBlendLevel: number;
  30324. /**
  30325. * Defines how strong the bump effect from the detail map is
  30326. * Bigger values mean stronger effect
  30327. */
  30328. bumpLevel: number;
  30329. private _normalBlendMethod;
  30330. /**
  30331. * The method used to blend the bump and detail normals together
  30332. */
  30333. normalBlendMethod: number;
  30334. private _isEnabled;
  30335. /**
  30336. * Enable or disable the detail map on this material
  30337. */
  30338. isEnabled: boolean;
  30339. /** @hidden */
  30340. private _internalMarkAllSubMeshesAsTexturesDirty;
  30341. /** @hidden */
  30342. _markAllSubMeshesAsTexturesDirty(): void;
  30343. /**
  30344. * Instantiate a new detail map
  30345. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30346. */
  30347. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30348. /**
  30349. * Gets whether the submesh is ready to be used or not.
  30350. * @param defines the list of "defines" to update.
  30351. * @param scene defines the scene the material belongs to.
  30352. * @returns - boolean indicating that the submesh is ready or not.
  30353. */
  30354. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30355. /**
  30356. * Update the defines for detail map usage
  30357. * @param defines the list of "defines" to update.
  30358. * @param scene defines the scene the material belongs to.
  30359. */
  30360. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30361. /**
  30362. * Binds the material data.
  30363. * @param uniformBuffer defines the Uniform buffer to fill in.
  30364. * @param scene defines the scene the material belongs to.
  30365. * @param isFrozen defines whether the material is frozen or not.
  30366. */
  30367. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30368. /**
  30369. * Checks to see if a texture is used in the material.
  30370. * @param texture - Base texture to use.
  30371. * @returns - Boolean specifying if a texture is used in the material.
  30372. */
  30373. hasTexture(texture: BaseTexture): boolean;
  30374. /**
  30375. * Returns an array of the actively used textures.
  30376. * @param activeTextures Array of BaseTextures
  30377. */
  30378. getActiveTextures(activeTextures: BaseTexture[]): void;
  30379. /**
  30380. * Returns the animatable textures.
  30381. * @param animatables Array of animatable textures.
  30382. */
  30383. getAnimatables(animatables: IAnimatable[]): void;
  30384. /**
  30385. * Disposes the resources of the material.
  30386. * @param forceDisposeTextures - Forces the disposal of all textures.
  30387. */
  30388. dispose(forceDisposeTextures?: boolean): void;
  30389. /**
  30390. * Get the current class name useful for serialization or dynamic coding.
  30391. * @returns "DetailMap"
  30392. */
  30393. getClassName(): string;
  30394. /**
  30395. * Add the required uniforms to the current list.
  30396. * @param uniforms defines the current uniform list.
  30397. */
  30398. static AddUniforms(uniforms: string[]): void;
  30399. /**
  30400. * Add the required samplers to the current list.
  30401. * @param samplers defines the current sampler list.
  30402. */
  30403. static AddSamplers(samplers: string[]): void;
  30404. /**
  30405. * Add the required uniforms to the current buffer.
  30406. * @param uniformBuffer defines the current uniform buffer.
  30407. */
  30408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30409. /**
  30410. * Makes a duplicate of the current instance into another one.
  30411. * @param detailMap define the instance where to copy the info
  30412. */
  30413. copyTo(detailMap: DetailMapConfiguration): void;
  30414. /**
  30415. * Serializes this detail map instance
  30416. * @returns - An object with the serialized instance.
  30417. */
  30418. serialize(): any;
  30419. /**
  30420. * Parses a detail map setting from a serialized object.
  30421. * @param source - Serialized object.
  30422. * @param scene Defines the scene we are parsing for
  30423. * @param rootUrl Defines the rootUrl to load from
  30424. */
  30425. parse(source: any, scene: Scene, rootUrl: string): void;
  30426. }
  30427. }
  30428. declare module "babylonjs/Materials/standardMaterial" {
  30429. import { SmartArray } from "babylonjs/Misc/smartArray";
  30430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30431. import { Nullable } from "babylonjs/types";
  30432. import { Scene } from "babylonjs/scene";
  30433. import { Matrix } from "babylonjs/Maths/math.vector";
  30434. import { Color3 } from "babylonjs/Maths/math.color";
  30435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30437. import { Mesh } from "babylonjs/Meshes/mesh";
  30438. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30439. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30440. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30441. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30442. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30444. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30445. import "babylonjs/Shaders/default.fragment";
  30446. import "babylonjs/Shaders/default.vertex";
  30447. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30448. /** @hidden */
  30449. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30450. MAINUV1: boolean;
  30451. MAINUV2: boolean;
  30452. DIFFUSE: boolean;
  30453. DIFFUSEDIRECTUV: number;
  30454. DETAIL: boolean;
  30455. DETAILDIRECTUV: number;
  30456. DETAIL_NORMALBLENDMETHOD: number;
  30457. AMBIENT: boolean;
  30458. AMBIENTDIRECTUV: number;
  30459. OPACITY: boolean;
  30460. OPACITYDIRECTUV: number;
  30461. OPACITYRGB: boolean;
  30462. REFLECTION: boolean;
  30463. EMISSIVE: boolean;
  30464. EMISSIVEDIRECTUV: number;
  30465. SPECULAR: boolean;
  30466. SPECULARDIRECTUV: number;
  30467. BUMP: boolean;
  30468. BUMPDIRECTUV: number;
  30469. PARALLAX: boolean;
  30470. PARALLAXOCCLUSION: boolean;
  30471. SPECULAROVERALPHA: boolean;
  30472. CLIPPLANE: boolean;
  30473. CLIPPLANE2: boolean;
  30474. CLIPPLANE3: boolean;
  30475. CLIPPLANE4: boolean;
  30476. CLIPPLANE5: boolean;
  30477. CLIPPLANE6: boolean;
  30478. ALPHATEST: boolean;
  30479. DEPTHPREPASS: boolean;
  30480. ALPHAFROMDIFFUSE: boolean;
  30481. POINTSIZE: boolean;
  30482. FOG: boolean;
  30483. SPECULARTERM: boolean;
  30484. DIFFUSEFRESNEL: boolean;
  30485. OPACITYFRESNEL: boolean;
  30486. REFLECTIONFRESNEL: boolean;
  30487. REFRACTIONFRESNEL: boolean;
  30488. EMISSIVEFRESNEL: boolean;
  30489. FRESNEL: boolean;
  30490. NORMAL: boolean;
  30491. UV1: boolean;
  30492. UV2: boolean;
  30493. VERTEXCOLOR: boolean;
  30494. VERTEXALPHA: boolean;
  30495. NUM_BONE_INFLUENCERS: number;
  30496. BonesPerMesh: number;
  30497. BONETEXTURE: boolean;
  30498. INSTANCES: boolean;
  30499. THIN_INSTANCES: boolean;
  30500. GLOSSINESS: boolean;
  30501. ROUGHNESS: boolean;
  30502. EMISSIVEASILLUMINATION: boolean;
  30503. LINKEMISSIVEWITHDIFFUSE: boolean;
  30504. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30505. LIGHTMAP: boolean;
  30506. LIGHTMAPDIRECTUV: number;
  30507. OBJECTSPACE_NORMALMAP: boolean;
  30508. USELIGHTMAPASSHADOWMAP: boolean;
  30509. REFLECTIONMAP_3D: boolean;
  30510. REFLECTIONMAP_SPHERICAL: boolean;
  30511. REFLECTIONMAP_PLANAR: boolean;
  30512. REFLECTIONMAP_CUBIC: boolean;
  30513. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30514. REFLECTIONMAP_PROJECTION: boolean;
  30515. REFLECTIONMAP_SKYBOX: boolean;
  30516. REFLECTIONMAP_EXPLICIT: boolean;
  30517. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30518. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30519. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30520. INVERTCUBICMAP: boolean;
  30521. LOGARITHMICDEPTH: boolean;
  30522. REFRACTION: boolean;
  30523. REFRACTIONMAP_3D: boolean;
  30524. REFLECTIONOVERALPHA: boolean;
  30525. TWOSIDEDLIGHTING: boolean;
  30526. SHADOWFLOAT: boolean;
  30527. MORPHTARGETS: boolean;
  30528. MORPHTARGETS_NORMAL: boolean;
  30529. MORPHTARGETS_TANGENT: boolean;
  30530. MORPHTARGETS_UV: boolean;
  30531. NUM_MORPH_INFLUENCERS: number;
  30532. NONUNIFORMSCALING: boolean;
  30533. PREMULTIPLYALPHA: boolean;
  30534. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30535. ALPHABLEND: boolean;
  30536. RGBDLIGHTMAP: boolean;
  30537. RGBDREFLECTION: boolean;
  30538. RGBDREFRACTION: boolean;
  30539. IMAGEPROCESSING: boolean;
  30540. VIGNETTE: boolean;
  30541. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30542. VIGNETTEBLENDMODEOPAQUE: boolean;
  30543. TONEMAPPING: boolean;
  30544. TONEMAPPING_ACES: boolean;
  30545. CONTRAST: boolean;
  30546. COLORCURVES: boolean;
  30547. COLORGRADING: boolean;
  30548. COLORGRADING3D: boolean;
  30549. SAMPLER3DGREENDEPTH: boolean;
  30550. SAMPLER3DBGRMAP: boolean;
  30551. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30552. MULTIVIEW: boolean;
  30553. /**
  30554. * If the reflection texture on this material is in linear color space
  30555. * @hidden
  30556. */
  30557. IS_REFLECTION_LINEAR: boolean;
  30558. /**
  30559. * If the refraction texture on this material is in linear color space
  30560. * @hidden
  30561. */
  30562. IS_REFRACTION_LINEAR: boolean;
  30563. EXPOSURE: boolean;
  30564. constructor();
  30565. setReflectionMode(modeToEnable: string): void;
  30566. }
  30567. /**
  30568. * This is the default material used in Babylon. It is the best trade off between quality
  30569. * and performances.
  30570. * @see http://doc.babylonjs.com/babylon101/materials
  30571. */
  30572. export class StandardMaterial extends PushMaterial {
  30573. private _diffuseTexture;
  30574. /**
  30575. * The basic texture of the material as viewed under a light.
  30576. */
  30577. diffuseTexture: Nullable<BaseTexture>;
  30578. private _ambientTexture;
  30579. /**
  30580. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30581. */
  30582. ambientTexture: Nullable<BaseTexture>;
  30583. private _opacityTexture;
  30584. /**
  30585. * Define the transparency of the material from a texture.
  30586. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30587. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30588. */
  30589. opacityTexture: Nullable<BaseTexture>;
  30590. private _reflectionTexture;
  30591. /**
  30592. * Define the texture used to display the reflection.
  30593. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30594. */
  30595. reflectionTexture: Nullable<BaseTexture>;
  30596. private _emissiveTexture;
  30597. /**
  30598. * Define texture of the material as if self lit.
  30599. * This will be mixed in the final result even in the absence of light.
  30600. */
  30601. emissiveTexture: Nullable<BaseTexture>;
  30602. private _specularTexture;
  30603. /**
  30604. * Define how the color and intensity of the highlight given by the light in the material.
  30605. */
  30606. specularTexture: Nullable<BaseTexture>;
  30607. private _bumpTexture;
  30608. /**
  30609. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30610. * 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.
  30611. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30612. */
  30613. bumpTexture: Nullable<BaseTexture>;
  30614. private _lightmapTexture;
  30615. /**
  30616. * Complex lighting can be computationally expensive to compute at runtime.
  30617. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30618. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30619. */
  30620. lightmapTexture: Nullable<BaseTexture>;
  30621. private _refractionTexture;
  30622. /**
  30623. * Define the texture used to display the refraction.
  30624. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30625. */
  30626. refractionTexture: Nullable<BaseTexture>;
  30627. /**
  30628. * The color of the material lit by the environmental background lighting.
  30629. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30630. */
  30631. ambientColor: Color3;
  30632. /**
  30633. * The basic color of the material as viewed under a light.
  30634. */
  30635. diffuseColor: Color3;
  30636. /**
  30637. * Define how the color and intensity of the highlight given by the light in the material.
  30638. */
  30639. specularColor: Color3;
  30640. /**
  30641. * Define the color of the material as if self lit.
  30642. * This will be mixed in the final result even in the absence of light.
  30643. */
  30644. emissiveColor: Color3;
  30645. /**
  30646. * Defines how sharp are the highlights in the material.
  30647. * The bigger the value the sharper giving a more glossy feeling to the result.
  30648. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30649. */
  30650. specularPower: number;
  30651. private _useAlphaFromDiffuseTexture;
  30652. /**
  30653. * Does the transparency come from the diffuse texture alpha channel.
  30654. */
  30655. useAlphaFromDiffuseTexture: boolean;
  30656. private _useEmissiveAsIllumination;
  30657. /**
  30658. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30659. */
  30660. useEmissiveAsIllumination: boolean;
  30661. private _linkEmissiveWithDiffuse;
  30662. /**
  30663. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30664. * the emissive level when the final color is close to one.
  30665. */
  30666. linkEmissiveWithDiffuse: boolean;
  30667. private _useSpecularOverAlpha;
  30668. /**
  30669. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30670. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30671. */
  30672. useSpecularOverAlpha: boolean;
  30673. private _useReflectionOverAlpha;
  30674. /**
  30675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30677. */
  30678. useReflectionOverAlpha: boolean;
  30679. private _disableLighting;
  30680. /**
  30681. * Does lights from the scene impacts this material.
  30682. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30683. */
  30684. disableLighting: boolean;
  30685. private _useObjectSpaceNormalMap;
  30686. /**
  30687. * Allows using an object space normal map (instead of tangent space).
  30688. */
  30689. useObjectSpaceNormalMap: boolean;
  30690. private _useParallax;
  30691. /**
  30692. * Is parallax enabled or not.
  30693. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30694. */
  30695. useParallax: boolean;
  30696. private _useParallaxOcclusion;
  30697. /**
  30698. * Is parallax occlusion enabled or not.
  30699. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30700. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30701. */
  30702. useParallaxOcclusion: boolean;
  30703. /**
  30704. * 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.
  30705. */
  30706. parallaxScaleBias: number;
  30707. private _roughness;
  30708. /**
  30709. * Helps to define how blurry the reflections should appears in the material.
  30710. */
  30711. roughness: number;
  30712. /**
  30713. * In case of refraction, define the value of the index of refraction.
  30714. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30715. */
  30716. indexOfRefraction: number;
  30717. /**
  30718. * Invert the refraction texture alongside the y axis.
  30719. * It can be useful with procedural textures or probe for instance.
  30720. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30721. */
  30722. invertRefractionY: boolean;
  30723. /**
  30724. * Defines the alpha limits in alpha test mode.
  30725. */
  30726. alphaCutOff: number;
  30727. private _useLightmapAsShadowmap;
  30728. /**
  30729. * In case of light mapping, define whether the map contains light or shadow informations.
  30730. */
  30731. useLightmapAsShadowmap: boolean;
  30732. private _diffuseFresnelParameters;
  30733. /**
  30734. * Define the diffuse fresnel parameters of the material.
  30735. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30736. */
  30737. diffuseFresnelParameters: FresnelParameters;
  30738. private _opacityFresnelParameters;
  30739. /**
  30740. * Define the opacity fresnel parameters of the material.
  30741. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30742. */
  30743. opacityFresnelParameters: FresnelParameters;
  30744. private _reflectionFresnelParameters;
  30745. /**
  30746. * Define the reflection fresnel parameters of the material.
  30747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30748. */
  30749. reflectionFresnelParameters: FresnelParameters;
  30750. private _refractionFresnelParameters;
  30751. /**
  30752. * Define the refraction fresnel parameters of the material.
  30753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30754. */
  30755. refractionFresnelParameters: FresnelParameters;
  30756. private _emissiveFresnelParameters;
  30757. /**
  30758. * Define the emissive fresnel parameters of the material.
  30759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30760. */
  30761. emissiveFresnelParameters: FresnelParameters;
  30762. private _useReflectionFresnelFromSpecular;
  30763. /**
  30764. * If true automatically deducts the fresnels values from the material specularity.
  30765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30766. */
  30767. useReflectionFresnelFromSpecular: boolean;
  30768. private _useGlossinessFromSpecularMapAlpha;
  30769. /**
  30770. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30771. */
  30772. useGlossinessFromSpecularMapAlpha: boolean;
  30773. private _maxSimultaneousLights;
  30774. /**
  30775. * Defines the maximum number of lights that can be used in the material
  30776. */
  30777. maxSimultaneousLights: number;
  30778. private _invertNormalMapX;
  30779. /**
  30780. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30781. */
  30782. invertNormalMapX: boolean;
  30783. private _invertNormalMapY;
  30784. /**
  30785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30786. */
  30787. invertNormalMapY: boolean;
  30788. private _twoSidedLighting;
  30789. /**
  30790. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30791. */
  30792. twoSidedLighting: boolean;
  30793. /**
  30794. * Default configuration related to image processing available in the standard Material.
  30795. */
  30796. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30797. /**
  30798. * Gets the image processing configuration used either in this material.
  30799. */
  30800. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30801. /**
  30802. * Sets the Default image processing configuration used either in the this material.
  30803. *
  30804. * If sets to null, the scene one is in use.
  30805. */
  30806. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30807. /**
  30808. * Keep track of the image processing observer to allow dispose and replace.
  30809. */
  30810. private _imageProcessingObserver;
  30811. /**
  30812. * Attaches a new image processing configuration to the Standard Material.
  30813. * @param configuration
  30814. */
  30815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30816. /**
  30817. * Gets wether the color curves effect is enabled.
  30818. */
  30819. get cameraColorCurvesEnabled(): boolean;
  30820. /**
  30821. * Sets wether the color curves effect is enabled.
  30822. */
  30823. set cameraColorCurvesEnabled(value: boolean);
  30824. /**
  30825. * Gets wether the color grading effect is enabled.
  30826. */
  30827. get cameraColorGradingEnabled(): boolean;
  30828. /**
  30829. * Gets wether the color grading effect is enabled.
  30830. */
  30831. set cameraColorGradingEnabled(value: boolean);
  30832. /**
  30833. * Gets wether tonemapping is enabled or not.
  30834. */
  30835. get cameraToneMappingEnabled(): boolean;
  30836. /**
  30837. * Sets wether tonemapping is enabled or not
  30838. */
  30839. set cameraToneMappingEnabled(value: boolean);
  30840. /**
  30841. * The camera exposure used on this material.
  30842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30843. * This corresponds to a photographic exposure.
  30844. */
  30845. get cameraExposure(): number;
  30846. /**
  30847. * The camera exposure used on this material.
  30848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30849. * This corresponds to a photographic exposure.
  30850. */
  30851. set cameraExposure(value: number);
  30852. /**
  30853. * Gets The camera contrast used on this material.
  30854. */
  30855. get cameraContrast(): number;
  30856. /**
  30857. * Sets The camera contrast used on this material.
  30858. */
  30859. set cameraContrast(value: number);
  30860. /**
  30861. * Gets the Color Grading 2D Lookup Texture.
  30862. */
  30863. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30864. /**
  30865. * Sets the Color Grading 2D Lookup Texture.
  30866. */
  30867. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30868. /**
  30869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30871. * 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;
  30872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30873. */
  30874. get cameraColorCurves(): Nullable<ColorCurves>;
  30875. /**
  30876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30878. * 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;
  30879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30880. */
  30881. set cameraColorCurves(value: Nullable<ColorCurves>);
  30882. /**
  30883. * Defines the detail map parameters for the material.
  30884. */
  30885. readonly detailMap: DetailMapConfiguration;
  30886. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30887. protected _worldViewProjectionMatrix: Matrix;
  30888. protected _globalAmbientColor: Color3;
  30889. protected _useLogarithmicDepth: boolean;
  30890. protected _rebuildInParallel: boolean;
  30891. /**
  30892. * Instantiates a new standard material.
  30893. * This is the default material used in Babylon. It is the best trade off between quality
  30894. * and performances.
  30895. * @see http://doc.babylonjs.com/babylon101/materials
  30896. * @param name Define the name of the material in the scene
  30897. * @param scene Define the scene the material belong to
  30898. */
  30899. constructor(name: string, scene: Scene);
  30900. /**
  30901. * Gets a boolean indicating that current material needs to register RTT
  30902. */
  30903. get hasRenderTargetTextures(): boolean;
  30904. /**
  30905. * Gets the current class name of the material e.g. "StandardMaterial"
  30906. * Mainly use in serialization.
  30907. * @returns the class name
  30908. */
  30909. getClassName(): string;
  30910. /**
  30911. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30912. * You can try switching to logarithmic depth.
  30913. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30914. */
  30915. get useLogarithmicDepth(): boolean;
  30916. set useLogarithmicDepth(value: boolean);
  30917. /**
  30918. * Specifies if the material will require alpha blending
  30919. * @returns a boolean specifying if alpha blending is needed
  30920. */
  30921. needAlphaBlending(): boolean;
  30922. /**
  30923. * Specifies if this material should be rendered in alpha test mode
  30924. * @returns a boolean specifying if an alpha test is needed.
  30925. */
  30926. needAlphaTesting(): boolean;
  30927. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30928. /**
  30929. * Get the texture used for alpha test purpose.
  30930. * @returns the diffuse texture in case of the standard material.
  30931. */
  30932. getAlphaTestTexture(): Nullable<BaseTexture>;
  30933. /**
  30934. * Get if the submesh is ready to be used and all its information available.
  30935. * Child classes can use it to update shaders
  30936. * @param mesh defines the mesh to check
  30937. * @param subMesh defines which submesh to check
  30938. * @param useInstances specifies that instances should be used
  30939. * @returns a boolean indicating that the submesh is ready or not
  30940. */
  30941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30942. /**
  30943. * Builds the material UBO layouts.
  30944. * Used internally during the effect preparation.
  30945. */
  30946. buildUniformLayout(): void;
  30947. /**
  30948. * Unbinds the material from the mesh
  30949. */
  30950. unbind(): void;
  30951. /**
  30952. * Binds the submesh to this material by preparing the effect and shader to draw
  30953. * @param world defines the world transformation matrix
  30954. * @param mesh defines the mesh containing the submesh
  30955. * @param subMesh defines the submesh to bind the material to
  30956. */
  30957. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30958. /**
  30959. * Get the list of animatables in the material.
  30960. * @returns the list of animatables object used in the material
  30961. */
  30962. getAnimatables(): IAnimatable[];
  30963. /**
  30964. * Gets the active textures from the material
  30965. * @returns an array of textures
  30966. */
  30967. getActiveTextures(): BaseTexture[];
  30968. /**
  30969. * Specifies if the material uses a texture
  30970. * @param texture defines the texture to check against the material
  30971. * @returns a boolean specifying if the material uses the texture
  30972. */
  30973. hasTexture(texture: BaseTexture): boolean;
  30974. /**
  30975. * Disposes the material
  30976. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30977. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30978. */
  30979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30980. /**
  30981. * Makes a duplicate of the material, and gives it a new name
  30982. * @param name defines the new name for the duplicated material
  30983. * @returns the cloned material
  30984. */
  30985. clone(name: string): StandardMaterial;
  30986. /**
  30987. * Serializes this material in a JSON representation
  30988. * @returns the serialized material object
  30989. */
  30990. serialize(): any;
  30991. /**
  30992. * Creates a standard material from parsed material data
  30993. * @param source defines the JSON representation of the material
  30994. * @param scene defines the hosting scene
  30995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30996. * @returns a new standard material
  30997. */
  30998. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30999. /**
  31000. * Are diffuse textures enabled in the application.
  31001. */
  31002. static get DiffuseTextureEnabled(): boolean;
  31003. static set DiffuseTextureEnabled(value: boolean);
  31004. /**
  31005. * Are detail textures enabled in the application.
  31006. */
  31007. static get DetailTextureEnabled(): boolean;
  31008. static set DetailTextureEnabled(value: boolean);
  31009. /**
  31010. * Are ambient textures enabled in the application.
  31011. */
  31012. static get AmbientTextureEnabled(): boolean;
  31013. static set AmbientTextureEnabled(value: boolean);
  31014. /**
  31015. * Are opacity textures enabled in the application.
  31016. */
  31017. static get OpacityTextureEnabled(): boolean;
  31018. static set OpacityTextureEnabled(value: boolean);
  31019. /**
  31020. * Are reflection textures enabled in the application.
  31021. */
  31022. static get ReflectionTextureEnabled(): boolean;
  31023. static set ReflectionTextureEnabled(value: boolean);
  31024. /**
  31025. * Are emissive textures enabled in the application.
  31026. */
  31027. static get EmissiveTextureEnabled(): boolean;
  31028. static set EmissiveTextureEnabled(value: boolean);
  31029. /**
  31030. * Are specular textures enabled in the application.
  31031. */
  31032. static get SpecularTextureEnabled(): boolean;
  31033. static set SpecularTextureEnabled(value: boolean);
  31034. /**
  31035. * Are bump textures enabled in the application.
  31036. */
  31037. static get BumpTextureEnabled(): boolean;
  31038. static set BumpTextureEnabled(value: boolean);
  31039. /**
  31040. * Are lightmap textures enabled in the application.
  31041. */
  31042. static get LightmapTextureEnabled(): boolean;
  31043. static set LightmapTextureEnabled(value: boolean);
  31044. /**
  31045. * Are refraction textures enabled in the application.
  31046. */
  31047. static get RefractionTextureEnabled(): boolean;
  31048. static set RefractionTextureEnabled(value: boolean);
  31049. /**
  31050. * Are color grading textures enabled in the application.
  31051. */
  31052. static get ColorGradingTextureEnabled(): boolean;
  31053. static set ColorGradingTextureEnabled(value: boolean);
  31054. /**
  31055. * Are fresnels enabled in the application.
  31056. */
  31057. static get FresnelEnabled(): boolean;
  31058. static set FresnelEnabled(value: boolean);
  31059. }
  31060. }
  31061. declare module "babylonjs/Particles/solidParticleSystem" {
  31062. import { Nullable } from "babylonjs/types";
  31063. import { Mesh } from "babylonjs/Meshes/mesh";
  31064. import { Scene, IDisposable } from "babylonjs/scene";
  31065. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31066. import { Material } from "babylonjs/Materials/material";
  31067. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31069. /**
  31070. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31071. *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.
  31072. * The SPS is also a particle system. It provides some methods to manage the particles.
  31073. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31074. *
  31075. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31076. */
  31077. export class SolidParticleSystem implements IDisposable {
  31078. /**
  31079. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31080. * Example : var p = SPS.particles[i];
  31081. */
  31082. particles: SolidParticle[];
  31083. /**
  31084. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31085. */
  31086. nbParticles: number;
  31087. /**
  31088. * If the particles must ever face the camera (default false). Useful for planar particles.
  31089. */
  31090. billboard: boolean;
  31091. /**
  31092. * Recompute normals when adding a shape
  31093. */
  31094. recomputeNormals: boolean;
  31095. /**
  31096. * This a counter ofr your own usage. It's not set by any SPS functions.
  31097. */
  31098. counter: number;
  31099. /**
  31100. * The SPS name. This name is also given to the underlying mesh.
  31101. */
  31102. name: string;
  31103. /**
  31104. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31105. */
  31106. mesh: Mesh;
  31107. /**
  31108. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31109. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31110. */
  31111. vars: any;
  31112. /**
  31113. * This array is populated when the SPS is set as 'pickable'.
  31114. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31115. * Each element of this array is an object `{idx: int, faceId: int}`.
  31116. * `idx` is the picked particle index in the `SPS.particles` array
  31117. * `faceId` is the picked face index counted within this particle.
  31118. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31119. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31120. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31121. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31122. */
  31123. pickedParticles: {
  31124. idx: number;
  31125. faceId: number;
  31126. }[];
  31127. /**
  31128. * This array is populated when the SPS is set as 'pickable'
  31129. * Each key of this array is a submesh index.
  31130. * Each element of this array is a second array defined like this :
  31131. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31132. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31133. * `idx` is the picked particle index in the `SPS.particles` array
  31134. * `faceId` is the picked face index counted within this particle.
  31135. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31136. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31137. */
  31138. pickedBySubMesh: {
  31139. idx: number;
  31140. faceId: number;
  31141. }[][];
  31142. /**
  31143. * This array is populated when `enableDepthSort` is set to true.
  31144. * Each element of this array is an instance of the class DepthSortedParticle.
  31145. */
  31146. depthSortedParticles: DepthSortedParticle[];
  31147. /**
  31148. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31149. * @hidden
  31150. */
  31151. _bSphereOnly: boolean;
  31152. /**
  31153. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31154. * @hidden
  31155. */
  31156. _bSphereRadiusFactor: number;
  31157. private _scene;
  31158. private _positions;
  31159. private _indices;
  31160. private _normals;
  31161. private _colors;
  31162. private _uvs;
  31163. private _indices32;
  31164. private _positions32;
  31165. private _normals32;
  31166. private _fixedNormal32;
  31167. private _colors32;
  31168. private _uvs32;
  31169. private _index;
  31170. private _updatable;
  31171. private _pickable;
  31172. private _isVisibilityBoxLocked;
  31173. private _alwaysVisible;
  31174. private _depthSort;
  31175. private _expandable;
  31176. private _shapeCounter;
  31177. private _copy;
  31178. private _color;
  31179. private _computeParticleColor;
  31180. private _computeParticleTexture;
  31181. private _computeParticleRotation;
  31182. private _computeParticleVertex;
  31183. private _computeBoundingBox;
  31184. private _depthSortParticles;
  31185. private _camera;
  31186. private _mustUnrotateFixedNormals;
  31187. private _particlesIntersect;
  31188. private _needs32Bits;
  31189. private _isNotBuilt;
  31190. private _lastParticleId;
  31191. private _idxOfId;
  31192. private _multimaterialEnabled;
  31193. private _useModelMaterial;
  31194. private _indicesByMaterial;
  31195. private _materialIndexes;
  31196. private _depthSortFunction;
  31197. private _materialSortFunction;
  31198. private _materials;
  31199. private _multimaterial;
  31200. private _materialIndexesById;
  31201. private _defaultMaterial;
  31202. private _autoUpdateSubMeshes;
  31203. private _tmpVertex;
  31204. /**
  31205. * Creates a SPS (Solid Particle System) object.
  31206. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31207. * @param scene (Scene) is the scene in which the SPS is added.
  31208. * @param options defines the options of the sps e.g.
  31209. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31210. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31211. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31212. * * 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.
  31213. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31214. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31215. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31216. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31217. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31218. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31219. */
  31220. constructor(name: string, scene: Scene, options?: {
  31221. updatable?: boolean;
  31222. isPickable?: boolean;
  31223. enableDepthSort?: boolean;
  31224. particleIntersection?: boolean;
  31225. boundingSphereOnly?: boolean;
  31226. bSphereRadiusFactor?: number;
  31227. expandable?: boolean;
  31228. useModelMaterial?: boolean;
  31229. enableMultiMaterial?: boolean;
  31230. });
  31231. /**
  31232. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31233. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31234. * @returns the created mesh
  31235. */
  31236. buildMesh(): Mesh;
  31237. /**
  31238. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31239. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31240. * Thus the particles generated from `digest()` have their property `position` set yet.
  31241. * @param mesh ( Mesh ) is the mesh to be digested
  31242. * @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
  31243. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31244. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31245. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31246. * @returns the current SPS
  31247. */
  31248. digest(mesh: Mesh, options?: {
  31249. facetNb?: number;
  31250. number?: number;
  31251. delta?: number;
  31252. storage?: [];
  31253. }): SolidParticleSystem;
  31254. /**
  31255. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31256. * @hidden
  31257. */
  31258. private _unrotateFixedNormals;
  31259. /**
  31260. * Resets the temporary working copy particle
  31261. * @hidden
  31262. */
  31263. private _resetCopy;
  31264. /**
  31265. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31266. * @param p the current index in the positions array to be updated
  31267. * @param ind the current index in the indices array
  31268. * @param shape a Vector3 array, the shape geometry
  31269. * @param positions the positions array to be updated
  31270. * @param meshInd the shape indices array
  31271. * @param indices the indices array to be updated
  31272. * @param meshUV the shape uv array
  31273. * @param uvs the uv array to be updated
  31274. * @param meshCol the shape color array
  31275. * @param colors the color array to be updated
  31276. * @param meshNor the shape normals array
  31277. * @param normals the normals array to be updated
  31278. * @param idx the particle index
  31279. * @param idxInShape the particle index in its shape
  31280. * @param options the addShape() method passed options
  31281. * @model the particle model
  31282. * @hidden
  31283. */
  31284. private _meshBuilder;
  31285. /**
  31286. * Returns a shape Vector3 array from positions float array
  31287. * @param positions float array
  31288. * @returns a vector3 array
  31289. * @hidden
  31290. */
  31291. private _posToShape;
  31292. /**
  31293. * Returns a shapeUV array from a float uvs (array deep copy)
  31294. * @param uvs as a float array
  31295. * @returns a shapeUV array
  31296. * @hidden
  31297. */
  31298. private _uvsToShapeUV;
  31299. /**
  31300. * Adds a new particle object in the particles array
  31301. * @param idx particle index in particles array
  31302. * @param id particle id
  31303. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31304. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31305. * @param model particle ModelShape object
  31306. * @param shapeId model shape identifier
  31307. * @param idxInShape index of the particle in the current model
  31308. * @param bInfo model bounding info object
  31309. * @param storage target storage array, if any
  31310. * @hidden
  31311. */
  31312. private _addParticle;
  31313. /**
  31314. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31315. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31316. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31317. * @param nb (positive integer) the number of particles to be created from this model
  31318. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31319. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31320. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31321. * @returns the number of shapes in the system
  31322. */
  31323. addShape(mesh: Mesh, nb: number, options?: {
  31324. positionFunction?: any;
  31325. vertexFunction?: any;
  31326. storage?: [];
  31327. }): number;
  31328. /**
  31329. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31330. * @hidden
  31331. */
  31332. private _rebuildParticle;
  31333. /**
  31334. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31335. * @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.
  31336. * @returns the SPS.
  31337. */
  31338. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31339. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31340. * Returns an array with the removed particles.
  31341. * 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.
  31342. * The SPS can't be empty so at least one particle needs to remain in place.
  31343. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31344. * @param start index of the first particle to remove
  31345. * @param end index of the last particle to remove (included)
  31346. * @returns an array populated with the removed particles
  31347. */
  31348. removeParticles(start: number, end: number): SolidParticle[];
  31349. /**
  31350. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31351. * @param solidParticleArray an array populated with Solid Particles objects
  31352. * @returns the SPS
  31353. */
  31354. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31355. /**
  31356. * Creates a new particle and modifies the SPS mesh geometry :
  31357. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31358. * - calls _addParticle() to populate the particle array
  31359. * factorized code from addShape() and insertParticlesFromArray()
  31360. * @param idx particle index in the particles array
  31361. * @param i particle index in its shape
  31362. * @param modelShape particle ModelShape object
  31363. * @param shape shape vertex array
  31364. * @param meshInd shape indices array
  31365. * @param meshUV shape uv array
  31366. * @param meshCol shape color array
  31367. * @param meshNor shape normals array
  31368. * @param bbInfo shape bounding info
  31369. * @param storage target particle storage
  31370. * @options addShape() passed options
  31371. * @hidden
  31372. */
  31373. private _insertNewParticle;
  31374. /**
  31375. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31376. * This method calls `updateParticle()` for each particle of the SPS.
  31377. * For an animated SPS, it is usually called within the render loop.
  31378. * 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.
  31379. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31380. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31381. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31382. * @returns the SPS.
  31383. */
  31384. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31385. /**
  31386. * Disposes the SPS.
  31387. */
  31388. dispose(): void;
  31389. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31390. * idx is the particle index in the SPS
  31391. * faceId is the picked face index counted within this particle.
  31392. * Returns null if the pickInfo can't identify a picked particle.
  31393. * @param pickingInfo (PickingInfo object)
  31394. * @returns {idx: number, faceId: number} or null
  31395. */
  31396. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31397. idx: number;
  31398. faceId: number;
  31399. }>;
  31400. /**
  31401. * Returns a SolidParticle object from its identifier : particle.id
  31402. * @param id (integer) the particle Id
  31403. * @returns the searched particle or null if not found in the SPS.
  31404. */
  31405. getParticleById(id: number): Nullable<SolidParticle>;
  31406. /**
  31407. * Returns a new array populated with the particles having the passed shapeId.
  31408. * @param shapeId (integer) the shape identifier
  31409. * @returns a new solid particle array
  31410. */
  31411. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31412. /**
  31413. * Populates the passed array "ref" with the particles having the passed shapeId.
  31414. * @param shapeId the shape identifier
  31415. * @returns the SPS
  31416. * @param ref
  31417. */
  31418. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31419. /**
  31420. * Computes the required SubMeshes according the materials assigned to the particles.
  31421. * @returns the solid particle system.
  31422. * Does nothing if called before the SPS mesh is built.
  31423. */
  31424. computeSubMeshes(): SolidParticleSystem;
  31425. /**
  31426. * Sorts the solid particles by material when MultiMaterial is enabled.
  31427. * Updates the indices32 array.
  31428. * Updates the indicesByMaterial array.
  31429. * Updates the mesh indices array.
  31430. * @returns the SPS
  31431. * @hidden
  31432. */
  31433. private _sortParticlesByMaterial;
  31434. /**
  31435. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31436. * @hidden
  31437. */
  31438. private _setMaterialIndexesById;
  31439. /**
  31440. * Returns an array with unique values of Materials from the passed array
  31441. * @param array the material array to be checked and filtered
  31442. * @hidden
  31443. */
  31444. private _filterUniqueMaterialId;
  31445. /**
  31446. * Sets a new Standard Material as _defaultMaterial if not already set.
  31447. * @hidden
  31448. */
  31449. private _setDefaultMaterial;
  31450. /**
  31451. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31452. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31453. * @returns the SPS.
  31454. */
  31455. refreshVisibleSize(): SolidParticleSystem;
  31456. /**
  31457. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31458. * @param size the size (float) of the visibility box
  31459. * note : this doesn't lock the SPS mesh bounding box.
  31460. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31461. */
  31462. setVisibilityBox(size: number): void;
  31463. /**
  31464. * Gets whether the SPS as always visible or not
  31465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31466. */
  31467. get isAlwaysVisible(): boolean;
  31468. /**
  31469. * Sets the SPS as always visible or not
  31470. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31471. */
  31472. set isAlwaysVisible(val: boolean);
  31473. /**
  31474. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31475. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31476. */
  31477. set isVisibilityBoxLocked(val: boolean);
  31478. /**
  31479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31480. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31481. */
  31482. get isVisibilityBoxLocked(): boolean;
  31483. /**
  31484. * Tells to `setParticles()` to compute the particle rotations or not.
  31485. * Default value : true. The SPS is faster when it's set to false.
  31486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31487. */
  31488. set computeParticleRotation(val: boolean);
  31489. /**
  31490. * Tells to `setParticles()` to compute the particle colors or not.
  31491. * Default value : true. The SPS is faster when it's set to false.
  31492. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31493. */
  31494. set computeParticleColor(val: boolean);
  31495. set computeParticleTexture(val: boolean);
  31496. /**
  31497. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31498. * Default value : false. The SPS is faster when it's set to false.
  31499. * Note : the particle custom vertex positions aren't stored values.
  31500. */
  31501. set computeParticleVertex(val: boolean);
  31502. /**
  31503. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31504. */
  31505. set computeBoundingBox(val: boolean);
  31506. /**
  31507. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31508. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31509. * Default : `true`
  31510. */
  31511. set depthSortParticles(val: boolean);
  31512. /**
  31513. * Gets if `setParticles()` computes the particle rotations or not.
  31514. * Default value : true. The SPS is faster when it's set to false.
  31515. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31516. */
  31517. get computeParticleRotation(): boolean;
  31518. /**
  31519. * Gets if `setParticles()` computes the particle colors or not.
  31520. * Default value : true. The SPS is faster when it's set to false.
  31521. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31522. */
  31523. get computeParticleColor(): boolean;
  31524. /**
  31525. * Gets if `setParticles()` computes the particle textures or not.
  31526. * Default value : true. The SPS is faster when it's set to false.
  31527. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31528. */
  31529. get computeParticleTexture(): boolean;
  31530. /**
  31531. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31532. * Default value : false. The SPS is faster when it's set to false.
  31533. * Note : the particle custom vertex positions aren't stored values.
  31534. */
  31535. get computeParticleVertex(): boolean;
  31536. /**
  31537. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31538. */
  31539. get computeBoundingBox(): boolean;
  31540. /**
  31541. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31542. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31543. * Default : `true`
  31544. */
  31545. get depthSortParticles(): boolean;
  31546. /**
  31547. * Gets if the SPS is created as expandable at construction time.
  31548. * Default : `false`
  31549. */
  31550. get expandable(): boolean;
  31551. /**
  31552. * Gets if the SPS supports the Multi Materials
  31553. */
  31554. get multimaterialEnabled(): boolean;
  31555. /**
  31556. * Gets if the SPS uses the model materials for its own multimaterial.
  31557. */
  31558. get useModelMaterial(): boolean;
  31559. /**
  31560. * The SPS used material array.
  31561. */
  31562. get materials(): Material[];
  31563. /**
  31564. * Sets the SPS MultiMaterial from the passed materials.
  31565. * Note : the passed array is internally copied and not used then by reference.
  31566. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31567. */
  31568. setMultiMaterial(materials: Material[]): void;
  31569. /**
  31570. * The SPS computed multimaterial object
  31571. */
  31572. get multimaterial(): MultiMaterial;
  31573. set multimaterial(mm: MultiMaterial);
  31574. /**
  31575. * If the subMeshes must be updated on the next call to setParticles()
  31576. */
  31577. get autoUpdateSubMeshes(): boolean;
  31578. set autoUpdateSubMeshes(val: boolean);
  31579. /**
  31580. * This function does nothing. It may be overwritten to set all the particle first values.
  31581. * The SPS doesn't call this function, you may have to call it by your own.
  31582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31583. */
  31584. initParticles(): void;
  31585. /**
  31586. * This function does nothing. It may be overwritten to recycle a particle.
  31587. * The SPS doesn't call this function, you may have to call it by your own.
  31588. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31589. * @param particle The particle to recycle
  31590. * @returns the recycled particle
  31591. */
  31592. recycleParticle(particle: SolidParticle): SolidParticle;
  31593. /**
  31594. * Updates a particle : this function should be overwritten by the user.
  31595. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31597. * @example : just set a particle position or velocity and recycle conditions
  31598. * @param particle The particle to update
  31599. * @returns the updated particle
  31600. */
  31601. updateParticle(particle: SolidParticle): SolidParticle;
  31602. /**
  31603. * Updates a vertex of a particle : it can be overwritten by the user.
  31604. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31605. * @param particle the current particle
  31606. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31607. * @param pt the index of the current vertex in the particle shape
  31608. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31609. * @example : just set a vertex particle position or color
  31610. * @returns the sps
  31611. */
  31612. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31613. /**
  31614. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31615. * This does nothing and may be overwritten by the user.
  31616. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31617. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31618. * @param update the boolean update value actually passed to setParticles()
  31619. */
  31620. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31621. /**
  31622. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31623. * This will be passed three parameters.
  31624. * This does nothing and may be overwritten by the user.
  31625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31627. * @param update the boolean update value actually passed to setParticles()
  31628. */
  31629. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31630. }
  31631. }
  31632. declare module "babylonjs/Particles/solidParticle" {
  31633. import { Nullable } from "babylonjs/types";
  31634. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31635. import { Color4 } from "babylonjs/Maths/math.color";
  31636. import { Mesh } from "babylonjs/Meshes/mesh";
  31637. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31638. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31639. import { Plane } from "babylonjs/Maths/math.plane";
  31640. import { Material } from "babylonjs/Materials/material";
  31641. /**
  31642. * Represents one particle of a solid particle system.
  31643. */
  31644. export class SolidParticle {
  31645. /**
  31646. * particle global index
  31647. */
  31648. idx: number;
  31649. /**
  31650. * particle identifier
  31651. */
  31652. id: number;
  31653. /**
  31654. * The color of the particle
  31655. */
  31656. color: Nullable<Color4>;
  31657. /**
  31658. * The world space position of the particle.
  31659. */
  31660. position: Vector3;
  31661. /**
  31662. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31663. */
  31664. rotation: Vector3;
  31665. /**
  31666. * The world space rotation quaternion of the particle.
  31667. */
  31668. rotationQuaternion: Nullable<Quaternion>;
  31669. /**
  31670. * The scaling of the particle.
  31671. */
  31672. scaling: Vector3;
  31673. /**
  31674. * The uvs of the particle.
  31675. */
  31676. uvs: Vector4;
  31677. /**
  31678. * The current speed of the particle.
  31679. */
  31680. velocity: Vector3;
  31681. /**
  31682. * The pivot point in the particle local space.
  31683. */
  31684. pivot: Vector3;
  31685. /**
  31686. * Must the particle be translated from its pivot point in its local space ?
  31687. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31688. * Default : false
  31689. */
  31690. translateFromPivot: boolean;
  31691. /**
  31692. * Is the particle active or not ?
  31693. */
  31694. alive: boolean;
  31695. /**
  31696. * Is the particle visible or not ?
  31697. */
  31698. isVisible: boolean;
  31699. /**
  31700. * Index of this particle in the global "positions" array (Internal use)
  31701. * @hidden
  31702. */
  31703. _pos: number;
  31704. /**
  31705. * @hidden Index of this particle in the global "indices" array (Internal use)
  31706. */
  31707. _ind: number;
  31708. /**
  31709. * @hidden ModelShape of this particle (Internal use)
  31710. */
  31711. _model: ModelShape;
  31712. /**
  31713. * ModelShape id of this particle
  31714. */
  31715. shapeId: number;
  31716. /**
  31717. * Index of the particle in its shape id
  31718. */
  31719. idxInShape: number;
  31720. /**
  31721. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31722. */
  31723. _modelBoundingInfo: BoundingInfo;
  31724. /**
  31725. * @hidden Particle BoundingInfo object (Internal use)
  31726. */
  31727. _boundingInfo: BoundingInfo;
  31728. /**
  31729. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31730. */
  31731. _sps: SolidParticleSystem;
  31732. /**
  31733. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31734. */
  31735. _stillInvisible: boolean;
  31736. /**
  31737. * @hidden Last computed particle rotation matrix
  31738. */
  31739. _rotationMatrix: number[];
  31740. /**
  31741. * Parent particle Id, if any.
  31742. * Default null.
  31743. */
  31744. parentId: Nullable<number>;
  31745. /**
  31746. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31747. */
  31748. materialIndex: Nullable<number>;
  31749. /**
  31750. * Custom object or properties.
  31751. */
  31752. props: Nullable<any>;
  31753. /**
  31754. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31755. * The possible values are :
  31756. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31757. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31759. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31760. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31761. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31762. * */
  31763. cullingStrategy: number;
  31764. /**
  31765. * @hidden Internal global position in the SPS.
  31766. */
  31767. _globalPosition: Vector3;
  31768. /**
  31769. * Creates a Solid Particle object.
  31770. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31771. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31772. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31773. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31774. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31775. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31776. * @param shapeId (integer) is the model shape identifier in the SPS.
  31777. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31778. * @param sps defines the sps it is associated to
  31779. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31780. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31781. */
  31782. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31783. /**
  31784. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31785. * @param target the particle target
  31786. * @returns the current particle
  31787. */
  31788. copyToRef(target: SolidParticle): SolidParticle;
  31789. /**
  31790. * Legacy support, changed scale to scaling
  31791. */
  31792. get scale(): Vector3;
  31793. /**
  31794. * Legacy support, changed scale to scaling
  31795. */
  31796. set scale(scale: Vector3);
  31797. /**
  31798. * Legacy support, changed quaternion to rotationQuaternion
  31799. */
  31800. get quaternion(): Nullable<Quaternion>;
  31801. /**
  31802. * Legacy support, changed quaternion to rotationQuaternion
  31803. */
  31804. set quaternion(q: Nullable<Quaternion>);
  31805. /**
  31806. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31807. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31808. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31809. * @returns true if it intersects
  31810. */
  31811. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31812. /**
  31813. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31814. * A particle is in the frustum if its bounding box intersects the frustum
  31815. * @param frustumPlanes defines the frustum to test
  31816. * @returns true if the particle is in the frustum planes
  31817. */
  31818. isInFrustum(frustumPlanes: Plane[]): boolean;
  31819. /**
  31820. * get the rotation matrix of the particle
  31821. * @hidden
  31822. */
  31823. getRotationMatrix(m: Matrix): void;
  31824. }
  31825. /**
  31826. * Represents the shape of the model used by one particle of a solid particle system.
  31827. * SPS internal tool, don't use it manually.
  31828. */
  31829. export class ModelShape {
  31830. /**
  31831. * The shape id
  31832. * @hidden
  31833. */
  31834. shapeID: number;
  31835. /**
  31836. * flat array of model positions (internal use)
  31837. * @hidden
  31838. */
  31839. _shape: Vector3[];
  31840. /**
  31841. * flat array of model UVs (internal use)
  31842. * @hidden
  31843. */
  31844. _shapeUV: number[];
  31845. /**
  31846. * color array of the model
  31847. * @hidden
  31848. */
  31849. _shapeColors: number[];
  31850. /**
  31851. * indices array of the model
  31852. * @hidden
  31853. */
  31854. _indices: number[];
  31855. /**
  31856. * normals array of the model
  31857. * @hidden
  31858. */
  31859. _normals: number[];
  31860. /**
  31861. * length of the shape in the model indices array (internal use)
  31862. * @hidden
  31863. */
  31864. _indicesLength: number;
  31865. /**
  31866. * Custom position function (internal use)
  31867. * @hidden
  31868. */
  31869. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31870. /**
  31871. * Custom vertex function (internal use)
  31872. * @hidden
  31873. */
  31874. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31875. /**
  31876. * Model material (internal use)
  31877. * @hidden
  31878. */
  31879. _material: Nullable<Material>;
  31880. /**
  31881. * 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.
  31882. * SPS internal tool, don't use it manually.
  31883. * @hidden
  31884. */
  31885. 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>);
  31886. }
  31887. /**
  31888. * Represents a Depth Sorted Particle in the solid particle system.
  31889. * @hidden
  31890. */
  31891. export class DepthSortedParticle {
  31892. /**
  31893. * Particle index
  31894. */
  31895. idx: number;
  31896. /**
  31897. * Index of the particle in the "indices" array
  31898. */
  31899. ind: number;
  31900. /**
  31901. * Length of the particle shape in the "indices" array
  31902. */
  31903. indicesLength: number;
  31904. /**
  31905. * Squared distance from the particle to the camera
  31906. */
  31907. sqDistance: number;
  31908. /**
  31909. * Material index when used with MultiMaterials
  31910. */
  31911. materialIndex: number;
  31912. /**
  31913. * Creates a new sorted particle
  31914. * @param materialIndex
  31915. */
  31916. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31917. }
  31918. /**
  31919. * Represents a solid particle vertex
  31920. */
  31921. export class SolidParticleVertex {
  31922. /**
  31923. * Vertex position
  31924. */
  31925. position: Vector3;
  31926. /**
  31927. * Vertex color
  31928. */
  31929. color: Color4;
  31930. /**
  31931. * Vertex UV
  31932. */
  31933. uv: Vector2;
  31934. /**
  31935. * Creates a new solid particle vertex
  31936. */
  31937. constructor();
  31938. /** Vertex x coordinate */
  31939. get x(): number;
  31940. set x(val: number);
  31941. /** Vertex y coordinate */
  31942. get y(): number;
  31943. set y(val: number);
  31944. /** Vertex z coordinate */
  31945. get z(): number;
  31946. set z(val: number);
  31947. }
  31948. }
  31949. declare module "babylonjs/Collisions/meshCollisionData" {
  31950. import { Collider } from "babylonjs/Collisions/collider";
  31951. import { Vector3 } from "babylonjs/Maths/math.vector";
  31952. import { Nullable } from "babylonjs/types";
  31953. import { Observer } from "babylonjs/Misc/observable";
  31954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31955. /**
  31956. * @hidden
  31957. */
  31958. export class _MeshCollisionData {
  31959. _checkCollisions: boolean;
  31960. _collisionMask: number;
  31961. _collisionGroup: number;
  31962. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31963. _collider: Nullable<Collider>;
  31964. _oldPositionForCollisions: Vector3;
  31965. _diffPositionForCollisions: Vector3;
  31966. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31967. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31968. }
  31969. }
  31970. declare module "babylonjs/Meshes/abstractMesh" {
  31971. import { Observable } from "babylonjs/Misc/observable";
  31972. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31973. import { Camera } from "babylonjs/Cameras/camera";
  31974. import { Scene, IDisposable } from "babylonjs/scene";
  31975. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31976. import { Node } from "babylonjs/node";
  31977. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31978. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31981. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31982. import { Material } from "babylonjs/Materials/material";
  31983. import { Light } from "babylonjs/Lights/light";
  31984. import { Skeleton } from "babylonjs/Bones/skeleton";
  31985. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31986. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31988. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31989. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31990. import { Plane } from "babylonjs/Maths/math.plane";
  31991. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31992. import { Ray } from "babylonjs/Culling/ray";
  31993. import { Collider } from "babylonjs/Collisions/collider";
  31994. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31995. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31996. /** @hidden */
  31997. class _FacetDataStorage {
  31998. facetPositions: Vector3[];
  31999. facetNormals: Vector3[];
  32000. facetPartitioning: number[][];
  32001. facetNb: number;
  32002. partitioningSubdivisions: number;
  32003. partitioningBBoxRatio: number;
  32004. facetDataEnabled: boolean;
  32005. facetParameters: any;
  32006. bbSize: Vector3;
  32007. subDiv: {
  32008. max: number;
  32009. X: number;
  32010. Y: number;
  32011. Z: number;
  32012. };
  32013. facetDepthSort: boolean;
  32014. facetDepthSortEnabled: boolean;
  32015. depthSortedIndices: IndicesArray;
  32016. depthSortedFacets: {
  32017. ind: number;
  32018. sqDistance: number;
  32019. }[];
  32020. facetDepthSortFunction: (f1: {
  32021. ind: number;
  32022. sqDistance: number;
  32023. }, f2: {
  32024. ind: number;
  32025. sqDistance: number;
  32026. }) => number;
  32027. facetDepthSortFrom: Vector3;
  32028. facetDepthSortOrigin: Vector3;
  32029. invertedMatrix: Matrix;
  32030. }
  32031. /**
  32032. * @hidden
  32033. **/
  32034. class _InternalAbstractMeshDataInfo {
  32035. _hasVertexAlpha: boolean;
  32036. _useVertexColors: boolean;
  32037. _numBoneInfluencers: number;
  32038. _applyFog: boolean;
  32039. _receiveShadows: boolean;
  32040. _facetData: _FacetDataStorage;
  32041. _visibility: number;
  32042. _skeleton: Nullable<Skeleton>;
  32043. _layerMask: number;
  32044. _computeBonesUsingShaders: boolean;
  32045. _isActive: boolean;
  32046. _onlyForInstances: boolean;
  32047. _isActiveIntermediate: boolean;
  32048. _onlyForInstancesIntermediate: boolean;
  32049. _actAsRegularMesh: boolean;
  32050. }
  32051. /**
  32052. * Class used to store all common mesh properties
  32053. */
  32054. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32055. /** No occlusion */
  32056. static OCCLUSION_TYPE_NONE: number;
  32057. /** Occlusion set to optimisitic */
  32058. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32059. /** Occlusion set to strict */
  32060. static OCCLUSION_TYPE_STRICT: number;
  32061. /** Use an accurante occlusion algorithm */
  32062. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32063. /** Use a conservative occlusion algorithm */
  32064. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32065. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32066. * Test order :
  32067. * Is the bounding sphere outside the frustum ?
  32068. * If not, are the bounding box vertices outside the frustum ?
  32069. * It not, then the cullable object is in the frustum.
  32070. */
  32071. static readonly CULLINGSTRATEGY_STANDARD: number;
  32072. /** Culling strategy : Bounding Sphere Only.
  32073. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32074. * It's also less accurate than the standard because some not visible objects can still be selected.
  32075. * Test : is the bounding sphere outside the frustum ?
  32076. * If not, then the cullable object is in the frustum.
  32077. */
  32078. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32079. /** Culling strategy : Optimistic Inclusion.
  32080. * This in an inclusion test first, then the standard exclusion test.
  32081. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32082. * 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.
  32083. * Anyway, it's as accurate as the standard strategy.
  32084. * Test :
  32085. * Is the cullable object bounding sphere center in the frustum ?
  32086. * If not, apply the default culling strategy.
  32087. */
  32088. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32089. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32090. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32091. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32092. * 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.
  32093. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32094. * Test :
  32095. * Is the cullable object bounding sphere center in the frustum ?
  32096. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32097. */
  32098. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32099. /**
  32100. * No billboard
  32101. */
  32102. static get BILLBOARDMODE_NONE(): number;
  32103. /** Billboard on X axis */
  32104. static get BILLBOARDMODE_X(): number;
  32105. /** Billboard on Y axis */
  32106. static get BILLBOARDMODE_Y(): number;
  32107. /** Billboard on Z axis */
  32108. static get BILLBOARDMODE_Z(): number;
  32109. /** Billboard on all axes */
  32110. static get BILLBOARDMODE_ALL(): number;
  32111. /** Billboard on using position instead of orientation */
  32112. static get BILLBOARDMODE_USE_POSITION(): number;
  32113. /** @hidden */
  32114. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32115. /**
  32116. * The culling strategy to use to check whether the mesh must be rendered or not.
  32117. * This value can be changed at any time and will be used on the next render mesh selection.
  32118. * The possible values are :
  32119. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32120. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32121. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32122. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32123. * Please read each static variable documentation to get details about the culling process.
  32124. * */
  32125. cullingStrategy: number;
  32126. /**
  32127. * Gets the number of facets in the mesh
  32128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32129. */
  32130. get facetNb(): number;
  32131. /**
  32132. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32134. */
  32135. get partitioningSubdivisions(): number;
  32136. set partitioningSubdivisions(nb: number);
  32137. /**
  32138. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32139. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32141. */
  32142. get partitioningBBoxRatio(): number;
  32143. set partitioningBBoxRatio(ratio: number);
  32144. /**
  32145. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32146. * Works only for updatable meshes.
  32147. * Doesn't work with multi-materials
  32148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32149. */
  32150. get mustDepthSortFacets(): boolean;
  32151. set mustDepthSortFacets(sort: boolean);
  32152. /**
  32153. * The location (Vector3) where the facet depth sort must be computed from.
  32154. * By default, the active camera position.
  32155. * Used only when facet depth sort is enabled
  32156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32157. */
  32158. get facetDepthSortFrom(): Vector3;
  32159. set facetDepthSortFrom(location: Vector3);
  32160. /**
  32161. * gets a boolean indicating if facetData is enabled
  32162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32163. */
  32164. get isFacetDataEnabled(): boolean;
  32165. /** @hidden */
  32166. _updateNonUniformScalingState(value: boolean): boolean;
  32167. /**
  32168. * An event triggered when this mesh collides with another one
  32169. */
  32170. onCollideObservable: Observable<AbstractMesh>;
  32171. /** Set a function to call when this mesh collides with another one */
  32172. set onCollide(callback: () => void);
  32173. /**
  32174. * An event triggered when the collision's position changes
  32175. */
  32176. onCollisionPositionChangeObservable: Observable<Vector3>;
  32177. /** Set a function to call when the collision's position changes */
  32178. set onCollisionPositionChange(callback: () => void);
  32179. /**
  32180. * An event triggered when material is changed
  32181. */
  32182. onMaterialChangedObservable: Observable<AbstractMesh>;
  32183. /**
  32184. * Gets or sets the orientation for POV movement & rotation
  32185. */
  32186. definedFacingForward: boolean;
  32187. /** @hidden */
  32188. _occlusionQuery: Nullable<WebGLQuery>;
  32189. /** @hidden */
  32190. _renderingGroup: Nullable<RenderingGroup>;
  32191. /**
  32192. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32193. */
  32194. get visibility(): number;
  32195. /**
  32196. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32197. */
  32198. set visibility(value: number);
  32199. /** Gets or sets the alpha index used to sort transparent meshes
  32200. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32201. */
  32202. alphaIndex: number;
  32203. /**
  32204. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32205. */
  32206. isVisible: boolean;
  32207. /**
  32208. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32209. */
  32210. isPickable: boolean;
  32211. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32212. showSubMeshesBoundingBox: boolean;
  32213. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32214. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32215. */
  32216. isBlocker: boolean;
  32217. /**
  32218. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32219. */
  32220. enablePointerMoveEvents: boolean;
  32221. /**
  32222. * Specifies the rendering group id for this mesh (0 by default)
  32223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32224. */
  32225. renderingGroupId: number;
  32226. private _material;
  32227. /** Gets or sets current material */
  32228. get material(): Nullable<Material>;
  32229. set material(value: Nullable<Material>);
  32230. /**
  32231. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32232. * @see http://doc.babylonjs.com/babylon101/shadows
  32233. */
  32234. get receiveShadows(): boolean;
  32235. set receiveShadows(value: boolean);
  32236. /** Defines color to use when rendering outline */
  32237. outlineColor: Color3;
  32238. /** Define width to use when rendering outline */
  32239. outlineWidth: number;
  32240. /** Defines color to use when rendering overlay */
  32241. overlayColor: Color3;
  32242. /** Defines alpha to use when rendering overlay */
  32243. overlayAlpha: number;
  32244. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32245. get hasVertexAlpha(): boolean;
  32246. set hasVertexAlpha(value: boolean);
  32247. /** 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) */
  32248. get useVertexColors(): boolean;
  32249. set useVertexColors(value: boolean);
  32250. /**
  32251. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32252. */
  32253. get computeBonesUsingShaders(): boolean;
  32254. set computeBonesUsingShaders(value: boolean);
  32255. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32256. get numBoneInfluencers(): number;
  32257. set numBoneInfluencers(value: number);
  32258. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32259. get applyFog(): boolean;
  32260. set applyFog(value: boolean);
  32261. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32262. useOctreeForRenderingSelection: boolean;
  32263. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32264. useOctreeForPicking: boolean;
  32265. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32266. useOctreeForCollisions: boolean;
  32267. /**
  32268. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32269. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32270. */
  32271. get layerMask(): number;
  32272. set layerMask(value: number);
  32273. /**
  32274. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32275. */
  32276. alwaysSelectAsActiveMesh: boolean;
  32277. /**
  32278. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32279. */
  32280. doNotSyncBoundingInfo: boolean;
  32281. /**
  32282. * Gets or sets the current action manager
  32283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32284. */
  32285. actionManager: Nullable<AbstractActionManager>;
  32286. private _meshCollisionData;
  32287. /**
  32288. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32290. */
  32291. ellipsoid: Vector3;
  32292. /**
  32293. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32294. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32295. */
  32296. ellipsoidOffset: Vector3;
  32297. /**
  32298. * Gets or sets a collision mask used to mask collisions (default is -1).
  32299. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32300. */
  32301. get collisionMask(): number;
  32302. set collisionMask(mask: number);
  32303. /**
  32304. * Gets or sets the current collision group mask (-1 by default).
  32305. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32306. */
  32307. get collisionGroup(): number;
  32308. set collisionGroup(mask: number);
  32309. /**
  32310. * Gets or sets current surrounding meshes (null by default).
  32311. *
  32312. * By default collision detection is tested against every mesh in the scene.
  32313. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32314. * meshes will be tested for the collision.
  32315. *
  32316. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32317. */
  32318. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32319. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32320. /**
  32321. * Defines edge width used when edgesRenderer is enabled
  32322. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32323. */
  32324. edgesWidth: number;
  32325. /**
  32326. * Defines edge color used when edgesRenderer is enabled
  32327. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32328. */
  32329. edgesColor: Color4;
  32330. /** @hidden */
  32331. _edgesRenderer: Nullable<IEdgesRenderer>;
  32332. /** @hidden */
  32333. _masterMesh: Nullable<AbstractMesh>;
  32334. /** @hidden */
  32335. _boundingInfo: Nullable<BoundingInfo>;
  32336. /** @hidden */
  32337. _renderId: number;
  32338. /**
  32339. * Gets or sets the list of subMeshes
  32340. * @see http://doc.babylonjs.com/how_to/multi_materials
  32341. */
  32342. subMeshes: SubMesh[];
  32343. /** @hidden */
  32344. _intersectionsInProgress: AbstractMesh[];
  32345. /** @hidden */
  32346. _unIndexed: boolean;
  32347. /** @hidden */
  32348. _lightSources: Light[];
  32349. /** Gets the list of lights affecting that mesh */
  32350. get lightSources(): Light[];
  32351. /** @hidden */
  32352. get _positions(): Nullable<Vector3[]>;
  32353. /** @hidden */
  32354. _waitingData: {
  32355. lods: Nullable<any>;
  32356. actions: Nullable<any>;
  32357. freezeWorldMatrix: Nullable<boolean>;
  32358. };
  32359. /** @hidden */
  32360. _bonesTransformMatrices: Nullable<Float32Array>;
  32361. /** @hidden */
  32362. _transformMatrixTexture: Nullable<RawTexture>;
  32363. /**
  32364. * Gets or sets a skeleton to apply skining transformations
  32365. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32366. */
  32367. set skeleton(value: Nullable<Skeleton>);
  32368. get skeleton(): Nullable<Skeleton>;
  32369. /**
  32370. * An event triggered when the mesh is rebuilt.
  32371. */
  32372. onRebuildObservable: Observable<AbstractMesh>;
  32373. /**
  32374. * Creates a new AbstractMesh
  32375. * @param name defines the name of the mesh
  32376. * @param scene defines the hosting scene
  32377. */
  32378. constructor(name: string, scene?: Nullable<Scene>);
  32379. /**
  32380. * Returns the string "AbstractMesh"
  32381. * @returns "AbstractMesh"
  32382. */
  32383. getClassName(): string;
  32384. /**
  32385. * Gets a string representation of the current mesh
  32386. * @param fullDetails defines a boolean indicating if full details must be included
  32387. * @returns a string representation of the current mesh
  32388. */
  32389. toString(fullDetails?: boolean): string;
  32390. /**
  32391. * @hidden
  32392. */
  32393. protected _getEffectiveParent(): Nullable<Node>;
  32394. /** @hidden */
  32395. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32396. /** @hidden */
  32397. _rebuild(): void;
  32398. /** @hidden */
  32399. _resyncLightSources(): void;
  32400. /** @hidden */
  32401. _resyncLightSource(light: Light): void;
  32402. /** @hidden */
  32403. _unBindEffect(): void;
  32404. /** @hidden */
  32405. _removeLightSource(light: Light, dispose: boolean): void;
  32406. private _markSubMeshesAsDirty;
  32407. /** @hidden */
  32408. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32409. /** @hidden */
  32410. _markSubMeshesAsAttributesDirty(): void;
  32411. /** @hidden */
  32412. _markSubMeshesAsMiscDirty(): void;
  32413. /**
  32414. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32415. */
  32416. get scaling(): Vector3;
  32417. set scaling(newScaling: Vector3);
  32418. /**
  32419. * Returns true if the mesh is blocked. Implemented by child classes
  32420. */
  32421. get isBlocked(): boolean;
  32422. /**
  32423. * Returns the mesh itself by default. Implemented by child classes
  32424. * @param camera defines the camera to use to pick the right LOD level
  32425. * @returns the currentAbstractMesh
  32426. */
  32427. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32428. /**
  32429. * Returns 0 by default. Implemented by child classes
  32430. * @returns an integer
  32431. */
  32432. getTotalVertices(): number;
  32433. /**
  32434. * Returns a positive integer : the total number of indices in this mesh geometry.
  32435. * @returns the numner of indices or zero if the mesh has no geometry.
  32436. */
  32437. getTotalIndices(): number;
  32438. /**
  32439. * Returns null by default. Implemented by child classes
  32440. * @returns null
  32441. */
  32442. getIndices(): Nullable<IndicesArray>;
  32443. /**
  32444. * Returns the array of the requested vertex data kind. Implemented by child classes
  32445. * @param kind defines the vertex data kind to use
  32446. * @returns null
  32447. */
  32448. getVerticesData(kind: string): Nullable<FloatArray>;
  32449. /**
  32450. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32451. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32452. * Note that a new underlying VertexBuffer object is created each call.
  32453. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32454. * @param kind defines vertex data kind:
  32455. * * VertexBuffer.PositionKind
  32456. * * VertexBuffer.UVKind
  32457. * * VertexBuffer.UV2Kind
  32458. * * VertexBuffer.UV3Kind
  32459. * * VertexBuffer.UV4Kind
  32460. * * VertexBuffer.UV5Kind
  32461. * * VertexBuffer.UV6Kind
  32462. * * VertexBuffer.ColorKind
  32463. * * VertexBuffer.MatricesIndicesKind
  32464. * * VertexBuffer.MatricesIndicesExtraKind
  32465. * * VertexBuffer.MatricesWeightsKind
  32466. * * VertexBuffer.MatricesWeightsExtraKind
  32467. * @param data defines the data source
  32468. * @param updatable defines if the data must be flagged as updatable (or static)
  32469. * @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
  32470. * @returns the current mesh
  32471. */
  32472. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32473. /**
  32474. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32475. * If the mesh has no geometry, it is simply returned as it is.
  32476. * @param kind defines vertex data kind:
  32477. * * VertexBuffer.PositionKind
  32478. * * VertexBuffer.UVKind
  32479. * * VertexBuffer.UV2Kind
  32480. * * VertexBuffer.UV3Kind
  32481. * * VertexBuffer.UV4Kind
  32482. * * VertexBuffer.UV5Kind
  32483. * * VertexBuffer.UV6Kind
  32484. * * VertexBuffer.ColorKind
  32485. * * VertexBuffer.MatricesIndicesKind
  32486. * * VertexBuffer.MatricesIndicesExtraKind
  32487. * * VertexBuffer.MatricesWeightsKind
  32488. * * VertexBuffer.MatricesWeightsExtraKind
  32489. * @param data defines the data source
  32490. * @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
  32491. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32492. * @returns the current mesh
  32493. */
  32494. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32495. /**
  32496. * Sets the mesh indices,
  32497. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32498. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32499. * @param totalVertices Defines the total number of vertices
  32500. * @returns the current mesh
  32501. */
  32502. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32503. /**
  32504. * Gets a boolean indicating if specific vertex data is present
  32505. * @param kind defines the vertex data kind to use
  32506. * @returns true is data kind is present
  32507. */
  32508. isVerticesDataPresent(kind: string): boolean;
  32509. /**
  32510. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32511. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32512. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32513. * @returns a BoundingInfo
  32514. */
  32515. getBoundingInfo(): BoundingInfo;
  32516. /**
  32517. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32518. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32519. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32520. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32521. * @returns the current mesh
  32522. */
  32523. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32524. /**
  32525. * Overwrite the current bounding info
  32526. * @param boundingInfo defines the new bounding info
  32527. * @returns the current mesh
  32528. */
  32529. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32530. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32531. get useBones(): boolean;
  32532. /** @hidden */
  32533. _preActivate(): void;
  32534. /** @hidden */
  32535. _preActivateForIntermediateRendering(renderId: number): void;
  32536. /** @hidden */
  32537. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32538. /** @hidden */
  32539. _postActivate(): void;
  32540. /** @hidden */
  32541. _freeze(): void;
  32542. /** @hidden */
  32543. _unFreeze(): void;
  32544. /**
  32545. * Gets the current world matrix
  32546. * @returns a Matrix
  32547. */
  32548. getWorldMatrix(): Matrix;
  32549. /** @hidden */
  32550. _getWorldMatrixDeterminant(): number;
  32551. /**
  32552. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32553. */
  32554. get isAnInstance(): boolean;
  32555. /**
  32556. * Gets a boolean indicating if this mesh has instances
  32557. */
  32558. get hasInstances(): boolean;
  32559. /**
  32560. * Gets a boolean indicating if this mesh has thin instances
  32561. */
  32562. get hasThinInstances(): boolean;
  32563. /**
  32564. * Perform relative position change from the point of view of behind the front of the mesh.
  32565. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32566. * Supports definition of mesh facing forward or backward
  32567. * @param amountRight defines the distance on the right axis
  32568. * @param amountUp defines the distance on the up axis
  32569. * @param amountForward defines the distance on the forward axis
  32570. * @returns the current mesh
  32571. */
  32572. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32573. /**
  32574. * Calculate relative position change from the point of view of behind the front of the mesh.
  32575. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32576. * Supports definition of mesh facing forward or backward
  32577. * @param amountRight defines the distance on the right axis
  32578. * @param amountUp defines the distance on the up axis
  32579. * @param amountForward defines the distance on the forward axis
  32580. * @returns the new displacement vector
  32581. */
  32582. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32583. /**
  32584. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32585. * Supports definition of mesh facing forward or backward
  32586. * @param flipBack defines the flip
  32587. * @param twirlClockwise defines the twirl
  32588. * @param tiltRight defines the tilt
  32589. * @returns the current mesh
  32590. */
  32591. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32592. /**
  32593. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32594. * Supports definition of mesh facing forward or backward.
  32595. * @param flipBack defines the flip
  32596. * @param twirlClockwise defines the twirl
  32597. * @param tiltRight defines the tilt
  32598. * @returns the new rotation vector
  32599. */
  32600. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32601. /**
  32602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32603. * This means the mesh underlying bounding box and sphere are recomputed.
  32604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32605. * @returns the current mesh
  32606. */
  32607. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32608. /** @hidden */
  32609. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32610. /** @hidden */
  32611. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32612. /** @hidden */
  32613. _updateBoundingInfo(): AbstractMesh;
  32614. /** @hidden */
  32615. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32616. /** @hidden */
  32617. protected _afterComputeWorldMatrix(): void;
  32618. /** @hidden */
  32619. get _effectiveMesh(): AbstractMesh;
  32620. /**
  32621. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32622. * A mesh is in the frustum if its bounding box intersects the frustum
  32623. * @param frustumPlanes defines the frustum to test
  32624. * @returns true if the mesh is in the frustum planes
  32625. */
  32626. isInFrustum(frustumPlanes: Plane[]): boolean;
  32627. /**
  32628. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32629. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32630. * @param frustumPlanes defines the frustum to test
  32631. * @returns true if the mesh is completely in the frustum planes
  32632. */
  32633. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32634. /**
  32635. * True if the mesh intersects another mesh or a SolidParticle object
  32636. * @param mesh defines a target mesh or SolidParticle to test
  32637. * @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)
  32638. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32639. * @returns true if there is an intersection
  32640. */
  32641. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32642. /**
  32643. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32644. * @param point defines the point to test
  32645. * @returns true if there is an intersection
  32646. */
  32647. intersectsPoint(point: Vector3): boolean;
  32648. /**
  32649. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32651. */
  32652. get checkCollisions(): boolean;
  32653. set checkCollisions(collisionEnabled: boolean);
  32654. /**
  32655. * Gets Collider object used to compute collisions (not physics)
  32656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32657. */
  32658. get collider(): Nullable<Collider>;
  32659. /**
  32660. * Move the mesh using collision engine
  32661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32662. * @param displacement defines the requested displacement vector
  32663. * @returns the current mesh
  32664. */
  32665. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32666. private _onCollisionPositionChange;
  32667. /** @hidden */
  32668. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32669. /** @hidden */
  32670. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32671. /** @hidden */
  32672. _checkCollision(collider: Collider): AbstractMesh;
  32673. /** @hidden */
  32674. _generatePointsArray(): boolean;
  32675. /**
  32676. * Checks if the passed Ray intersects with the mesh
  32677. * @param ray defines the ray to use
  32678. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32680. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32681. * @returns the picking info
  32682. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32683. */
  32684. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32685. /**
  32686. * Clones the current mesh
  32687. * @param name defines the mesh name
  32688. * @param newParent defines the new mesh parent
  32689. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32690. * @returns the new mesh
  32691. */
  32692. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32693. /**
  32694. * Disposes all the submeshes of the current meshnp
  32695. * @returns the current mesh
  32696. */
  32697. releaseSubMeshes(): AbstractMesh;
  32698. /**
  32699. * Releases resources associated with this abstract mesh.
  32700. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32701. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32702. */
  32703. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32704. /**
  32705. * Adds the passed mesh as a child to the current mesh
  32706. * @param mesh defines the child mesh
  32707. * @returns the current mesh
  32708. */
  32709. addChild(mesh: AbstractMesh): AbstractMesh;
  32710. /**
  32711. * Removes the passed mesh from the current mesh children list
  32712. * @param mesh defines the child mesh
  32713. * @returns the current mesh
  32714. */
  32715. removeChild(mesh: AbstractMesh): AbstractMesh;
  32716. /** @hidden */
  32717. private _initFacetData;
  32718. /**
  32719. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32720. * This method can be called within the render loop.
  32721. * 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
  32722. * @returns the current mesh
  32723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32724. */
  32725. updateFacetData(): AbstractMesh;
  32726. /**
  32727. * Returns the facetLocalNormals array.
  32728. * The normals are expressed in the mesh local spac
  32729. * @returns an array of Vector3
  32730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32731. */
  32732. getFacetLocalNormals(): Vector3[];
  32733. /**
  32734. * Returns the facetLocalPositions array.
  32735. * The facet positions are expressed in the mesh local space
  32736. * @returns an array of Vector3
  32737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32738. */
  32739. getFacetLocalPositions(): Vector3[];
  32740. /**
  32741. * Returns the facetLocalPartioning array
  32742. * @returns an array of array of numbers
  32743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32744. */
  32745. getFacetLocalPartitioning(): number[][];
  32746. /**
  32747. * Returns the i-th facet position in the world system.
  32748. * This method allocates a new Vector3 per call
  32749. * @param i defines the facet index
  32750. * @returns a new Vector3
  32751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32752. */
  32753. getFacetPosition(i: number): Vector3;
  32754. /**
  32755. * Sets the reference Vector3 with the i-th facet position in the world system
  32756. * @param i defines the facet index
  32757. * @param ref defines the target vector
  32758. * @returns the current mesh
  32759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32760. */
  32761. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32762. /**
  32763. * Returns the i-th facet normal in the world system.
  32764. * This method allocates a new Vector3 per call
  32765. * @param i defines the facet index
  32766. * @returns a new Vector3
  32767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32768. */
  32769. getFacetNormal(i: number): Vector3;
  32770. /**
  32771. * Sets the reference Vector3 with the i-th facet normal in the world system
  32772. * @param i defines the facet index
  32773. * @param ref defines the target vector
  32774. * @returns the current mesh
  32775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32776. */
  32777. getFacetNormalToRef(i: number, ref: Vector3): this;
  32778. /**
  32779. * 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)
  32780. * @param x defines x coordinate
  32781. * @param y defines y coordinate
  32782. * @param z defines z coordinate
  32783. * @returns the array of facet indexes
  32784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32785. */
  32786. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32787. /**
  32788. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32789. * @param projected sets as the (x,y,z) world projection on the facet
  32790. * @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
  32791. * @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
  32792. * @param x defines x coordinate
  32793. * @param y defines y coordinate
  32794. * @param z defines z coordinate
  32795. * @returns the face index if found (or null instead)
  32796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32797. */
  32798. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32799. /**
  32800. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32801. * @param projected sets as the (x,y,z) local projection on the facet
  32802. * @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
  32803. * @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
  32804. * @param x defines x coordinate
  32805. * @param y defines y coordinate
  32806. * @param z defines z coordinate
  32807. * @returns the face index if found (or null instead)
  32808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32809. */
  32810. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32811. /**
  32812. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32813. * @returns the parameters
  32814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32815. */
  32816. getFacetDataParameters(): any;
  32817. /**
  32818. * Disables the feature FacetData and frees the related memory
  32819. * @returns the current mesh
  32820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32821. */
  32822. disableFacetData(): AbstractMesh;
  32823. /**
  32824. * Updates the AbstractMesh indices array
  32825. * @param indices defines the data source
  32826. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32827. * @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)
  32828. * @returns the current mesh
  32829. */
  32830. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32831. /**
  32832. * Creates new normals data for the mesh
  32833. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32834. * @returns the current mesh
  32835. */
  32836. createNormals(updatable: boolean): AbstractMesh;
  32837. /**
  32838. * Align the mesh with a normal
  32839. * @param normal defines the normal to use
  32840. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32841. * @returns the current mesh
  32842. */
  32843. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32844. /** @hidden */
  32845. _checkOcclusionQuery(): boolean;
  32846. /**
  32847. * Disables the mesh edge rendering mode
  32848. * @returns the currentAbstractMesh
  32849. */
  32850. disableEdgesRendering(): AbstractMesh;
  32851. /**
  32852. * Enables the edge rendering mode on the mesh.
  32853. * This mode makes the mesh edges visible
  32854. * @param epsilon defines the maximal distance between two angles to detect a face
  32855. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32856. * @returns the currentAbstractMesh
  32857. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32858. */
  32859. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32860. /**
  32861. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32862. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32863. */
  32864. getConnectedParticleSystems(): IParticleSystem[];
  32865. }
  32866. }
  32867. declare module "babylonjs/Actions/actionEvent" {
  32868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32869. import { Nullable } from "babylonjs/types";
  32870. import { Sprite } from "babylonjs/Sprites/sprite";
  32871. import { Scene } from "babylonjs/scene";
  32872. import { Vector2 } from "babylonjs/Maths/math.vector";
  32873. /**
  32874. * Interface used to define ActionEvent
  32875. */
  32876. export interface IActionEvent {
  32877. /** The mesh or sprite that triggered the action */
  32878. source: any;
  32879. /** The X mouse cursor position at the time of the event */
  32880. pointerX: number;
  32881. /** The Y mouse cursor position at the time of the event */
  32882. pointerY: number;
  32883. /** The mesh that is currently pointed at (can be null) */
  32884. meshUnderPointer: Nullable<AbstractMesh>;
  32885. /** the original (browser) event that triggered the ActionEvent */
  32886. sourceEvent?: any;
  32887. /** additional data for the event */
  32888. additionalData?: any;
  32889. }
  32890. /**
  32891. * ActionEvent is the event being sent when an action is triggered.
  32892. */
  32893. export class ActionEvent implements IActionEvent {
  32894. /** The mesh or sprite that triggered the action */
  32895. source: any;
  32896. /** The X mouse cursor position at the time of the event */
  32897. pointerX: number;
  32898. /** The Y mouse cursor position at the time of the event */
  32899. pointerY: number;
  32900. /** The mesh that is currently pointed at (can be null) */
  32901. meshUnderPointer: Nullable<AbstractMesh>;
  32902. /** the original (browser) event that triggered the ActionEvent */
  32903. sourceEvent?: any;
  32904. /** additional data for the event */
  32905. additionalData?: any;
  32906. /**
  32907. * Creates a new ActionEvent
  32908. * @param source The mesh or sprite that triggered the action
  32909. * @param pointerX The X mouse cursor position at the time of the event
  32910. * @param pointerY The Y mouse cursor position at the time of the event
  32911. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32912. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32913. * @param additionalData additional data for the event
  32914. */
  32915. constructor(
  32916. /** The mesh or sprite that triggered the action */
  32917. source: any,
  32918. /** The X mouse cursor position at the time of the event */
  32919. pointerX: number,
  32920. /** The Y mouse cursor position at the time of the event */
  32921. pointerY: number,
  32922. /** The mesh that is currently pointed at (can be null) */
  32923. meshUnderPointer: Nullable<AbstractMesh>,
  32924. /** the original (browser) event that triggered the ActionEvent */
  32925. sourceEvent?: any,
  32926. /** additional data for the event */
  32927. additionalData?: any);
  32928. /**
  32929. * Helper function to auto-create an ActionEvent from a source mesh.
  32930. * @param source The source mesh that triggered the event
  32931. * @param evt The original (browser) event
  32932. * @param additionalData additional data for the event
  32933. * @returns the new ActionEvent
  32934. */
  32935. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32936. /**
  32937. * Helper function to auto-create an ActionEvent from a source sprite
  32938. * @param source The source sprite that triggered the event
  32939. * @param scene Scene associated with the sprite
  32940. * @param evt The original (browser) event
  32941. * @param additionalData additional data for the event
  32942. * @returns the new ActionEvent
  32943. */
  32944. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32945. /**
  32946. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32947. * @param scene the scene where the event occurred
  32948. * @param evt The original (browser) event
  32949. * @returns the new ActionEvent
  32950. */
  32951. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32952. /**
  32953. * Helper function to auto-create an ActionEvent from a primitive
  32954. * @param prim defines the target primitive
  32955. * @param pointerPos defines the pointer position
  32956. * @param evt The original (browser) event
  32957. * @param additionalData additional data for the event
  32958. * @returns the new ActionEvent
  32959. */
  32960. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32961. }
  32962. }
  32963. declare module "babylonjs/Actions/abstractActionManager" {
  32964. import { IDisposable } from "babylonjs/scene";
  32965. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32966. import { IAction } from "babylonjs/Actions/action";
  32967. import { Nullable } from "babylonjs/types";
  32968. /**
  32969. * Abstract class used to decouple action Manager from scene and meshes.
  32970. * Do not instantiate.
  32971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32972. */
  32973. export abstract class AbstractActionManager implements IDisposable {
  32974. /** Gets the list of active triggers */
  32975. static Triggers: {
  32976. [key: string]: number;
  32977. };
  32978. /** Gets the cursor to use when hovering items */
  32979. hoverCursor: string;
  32980. /** Gets the list of actions */
  32981. actions: IAction[];
  32982. /**
  32983. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32984. */
  32985. isRecursive: boolean;
  32986. /**
  32987. * Releases all associated resources
  32988. */
  32989. abstract dispose(): void;
  32990. /**
  32991. * Does this action manager has pointer triggers
  32992. */
  32993. abstract get hasPointerTriggers(): boolean;
  32994. /**
  32995. * Does this action manager has pick triggers
  32996. */
  32997. abstract get hasPickTriggers(): boolean;
  32998. /**
  32999. * Process a specific trigger
  33000. * @param trigger defines the trigger to process
  33001. * @param evt defines the event details to be processed
  33002. */
  33003. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33004. /**
  33005. * Does this action manager handles actions of any of the given triggers
  33006. * @param triggers defines the triggers to be tested
  33007. * @return a boolean indicating whether one (or more) of the triggers is handled
  33008. */
  33009. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33010. /**
  33011. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33012. * speed.
  33013. * @param triggerA defines the trigger to be tested
  33014. * @param triggerB defines the trigger to be tested
  33015. * @return a boolean indicating whether one (or more) of the triggers is handled
  33016. */
  33017. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33018. /**
  33019. * Does this action manager handles actions of a given trigger
  33020. * @param trigger defines the trigger to be tested
  33021. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33022. * @return whether the trigger is handled
  33023. */
  33024. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33025. /**
  33026. * Serialize this manager to a JSON object
  33027. * @param name defines the property name to store this manager
  33028. * @returns a JSON representation of this manager
  33029. */
  33030. abstract serialize(name: string): any;
  33031. /**
  33032. * Registers an action to this action manager
  33033. * @param action defines the action to be registered
  33034. * @return the action amended (prepared) after registration
  33035. */
  33036. abstract registerAction(action: IAction): Nullable<IAction>;
  33037. /**
  33038. * Unregisters an action to this action manager
  33039. * @param action defines the action to be unregistered
  33040. * @return a boolean indicating whether the action has been unregistered
  33041. */
  33042. abstract unregisterAction(action: IAction): Boolean;
  33043. /**
  33044. * Does exist one action manager with at least one trigger
  33045. **/
  33046. static get HasTriggers(): boolean;
  33047. /**
  33048. * Does exist one action manager with at least one pick trigger
  33049. **/
  33050. static get HasPickTriggers(): boolean;
  33051. /**
  33052. * Does exist one action manager that handles actions of a given trigger
  33053. * @param trigger defines the trigger to be tested
  33054. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33055. **/
  33056. static HasSpecificTrigger(trigger: number): boolean;
  33057. }
  33058. }
  33059. declare module "babylonjs/node" {
  33060. import { Scene } from "babylonjs/scene";
  33061. import { Nullable } from "babylonjs/types";
  33062. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33063. import { Engine } from "babylonjs/Engines/engine";
  33064. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33065. import { Observable } from "babylonjs/Misc/observable";
  33066. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33067. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33068. import { Animatable } from "babylonjs/Animations/animatable";
  33069. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33070. import { Animation } from "babylonjs/Animations/animation";
  33071. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33073. /**
  33074. * Defines how a node can be built from a string name.
  33075. */
  33076. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33077. /**
  33078. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33079. */
  33080. export class Node implements IBehaviorAware<Node> {
  33081. /** @hidden */
  33082. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33083. private static _NodeConstructors;
  33084. /**
  33085. * Add a new node constructor
  33086. * @param type defines the type name of the node to construct
  33087. * @param constructorFunc defines the constructor function
  33088. */
  33089. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33090. /**
  33091. * Returns a node constructor based on type name
  33092. * @param type defines the type name
  33093. * @param name defines the new node name
  33094. * @param scene defines the hosting scene
  33095. * @param options defines optional options to transmit to constructors
  33096. * @returns the new constructor or null
  33097. */
  33098. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33099. /**
  33100. * Gets or sets the name of the node
  33101. */
  33102. name: string;
  33103. /**
  33104. * Gets or sets the id of the node
  33105. */
  33106. id: string;
  33107. /**
  33108. * Gets or sets the unique id of the node
  33109. */
  33110. uniqueId: number;
  33111. /**
  33112. * Gets or sets a string used to store user defined state for the node
  33113. */
  33114. state: string;
  33115. /**
  33116. * Gets or sets an object used to store user defined information for the node
  33117. */
  33118. metadata: any;
  33119. /**
  33120. * For internal use only. Please do not use.
  33121. */
  33122. reservedDataStore: any;
  33123. /**
  33124. * List of inspectable custom properties (used by the Inspector)
  33125. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33126. */
  33127. inspectableCustomProperties: IInspectable[];
  33128. private _doNotSerialize;
  33129. /**
  33130. * Gets or sets a boolean used to define if the node must be serialized
  33131. */
  33132. get doNotSerialize(): boolean;
  33133. set doNotSerialize(value: boolean);
  33134. /** @hidden */
  33135. _isDisposed: boolean;
  33136. /**
  33137. * Gets a list of Animations associated with the node
  33138. */
  33139. animations: import("babylonjs/Animations/animation").Animation[];
  33140. protected _ranges: {
  33141. [name: string]: Nullable<AnimationRange>;
  33142. };
  33143. /**
  33144. * Callback raised when the node is ready to be used
  33145. */
  33146. onReady: Nullable<(node: Node) => void>;
  33147. private _isEnabled;
  33148. private _isParentEnabled;
  33149. private _isReady;
  33150. /** @hidden */
  33151. _currentRenderId: number;
  33152. private _parentUpdateId;
  33153. /** @hidden */
  33154. _childUpdateId: number;
  33155. /** @hidden */
  33156. _waitingParentId: Nullable<string>;
  33157. /** @hidden */
  33158. _scene: Scene;
  33159. /** @hidden */
  33160. _cache: any;
  33161. private _parentNode;
  33162. private _children;
  33163. /** @hidden */
  33164. _worldMatrix: Matrix;
  33165. /** @hidden */
  33166. _worldMatrixDeterminant: number;
  33167. /** @hidden */
  33168. _worldMatrixDeterminantIsDirty: boolean;
  33169. /** @hidden */
  33170. private _sceneRootNodesIndex;
  33171. /**
  33172. * Gets a boolean indicating if the node has been disposed
  33173. * @returns true if the node was disposed
  33174. */
  33175. isDisposed(): boolean;
  33176. /**
  33177. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33178. * @see https://doc.babylonjs.com/how_to/parenting
  33179. */
  33180. set parent(parent: Nullable<Node>);
  33181. get parent(): Nullable<Node>;
  33182. /** @hidden */
  33183. _addToSceneRootNodes(): void;
  33184. /** @hidden */
  33185. _removeFromSceneRootNodes(): void;
  33186. private _animationPropertiesOverride;
  33187. /**
  33188. * Gets or sets the animation properties override
  33189. */
  33190. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33191. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33192. /**
  33193. * Gets a string idenfifying the name of the class
  33194. * @returns "Node" string
  33195. */
  33196. getClassName(): string;
  33197. /** @hidden */
  33198. readonly _isNode: boolean;
  33199. /**
  33200. * An event triggered when the mesh is disposed
  33201. */
  33202. onDisposeObservable: Observable<Node>;
  33203. private _onDisposeObserver;
  33204. /**
  33205. * Sets a callback that will be raised when the node will be disposed
  33206. */
  33207. set onDispose(callback: () => void);
  33208. /**
  33209. * Creates a new Node
  33210. * @param name the name and id to be given to this node
  33211. * @param scene the scene this node will be added to
  33212. */
  33213. constructor(name: string, scene?: Nullable<Scene>);
  33214. /**
  33215. * Gets the scene of the node
  33216. * @returns a scene
  33217. */
  33218. getScene(): Scene;
  33219. /**
  33220. * Gets the engine of the node
  33221. * @returns a Engine
  33222. */
  33223. getEngine(): Engine;
  33224. private _behaviors;
  33225. /**
  33226. * Attach a behavior to the node
  33227. * @see http://doc.babylonjs.com/features/behaviour
  33228. * @param behavior defines the behavior to attach
  33229. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33230. * @returns the current Node
  33231. */
  33232. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33233. /**
  33234. * Remove an attached behavior
  33235. * @see http://doc.babylonjs.com/features/behaviour
  33236. * @param behavior defines the behavior to attach
  33237. * @returns the current Node
  33238. */
  33239. removeBehavior(behavior: Behavior<Node>): Node;
  33240. /**
  33241. * Gets the list of attached behaviors
  33242. * @see http://doc.babylonjs.com/features/behaviour
  33243. */
  33244. get behaviors(): Behavior<Node>[];
  33245. /**
  33246. * Gets an attached behavior by name
  33247. * @param name defines the name of the behavior to look for
  33248. * @see http://doc.babylonjs.com/features/behaviour
  33249. * @returns null if behavior was not found else the requested behavior
  33250. */
  33251. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33252. /**
  33253. * Returns the latest update of the World matrix
  33254. * @returns a Matrix
  33255. */
  33256. getWorldMatrix(): Matrix;
  33257. /** @hidden */
  33258. _getWorldMatrixDeterminant(): number;
  33259. /**
  33260. * Returns directly the latest state of the mesh World matrix.
  33261. * A Matrix is returned.
  33262. */
  33263. get worldMatrixFromCache(): Matrix;
  33264. /** @hidden */
  33265. _initCache(): void;
  33266. /** @hidden */
  33267. updateCache(force?: boolean): void;
  33268. /** @hidden */
  33269. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33270. /** @hidden */
  33271. _updateCache(ignoreParentClass?: boolean): void;
  33272. /** @hidden */
  33273. _isSynchronized(): boolean;
  33274. /** @hidden */
  33275. _markSyncedWithParent(): void;
  33276. /** @hidden */
  33277. isSynchronizedWithParent(): boolean;
  33278. /** @hidden */
  33279. isSynchronized(): boolean;
  33280. /**
  33281. * Is this node ready to be used/rendered
  33282. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33283. * @return true if the node is ready
  33284. */
  33285. isReady(completeCheck?: boolean): boolean;
  33286. /**
  33287. * Is this node enabled?
  33288. * 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
  33289. * @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
  33290. * @return whether this node (and its parent) is enabled
  33291. */
  33292. isEnabled(checkAncestors?: boolean): boolean;
  33293. /** @hidden */
  33294. protected _syncParentEnabledState(): void;
  33295. /**
  33296. * Set the enabled state of this node
  33297. * @param value defines the new enabled state
  33298. */
  33299. setEnabled(value: boolean): void;
  33300. /**
  33301. * Is this node a descendant of the given node?
  33302. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33303. * @param ancestor defines the parent node to inspect
  33304. * @returns a boolean indicating if this node is a descendant of the given node
  33305. */
  33306. isDescendantOf(ancestor: Node): boolean;
  33307. /** @hidden */
  33308. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33309. /**
  33310. * Will return all nodes that have this node as ascendant
  33311. * @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
  33312. * @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
  33313. * @return all children nodes of all types
  33314. */
  33315. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33316. /**
  33317. * Get all child-meshes of this node
  33318. * @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)
  33319. * @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
  33320. * @returns an array of AbstractMesh
  33321. */
  33322. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33323. /**
  33324. * Get all direct children of this node
  33325. * @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
  33326. * @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)
  33327. * @returns an array of Node
  33328. */
  33329. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33330. /** @hidden */
  33331. _setReady(state: boolean): void;
  33332. /**
  33333. * Get an animation by name
  33334. * @param name defines the name of the animation to look for
  33335. * @returns null if not found else the requested animation
  33336. */
  33337. getAnimationByName(name: string): Nullable<Animation>;
  33338. /**
  33339. * Creates an animation range for this node
  33340. * @param name defines the name of the range
  33341. * @param from defines the starting key
  33342. * @param to defines the end key
  33343. */
  33344. createAnimationRange(name: string, from: number, to: number): void;
  33345. /**
  33346. * Delete a specific animation range
  33347. * @param name defines the name of the range to delete
  33348. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33349. */
  33350. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33351. /**
  33352. * Get an animation range by name
  33353. * @param name defines the name of the animation range to look for
  33354. * @returns null if not found else the requested animation range
  33355. */
  33356. getAnimationRange(name: string): Nullable<AnimationRange>;
  33357. /**
  33358. * Gets the list of all animation ranges defined on this node
  33359. * @returns an array
  33360. */
  33361. getAnimationRanges(): Nullable<AnimationRange>[];
  33362. /**
  33363. * Will start the animation sequence
  33364. * @param name defines the range frames for animation sequence
  33365. * @param loop defines if the animation should loop (false by default)
  33366. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33367. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33368. * @returns the object created for this animation. If range does not exist, it will return null
  33369. */
  33370. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33371. /**
  33372. * Serialize animation ranges into a JSON compatible object
  33373. * @returns serialization object
  33374. */
  33375. serializeAnimationRanges(): any;
  33376. /**
  33377. * Computes the world matrix of the node
  33378. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33379. * @returns the world matrix
  33380. */
  33381. computeWorldMatrix(force?: boolean): Matrix;
  33382. /**
  33383. * Releases resources associated with this node.
  33384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33386. */
  33387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33388. /**
  33389. * Parse animation range data from a serialization object and store them into a given node
  33390. * @param node defines where to store the animation ranges
  33391. * @param parsedNode defines the serialization object to read data from
  33392. * @param scene defines the hosting scene
  33393. */
  33394. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33395. /**
  33396. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33397. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33398. * @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
  33399. * @returns the new bounding vectors
  33400. */
  33401. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33402. min: Vector3;
  33403. max: Vector3;
  33404. };
  33405. }
  33406. }
  33407. declare module "babylonjs/Animations/animation" {
  33408. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33409. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33411. import { Nullable } from "babylonjs/types";
  33412. import { Scene } from "babylonjs/scene";
  33413. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33414. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33415. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33416. import { Node } from "babylonjs/node";
  33417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33418. import { Size } from "babylonjs/Maths/math.size";
  33419. import { Animatable } from "babylonjs/Animations/animatable";
  33420. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33421. /**
  33422. * @hidden
  33423. */
  33424. export class _IAnimationState {
  33425. key: number;
  33426. repeatCount: number;
  33427. workValue?: any;
  33428. loopMode?: number;
  33429. offsetValue?: any;
  33430. highLimitValue?: any;
  33431. }
  33432. /**
  33433. * Class used to store any kind of animation
  33434. */
  33435. export class Animation {
  33436. /**Name of the animation */
  33437. name: string;
  33438. /**Property to animate */
  33439. targetProperty: string;
  33440. /**The frames per second of the animation */
  33441. framePerSecond: number;
  33442. /**The data type of the animation */
  33443. dataType: number;
  33444. /**The loop mode of the animation */
  33445. loopMode?: number | undefined;
  33446. /**Specifies if blending should be enabled */
  33447. enableBlending?: boolean | undefined;
  33448. /**
  33449. * Use matrix interpolation instead of using direct key value when animating matrices
  33450. */
  33451. static AllowMatricesInterpolation: boolean;
  33452. /**
  33453. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33454. */
  33455. static AllowMatrixDecomposeForInterpolation: boolean;
  33456. /** Define the Url to load snippets */
  33457. static SnippetUrl: string;
  33458. /** Snippet ID if the animation was created from the snippet server */
  33459. snippetId: string;
  33460. /**
  33461. * Stores the key frames of the animation
  33462. */
  33463. private _keys;
  33464. /**
  33465. * Stores the easing function of the animation
  33466. */
  33467. private _easingFunction;
  33468. /**
  33469. * @hidden Internal use only
  33470. */
  33471. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33472. /**
  33473. * The set of event that will be linked to this animation
  33474. */
  33475. private _events;
  33476. /**
  33477. * Stores an array of target property paths
  33478. */
  33479. targetPropertyPath: string[];
  33480. /**
  33481. * Stores the blending speed of the animation
  33482. */
  33483. blendingSpeed: number;
  33484. /**
  33485. * Stores the animation ranges for the animation
  33486. */
  33487. private _ranges;
  33488. /**
  33489. * @hidden Internal use
  33490. */
  33491. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33492. /**
  33493. * Sets up an animation
  33494. * @param property The property to animate
  33495. * @param animationType The animation type to apply
  33496. * @param framePerSecond The frames per second of the animation
  33497. * @param easingFunction The easing function used in the animation
  33498. * @returns The created animation
  33499. */
  33500. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33501. /**
  33502. * Create and start an animation on a node
  33503. * @param name defines the name of the global animation that will be run on all nodes
  33504. * @param node defines the root node where the animation will take place
  33505. * @param targetProperty defines property to animate
  33506. * @param framePerSecond defines the number of frame per second yo use
  33507. * @param totalFrame defines the number of frames in total
  33508. * @param from defines the initial value
  33509. * @param to defines the final value
  33510. * @param loopMode defines which loop mode you want to use (off by default)
  33511. * @param easingFunction defines the easing function to use (linear by default)
  33512. * @param onAnimationEnd defines the callback to call when animation end
  33513. * @returns the animatable created for this animation
  33514. */
  33515. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33516. /**
  33517. * Create and start an animation on a node and its descendants
  33518. * @param name defines the name of the global animation that will be run on all nodes
  33519. * @param node defines the root node where the animation will take place
  33520. * @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
  33521. * @param targetProperty defines property to animate
  33522. * @param framePerSecond defines the number of frame per second to use
  33523. * @param totalFrame defines the number of frames in total
  33524. * @param from defines the initial value
  33525. * @param to defines the final value
  33526. * @param loopMode defines which loop mode you want to use (off by default)
  33527. * @param easingFunction defines the easing function to use (linear by default)
  33528. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33529. * @returns the list of animatables created for all nodes
  33530. * @example https://www.babylonjs-playground.com/#MH0VLI
  33531. */
  33532. 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[]>;
  33533. /**
  33534. * Creates a new animation, merges it with the existing animations and starts it
  33535. * @param name Name of the animation
  33536. * @param node Node which contains the scene that begins the animations
  33537. * @param targetProperty Specifies which property to animate
  33538. * @param framePerSecond The frames per second of the animation
  33539. * @param totalFrame The total number of frames
  33540. * @param from The frame at the beginning of the animation
  33541. * @param to The frame at the end of the animation
  33542. * @param loopMode Specifies the loop mode of the animation
  33543. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33544. * @param onAnimationEnd Callback to run once the animation is complete
  33545. * @returns Nullable animation
  33546. */
  33547. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33548. /**
  33549. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33550. * @param sourceAnimation defines the Animation containing keyframes to convert
  33551. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33552. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33553. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33554. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33555. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33556. */
  33557. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33558. /**
  33559. * Transition property of an host to the target Value
  33560. * @param property The property to transition
  33561. * @param targetValue The target Value of the property
  33562. * @param host The object where the property to animate belongs
  33563. * @param scene Scene used to run the animation
  33564. * @param frameRate Framerate (in frame/s) to use
  33565. * @param transition The transition type we want to use
  33566. * @param duration The duration of the animation, in milliseconds
  33567. * @param onAnimationEnd Callback trigger at the end of the animation
  33568. * @returns Nullable animation
  33569. */
  33570. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33571. /**
  33572. * Return the array of runtime animations currently using this animation
  33573. */
  33574. get runtimeAnimations(): RuntimeAnimation[];
  33575. /**
  33576. * Specifies if any of the runtime animations are currently running
  33577. */
  33578. get hasRunningRuntimeAnimations(): boolean;
  33579. /**
  33580. * Initializes the animation
  33581. * @param name Name of the animation
  33582. * @param targetProperty Property to animate
  33583. * @param framePerSecond The frames per second of the animation
  33584. * @param dataType The data type of the animation
  33585. * @param loopMode The loop mode of the animation
  33586. * @param enableBlending Specifies if blending should be enabled
  33587. */
  33588. constructor(
  33589. /**Name of the animation */
  33590. name: string,
  33591. /**Property to animate */
  33592. targetProperty: string,
  33593. /**The frames per second of the animation */
  33594. framePerSecond: number,
  33595. /**The data type of the animation */
  33596. dataType: number,
  33597. /**The loop mode of the animation */
  33598. loopMode?: number | undefined,
  33599. /**Specifies if blending should be enabled */
  33600. enableBlending?: boolean | undefined);
  33601. /**
  33602. * Converts the animation to a string
  33603. * @param fullDetails support for multiple levels of logging within scene loading
  33604. * @returns String form of the animation
  33605. */
  33606. toString(fullDetails?: boolean): string;
  33607. /**
  33608. * Add an event to this animation
  33609. * @param event Event to add
  33610. */
  33611. addEvent(event: AnimationEvent): void;
  33612. /**
  33613. * Remove all events found at the given frame
  33614. * @param frame The frame to remove events from
  33615. */
  33616. removeEvents(frame: number): void;
  33617. /**
  33618. * Retrieves all the events from the animation
  33619. * @returns Events from the animation
  33620. */
  33621. getEvents(): AnimationEvent[];
  33622. /**
  33623. * Creates an animation range
  33624. * @param name Name of the animation range
  33625. * @param from Starting frame of the animation range
  33626. * @param to Ending frame of the animation
  33627. */
  33628. createRange(name: string, from: number, to: number): void;
  33629. /**
  33630. * Deletes an animation range by name
  33631. * @param name Name of the animation range to delete
  33632. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33633. */
  33634. deleteRange(name: string, deleteFrames?: boolean): void;
  33635. /**
  33636. * Gets the animation range by name, or null if not defined
  33637. * @param name Name of the animation range
  33638. * @returns Nullable animation range
  33639. */
  33640. getRange(name: string): Nullable<AnimationRange>;
  33641. /**
  33642. * Gets the key frames from the animation
  33643. * @returns The key frames of the animation
  33644. */
  33645. getKeys(): Array<IAnimationKey>;
  33646. /**
  33647. * Gets the highest frame rate of the animation
  33648. * @returns Highest frame rate of the animation
  33649. */
  33650. getHighestFrame(): number;
  33651. /**
  33652. * Gets the easing function of the animation
  33653. * @returns Easing function of the animation
  33654. */
  33655. getEasingFunction(): IEasingFunction;
  33656. /**
  33657. * Sets the easing function of the animation
  33658. * @param easingFunction A custom mathematical formula for animation
  33659. */
  33660. setEasingFunction(easingFunction: EasingFunction): void;
  33661. /**
  33662. * Interpolates a scalar linearly
  33663. * @param startValue Start value of the animation curve
  33664. * @param endValue End value of the animation curve
  33665. * @param gradient Scalar amount to interpolate
  33666. * @returns Interpolated scalar value
  33667. */
  33668. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33669. /**
  33670. * Interpolates a scalar cubically
  33671. * @param startValue Start value of the animation curve
  33672. * @param outTangent End tangent of the animation
  33673. * @param endValue End value of the animation curve
  33674. * @param inTangent Start tangent of the animation curve
  33675. * @param gradient Scalar amount to interpolate
  33676. * @returns Interpolated scalar value
  33677. */
  33678. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33679. /**
  33680. * Interpolates a quaternion using a spherical linear interpolation
  33681. * @param startValue Start value of the animation curve
  33682. * @param endValue End value of the animation curve
  33683. * @param gradient Scalar amount to interpolate
  33684. * @returns Interpolated quaternion value
  33685. */
  33686. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33687. /**
  33688. * Interpolates a quaternion cubically
  33689. * @param startValue Start value of the animation curve
  33690. * @param outTangent End tangent of the animation curve
  33691. * @param endValue End value of the animation curve
  33692. * @param inTangent Start tangent of the animation curve
  33693. * @param gradient Scalar amount to interpolate
  33694. * @returns Interpolated quaternion value
  33695. */
  33696. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33697. /**
  33698. * Interpolates a Vector3 linearl
  33699. * @param startValue Start value of the animation curve
  33700. * @param endValue End value of the animation curve
  33701. * @param gradient Scalar amount to interpolate
  33702. * @returns Interpolated scalar value
  33703. */
  33704. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33705. /**
  33706. * Interpolates a Vector3 cubically
  33707. * @param startValue Start value of the animation curve
  33708. * @param outTangent End tangent of the animation
  33709. * @param endValue End value of the animation curve
  33710. * @param inTangent Start tangent of the animation curve
  33711. * @param gradient Scalar amount to interpolate
  33712. * @returns InterpolatedVector3 value
  33713. */
  33714. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33715. /**
  33716. * Interpolates a Vector2 linearly
  33717. * @param startValue Start value of the animation curve
  33718. * @param endValue End value of the animation curve
  33719. * @param gradient Scalar amount to interpolate
  33720. * @returns Interpolated Vector2 value
  33721. */
  33722. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33723. /**
  33724. * Interpolates a Vector2 cubically
  33725. * @param startValue Start value of the animation curve
  33726. * @param outTangent End tangent of the animation
  33727. * @param endValue End value of the animation curve
  33728. * @param inTangent Start tangent of the animation curve
  33729. * @param gradient Scalar amount to interpolate
  33730. * @returns Interpolated Vector2 value
  33731. */
  33732. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33733. /**
  33734. * Interpolates a size linearly
  33735. * @param startValue Start value of the animation curve
  33736. * @param endValue End value of the animation curve
  33737. * @param gradient Scalar amount to interpolate
  33738. * @returns Interpolated Size value
  33739. */
  33740. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33741. /**
  33742. * Interpolates a Color3 linearly
  33743. * @param startValue Start value of the animation curve
  33744. * @param endValue End value of the animation curve
  33745. * @param gradient Scalar amount to interpolate
  33746. * @returns Interpolated Color3 value
  33747. */
  33748. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33749. /**
  33750. * Interpolates a Color4 linearly
  33751. * @param startValue Start value of the animation curve
  33752. * @param endValue End value of the animation curve
  33753. * @param gradient Scalar amount to interpolate
  33754. * @returns Interpolated Color3 value
  33755. */
  33756. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33757. /**
  33758. * @hidden Internal use only
  33759. */
  33760. _getKeyValue(value: any): any;
  33761. /**
  33762. * @hidden Internal use only
  33763. */
  33764. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33765. /**
  33766. * Defines the function to use to interpolate matrices
  33767. * @param startValue defines the start matrix
  33768. * @param endValue defines the end matrix
  33769. * @param gradient defines the gradient between both matrices
  33770. * @param result defines an optional target matrix where to store the interpolation
  33771. * @returns the interpolated matrix
  33772. */
  33773. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33774. /**
  33775. * Makes a copy of the animation
  33776. * @returns Cloned animation
  33777. */
  33778. clone(): Animation;
  33779. /**
  33780. * Sets the key frames of the animation
  33781. * @param values The animation key frames to set
  33782. */
  33783. setKeys(values: Array<IAnimationKey>): void;
  33784. /**
  33785. * Serializes the animation to an object
  33786. * @returns Serialized object
  33787. */
  33788. serialize(): any;
  33789. /**
  33790. * Float animation type
  33791. */
  33792. static readonly ANIMATIONTYPE_FLOAT: number;
  33793. /**
  33794. * Vector3 animation type
  33795. */
  33796. static readonly ANIMATIONTYPE_VECTOR3: number;
  33797. /**
  33798. * Quaternion animation type
  33799. */
  33800. static readonly ANIMATIONTYPE_QUATERNION: number;
  33801. /**
  33802. * Matrix animation type
  33803. */
  33804. static readonly ANIMATIONTYPE_MATRIX: number;
  33805. /**
  33806. * Color3 animation type
  33807. */
  33808. static readonly ANIMATIONTYPE_COLOR3: number;
  33809. /**
  33810. * Color3 animation type
  33811. */
  33812. static readonly ANIMATIONTYPE_COLOR4: number;
  33813. /**
  33814. * Vector2 animation type
  33815. */
  33816. static readonly ANIMATIONTYPE_VECTOR2: number;
  33817. /**
  33818. * Size animation type
  33819. */
  33820. static readonly ANIMATIONTYPE_SIZE: number;
  33821. /**
  33822. * Relative Loop Mode
  33823. */
  33824. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33825. /**
  33826. * Cycle Loop Mode
  33827. */
  33828. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33829. /**
  33830. * Constant Loop Mode
  33831. */
  33832. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33833. /** @hidden */
  33834. static _UniversalLerp(left: any, right: any, amount: number): any;
  33835. /**
  33836. * Parses an animation object and creates an animation
  33837. * @param parsedAnimation Parsed animation object
  33838. * @returns Animation object
  33839. */
  33840. static Parse(parsedAnimation: any): Animation;
  33841. /**
  33842. * Appends the serialized animations from the source animations
  33843. * @param source Source containing the animations
  33844. * @param destination Target to store the animations
  33845. */
  33846. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33847. /**
  33848. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33849. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33850. * @param url defines the url to load from
  33851. * @returns a promise that will resolve to the new animation or an array of animations
  33852. */
  33853. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33854. /**
  33855. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33856. * @param snippetId defines the snippet to load
  33857. * @returns a promise that will resolve to the new animation or a new array of animations
  33858. */
  33859. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33860. }
  33861. }
  33862. declare module "babylonjs/Animations/animatable.interface" {
  33863. import { Nullable } from "babylonjs/types";
  33864. import { Animation } from "babylonjs/Animations/animation";
  33865. /**
  33866. * Interface containing an array of animations
  33867. */
  33868. export interface IAnimatable {
  33869. /**
  33870. * Array of animations
  33871. */
  33872. animations: Nullable<Array<Animation>>;
  33873. }
  33874. }
  33875. declare module "babylonjs/Misc/decorators" {
  33876. import { Nullable } from "babylonjs/types";
  33877. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33878. import { Scene } from "babylonjs/scene";
  33879. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33880. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33881. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33882. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33883. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33884. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33885. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33886. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33887. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33888. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33889. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33890. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33891. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33892. /**
  33893. * Decorator used to define property that can be serialized as reference to a camera
  33894. * @param sourceName defines the name of the property to decorate
  33895. */
  33896. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33897. /**
  33898. * Class used to help serialization objects
  33899. */
  33900. export class SerializationHelper {
  33901. /** @hidden */
  33902. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33903. /** @hidden */
  33904. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33905. /** @hidden */
  33906. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33907. /** @hidden */
  33908. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33909. /**
  33910. * Appends the serialized animations from the source animations
  33911. * @param source Source containing the animations
  33912. * @param destination Target to store the animations
  33913. */
  33914. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33915. /**
  33916. * Static function used to serialized a specific entity
  33917. * @param entity defines the entity to serialize
  33918. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33919. * @returns a JSON compatible object representing the serialization of the entity
  33920. */
  33921. static Serialize<T>(entity: T, serializationObject?: any): any;
  33922. /**
  33923. * Creates a new entity from a serialization data object
  33924. * @param creationFunction defines a function used to instanciated the new entity
  33925. * @param source defines the source serialization data
  33926. * @param scene defines the hosting scene
  33927. * @param rootUrl defines the root url for resources
  33928. * @returns a new entity
  33929. */
  33930. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33931. /**
  33932. * Clones an object
  33933. * @param creationFunction defines the function used to instanciate the new object
  33934. * @param source defines the source object
  33935. * @returns the cloned object
  33936. */
  33937. static Clone<T>(creationFunction: () => T, source: T): T;
  33938. /**
  33939. * Instanciates a new object based on a source one (some data will be shared between both object)
  33940. * @param creationFunction defines the function used to instanciate the new object
  33941. * @param source defines the source object
  33942. * @returns the new object
  33943. */
  33944. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33945. }
  33946. }
  33947. declare module "babylonjs/Materials/Textures/baseTexture" {
  33948. import { Observable } from "babylonjs/Misc/observable";
  33949. import { Nullable } from "babylonjs/types";
  33950. import { Scene } from "babylonjs/scene";
  33951. import { Matrix } from "babylonjs/Maths/math.vector";
  33952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33953. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33954. import { ISize } from "babylonjs/Maths/math.size";
  33955. import "babylonjs/Misc/fileTools";
  33956. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33957. /**
  33958. * Base class of all the textures in babylon.
  33959. * It groups all the common properties the materials, post process, lights... might need
  33960. * in order to make a correct use of the texture.
  33961. */
  33962. export class BaseTexture implements IAnimatable {
  33963. /**
  33964. * Default anisotropic filtering level for the application.
  33965. * It is set to 4 as a good tradeoff between perf and quality.
  33966. */
  33967. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33968. /**
  33969. * Gets or sets the unique id of the texture
  33970. */
  33971. uniqueId: number;
  33972. /**
  33973. * Define the name of the texture.
  33974. */
  33975. name: string;
  33976. /**
  33977. * Gets or sets an object used to store user defined information.
  33978. */
  33979. metadata: any;
  33980. /**
  33981. * For internal use only. Please do not use.
  33982. */
  33983. reservedDataStore: any;
  33984. private _hasAlpha;
  33985. /**
  33986. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33987. */
  33988. set hasAlpha(value: boolean);
  33989. get hasAlpha(): boolean;
  33990. /**
  33991. * Defines if the alpha value should be determined via the rgb values.
  33992. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33993. */
  33994. getAlphaFromRGB: boolean;
  33995. /**
  33996. * Intensity or strength of the texture.
  33997. * It is commonly used by materials to fine tune the intensity of the texture
  33998. */
  33999. level: number;
  34000. /**
  34001. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34002. * This is part of the texture as textures usually maps to one uv set.
  34003. */
  34004. coordinatesIndex: number;
  34005. private _coordinatesMode;
  34006. /**
  34007. * How a texture is mapped.
  34008. *
  34009. * | Value | Type | Description |
  34010. * | ----- | ----------------------------------- | ----------- |
  34011. * | 0 | EXPLICIT_MODE | |
  34012. * | 1 | SPHERICAL_MODE | |
  34013. * | 2 | PLANAR_MODE | |
  34014. * | 3 | CUBIC_MODE | |
  34015. * | 4 | PROJECTION_MODE | |
  34016. * | 5 | SKYBOX_MODE | |
  34017. * | 6 | INVCUBIC_MODE | |
  34018. * | 7 | EQUIRECTANGULAR_MODE | |
  34019. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34020. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34021. */
  34022. set coordinatesMode(value: number);
  34023. get coordinatesMode(): number;
  34024. /**
  34025. * | Value | Type | Description |
  34026. * | ----- | ------------------ | ----------- |
  34027. * | 0 | CLAMP_ADDRESSMODE | |
  34028. * | 1 | WRAP_ADDRESSMODE | |
  34029. * | 2 | MIRROR_ADDRESSMODE | |
  34030. */
  34031. wrapU: number;
  34032. /**
  34033. * | Value | Type | Description |
  34034. * | ----- | ------------------ | ----------- |
  34035. * | 0 | CLAMP_ADDRESSMODE | |
  34036. * | 1 | WRAP_ADDRESSMODE | |
  34037. * | 2 | MIRROR_ADDRESSMODE | |
  34038. */
  34039. wrapV: number;
  34040. /**
  34041. * | Value | Type | Description |
  34042. * | ----- | ------------------ | ----------- |
  34043. * | 0 | CLAMP_ADDRESSMODE | |
  34044. * | 1 | WRAP_ADDRESSMODE | |
  34045. * | 2 | MIRROR_ADDRESSMODE | |
  34046. */
  34047. wrapR: number;
  34048. /**
  34049. * With compliant hardware and browser (supporting anisotropic filtering)
  34050. * this defines the level of anisotropic filtering in the texture.
  34051. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34052. */
  34053. anisotropicFilteringLevel: number;
  34054. /**
  34055. * Define if the texture is a cube texture or if false a 2d texture.
  34056. */
  34057. get isCube(): boolean;
  34058. set isCube(value: boolean);
  34059. /**
  34060. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34061. */
  34062. get is3D(): boolean;
  34063. set is3D(value: boolean);
  34064. /**
  34065. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34066. */
  34067. get is2DArray(): boolean;
  34068. set is2DArray(value: boolean);
  34069. /**
  34070. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34071. * HDR texture are usually stored in linear space.
  34072. * This only impacts the PBR and Background materials
  34073. */
  34074. gammaSpace: boolean;
  34075. /**
  34076. * Gets or sets whether or not the texture contains RGBD data.
  34077. */
  34078. get isRGBD(): boolean;
  34079. set isRGBD(value: boolean);
  34080. /**
  34081. * Is Z inverted in the texture (useful in a cube texture).
  34082. */
  34083. invertZ: boolean;
  34084. /**
  34085. * Are mip maps generated for this texture or not.
  34086. */
  34087. get noMipmap(): boolean;
  34088. /**
  34089. * @hidden
  34090. */
  34091. lodLevelInAlpha: boolean;
  34092. /**
  34093. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34094. */
  34095. get lodGenerationOffset(): number;
  34096. set lodGenerationOffset(value: number);
  34097. /**
  34098. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34099. */
  34100. get lodGenerationScale(): number;
  34101. set lodGenerationScale(value: number);
  34102. /**
  34103. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34104. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34105. * average roughness values.
  34106. */
  34107. get linearSpecularLOD(): boolean;
  34108. set linearSpecularLOD(value: boolean);
  34109. /**
  34110. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34111. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34112. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34113. */
  34114. get irradianceTexture(): Nullable<BaseTexture>;
  34115. set irradianceTexture(value: Nullable<BaseTexture>);
  34116. /**
  34117. * Define if the texture is a render target.
  34118. */
  34119. isRenderTarget: boolean;
  34120. /**
  34121. * Define the unique id of the texture in the scene.
  34122. */
  34123. get uid(): string;
  34124. /** @hidden */
  34125. _prefiltered: boolean;
  34126. /**
  34127. * Return a string representation of the texture.
  34128. * @returns the texture as a string
  34129. */
  34130. toString(): string;
  34131. /**
  34132. * Get the class name of the texture.
  34133. * @returns "BaseTexture"
  34134. */
  34135. getClassName(): string;
  34136. /**
  34137. * Define the list of animation attached to the texture.
  34138. */
  34139. animations: import("babylonjs/Animations/animation").Animation[];
  34140. /**
  34141. * An event triggered when the texture is disposed.
  34142. */
  34143. onDisposeObservable: Observable<BaseTexture>;
  34144. private _onDisposeObserver;
  34145. /**
  34146. * Callback triggered when the texture has been disposed.
  34147. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34148. */
  34149. set onDispose(callback: () => void);
  34150. /**
  34151. * Define the current state of the loading sequence when in delayed load mode.
  34152. */
  34153. delayLoadState: number;
  34154. private _scene;
  34155. private _engine;
  34156. /** @hidden */
  34157. _texture: Nullable<InternalTexture>;
  34158. private _uid;
  34159. /**
  34160. * Define if the texture is preventinga material to render or not.
  34161. * If not and the texture is not ready, the engine will use a default black texture instead.
  34162. */
  34163. get isBlocking(): boolean;
  34164. /**
  34165. * Instantiates a new BaseTexture.
  34166. * Base class of all the textures in babylon.
  34167. * It groups all the common properties the materials, post process, lights... might need
  34168. * in order to make a correct use of the texture.
  34169. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34170. */
  34171. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34172. /**
  34173. * Get the scene the texture belongs to.
  34174. * @returns the scene or null if undefined
  34175. */
  34176. getScene(): Nullable<Scene>;
  34177. /** @hidden */
  34178. protected _getEngine(): Nullable<ThinEngine>;
  34179. /**
  34180. * Get the texture transform matrix used to offset tile the texture for istance.
  34181. * @returns the transformation matrix
  34182. */
  34183. getTextureMatrix(): Matrix;
  34184. /**
  34185. * Get the texture reflection matrix used to rotate/transform the reflection.
  34186. * @returns the reflection matrix
  34187. */
  34188. getReflectionTextureMatrix(): Matrix;
  34189. /**
  34190. * Get the underlying lower level texture from Babylon.
  34191. * @returns the insternal texture
  34192. */
  34193. getInternalTexture(): Nullable<InternalTexture>;
  34194. /**
  34195. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34196. * @returns true if ready or not blocking
  34197. */
  34198. isReadyOrNotBlocking(): boolean;
  34199. /**
  34200. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34201. * @returns true if fully ready
  34202. */
  34203. isReady(): boolean;
  34204. private _cachedSize;
  34205. /**
  34206. * Get the size of the texture.
  34207. * @returns the texture size.
  34208. */
  34209. getSize(): ISize;
  34210. /**
  34211. * Get the base size of the texture.
  34212. * It can be different from the size if the texture has been resized for POT for instance
  34213. * @returns the base size
  34214. */
  34215. getBaseSize(): ISize;
  34216. /**
  34217. * Update the sampling mode of the texture.
  34218. * Default is Trilinear mode.
  34219. *
  34220. * | Value | Type | Description |
  34221. * | ----- | ------------------ | ----------- |
  34222. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34223. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34224. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34225. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34226. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34227. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34228. * | 7 | NEAREST_LINEAR | |
  34229. * | 8 | NEAREST_NEAREST | |
  34230. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34231. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34232. * | 11 | LINEAR_LINEAR | |
  34233. * | 12 | LINEAR_NEAREST | |
  34234. *
  34235. * > _mag_: magnification filter (close to the viewer)
  34236. * > _min_: minification filter (far from the viewer)
  34237. * > _mip_: filter used between mip map levels
  34238. *@param samplingMode Define the new sampling mode of the texture
  34239. */
  34240. updateSamplingMode(samplingMode: number): void;
  34241. /**
  34242. * Scales the texture if is `canRescale()`
  34243. * @param ratio the resize factor we want to use to rescale
  34244. */
  34245. scale(ratio: number): void;
  34246. /**
  34247. * Get if the texture can rescale.
  34248. */
  34249. get canRescale(): boolean;
  34250. /** @hidden */
  34251. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34252. /** @hidden */
  34253. _rebuild(): void;
  34254. /**
  34255. * Triggers the load sequence in delayed load mode.
  34256. */
  34257. delayLoad(): void;
  34258. /**
  34259. * Clones the texture.
  34260. * @returns the cloned texture
  34261. */
  34262. clone(): Nullable<BaseTexture>;
  34263. /**
  34264. * Get the texture underlying type (INT, FLOAT...)
  34265. */
  34266. get textureType(): number;
  34267. /**
  34268. * Get the texture underlying format (RGB, RGBA...)
  34269. */
  34270. get textureFormat(): number;
  34271. /**
  34272. * Indicates that textures need to be re-calculated for all materials
  34273. */
  34274. protected _markAllSubMeshesAsTexturesDirty(): void;
  34275. /**
  34276. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34277. * This will returns an RGBA array buffer containing either in values (0-255) or
  34278. * float values (0-1) depending of the underlying buffer type.
  34279. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34280. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34281. * @param buffer defines a user defined buffer to fill with data (can be null)
  34282. * @returns The Array buffer containing the pixels data.
  34283. */
  34284. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34285. /**
  34286. * Release and destroy the underlying lower level texture aka internalTexture.
  34287. */
  34288. releaseInternalTexture(): void;
  34289. /** @hidden */
  34290. get _lodTextureHigh(): Nullable<BaseTexture>;
  34291. /** @hidden */
  34292. get _lodTextureMid(): Nullable<BaseTexture>;
  34293. /** @hidden */
  34294. get _lodTextureLow(): Nullable<BaseTexture>;
  34295. /**
  34296. * Dispose the texture and release its associated resources.
  34297. */
  34298. dispose(): void;
  34299. /**
  34300. * Serialize the texture into a JSON representation that can be parsed later on.
  34301. * @returns the JSON representation of the texture
  34302. */
  34303. serialize(): any;
  34304. /**
  34305. * Helper function to be called back once a list of texture contains only ready textures.
  34306. * @param textures Define the list of textures to wait for
  34307. * @param callback Define the callback triggered once the entire list will be ready
  34308. */
  34309. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34310. private static _isScene;
  34311. }
  34312. }
  34313. declare module "babylonjs/Materials/effect" {
  34314. import { Observable } from "babylonjs/Misc/observable";
  34315. import { Nullable } from "babylonjs/types";
  34316. import { IDisposable } from "babylonjs/scene";
  34317. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34319. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34320. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34321. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34322. import { Engine } from "babylonjs/Engines/engine";
  34323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34327. /**
  34328. * Options to be used when creating an effect.
  34329. */
  34330. export interface IEffectCreationOptions {
  34331. /**
  34332. * Atrributes that will be used in the shader.
  34333. */
  34334. attributes: string[];
  34335. /**
  34336. * Uniform varible names that will be set in the shader.
  34337. */
  34338. uniformsNames: string[];
  34339. /**
  34340. * Uniform buffer variable names that will be set in the shader.
  34341. */
  34342. uniformBuffersNames: string[];
  34343. /**
  34344. * Sampler texture variable names that will be set in the shader.
  34345. */
  34346. samplers: string[];
  34347. /**
  34348. * Define statements that will be set in the shader.
  34349. */
  34350. defines: any;
  34351. /**
  34352. * Possible fallbacks for this effect to improve performance when needed.
  34353. */
  34354. fallbacks: Nullable<IEffectFallbacks>;
  34355. /**
  34356. * Callback that will be called when the shader is compiled.
  34357. */
  34358. onCompiled: Nullable<(effect: Effect) => void>;
  34359. /**
  34360. * Callback that will be called if an error occurs during shader compilation.
  34361. */
  34362. onError: Nullable<(effect: Effect, errors: string) => void>;
  34363. /**
  34364. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34365. */
  34366. indexParameters?: any;
  34367. /**
  34368. * Max number of lights that can be used in the shader.
  34369. */
  34370. maxSimultaneousLights?: number;
  34371. /**
  34372. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34373. */
  34374. transformFeedbackVaryings?: Nullable<string[]>;
  34375. /**
  34376. * 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
  34377. */
  34378. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34379. }
  34380. /**
  34381. * Effect containing vertex and fragment shader that can be executed on an object.
  34382. */
  34383. export class Effect implements IDisposable {
  34384. /**
  34385. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34386. */
  34387. static ShadersRepository: string;
  34388. /**
  34389. * Enable logging of the shader code when a compilation error occurs
  34390. */
  34391. static LogShaderCodeOnCompilationError: boolean;
  34392. /**
  34393. * Name of the effect.
  34394. */
  34395. name: any;
  34396. /**
  34397. * String container all the define statements that should be set on the shader.
  34398. */
  34399. defines: string;
  34400. /**
  34401. * Callback that will be called when the shader is compiled.
  34402. */
  34403. onCompiled: Nullable<(effect: Effect) => void>;
  34404. /**
  34405. * Callback that will be called if an error occurs during shader compilation.
  34406. */
  34407. onError: Nullable<(effect: Effect, errors: string) => void>;
  34408. /**
  34409. * Callback that will be called when effect is bound.
  34410. */
  34411. onBind: Nullable<(effect: Effect) => void>;
  34412. /**
  34413. * Unique ID of the effect.
  34414. */
  34415. uniqueId: number;
  34416. /**
  34417. * Observable that will be called when the shader is compiled.
  34418. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34419. */
  34420. onCompileObservable: Observable<Effect>;
  34421. /**
  34422. * Observable that will be called if an error occurs during shader compilation.
  34423. */
  34424. onErrorObservable: Observable<Effect>;
  34425. /** @hidden */
  34426. _onBindObservable: Nullable<Observable<Effect>>;
  34427. /**
  34428. * @hidden
  34429. * Specifies if the effect was previously ready
  34430. */
  34431. _wasPreviouslyReady: boolean;
  34432. /**
  34433. * Observable that will be called when effect is bound.
  34434. */
  34435. get onBindObservable(): Observable<Effect>;
  34436. /** @hidden */
  34437. _bonesComputationForcedToCPU: boolean;
  34438. private static _uniqueIdSeed;
  34439. private _engine;
  34440. private _uniformBuffersNames;
  34441. private _uniformBuffersNamesList;
  34442. private _uniformsNames;
  34443. private _samplerList;
  34444. private _samplers;
  34445. private _isReady;
  34446. private _compilationError;
  34447. private _allFallbacksProcessed;
  34448. private _attributesNames;
  34449. private _attributes;
  34450. private _attributeLocationByName;
  34451. private _uniforms;
  34452. /**
  34453. * Key for the effect.
  34454. * @hidden
  34455. */
  34456. _key: string;
  34457. private _indexParameters;
  34458. private _fallbacks;
  34459. private _vertexSourceCode;
  34460. private _fragmentSourceCode;
  34461. private _vertexSourceCodeOverride;
  34462. private _fragmentSourceCodeOverride;
  34463. private _transformFeedbackVaryings;
  34464. /**
  34465. * Compiled shader to webGL program.
  34466. * @hidden
  34467. */
  34468. _pipelineContext: Nullable<IPipelineContext>;
  34469. private _valueCache;
  34470. private static _baseCache;
  34471. /**
  34472. * Instantiates an effect.
  34473. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34474. * @param baseName Name of the effect.
  34475. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34476. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34477. * @param samplers List of sampler variables that will be passed to the shader.
  34478. * @param engine Engine to be used to render the effect
  34479. * @param defines Define statements to be added to the shader.
  34480. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34481. * @param onCompiled Callback that will be called when the shader is compiled.
  34482. * @param onError Callback that will be called if an error occurs during shader compilation.
  34483. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34484. */
  34485. 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);
  34486. private _useFinalCode;
  34487. /**
  34488. * Unique key for this effect
  34489. */
  34490. get key(): string;
  34491. /**
  34492. * If the effect has been compiled and prepared.
  34493. * @returns if the effect is compiled and prepared.
  34494. */
  34495. isReady(): boolean;
  34496. private _isReadyInternal;
  34497. /**
  34498. * The engine the effect was initialized with.
  34499. * @returns the engine.
  34500. */
  34501. getEngine(): Engine;
  34502. /**
  34503. * The pipeline context for this effect
  34504. * @returns the associated pipeline context
  34505. */
  34506. getPipelineContext(): Nullable<IPipelineContext>;
  34507. /**
  34508. * The set of names of attribute variables for the shader.
  34509. * @returns An array of attribute names.
  34510. */
  34511. getAttributesNames(): string[];
  34512. /**
  34513. * Returns the attribute at the given index.
  34514. * @param index The index of the attribute.
  34515. * @returns The location of the attribute.
  34516. */
  34517. getAttributeLocation(index: number): number;
  34518. /**
  34519. * Returns the attribute based on the name of the variable.
  34520. * @param name of the attribute to look up.
  34521. * @returns the attribute location.
  34522. */
  34523. getAttributeLocationByName(name: string): number;
  34524. /**
  34525. * The number of attributes.
  34526. * @returns the numnber of attributes.
  34527. */
  34528. getAttributesCount(): number;
  34529. /**
  34530. * Gets the index of a uniform variable.
  34531. * @param uniformName of the uniform to look up.
  34532. * @returns the index.
  34533. */
  34534. getUniformIndex(uniformName: string): number;
  34535. /**
  34536. * Returns the attribute based on the name of the variable.
  34537. * @param uniformName of the uniform to look up.
  34538. * @returns the location of the uniform.
  34539. */
  34540. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34541. /**
  34542. * Returns an array of sampler variable names
  34543. * @returns The array of sampler variable names.
  34544. */
  34545. getSamplers(): string[];
  34546. /**
  34547. * Returns an array of uniform variable names
  34548. * @returns The array of uniform variable names.
  34549. */
  34550. getUniformNames(): string[];
  34551. /**
  34552. * Returns an array of uniform buffer variable names
  34553. * @returns The array of uniform buffer variable names.
  34554. */
  34555. getUniformBuffersNames(): string[];
  34556. /**
  34557. * Returns the index parameters used to create the effect
  34558. * @returns The index parameters object
  34559. */
  34560. getIndexParameters(): any;
  34561. /**
  34562. * The error from the last compilation.
  34563. * @returns the error string.
  34564. */
  34565. getCompilationError(): string;
  34566. /**
  34567. * Gets a boolean indicating that all fallbacks were used during compilation
  34568. * @returns true if all fallbacks were used
  34569. */
  34570. allFallbacksProcessed(): boolean;
  34571. /**
  34572. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34573. * @param func The callback to be used.
  34574. */
  34575. executeWhenCompiled(func: (effect: Effect) => void): void;
  34576. private _checkIsReady;
  34577. private _loadShader;
  34578. /**
  34579. * Gets the vertex shader source code of this effect
  34580. */
  34581. get vertexSourceCode(): string;
  34582. /**
  34583. * Gets the fragment shader source code of this effect
  34584. */
  34585. get fragmentSourceCode(): string;
  34586. /**
  34587. * Recompiles the webGL program
  34588. * @param vertexSourceCode The source code for the vertex shader.
  34589. * @param fragmentSourceCode The source code for the fragment shader.
  34590. * @param onCompiled Callback called when completed.
  34591. * @param onError Callback called on error.
  34592. * @hidden
  34593. */
  34594. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34595. /**
  34596. * Prepares the effect
  34597. * @hidden
  34598. */
  34599. _prepareEffect(): void;
  34600. private _getShaderCodeAndErrorLine;
  34601. private _processCompilationErrors;
  34602. /**
  34603. * Checks if the effect is supported. (Must be called after compilation)
  34604. */
  34605. get isSupported(): boolean;
  34606. /**
  34607. * Binds a texture to the engine to be used as output of the shader.
  34608. * @param channel Name of the output variable.
  34609. * @param texture Texture to bind.
  34610. * @hidden
  34611. */
  34612. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34613. /**
  34614. * Sets a texture on the engine to be used in the shader.
  34615. * @param channel Name of the sampler variable.
  34616. * @param texture Texture to set.
  34617. */
  34618. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34619. /**
  34620. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34621. * @param channel Name of the sampler variable.
  34622. * @param texture Texture to set.
  34623. */
  34624. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34625. /**
  34626. * Sets an array of textures on the engine to be used in the shader.
  34627. * @param channel Name of the variable.
  34628. * @param textures Textures to set.
  34629. */
  34630. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34631. /**
  34632. * 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)
  34633. * @param channel Name of the sampler variable.
  34634. * @param postProcess Post process to get the input texture from.
  34635. */
  34636. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34637. /**
  34638. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34639. * 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)
  34640. * @param channel Name of the sampler variable.
  34641. * @param postProcess Post process to get the output texture from.
  34642. */
  34643. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34644. /** @hidden */
  34645. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34646. /** @hidden */
  34647. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34648. /** @hidden */
  34649. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34650. /** @hidden */
  34651. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34652. /**
  34653. * Binds a buffer to a uniform.
  34654. * @param buffer Buffer to bind.
  34655. * @param name Name of the uniform variable to bind to.
  34656. */
  34657. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34658. /**
  34659. * Binds block to a uniform.
  34660. * @param blockName Name of the block to bind.
  34661. * @param index Index to bind.
  34662. */
  34663. bindUniformBlock(blockName: string, index: number): void;
  34664. /**
  34665. * Sets an interger value on a uniform variable.
  34666. * @param uniformName Name of the variable.
  34667. * @param value Value to be set.
  34668. * @returns this effect.
  34669. */
  34670. setInt(uniformName: string, value: number): Effect;
  34671. /**
  34672. * Sets an int array on a uniform variable.
  34673. * @param uniformName Name of the variable.
  34674. * @param array array to be set.
  34675. * @returns this effect.
  34676. */
  34677. setIntArray(uniformName: string, array: Int32Array): Effect;
  34678. /**
  34679. * 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)
  34680. * @param uniformName Name of the variable.
  34681. * @param array array to be set.
  34682. * @returns this effect.
  34683. */
  34684. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34685. /**
  34686. * 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)
  34687. * @param uniformName Name of the variable.
  34688. * @param array array to be set.
  34689. * @returns this effect.
  34690. */
  34691. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34692. /**
  34693. * 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)
  34694. * @param uniformName Name of the variable.
  34695. * @param array array to be set.
  34696. * @returns this effect.
  34697. */
  34698. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34699. /**
  34700. * Sets an float array on a uniform variable.
  34701. * @param uniformName Name of the variable.
  34702. * @param array array to be set.
  34703. * @returns this effect.
  34704. */
  34705. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34706. /**
  34707. * 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)
  34708. * @param uniformName Name of the variable.
  34709. * @param array array to be set.
  34710. * @returns this effect.
  34711. */
  34712. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34713. /**
  34714. * 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)
  34715. * @param uniformName Name of the variable.
  34716. * @param array array to be set.
  34717. * @returns this effect.
  34718. */
  34719. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34720. /**
  34721. * 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)
  34722. * @param uniformName Name of the variable.
  34723. * @param array array to be set.
  34724. * @returns this effect.
  34725. */
  34726. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34727. /**
  34728. * Sets an array on a uniform variable.
  34729. * @param uniformName Name of the variable.
  34730. * @param array array to be set.
  34731. * @returns this effect.
  34732. */
  34733. setArray(uniformName: string, array: number[]): Effect;
  34734. /**
  34735. * 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)
  34736. * @param uniformName Name of the variable.
  34737. * @param array array to be set.
  34738. * @returns this effect.
  34739. */
  34740. setArray2(uniformName: string, array: number[]): Effect;
  34741. /**
  34742. * 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)
  34743. * @param uniformName Name of the variable.
  34744. * @param array array to be set.
  34745. * @returns this effect.
  34746. */
  34747. setArray3(uniformName: string, array: number[]): Effect;
  34748. /**
  34749. * 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)
  34750. * @param uniformName Name of the variable.
  34751. * @param array array to be set.
  34752. * @returns this effect.
  34753. */
  34754. setArray4(uniformName: string, array: number[]): Effect;
  34755. /**
  34756. * Sets matrices on a uniform variable.
  34757. * @param uniformName Name of the variable.
  34758. * @param matrices matrices to be set.
  34759. * @returns this effect.
  34760. */
  34761. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34762. /**
  34763. * Sets matrix on a uniform variable.
  34764. * @param uniformName Name of the variable.
  34765. * @param matrix matrix to be set.
  34766. * @returns this effect.
  34767. */
  34768. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34769. /**
  34770. * 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)
  34771. * @param uniformName Name of the variable.
  34772. * @param matrix matrix to be set.
  34773. * @returns this effect.
  34774. */
  34775. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34776. /**
  34777. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34778. * @param uniformName Name of the variable.
  34779. * @param matrix matrix to be set.
  34780. * @returns this effect.
  34781. */
  34782. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34783. /**
  34784. * Sets a float on a uniform variable.
  34785. * @param uniformName Name of the variable.
  34786. * @param value value to be set.
  34787. * @returns this effect.
  34788. */
  34789. setFloat(uniformName: string, value: number): Effect;
  34790. /**
  34791. * Sets a boolean on a uniform variable.
  34792. * @param uniformName Name of the variable.
  34793. * @param bool value to be set.
  34794. * @returns this effect.
  34795. */
  34796. setBool(uniformName: string, bool: boolean): Effect;
  34797. /**
  34798. * Sets a Vector2 on a uniform variable.
  34799. * @param uniformName Name of the variable.
  34800. * @param vector2 vector2 to be set.
  34801. * @returns this effect.
  34802. */
  34803. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34804. /**
  34805. * Sets a float2 on a uniform variable.
  34806. * @param uniformName Name of the variable.
  34807. * @param x First float in float2.
  34808. * @param y Second float in float2.
  34809. * @returns this effect.
  34810. */
  34811. setFloat2(uniformName: string, x: number, y: number): Effect;
  34812. /**
  34813. * Sets a Vector3 on a uniform variable.
  34814. * @param uniformName Name of the variable.
  34815. * @param vector3 Value to be set.
  34816. * @returns this effect.
  34817. */
  34818. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34819. /**
  34820. * Sets a float3 on a uniform variable.
  34821. * @param uniformName Name of the variable.
  34822. * @param x First float in float3.
  34823. * @param y Second float in float3.
  34824. * @param z Third float in float3.
  34825. * @returns this effect.
  34826. */
  34827. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34828. /**
  34829. * Sets a Vector4 on a uniform variable.
  34830. * @param uniformName Name of the variable.
  34831. * @param vector4 Value to be set.
  34832. * @returns this effect.
  34833. */
  34834. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34835. /**
  34836. * Sets a float4 on a uniform variable.
  34837. * @param uniformName Name of the variable.
  34838. * @param x First float in float4.
  34839. * @param y Second float in float4.
  34840. * @param z Third float in float4.
  34841. * @param w Fourth float in float4.
  34842. * @returns this effect.
  34843. */
  34844. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34845. /**
  34846. * Sets a Color3 on a uniform variable.
  34847. * @param uniformName Name of the variable.
  34848. * @param color3 Value to be set.
  34849. * @returns this effect.
  34850. */
  34851. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34852. /**
  34853. * Sets a Color4 on a uniform variable.
  34854. * @param uniformName Name of the variable.
  34855. * @param color3 Value to be set.
  34856. * @param alpha Alpha value to be set.
  34857. * @returns this effect.
  34858. */
  34859. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34860. /**
  34861. * Sets a Color4 on a uniform variable
  34862. * @param uniformName defines the name of the variable
  34863. * @param color4 defines the value to be set
  34864. * @returns this effect.
  34865. */
  34866. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34867. /** Release all associated resources */
  34868. dispose(): void;
  34869. /**
  34870. * This function will add a new shader to the shader store
  34871. * @param name the name of the shader
  34872. * @param pixelShader optional pixel shader content
  34873. * @param vertexShader optional vertex shader content
  34874. */
  34875. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34876. /**
  34877. * Store of each shader (The can be looked up using effect.key)
  34878. */
  34879. static ShadersStore: {
  34880. [key: string]: string;
  34881. };
  34882. /**
  34883. * Store of each included file for a shader (The can be looked up using effect.key)
  34884. */
  34885. static IncludesShadersStore: {
  34886. [key: string]: string;
  34887. };
  34888. /**
  34889. * Resets the cache of effects.
  34890. */
  34891. static ResetCache(): void;
  34892. }
  34893. }
  34894. declare module "babylonjs/Engines/engineCapabilities" {
  34895. /**
  34896. * Interface used to describe the capabilities of the engine relatively to the current browser
  34897. */
  34898. export interface EngineCapabilities {
  34899. /** Maximum textures units per fragment shader */
  34900. maxTexturesImageUnits: number;
  34901. /** Maximum texture units per vertex shader */
  34902. maxVertexTextureImageUnits: number;
  34903. /** Maximum textures units in the entire pipeline */
  34904. maxCombinedTexturesImageUnits: number;
  34905. /** Maximum texture size */
  34906. maxTextureSize: number;
  34907. /** Maximum texture samples */
  34908. maxSamples?: number;
  34909. /** Maximum cube texture size */
  34910. maxCubemapTextureSize: number;
  34911. /** Maximum render texture size */
  34912. maxRenderTextureSize: number;
  34913. /** Maximum number of vertex attributes */
  34914. maxVertexAttribs: number;
  34915. /** Maximum number of varyings */
  34916. maxVaryingVectors: number;
  34917. /** Maximum number of uniforms per vertex shader */
  34918. maxVertexUniformVectors: number;
  34919. /** Maximum number of uniforms per fragment shader */
  34920. maxFragmentUniformVectors: number;
  34921. /** Defines if standard derivates (dx/dy) are supported */
  34922. standardDerivatives: boolean;
  34923. /** Defines if s3tc texture compression is supported */
  34924. s3tc?: WEBGL_compressed_texture_s3tc;
  34925. /** Defines if pvrtc texture compression is supported */
  34926. pvrtc: any;
  34927. /** Defines if etc1 texture compression is supported */
  34928. etc1: any;
  34929. /** Defines if etc2 texture compression is supported */
  34930. etc2: any;
  34931. /** Defines if astc texture compression is supported */
  34932. astc: any;
  34933. /** Defines if float textures are supported */
  34934. textureFloat: boolean;
  34935. /** Defines if vertex array objects are supported */
  34936. vertexArrayObject: boolean;
  34937. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34938. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34939. /** Gets the maximum level of anisotropy supported */
  34940. maxAnisotropy: number;
  34941. /** Defines if instancing is supported */
  34942. instancedArrays: boolean;
  34943. /** Defines if 32 bits indices are supported */
  34944. uintIndices: boolean;
  34945. /** Defines if high precision shaders are supported */
  34946. highPrecisionShaderSupported: boolean;
  34947. /** Defines if depth reading in the fragment shader is supported */
  34948. fragmentDepthSupported: boolean;
  34949. /** Defines if float texture linear filtering is supported*/
  34950. textureFloatLinearFiltering: boolean;
  34951. /** Defines if rendering to float textures is supported */
  34952. textureFloatRender: boolean;
  34953. /** Defines if half float textures are supported*/
  34954. textureHalfFloat: boolean;
  34955. /** Defines if half float texture linear filtering is supported*/
  34956. textureHalfFloatLinearFiltering: boolean;
  34957. /** Defines if rendering to half float textures is supported */
  34958. textureHalfFloatRender: boolean;
  34959. /** Defines if textureLOD shader command is supported */
  34960. textureLOD: boolean;
  34961. /** Defines if draw buffers extension is supported */
  34962. drawBuffersExtension: boolean;
  34963. /** Defines if depth textures are supported */
  34964. depthTextureExtension: boolean;
  34965. /** Defines if float color buffer are supported */
  34966. colorBufferFloat: boolean;
  34967. /** Gets disjoint timer query extension (null if not supported) */
  34968. timerQuery?: EXT_disjoint_timer_query;
  34969. /** Defines if timestamp can be used with timer query */
  34970. canUseTimestampForTimerQuery: boolean;
  34971. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34972. multiview?: any;
  34973. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34974. oculusMultiview?: any;
  34975. /** Function used to let the system compiles shaders in background */
  34976. parallelShaderCompile?: {
  34977. COMPLETION_STATUS_KHR: number;
  34978. };
  34979. /** Max number of texture samples for MSAA */
  34980. maxMSAASamples: number;
  34981. /** Defines if the blend min max extension is supported */
  34982. blendMinMax: boolean;
  34983. }
  34984. }
  34985. declare module "babylonjs/States/depthCullingState" {
  34986. import { Nullable } from "babylonjs/types";
  34987. /**
  34988. * @hidden
  34989. **/
  34990. export class DepthCullingState {
  34991. private _isDepthTestDirty;
  34992. private _isDepthMaskDirty;
  34993. private _isDepthFuncDirty;
  34994. private _isCullFaceDirty;
  34995. private _isCullDirty;
  34996. private _isZOffsetDirty;
  34997. private _isFrontFaceDirty;
  34998. private _depthTest;
  34999. private _depthMask;
  35000. private _depthFunc;
  35001. private _cull;
  35002. private _cullFace;
  35003. private _zOffset;
  35004. private _frontFace;
  35005. /**
  35006. * Initializes the state.
  35007. */
  35008. constructor();
  35009. get isDirty(): boolean;
  35010. get zOffset(): number;
  35011. set zOffset(value: number);
  35012. get cullFace(): Nullable<number>;
  35013. set cullFace(value: Nullable<number>);
  35014. get cull(): Nullable<boolean>;
  35015. set cull(value: Nullable<boolean>);
  35016. get depthFunc(): Nullable<number>;
  35017. set depthFunc(value: Nullable<number>);
  35018. get depthMask(): boolean;
  35019. set depthMask(value: boolean);
  35020. get depthTest(): boolean;
  35021. set depthTest(value: boolean);
  35022. get frontFace(): Nullable<number>;
  35023. set frontFace(value: Nullable<number>);
  35024. reset(): void;
  35025. apply(gl: WebGLRenderingContext): void;
  35026. }
  35027. }
  35028. declare module "babylonjs/States/stencilState" {
  35029. /**
  35030. * @hidden
  35031. **/
  35032. export class StencilState {
  35033. /** 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 */
  35034. static readonly ALWAYS: number;
  35035. /** Passed to stencilOperation to specify that stencil value must be kept */
  35036. static readonly KEEP: number;
  35037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35038. static readonly REPLACE: number;
  35039. private _isStencilTestDirty;
  35040. private _isStencilMaskDirty;
  35041. private _isStencilFuncDirty;
  35042. private _isStencilOpDirty;
  35043. private _stencilTest;
  35044. private _stencilMask;
  35045. private _stencilFunc;
  35046. private _stencilFuncRef;
  35047. private _stencilFuncMask;
  35048. private _stencilOpStencilFail;
  35049. private _stencilOpDepthFail;
  35050. private _stencilOpStencilDepthPass;
  35051. get isDirty(): boolean;
  35052. get stencilFunc(): number;
  35053. set stencilFunc(value: number);
  35054. get stencilFuncRef(): number;
  35055. set stencilFuncRef(value: number);
  35056. get stencilFuncMask(): number;
  35057. set stencilFuncMask(value: number);
  35058. get stencilOpStencilFail(): number;
  35059. set stencilOpStencilFail(value: number);
  35060. get stencilOpDepthFail(): number;
  35061. set stencilOpDepthFail(value: number);
  35062. get stencilOpStencilDepthPass(): number;
  35063. set stencilOpStencilDepthPass(value: number);
  35064. get stencilMask(): number;
  35065. set stencilMask(value: number);
  35066. get stencilTest(): boolean;
  35067. set stencilTest(value: boolean);
  35068. constructor();
  35069. reset(): void;
  35070. apply(gl: WebGLRenderingContext): void;
  35071. }
  35072. }
  35073. declare module "babylonjs/States/alphaCullingState" {
  35074. /**
  35075. * @hidden
  35076. **/
  35077. export class AlphaState {
  35078. private _isAlphaBlendDirty;
  35079. private _isBlendFunctionParametersDirty;
  35080. private _isBlendEquationParametersDirty;
  35081. private _isBlendConstantsDirty;
  35082. private _alphaBlend;
  35083. private _blendFunctionParameters;
  35084. private _blendEquationParameters;
  35085. private _blendConstants;
  35086. /**
  35087. * Initializes the state.
  35088. */
  35089. constructor();
  35090. get isDirty(): boolean;
  35091. get alphaBlend(): boolean;
  35092. set alphaBlend(value: boolean);
  35093. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35094. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35095. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35096. reset(): void;
  35097. apply(gl: WebGLRenderingContext): void;
  35098. }
  35099. }
  35100. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35101. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35102. /** @hidden */
  35103. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35104. attributeProcessor(attribute: string): string;
  35105. varyingProcessor(varying: string, isFragment: boolean): string;
  35106. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35107. }
  35108. }
  35109. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35110. /**
  35111. * Interface for attribute information associated with buffer instanciation
  35112. */
  35113. export interface InstancingAttributeInfo {
  35114. /**
  35115. * Name of the GLSL attribute
  35116. * if attribute index is not specified, this is used to retrieve the index from the effect
  35117. */
  35118. attributeName: string;
  35119. /**
  35120. * Index/offset of the attribute in the vertex shader
  35121. * if not specified, this will be computes from the name.
  35122. */
  35123. index?: number;
  35124. /**
  35125. * size of the attribute, 1, 2, 3 or 4
  35126. */
  35127. attributeSize: number;
  35128. /**
  35129. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35130. */
  35131. offset: number;
  35132. /**
  35133. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35134. * default to 1
  35135. */
  35136. divisor?: number;
  35137. /**
  35138. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35139. * default is FLOAT
  35140. */
  35141. attributeType?: number;
  35142. /**
  35143. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35144. */
  35145. normalized?: boolean;
  35146. }
  35147. }
  35148. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35150. import { Nullable } from "babylonjs/types";
  35151. module "babylonjs/Engines/thinEngine" {
  35152. interface ThinEngine {
  35153. /**
  35154. * Update a video texture
  35155. * @param texture defines the texture to update
  35156. * @param video defines the video element to use
  35157. * @param invertY defines if data must be stored with Y axis inverted
  35158. */
  35159. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35160. }
  35161. }
  35162. }
  35163. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35165. import { Nullable } from "babylonjs/types";
  35166. module "babylonjs/Engines/thinEngine" {
  35167. interface ThinEngine {
  35168. /**
  35169. * Creates a dynamic texture
  35170. * @param width defines the width of the texture
  35171. * @param height defines the height of the texture
  35172. * @param generateMipMaps defines if the engine should generate the mip levels
  35173. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35174. * @returns the dynamic texture inside an InternalTexture
  35175. */
  35176. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35177. /**
  35178. * Update the content of a dynamic texture
  35179. * @param texture defines the texture to update
  35180. * @param canvas defines the canvas containing the source
  35181. * @param invertY defines if data must be stored with Y axis inverted
  35182. * @param premulAlpha defines if alpha is stored as premultiplied
  35183. * @param format defines the format of the data
  35184. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35185. */
  35186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35187. }
  35188. }
  35189. }
  35190. declare module "babylonjs/Materials/Textures/videoTexture" {
  35191. import { Observable } from "babylonjs/Misc/observable";
  35192. import { Nullable } from "babylonjs/types";
  35193. import { Scene } from "babylonjs/scene";
  35194. import { Texture } from "babylonjs/Materials/Textures/texture";
  35195. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35196. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35197. /**
  35198. * Settings for finer control over video usage
  35199. */
  35200. export interface VideoTextureSettings {
  35201. /**
  35202. * Applies `autoplay` to video, if specified
  35203. */
  35204. autoPlay?: boolean;
  35205. /**
  35206. * Applies `loop` to video, if specified
  35207. */
  35208. loop?: boolean;
  35209. /**
  35210. * Automatically updates internal texture from video at every frame in the render loop
  35211. */
  35212. autoUpdateTexture: boolean;
  35213. /**
  35214. * Image src displayed during the video loading or until the user interacts with the video.
  35215. */
  35216. poster?: string;
  35217. }
  35218. /**
  35219. * If you want to display a video in your scene, this is the special texture for that.
  35220. * This special texture works similar to other textures, with the exception of a few parameters.
  35221. * @see https://doc.babylonjs.com/how_to/video_texture
  35222. */
  35223. export class VideoTexture extends Texture {
  35224. /**
  35225. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35226. */
  35227. readonly autoUpdateTexture: boolean;
  35228. /**
  35229. * The video instance used by the texture internally
  35230. */
  35231. readonly video: HTMLVideoElement;
  35232. private _onUserActionRequestedObservable;
  35233. /**
  35234. * Event triggerd when a dom action is required by the user to play the video.
  35235. * This happens due to recent changes in browser policies preventing video to auto start.
  35236. */
  35237. get onUserActionRequestedObservable(): Observable<Texture>;
  35238. private _generateMipMaps;
  35239. private _stillImageCaptured;
  35240. private _displayingPosterTexture;
  35241. private _settings;
  35242. private _createInternalTextureOnEvent;
  35243. private _frameId;
  35244. private _currentSrc;
  35245. /**
  35246. * Creates a video texture.
  35247. * If you want to display a video in your scene, this is the special texture for that.
  35248. * This special texture works similar to other textures, with the exception of a few parameters.
  35249. * @see https://doc.babylonjs.com/how_to/video_texture
  35250. * @param name optional name, will detect from video source, if not defined
  35251. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35252. * @param scene is obviously the current scene.
  35253. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35254. * @param invertY is false by default but can be used to invert video on Y axis
  35255. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35256. * @param settings allows finer control over video usage
  35257. */
  35258. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35259. private _getName;
  35260. private _getVideo;
  35261. private _createInternalTexture;
  35262. private reset;
  35263. /**
  35264. * @hidden Internal method to initiate `update`.
  35265. */
  35266. _rebuild(): void;
  35267. /**
  35268. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35269. */
  35270. update(): void;
  35271. /**
  35272. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35273. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35274. */
  35275. updateTexture(isVisible: boolean): void;
  35276. protected _updateInternalTexture: () => void;
  35277. /**
  35278. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35279. * @param url New url.
  35280. */
  35281. updateURL(url: string): void;
  35282. /**
  35283. * Clones the texture.
  35284. * @returns the cloned texture
  35285. */
  35286. clone(): VideoTexture;
  35287. /**
  35288. * Dispose the texture and release its associated resources.
  35289. */
  35290. dispose(): void;
  35291. /**
  35292. * Creates a video texture straight from a stream.
  35293. * @param scene Define the scene the texture should be created in
  35294. * @param stream Define the stream the texture should be created from
  35295. * @returns The created video texture as a promise
  35296. */
  35297. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35298. /**
  35299. * Creates a video texture straight from your WebCam video feed.
  35300. * @param scene Define the scene the texture should be created in
  35301. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35302. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35303. * @returns The created video texture as a promise
  35304. */
  35305. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35306. minWidth: number;
  35307. maxWidth: number;
  35308. minHeight: number;
  35309. maxHeight: number;
  35310. deviceId: string;
  35311. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35312. /**
  35313. * Creates a video texture straight from your WebCam video feed.
  35314. * @param scene Define the scene the texture should be created in
  35315. * @param onReady Define a callback to triggered once the texture will be ready
  35316. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35317. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35318. */
  35319. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35320. minWidth: number;
  35321. maxWidth: number;
  35322. minHeight: number;
  35323. maxHeight: number;
  35324. deviceId: string;
  35325. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35326. }
  35327. }
  35328. declare module "babylonjs/Engines/thinEngine" {
  35329. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35330. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35331. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35332. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35333. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35334. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35335. import { Observable } from "babylonjs/Misc/observable";
  35336. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35337. import { StencilState } from "babylonjs/States/stencilState";
  35338. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35340. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35341. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35344. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35346. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35348. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35349. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35350. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35351. import { WebRequest } from "babylonjs/Misc/webRequest";
  35352. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35353. /**
  35354. * Defines the interface used by objects working like Scene
  35355. * @hidden
  35356. */
  35357. export interface ISceneLike {
  35358. _addPendingData(data: any): void;
  35359. _removePendingData(data: any): void;
  35360. offlineProvider: IOfflineProvider;
  35361. }
  35362. /** Interface defining initialization parameters for Engine class */
  35363. export interface EngineOptions extends WebGLContextAttributes {
  35364. /**
  35365. * Defines if the engine should no exceed a specified device ratio
  35366. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35367. */
  35368. limitDeviceRatio?: number;
  35369. /**
  35370. * Defines if webvr should be enabled automatically
  35371. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35372. */
  35373. autoEnableWebVR?: boolean;
  35374. /**
  35375. * Defines if webgl2 should be turned off even if supported
  35376. * @see http://doc.babylonjs.com/features/webgl2
  35377. */
  35378. disableWebGL2Support?: boolean;
  35379. /**
  35380. * Defines if webaudio should be initialized as well
  35381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35382. */
  35383. audioEngine?: boolean;
  35384. /**
  35385. * Defines if animations should run using a deterministic lock step
  35386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35387. */
  35388. deterministicLockstep?: boolean;
  35389. /** Defines the maximum steps to use with deterministic lock step mode */
  35390. lockstepMaxSteps?: number;
  35391. /** Defines the seconds between each deterministic lock step */
  35392. timeStep?: number;
  35393. /**
  35394. * Defines that engine should ignore context lost events
  35395. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35396. */
  35397. doNotHandleContextLost?: boolean;
  35398. /**
  35399. * Defines that engine should ignore modifying touch action attribute and style
  35400. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35401. */
  35402. doNotHandleTouchAction?: boolean;
  35403. /**
  35404. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35405. */
  35406. useHighPrecisionFloats?: boolean;
  35407. /**
  35408. * Make the canvas XR Compatible for XR sessions
  35409. */
  35410. xrCompatible?: boolean;
  35411. }
  35412. /**
  35413. * The base engine class (root of all engines)
  35414. */
  35415. export class ThinEngine {
  35416. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35417. static ExceptionList: ({
  35418. key: string;
  35419. capture: string;
  35420. captureConstraint: number;
  35421. targets: string[];
  35422. } | {
  35423. key: string;
  35424. capture: null;
  35425. captureConstraint: null;
  35426. targets: string[];
  35427. })[];
  35428. /** @hidden */
  35429. static _TextureLoaders: IInternalTextureLoader[];
  35430. /**
  35431. * Returns the current npm package of the sdk
  35432. */
  35433. static get NpmPackage(): string;
  35434. /**
  35435. * Returns the current version of the framework
  35436. */
  35437. static get Version(): string;
  35438. /**
  35439. * Returns a string describing the current engine
  35440. */
  35441. get description(): string;
  35442. /**
  35443. * Gets or sets the epsilon value used by collision engine
  35444. */
  35445. static CollisionsEpsilon: number;
  35446. /**
  35447. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35448. */
  35449. static get ShadersRepository(): string;
  35450. static set ShadersRepository(value: string);
  35451. /** @hidden */
  35452. _shaderProcessor: IShaderProcessor;
  35453. /**
  35454. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35455. */
  35456. forcePOTTextures: boolean;
  35457. /**
  35458. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35459. */
  35460. isFullscreen: boolean;
  35461. /**
  35462. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35463. */
  35464. cullBackFaces: boolean;
  35465. /**
  35466. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35467. */
  35468. renderEvenInBackground: boolean;
  35469. /**
  35470. * Gets or sets a boolean indicating that cache can be kept between frames
  35471. */
  35472. preventCacheWipeBetweenFrames: boolean;
  35473. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35474. validateShaderPrograms: boolean;
  35475. /**
  35476. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35477. * This can provide greater z depth for distant objects.
  35478. */
  35479. useReverseDepthBuffer: boolean;
  35480. /**
  35481. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35482. */
  35483. disableUniformBuffers: boolean;
  35484. /** @hidden */
  35485. _uniformBuffers: UniformBuffer[];
  35486. /**
  35487. * Gets a boolean indicating that the engine supports uniform buffers
  35488. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35489. */
  35490. get supportsUniformBuffers(): boolean;
  35491. /** @hidden */
  35492. _gl: WebGLRenderingContext;
  35493. /** @hidden */
  35494. _webGLVersion: number;
  35495. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35496. protected _windowIsBackground: boolean;
  35497. protected _creationOptions: EngineOptions;
  35498. protected _highPrecisionShadersAllowed: boolean;
  35499. /** @hidden */
  35500. get _shouldUseHighPrecisionShader(): boolean;
  35501. /**
  35502. * Gets a boolean indicating that only power of 2 textures are supported
  35503. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35504. */
  35505. get needPOTTextures(): boolean;
  35506. /** @hidden */
  35507. _badOS: boolean;
  35508. /** @hidden */
  35509. _badDesktopOS: boolean;
  35510. private _hardwareScalingLevel;
  35511. /** @hidden */
  35512. _caps: EngineCapabilities;
  35513. private _isStencilEnable;
  35514. private _glVersion;
  35515. private _glRenderer;
  35516. private _glVendor;
  35517. /** @hidden */
  35518. _videoTextureSupported: boolean;
  35519. protected _renderingQueueLaunched: boolean;
  35520. protected _activeRenderLoops: (() => void)[];
  35521. /**
  35522. * Observable signaled when a context lost event is raised
  35523. */
  35524. onContextLostObservable: Observable<ThinEngine>;
  35525. /**
  35526. * Observable signaled when a context restored event is raised
  35527. */
  35528. onContextRestoredObservable: Observable<ThinEngine>;
  35529. private _onContextLost;
  35530. private _onContextRestored;
  35531. protected _contextWasLost: boolean;
  35532. /** @hidden */
  35533. _doNotHandleContextLost: boolean;
  35534. /**
  35535. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35537. */
  35538. get doNotHandleContextLost(): boolean;
  35539. set doNotHandleContextLost(value: boolean);
  35540. /**
  35541. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35542. */
  35543. disableVertexArrayObjects: boolean;
  35544. /** @hidden */
  35545. protected _colorWrite: boolean;
  35546. /** @hidden */
  35547. protected _colorWriteChanged: boolean;
  35548. /** @hidden */
  35549. protected _depthCullingState: DepthCullingState;
  35550. /** @hidden */
  35551. protected _stencilState: StencilState;
  35552. /** @hidden */
  35553. _alphaState: AlphaState;
  35554. /** @hidden */
  35555. _alphaMode: number;
  35556. /** @hidden */
  35557. _alphaEquation: number;
  35558. /** @hidden */
  35559. _internalTexturesCache: InternalTexture[];
  35560. /** @hidden */
  35561. protected _activeChannel: number;
  35562. private _currentTextureChannel;
  35563. /** @hidden */
  35564. protected _boundTexturesCache: {
  35565. [key: string]: Nullable<InternalTexture>;
  35566. };
  35567. /** @hidden */
  35568. protected _currentEffect: Nullable<Effect>;
  35569. /** @hidden */
  35570. protected _currentProgram: Nullable<WebGLProgram>;
  35571. private _compiledEffects;
  35572. private _vertexAttribArraysEnabled;
  35573. /** @hidden */
  35574. protected _cachedViewport: Nullable<IViewportLike>;
  35575. private _cachedVertexArrayObject;
  35576. /** @hidden */
  35577. protected _cachedVertexBuffers: any;
  35578. /** @hidden */
  35579. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35580. /** @hidden */
  35581. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35582. /** @hidden */
  35583. _currentRenderTarget: Nullable<InternalTexture>;
  35584. private _uintIndicesCurrentlySet;
  35585. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35586. /** @hidden */
  35587. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35588. /** @hidden */
  35589. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35590. private _currentBufferPointers;
  35591. private _currentInstanceLocations;
  35592. private _currentInstanceBuffers;
  35593. private _textureUnits;
  35594. /** @hidden */
  35595. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35596. /** @hidden */
  35597. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35598. /** @hidden */
  35599. _boundRenderFunction: any;
  35600. private _vaoRecordInProgress;
  35601. private _mustWipeVertexAttributes;
  35602. private _emptyTexture;
  35603. private _emptyCubeTexture;
  35604. private _emptyTexture3D;
  35605. private _emptyTexture2DArray;
  35606. /** @hidden */
  35607. _frameHandler: number;
  35608. private _nextFreeTextureSlots;
  35609. private _maxSimultaneousTextures;
  35610. private _activeRequests;
  35611. /** @hidden */
  35612. _transformTextureUrl: Nullable<(url: string) => string>;
  35613. protected get _supportsHardwareTextureRescaling(): boolean;
  35614. private _framebufferDimensionsObject;
  35615. /**
  35616. * sets the object from which width and height will be taken from when getting render width and height
  35617. * Will fallback to the gl object
  35618. * @param dimensions the framebuffer width and height that will be used.
  35619. */
  35620. set framebufferDimensionsObject(dimensions: Nullable<{
  35621. framebufferWidth: number;
  35622. framebufferHeight: number;
  35623. }>);
  35624. /**
  35625. * Gets the current viewport
  35626. */
  35627. get currentViewport(): Nullable<IViewportLike>;
  35628. /**
  35629. * Gets the default empty texture
  35630. */
  35631. get emptyTexture(): InternalTexture;
  35632. /**
  35633. * Gets the default empty 3D texture
  35634. */
  35635. get emptyTexture3D(): InternalTexture;
  35636. /**
  35637. * Gets the default empty 2D array texture
  35638. */
  35639. get emptyTexture2DArray(): InternalTexture;
  35640. /**
  35641. * Gets the default empty cube texture
  35642. */
  35643. get emptyCubeTexture(): InternalTexture;
  35644. /**
  35645. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35646. */
  35647. readonly premultipliedAlpha: boolean;
  35648. /**
  35649. * Observable event triggered before each texture is initialized
  35650. */
  35651. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35652. /**
  35653. * Creates a new engine
  35654. * @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
  35655. * @param antialias defines enable antialiasing (default: false)
  35656. * @param options defines further options to be sent to the getContext() function
  35657. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35658. */
  35659. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35660. private _rebuildInternalTextures;
  35661. private _rebuildEffects;
  35662. /**
  35663. * Gets a boolean indicating if all created effects are ready
  35664. * @returns true if all effects are ready
  35665. */
  35666. areAllEffectsReady(): boolean;
  35667. protected _rebuildBuffers(): void;
  35668. protected _initGLContext(): void;
  35669. /**
  35670. * Gets version of the current webGL context
  35671. */
  35672. get webGLVersion(): number;
  35673. /**
  35674. * Gets a string idenfifying the name of the class
  35675. * @returns "Engine" string
  35676. */
  35677. getClassName(): string;
  35678. /**
  35679. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35680. */
  35681. get isStencilEnable(): boolean;
  35682. /** @hidden */
  35683. _prepareWorkingCanvas(): void;
  35684. /**
  35685. * Reset the texture cache to empty state
  35686. */
  35687. resetTextureCache(): void;
  35688. /**
  35689. * Gets an object containing information about the current webGL context
  35690. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35691. */
  35692. getGlInfo(): {
  35693. vendor: string;
  35694. renderer: string;
  35695. version: string;
  35696. };
  35697. /**
  35698. * Defines the hardware scaling level.
  35699. * By default the hardware scaling level is computed from the window device ratio.
  35700. * 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.
  35701. * @param level defines the level to use
  35702. */
  35703. setHardwareScalingLevel(level: number): void;
  35704. /**
  35705. * Gets the current hardware scaling level.
  35706. * By default the hardware scaling level is computed from the window device ratio.
  35707. * 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.
  35708. * @returns a number indicating the current hardware scaling level
  35709. */
  35710. getHardwareScalingLevel(): number;
  35711. /**
  35712. * Gets the list of loaded textures
  35713. * @returns an array containing all loaded textures
  35714. */
  35715. getLoadedTexturesCache(): InternalTexture[];
  35716. /**
  35717. * Gets the object containing all engine capabilities
  35718. * @returns the EngineCapabilities object
  35719. */
  35720. getCaps(): EngineCapabilities;
  35721. /**
  35722. * stop executing a render loop function and remove it from the execution array
  35723. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35724. */
  35725. stopRenderLoop(renderFunction?: () => void): void;
  35726. /** @hidden */
  35727. _renderLoop(): void;
  35728. /**
  35729. * Gets the HTML canvas attached with the current webGL context
  35730. * @returns a HTML canvas
  35731. */
  35732. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35733. /**
  35734. * Gets host window
  35735. * @returns the host window object
  35736. */
  35737. getHostWindow(): Nullable<Window>;
  35738. /**
  35739. * Gets the current render width
  35740. * @param useScreen defines if screen size must be used (or the current render target if any)
  35741. * @returns a number defining the current render width
  35742. */
  35743. getRenderWidth(useScreen?: boolean): number;
  35744. /**
  35745. * Gets the current render height
  35746. * @param useScreen defines if screen size must be used (or the current render target if any)
  35747. * @returns a number defining the current render height
  35748. */
  35749. getRenderHeight(useScreen?: boolean): number;
  35750. /**
  35751. * Can be used to override the current requestAnimationFrame requester.
  35752. * @hidden
  35753. */
  35754. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35755. /**
  35756. * Register and execute a render loop. The engine can have more than one render function
  35757. * @param renderFunction defines the function to continuously execute
  35758. */
  35759. runRenderLoop(renderFunction: () => void): void;
  35760. /**
  35761. * Clear the current render buffer or the current render target (if any is set up)
  35762. * @param color defines the color to use
  35763. * @param backBuffer defines if the back buffer must be cleared
  35764. * @param depth defines if the depth buffer must be cleared
  35765. * @param stencil defines if the stencil buffer must be cleared
  35766. */
  35767. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35768. private _viewportCached;
  35769. /** @hidden */
  35770. _viewport(x: number, y: number, width: number, height: number): void;
  35771. /**
  35772. * Set the WebGL's viewport
  35773. * @param viewport defines the viewport element to be used
  35774. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35775. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35776. */
  35777. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35778. /**
  35779. * Begin a new frame
  35780. */
  35781. beginFrame(): void;
  35782. /**
  35783. * Enf the current frame
  35784. */
  35785. endFrame(): void;
  35786. /**
  35787. * Resize the view according to the canvas' size
  35788. */
  35789. resize(): void;
  35790. /**
  35791. * Force a specific size of the canvas
  35792. * @param width defines the new canvas' width
  35793. * @param height defines the new canvas' height
  35794. * @returns true if the size was changed
  35795. */
  35796. setSize(width: number, height: number): boolean;
  35797. /**
  35798. * Binds the frame buffer to the specified texture.
  35799. * @param texture The texture to render to or null for the default canvas
  35800. * @param faceIndex The face of the texture to render to in case of cube texture
  35801. * @param requiredWidth The width of the target to render to
  35802. * @param requiredHeight The height of the target to render to
  35803. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35804. * @param lodLevel defines the lod level to bind to the frame buffer
  35805. * @param layer defines the 2d array index to bind to frame buffer to
  35806. */
  35807. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35808. /** @hidden */
  35809. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35810. /**
  35811. * Unbind the current render target texture from the webGL context
  35812. * @param texture defines the render target texture to unbind
  35813. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35814. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35815. */
  35816. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35817. /**
  35818. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35819. */
  35820. flushFramebuffer(): void;
  35821. /**
  35822. * Unbind the current render target and bind the default framebuffer
  35823. */
  35824. restoreDefaultFramebuffer(): void;
  35825. /** @hidden */
  35826. protected _resetVertexBufferBinding(): void;
  35827. /**
  35828. * Creates a vertex buffer
  35829. * @param data the data for the vertex buffer
  35830. * @returns the new WebGL static buffer
  35831. */
  35832. createVertexBuffer(data: DataArray): DataBuffer;
  35833. private _createVertexBuffer;
  35834. /**
  35835. * Creates a dynamic vertex buffer
  35836. * @param data the data for the dynamic vertex buffer
  35837. * @returns the new WebGL dynamic buffer
  35838. */
  35839. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35840. protected _resetIndexBufferBinding(): void;
  35841. /**
  35842. * Creates a new index buffer
  35843. * @param indices defines the content of the index buffer
  35844. * @param updatable defines if the index buffer must be updatable
  35845. * @returns a new webGL buffer
  35846. */
  35847. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35848. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35849. /**
  35850. * Bind a webGL buffer to the webGL context
  35851. * @param buffer defines the buffer to bind
  35852. */
  35853. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35854. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35855. private bindBuffer;
  35856. /**
  35857. * update the bound buffer with the given data
  35858. * @param data defines the data to update
  35859. */
  35860. updateArrayBuffer(data: Float32Array): void;
  35861. private _vertexAttribPointer;
  35862. /** @hidden */
  35863. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35864. private _bindVertexBuffersAttributes;
  35865. /**
  35866. * Records a vertex array object
  35867. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35868. * @param vertexBuffers defines the list of vertex buffers to store
  35869. * @param indexBuffer defines the index buffer to store
  35870. * @param effect defines the effect to store
  35871. * @returns the new vertex array object
  35872. */
  35873. recordVertexArrayObject(vertexBuffers: {
  35874. [key: string]: VertexBuffer;
  35875. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35876. /**
  35877. * Bind a specific vertex array object
  35878. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35879. * @param vertexArrayObject defines the vertex array object to bind
  35880. * @param indexBuffer defines the index buffer to bind
  35881. */
  35882. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35883. /**
  35884. * Bind webGl buffers directly to the webGL context
  35885. * @param vertexBuffer defines the vertex buffer to bind
  35886. * @param indexBuffer defines the index buffer to bind
  35887. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35888. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35889. * @param effect defines the effect associated with the vertex buffer
  35890. */
  35891. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35892. private _unbindVertexArrayObject;
  35893. /**
  35894. * Bind a list of vertex buffers to the webGL context
  35895. * @param vertexBuffers defines the list of vertex buffers to bind
  35896. * @param indexBuffer defines the index buffer to bind
  35897. * @param effect defines the effect associated with the vertex buffers
  35898. */
  35899. bindBuffers(vertexBuffers: {
  35900. [key: string]: Nullable<VertexBuffer>;
  35901. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35902. /**
  35903. * Unbind all instance attributes
  35904. */
  35905. unbindInstanceAttributes(): void;
  35906. /**
  35907. * Release and free the memory of a vertex array object
  35908. * @param vao defines the vertex array object to delete
  35909. */
  35910. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35911. /** @hidden */
  35912. _releaseBuffer(buffer: DataBuffer): boolean;
  35913. protected _deleteBuffer(buffer: DataBuffer): void;
  35914. /**
  35915. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35916. * @param instancesBuffer defines the webGL buffer to update and bind
  35917. * @param data defines the data to store in the buffer
  35918. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35919. */
  35920. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35921. /**
  35922. * Bind the content of a webGL buffer used with instantiation
  35923. * @param instancesBuffer defines the webGL buffer to bind
  35924. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35925. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35926. */
  35927. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35928. /**
  35929. * Disable the instance attribute corresponding to the name in parameter
  35930. * @param name defines the name of the attribute to disable
  35931. */
  35932. disableInstanceAttributeByName(name: string): void;
  35933. /**
  35934. * Disable the instance attribute corresponding to the location in parameter
  35935. * @param attributeLocation defines the attribute location of the attribute to disable
  35936. */
  35937. disableInstanceAttribute(attributeLocation: number): void;
  35938. /**
  35939. * Disable the attribute corresponding to the location in parameter
  35940. * @param attributeLocation defines the attribute location of the attribute to disable
  35941. */
  35942. disableAttributeByIndex(attributeLocation: number): void;
  35943. /**
  35944. * Send a draw order
  35945. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35946. * @param indexStart defines the starting index
  35947. * @param indexCount defines the number of index to draw
  35948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35949. */
  35950. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35951. /**
  35952. * Draw a list of points
  35953. * @param verticesStart defines the index of first vertex to draw
  35954. * @param verticesCount defines the count of vertices to draw
  35955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35956. */
  35957. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35958. /**
  35959. * Draw a list of unindexed primitives
  35960. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35961. * @param verticesStart defines the index of first vertex to draw
  35962. * @param verticesCount defines the count of vertices to draw
  35963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35964. */
  35965. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35966. /**
  35967. * Draw a list of indexed primitives
  35968. * @param fillMode defines the primitive to use
  35969. * @param indexStart defines the starting index
  35970. * @param indexCount defines the number of index to draw
  35971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35972. */
  35973. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35974. /**
  35975. * Draw a list of unindexed primitives
  35976. * @param fillMode defines the primitive to use
  35977. * @param verticesStart defines the index of first vertex to draw
  35978. * @param verticesCount defines the count of vertices to draw
  35979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35980. */
  35981. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35982. private _drawMode;
  35983. /** @hidden */
  35984. protected _reportDrawCall(): void;
  35985. /** @hidden */
  35986. _releaseEffect(effect: Effect): void;
  35987. /** @hidden */
  35988. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35989. /**
  35990. * Create a new effect (used to store vertex/fragment shaders)
  35991. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35992. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35993. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35994. * @param samplers defines an array of string used to represent textures
  35995. * @param defines defines the string containing the defines to use to compile the shaders
  35996. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35997. * @param onCompiled defines a function to call when the effect creation is successful
  35998. * @param onError defines a function to call when the effect creation has failed
  35999. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36000. * @returns the new Effect
  36001. */
  36002. 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;
  36003. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36004. private _compileShader;
  36005. private _compileRawShader;
  36006. /** @hidden */
  36007. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36008. /**
  36009. * Directly creates a webGL program
  36010. * @param pipelineContext defines the pipeline context to attach to
  36011. * @param vertexCode defines the vertex shader code to use
  36012. * @param fragmentCode defines the fragment shader code to use
  36013. * @param context defines the webGL context to use (if not set, the current one will be used)
  36014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36015. * @returns the new webGL program
  36016. */
  36017. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36018. /**
  36019. * Creates a webGL program
  36020. * @param pipelineContext defines the pipeline context to attach to
  36021. * @param vertexCode defines the vertex shader code to use
  36022. * @param fragmentCode defines the fragment shader code to use
  36023. * @param defines defines the string containing the defines to use to compile the shaders
  36024. * @param context defines the webGL context to use (if not set, the current one will be used)
  36025. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36026. * @returns the new webGL program
  36027. */
  36028. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36029. /**
  36030. * Creates a new pipeline context
  36031. * @returns the new pipeline
  36032. */
  36033. createPipelineContext(): IPipelineContext;
  36034. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36035. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36036. /** @hidden */
  36037. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36038. /** @hidden */
  36039. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36040. /** @hidden */
  36041. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36042. /**
  36043. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36044. * @param pipelineContext defines the pipeline context to use
  36045. * @param uniformsNames defines the list of uniform names
  36046. * @returns an array of webGL uniform locations
  36047. */
  36048. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36049. /**
  36050. * Gets the lsit of active attributes for a given webGL program
  36051. * @param pipelineContext defines the pipeline context to use
  36052. * @param attributesNames defines the list of attribute names to get
  36053. * @returns an array of indices indicating the offset of each attribute
  36054. */
  36055. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36056. /**
  36057. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36058. * @param effect defines the effect to activate
  36059. */
  36060. enableEffect(effect: Nullable<Effect>): void;
  36061. /**
  36062. * Set the value of an uniform to a number (int)
  36063. * @param uniform defines the webGL uniform location where to store the value
  36064. * @param value defines the int number to store
  36065. */
  36066. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36067. /**
  36068. * Set the value of an uniform to an array of int32
  36069. * @param uniform defines the webGL uniform location where to store the value
  36070. * @param array defines the array of int32 to store
  36071. */
  36072. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36073. /**
  36074. * Set the value of an uniform to an array of int32 (stored as vec2)
  36075. * @param uniform defines the webGL uniform location where to store the value
  36076. * @param array defines the array of int32 to store
  36077. */
  36078. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36079. /**
  36080. * Set the value of an uniform to an array of int32 (stored as vec3)
  36081. * @param uniform defines the webGL uniform location where to store the value
  36082. * @param array defines the array of int32 to store
  36083. */
  36084. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36085. /**
  36086. * Set the value of an uniform to an array of int32 (stored as vec4)
  36087. * @param uniform defines the webGL uniform location where to store the value
  36088. * @param array defines the array of int32 to store
  36089. */
  36090. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36091. /**
  36092. * Set the value of an uniform to an array of number
  36093. * @param uniform defines the webGL uniform location where to store the value
  36094. * @param array defines the array of number to store
  36095. */
  36096. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36097. /**
  36098. * Set the value of an uniform to an array of number (stored as vec2)
  36099. * @param uniform defines the webGL uniform location where to store the value
  36100. * @param array defines the array of number to store
  36101. */
  36102. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36103. /**
  36104. * Set the value of an uniform to an array of number (stored as vec3)
  36105. * @param uniform defines the webGL uniform location where to store the value
  36106. * @param array defines the array of number to store
  36107. */
  36108. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36109. /**
  36110. * Set the value of an uniform to an array of number (stored as vec4)
  36111. * @param uniform defines the webGL uniform location where to store the value
  36112. * @param array defines the array of number to store
  36113. */
  36114. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36115. /**
  36116. * Set the value of an uniform to an array of float32 (stored as matrices)
  36117. * @param uniform defines the webGL uniform location where to store the value
  36118. * @param matrices defines the array of float32 to store
  36119. */
  36120. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36121. /**
  36122. * Set the value of an uniform to a matrix (3x3)
  36123. * @param uniform defines the webGL uniform location where to store the value
  36124. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36125. */
  36126. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36127. /**
  36128. * Set the value of an uniform to a matrix (2x2)
  36129. * @param uniform defines the webGL uniform location where to store the value
  36130. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36131. */
  36132. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36133. /**
  36134. * Set the value of an uniform to a number (float)
  36135. * @param uniform defines the webGL uniform location where to store the value
  36136. * @param value defines the float number to store
  36137. */
  36138. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36139. /**
  36140. * Set the value of an uniform to a vec2
  36141. * @param uniform defines the webGL uniform location where to store the value
  36142. * @param x defines the 1st component of the value
  36143. * @param y defines the 2nd component of the value
  36144. */
  36145. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36146. /**
  36147. * Set the value of an uniform to a vec3
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param x defines the 1st component of the value
  36150. * @param y defines the 2nd component of the value
  36151. * @param z defines the 3rd component of the value
  36152. */
  36153. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36154. /**
  36155. * Set the value of an uniform to a vec4
  36156. * @param uniform defines the webGL uniform location where to store the value
  36157. * @param x defines the 1st component of the value
  36158. * @param y defines the 2nd component of the value
  36159. * @param z defines the 3rd component of the value
  36160. * @param w defines the 4th component of the value
  36161. */
  36162. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36163. /**
  36164. * Apply all cached states (depth, culling, stencil and alpha)
  36165. */
  36166. applyStates(): void;
  36167. /**
  36168. * Enable or disable color writing
  36169. * @param enable defines the state to set
  36170. */
  36171. setColorWrite(enable: boolean): void;
  36172. /**
  36173. * Gets a boolean indicating if color writing is enabled
  36174. * @returns the current color writing state
  36175. */
  36176. getColorWrite(): boolean;
  36177. /**
  36178. * Gets the depth culling state manager
  36179. */
  36180. get depthCullingState(): DepthCullingState;
  36181. /**
  36182. * Gets the alpha state manager
  36183. */
  36184. get alphaState(): AlphaState;
  36185. /**
  36186. * Gets the stencil state manager
  36187. */
  36188. get stencilState(): StencilState;
  36189. /**
  36190. * Clears the list of texture accessible through engine.
  36191. * This can help preventing texture load conflict due to name collision.
  36192. */
  36193. clearInternalTexturesCache(): void;
  36194. /**
  36195. * Force the entire cache to be cleared
  36196. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36197. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36198. */
  36199. wipeCaches(bruteForce?: boolean): void;
  36200. /** @hidden */
  36201. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36202. min: number;
  36203. mag: number;
  36204. };
  36205. /** @hidden */
  36206. _createTexture(): WebGLTexture;
  36207. /**
  36208. * Usually called from Texture.ts.
  36209. * Passed information to create a WebGLTexture
  36210. * @param url defines a value which contains one of the following:
  36211. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36212. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36213. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36214. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36215. * @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)
  36216. * @param scene needed for loading to the correct scene
  36217. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36218. * @param onLoad optional callback to be called upon successful completion
  36219. * @param onError optional callback to be called upon failure
  36220. * @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
  36221. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36222. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36223. * @param forcedExtension defines the extension to use to pick the right loader
  36224. * @param mimeType defines an optional mime type
  36225. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36226. */
  36227. 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;
  36228. /**
  36229. * Loads an image as an HTMLImageElement.
  36230. * @param input url string, ArrayBuffer, or Blob to load
  36231. * @param onLoad callback called when the image successfully loads
  36232. * @param onError callback called when the image fails to load
  36233. * @param offlineProvider offline provider for caching
  36234. * @param mimeType optional mime type
  36235. * @returns the HTMLImageElement of the loaded image
  36236. * @hidden
  36237. */
  36238. 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>;
  36239. /**
  36240. * @hidden
  36241. */
  36242. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36243. private _unpackFlipYCached;
  36244. /**
  36245. * In case you are sharing the context with other applications, it might
  36246. * be interested to not cache the unpack flip y state to ensure a consistent
  36247. * value would be set.
  36248. */
  36249. enableUnpackFlipYCached: boolean;
  36250. /** @hidden */
  36251. _unpackFlipY(value: boolean): void;
  36252. /** @hidden */
  36253. _getUnpackAlignement(): number;
  36254. private _getTextureTarget;
  36255. /**
  36256. * Update the sampling mode of a given texture
  36257. * @param samplingMode defines the required sampling mode
  36258. * @param texture defines the texture to update
  36259. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36260. */
  36261. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36262. /**
  36263. * Update the sampling mode of a given texture
  36264. * @param texture defines the texture to update
  36265. * @param wrapU defines the texture wrap mode of the u coordinates
  36266. * @param wrapV defines the texture wrap mode of the v coordinates
  36267. * @param wrapR defines the texture wrap mode of the r coordinates
  36268. */
  36269. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36270. /** @hidden */
  36271. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36272. width: number;
  36273. height: number;
  36274. layers?: number;
  36275. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36276. /** @hidden */
  36277. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36278. /** @hidden */
  36279. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36280. /**
  36281. * Update a portion of an internal texture
  36282. * @param texture defines the texture to update
  36283. * @param imageData defines the data to store into the texture
  36284. * @param xOffset defines the x coordinates of the update rectangle
  36285. * @param yOffset defines the y coordinates of the update rectangle
  36286. * @param width defines the width of the update rectangle
  36287. * @param height defines the height of the update rectangle
  36288. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36289. * @param lod defines the lod level to update (0 by default)
  36290. */
  36291. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36292. /** @hidden */
  36293. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36294. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36295. private _prepareWebGLTexture;
  36296. /** @hidden */
  36297. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36298. private _getDepthStencilBuffer;
  36299. /** @hidden */
  36300. _releaseFramebufferObjects(texture: InternalTexture): void;
  36301. /** @hidden */
  36302. _releaseTexture(texture: InternalTexture): void;
  36303. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36304. protected _setProgram(program: WebGLProgram): void;
  36305. protected _boundUniforms: {
  36306. [key: number]: WebGLUniformLocation;
  36307. };
  36308. /**
  36309. * Binds an effect to the webGL context
  36310. * @param effect defines the effect to bind
  36311. */
  36312. bindSamplers(effect: Effect): void;
  36313. private _activateCurrentTexture;
  36314. /** @hidden */
  36315. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36316. /** @hidden */
  36317. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36318. /**
  36319. * Unbind all textures from the webGL context
  36320. */
  36321. unbindAllTextures(): void;
  36322. /**
  36323. * Sets a texture to the according uniform.
  36324. * @param channel The texture channel
  36325. * @param uniform The uniform to set
  36326. * @param texture The texture to apply
  36327. */
  36328. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36329. private _bindSamplerUniformToChannel;
  36330. private _getTextureWrapMode;
  36331. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36332. /**
  36333. * Sets an array of texture to the webGL context
  36334. * @param channel defines the channel where the texture array must be set
  36335. * @param uniform defines the associated uniform location
  36336. * @param textures defines the array of textures to bind
  36337. */
  36338. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36339. /** @hidden */
  36340. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36341. private _setTextureParameterFloat;
  36342. private _setTextureParameterInteger;
  36343. /**
  36344. * Unbind all vertex attributes from the webGL context
  36345. */
  36346. unbindAllAttributes(): void;
  36347. /**
  36348. * 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
  36349. */
  36350. releaseEffects(): void;
  36351. /**
  36352. * Dispose and release all associated resources
  36353. */
  36354. dispose(): void;
  36355. /**
  36356. * Attach a new callback raised when context lost event is fired
  36357. * @param callback defines the callback to call
  36358. */
  36359. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36360. /**
  36361. * Attach a new callback raised when context restored event is fired
  36362. * @param callback defines the callback to call
  36363. */
  36364. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36365. /**
  36366. * Get the current error code of the webGL context
  36367. * @returns the error code
  36368. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36369. */
  36370. getError(): number;
  36371. private _canRenderToFloatFramebuffer;
  36372. private _canRenderToHalfFloatFramebuffer;
  36373. private _canRenderToFramebuffer;
  36374. /** @hidden */
  36375. _getWebGLTextureType(type: number): number;
  36376. /** @hidden */
  36377. _getInternalFormat(format: number): number;
  36378. /** @hidden */
  36379. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36380. /** @hidden */
  36381. _getRGBAMultiSampleBufferFormat(type: number): number;
  36382. /** @hidden */
  36383. _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;
  36384. /**
  36385. * Loads a file from a url
  36386. * @param url url to load
  36387. * @param onSuccess callback called when the file successfully loads
  36388. * @param onProgress callback called while file is loading (if the server supports this mode)
  36389. * @param offlineProvider defines the offline provider for caching
  36390. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36391. * @param onError callback called when the file fails to load
  36392. * @returns a file request object
  36393. * @hidden
  36394. */
  36395. 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;
  36396. /**
  36397. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36398. * @param x defines the x coordinate of the rectangle where pixels must be read
  36399. * @param y defines the y coordinate of the rectangle where pixels must be read
  36400. * @param width defines the width of the rectangle where pixels must be read
  36401. * @param height defines the height of the rectangle where pixels must be read
  36402. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36403. * @returns a Uint8Array containing RGBA colors
  36404. */
  36405. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36406. private static _isSupported;
  36407. /**
  36408. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36409. * @returns true if the engine can be created
  36410. * @ignorenaming
  36411. */
  36412. static isSupported(): boolean;
  36413. /**
  36414. * Find the next highest power of two.
  36415. * @param x Number to start search from.
  36416. * @return Next highest power of two.
  36417. */
  36418. static CeilingPOT(x: number): number;
  36419. /**
  36420. * Find the next lowest power of two.
  36421. * @param x Number to start search from.
  36422. * @return Next lowest power of two.
  36423. */
  36424. static FloorPOT(x: number): number;
  36425. /**
  36426. * Find the nearest power of two.
  36427. * @param x Number to start search from.
  36428. * @return Next nearest power of two.
  36429. */
  36430. static NearestPOT(x: number): number;
  36431. /**
  36432. * Get the closest exponent of two
  36433. * @param value defines the value to approximate
  36434. * @param max defines the maximum value to return
  36435. * @param mode defines how to define the closest value
  36436. * @returns closest exponent of two of the given value
  36437. */
  36438. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36439. /**
  36440. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36441. * @param func - the function to be called
  36442. * @param requester - the object that will request the next frame. Falls back to window.
  36443. * @returns frame number
  36444. */
  36445. static QueueNewFrame(func: () => void, requester?: any): number;
  36446. /**
  36447. * Gets host document
  36448. * @returns the host document object
  36449. */
  36450. getHostDocument(): Nullable<Document>;
  36451. }
  36452. }
  36453. declare module "babylonjs/Maths/sphericalPolynomial" {
  36454. import { Vector3 } from "babylonjs/Maths/math.vector";
  36455. import { Color3 } from "babylonjs/Maths/math.color";
  36456. /**
  36457. * Class representing spherical harmonics coefficients to the 3rd degree
  36458. */
  36459. export class SphericalHarmonics {
  36460. /**
  36461. * Defines whether or not the harmonics have been prescaled for rendering.
  36462. */
  36463. preScaled: boolean;
  36464. /**
  36465. * The l0,0 coefficients of the spherical harmonics
  36466. */
  36467. l00: Vector3;
  36468. /**
  36469. * The l1,-1 coefficients of the spherical harmonics
  36470. */
  36471. l1_1: Vector3;
  36472. /**
  36473. * The l1,0 coefficients of the spherical harmonics
  36474. */
  36475. l10: Vector3;
  36476. /**
  36477. * The l1,1 coefficients of the spherical harmonics
  36478. */
  36479. l11: Vector3;
  36480. /**
  36481. * The l2,-2 coefficients of the spherical harmonics
  36482. */
  36483. l2_2: Vector3;
  36484. /**
  36485. * The l2,-1 coefficients of the spherical harmonics
  36486. */
  36487. l2_1: Vector3;
  36488. /**
  36489. * The l2,0 coefficients of the spherical harmonics
  36490. */
  36491. l20: Vector3;
  36492. /**
  36493. * The l2,1 coefficients of the spherical harmonics
  36494. */
  36495. l21: Vector3;
  36496. /**
  36497. * The l2,2 coefficients of the spherical harmonics
  36498. */
  36499. l22: Vector3;
  36500. /**
  36501. * Adds a light to the spherical harmonics
  36502. * @param direction the direction of the light
  36503. * @param color the color of the light
  36504. * @param deltaSolidAngle the delta solid angle of the light
  36505. */
  36506. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36507. /**
  36508. * Scales the spherical harmonics by the given amount
  36509. * @param scale the amount to scale
  36510. */
  36511. scaleInPlace(scale: number): void;
  36512. /**
  36513. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36514. *
  36515. * ```
  36516. * E_lm = A_l * L_lm
  36517. * ```
  36518. *
  36519. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36520. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36521. * the scaling factors are given in equation 9.
  36522. */
  36523. convertIncidentRadianceToIrradiance(): void;
  36524. /**
  36525. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36526. *
  36527. * ```
  36528. * L = (1/pi) * E * rho
  36529. * ```
  36530. *
  36531. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36532. */
  36533. convertIrradianceToLambertianRadiance(): void;
  36534. /**
  36535. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36536. * required operations at run time.
  36537. *
  36538. * This is simply done by scaling back the SH with Ylm constants parameter.
  36539. * The trigonometric part being applied by the shader at run time.
  36540. */
  36541. preScaleForRendering(): void;
  36542. /**
  36543. * Constructs a spherical harmonics from an array.
  36544. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36545. * @returns the spherical harmonics
  36546. */
  36547. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36548. /**
  36549. * Gets the spherical harmonics from polynomial
  36550. * @param polynomial the spherical polynomial
  36551. * @returns the spherical harmonics
  36552. */
  36553. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36554. }
  36555. /**
  36556. * Class representing spherical polynomial coefficients to the 3rd degree
  36557. */
  36558. export class SphericalPolynomial {
  36559. private _harmonics;
  36560. /**
  36561. * The spherical harmonics used to create the polynomials.
  36562. */
  36563. get preScaledHarmonics(): SphericalHarmonics;
  36564. /**
  36565. * The x coefficients of the spherical polynomial
  36566. */
  36567. x: Vector3;
  36568. /**
  36569. * The y coefficients of the spherical polynomial
  36570. */
  36571. y: Vector3;
  36572. /**
  36573. * The z coefficients of the spherical polynomial
  36574. */
  36575. z: Vector3;
  36576. /**
  36577. * The xx coefficients of the spherical polynomial
  36578. */
  36579. xx: Vector3;
  36580. /**
  36581. * The yy coefficients of the spherical polynomial
  36582. */
  36583. yy: Vector3;
  36584. /**
  36585. * The zz coefficients of the spherical polynomial
  36586. */
  36587. zz: Vector3;
  36588. /**
  36589. * The xy coefficients of the spherical polynomial
  36590. */
  36591. xy: Vector3;
  36592. /**
  36593. * The yz coefficients of the spherical polynomial
  36594. */
  36595. yz: Vector3;
  36596. /**
  36597. * The zx coefficients of the spherical polynomial
  36598. */
  36599. zx: Vector3;
  36600. /**
  36601. * Adds an ambient color to the spherical polynomial
  36602. * @param color the color to add
  36603. */
  36604. addAmbient(color: Color3): void;
  36605. /**
  36606. * Scales the spherical polynomial by the given amount
  36607. * @param scale the amount to scale
  36608. */
  36609. scaleInPlace(scale: number): void;
  36610. /**
  36611. * Gets the spherical polynomial from harmonics
  36612. * @param harmonics the spherical harmonics
  36613. * @returns the spherical polynomial
  36614. */
  36615. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36616. /**
  36617. * Constructs a spherical polynomial from an array.
  36618. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36619. * @returns the spherical polynomial
  36620. */
  36621. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36622. }
  36623. }
  36624. declare module "babylonjs/Materials/Textures/internalTexture" {
  36625. import { Observable } from "babylonjs/Misc/observable";
  36626. import { Nullable, int } from "babylonjs/types";
  36627. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36629. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36630. /**
  36631. * Defines the source of the internal texture
  36632. */
  36633. export enum InternalTextureSource {
  36634. /**
  36635. * The source of the texture data is unknown
  36636. */
  36637. Unknown = 0,
  36638. /**
  36639. * Texture data comes from an URL
  36640. */
  36641. Url = 1,
  36642. /**
  36643. * Texture data is only used for temporary storage
  36644. */
  36645. Temp = 2,
  36646. /**
  36647. * Texture data comes from raw data (ArrayBuffer)
  36648. */
  36649. Raw = 3,
  36650. /**
  36651. * Texture content is dynamic (video or dynamic texture)
  36652. */
  36653. Dynamic = 4,
  36654. /**
  36655. * Texture content is generated by rendering to it
  36656. */
  36657. RenderTarget = 5,
  36658. /**
  36659. * Texture content is part of a multi render target process
  36660. */
  36661. MultiRenderTarget = 6,
  36662. /**
  36663. * Texture data comes from a cube data file
  36664. */
  36665. Cube = 7,
  36666. /**
  36667. * Texture data comes from a raw cube data
  36668. */
  36669. CubeRaw = 8,
  36670. /**
  36671. * Texture data come from a prefiltered cube data file
  36672. */
  36673. CubePrefiltered = 9,
  36674. /**
  36675. * Texture content is raw 3D data
  36676. */
  36677. Raw3D = 10,
  36678. /**
  36679. * Texture content is raw 2D array data
  36680. */
  36681. Raw2DArray = 11,
  36682. /**
  36683. * Texture content is a depth texture
  36684. */
  36685. Depth = 12,
  36686. /**
  36687. * Texture data comes from a raw cube data encoded with RGBD
  36688. */
  36689. CubeRawRGBD = 13
  36690. }
  36691. /**
  36692. * Class used to store data associated with WebGL texture data for the engine
  36693. * This class should not be used directly
  36694. */
  36695. export class InternalTexture {
  36696. /** @hidden */
  36697. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36698. /**
  36699. * Defines if the texture is ready
  36700. */
  36701. isReady: boolean;
  36702. /**
  36703. * Defines if the texture is a cube texture
  36704. */
  36705. isCube: boolean;
  36706. /**
  36707. * Defines if the texture contains 3D data
  36708. */
  36709. is3D: boolean;
  36710. /**
  36711. * Defines if the texture contains 2D array data
  36712. */
  36713. is2DArray: boolean;
  36714. /**
  36715. * Defines if the texture contains multiview data
  36716. */
  36717. isMultiview: boolean;
  36718. /**
  36719. * Gets the URL used to load this texture
  36720. */
  36721. url: string;
  36722. /**
  36723. * Gets the sampling mode of the texture
  36724. */
  36725. samplingMode: number;
  36726. /**
  36727. * Gets a boolean indicating if the texture needs mipmaps generation
  36728. */
  36729. generateMipMaps: boolean;
  36730. /**
  36731. * Gets the number of samples used by the texture (WebGL2+ only)
  36732. */
  36733. samples: number;
  36734. /**
  36735. * Gets the type of the texture (int, float...)
  36736. */
  36737. type: number;
  36738. /**
  36739. * Gets the format of the texture (RGB, RGBA...)
  36740. */
  36741. format: number;
  36742. /**
  36743. * Observable called when the texture is loaded
  36744. */
  36745. onLoadedObservable: Observable<InternalTexture>;
  36746. /**
  36747. * Gets the width of the texture
  36748. */
  36749. width: number;
  36750. /**
  36751. * Gets the height of the texture
  36752. */
  36753. height: number;
  36754. /**
  36755. * Gets the depth of the texture
  36756. */
  36757. depth: number;
  36758. /**
  36759. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36760. */
  36761. baseWidth: number;
  36762. /**
  36763. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36764. */
  36765. baseHeight: number;
  36766. /**
  36767. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36768. */
  36769. baseDepth: number;
  36770. /**
  36771. * Gets a boolean indicating if the texture is inverted on Y axis
  36772. */
  36773. invertY: boolean;
  36774. /** @hidden */
  36775. _invertVScale: boolean;
  36776. /** @hidden */
  36777. _associatedChannel: number;
  36778. /** @hidden */
  36779. _source: InternalTextureSource;
  36780. /** @hidden */
  36781. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36782. /** @hidden */
  36783. _bufferView: Nullable<ArrayBufferView>;
  36784. /** @hidden */
  36785. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36786. /** @hidden */
  36787. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36788. /** @hidden */
  36789. _size: number;
  36790. /** @hidden */
  36791. _extension: string;
  36792. /** @hidden */
  36793. _files: Nullable<string[]>;
  36794. /** @hidden */
  36795. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36796. /** @hidden */
  36797. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36798. /** @hidden */
  36799. _framebuffer: Nullable<WebGLFramebuffer>;
  36800. /** @hidden */
  36801. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36802. /** @hidden */
  36803. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36804. /** @hidden */
  36805. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36806. /** @hidden */
  36807. _attachments: Nullable<number[]>;
  36808. /** @hidden */
  36809. _cachedCoordinatesMode: Nullable<number>;
  36810. /** @hidden */
  36811. _cachedWrapU: Nullable<number>;
  36812. /** @hidden */
  36813. _cachedWrapV: Nullable<number>;
  36814. /** @hidden */
  36815. _cachedWrapR: Nullable<number>;
  36816. /** @hidden */
  36817. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36818. /** @hidden */
  36819. _isDisabled: boolean;
  36820. /** @hidden */
  36821. _compression: Nullable<string>;
  36822. /** @hidden */
  36823. _generateStencilBuffer: boolean;
  36824. /** @hidden */
  36825. _generateDepthBuffer: boolean;
  36826. /** @hidden */
  36827. _comparisonFunction: number;
  36828. /** @hidden */
  36829. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36830. /** @hidden */
  36831. _lodGenerationScale: number;
  36832. /** @hidden */
  36833. _lodGenerationOffset: number;
  36834. /** @hidden */
  36835. _depthStencilTexture: Nullable<InternalTexture>;
  36836. /** @hidden */
  36837. _colorTextureArray: Nullable<WebGLTexture>;
  36838. /** @hidden */
  36839. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36840. /** @hidden */
  36841. _lodTextureHigh: Nullable<BaseTexture>;
  36842. /** @hidden */
  36843. _lodTextureMid: Nullable<BaseTexture>;
  36844. /** @hidden */
  36845. _lodTextureLow: Nullable<BaseTexture>;
  36846. /** @hidden */
  36847. _isRGBD: boolean;
  36848. /** @hidden */
  36849. _linearSpecularLOD: boolean;
  36850. /** @hidden */
  36851. _irradianceTexture: Nullable<BaseTexture>;
  36852. /** @hidden */
  36853. _webGLTexture: Nullable<WebGLTexture>;
  36854. /** @hidden */
  36855. _references: number;
  36856. private _engine;
  36857. /**
  36858. * Gets the Engine the texture belongs to.
  36859. * @returns The babylon engine
  36860. */
  36861. getEngine(): ThinEngine;
  36862. /**
  36863. * Gets the data source type of the texture
  36864. */
  36865. get source(): InternalTextureSource;
  36866. /**
  36867. * Creates a new InternalTexture
  36868. * @param engine defines the engine to use
  36869. * @param source defines the type of data that will be used
  36870. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36871. */
  36872. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36873. /**
  36874. * Increments the number of references (ie. the number of Texture that point to it)
  36875. */
  36876. incrementReferences(): void;
  36877. /**
  36878. * Change the size of the texture (not the size of the content)
  36879. * @param width defines the new width
  36880. * @param height defines the new height
  36881. * @param depth defines the new depth (1 by default)
  36882. */
  36883. updateSize(width: int, height: int, depth?: int): void;
  36884. /** @hidden */
  36885. _rebuild(): void;
  36886. /** @hidden */
  36887. _swapAndDie(target: InternalTexture): void;
  36888. /**
  36889. * Dispose the current allocated resources
  36890. */
  36891. dispose(): void;
  36892. }
  36893. }
  36894. declare module "babylonjs/Audio/analyser" {
  36895. import { Scene } from "babylonjs/scene";
  36896. /**
  36897. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36899. */
  36900. export class Analyser {
  36901. /**
  36902. * Gets or sets the smoothing
  36903. * @ignorenaming
  36904. */
  36905. SMOOTHING: number;
  36906. /**
  36907. * Gets or sets the FFT table size
  36908. * @ignorenaming
  36909. */
  36910. FFT_SIZE: number;
  36911. /**
  36912. * Gets or sets the bar graph amplitude
  36913. * @ignorenaming
  36914. */
  36915. BARGRAPHAMPLITUDE: number;
  36916. /**
  36917. * Gets or sets the position of the debug canvas
  36918. * @ignorenaming
  36919. */
  36920. DEBUGCANVASPOS: {
  36921. x: number;
  36922. y: number;
  36923. };
  36924. /**
  36925. * Gets or sets the debug canvas size
  36926. * @ignorenaming
  36927. */
  36928. DEBUGCANVASSIZE: {
  36929. width: number;
  36930. height: number;
  36931. };
  36932. private _byteFreqs;
  36933. private _byteTime;
  36934. private _floatFreqs;
  36935. private _webAudioAnalyser;
  36936. private _debugCanvas;
  36937. private _debugCanvasContext;
  36938. private _scene;
  36939. private _registerFunc;
  36940. private _audioEngine;
  36941. /**
  36942. * Creates a new analyser
  36943. * @param scene defines hosting scene
  36944. */
  36945. constructor(scene: Scene);
  36946. /**
  36947. * Get the number of data values you will have to play with for the visualization
  36948. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36949. * @returns a number
  36950. */
  36951. getFrequencyBinCount(): number;
  36952. /**
  36953. * Gets the current frequency data as a byte array
  36954. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36955. * @returns a Uint8Array
  36956. */
  36957. getByteFrequencyData(): Uint8Array;
  36958. /**
  36959. * Gets the current waveform as a byte array
  36960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36961. * @returns a Uint8Array
  36962. */
  36963. getByteTimeDomainData(): Uint8Array;
  36964. /**
  36965. * Gets the current frequency data as a float array
  36966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36967. * @returns a Float32Array
  36968. */
  36969. getFloatFrequencyData(): Float32Array;
  36970. /**
  36971. * Renders the debug canvas
  36972. */
  36973. drawDebugCanvas(): void;
  36974. /**
  36975. * Stops rendering the debug canvas and removes it
  36976. */
  36977. stopDebugCanvas(): void;
  36978. /**
  36979. * Connects two audio nodes
  36980. * @param inputAudioNode defines first node to connect
  36981. * @param outputAudioNode defines second node to connect
  36982. */
  36983. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36984. /**
  36985. * Releases all associated resources
  36986. */
  36987. dispose(): void;
  36988. }
  36989. }
  36990. declare module "babylonjs/Audio/audioEngine" {
  36991. import { IDisposable } from "babylonjs/scene";
  36992. import { Analyser } from "babylonjs/Audio/analyser";
  36993. import { Nullable } from "babylonjs/types";
  36994. import { Observable } from "babylonjs/Misc/observable";
  36995. /**
  36996. * This represents an audio engine and it is responsible
  36997. * to play, synchronize and analyse sounds throughout the application.
  36998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36999. */
  37000. export interface IAudioEngine extends IDisposable {
  37001. /**
  37002. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37003. */
  37004. readonly canUseWebAudio: boolean;
  37005. /**
  37006. * Gets the current AudioContext if available.
  37007. */
  37008. readonly audioContext: Nullable<AudioContext>;
  37009. /**
  37010. * The master gain node defines the global audio volume of your audio engine.
  37011. */
  37012. readonly masterGain: GainNode;
  37013. /**
  37014. * Gets whether or not mp3 are supported by your browser.
  37015. */
  37016. readonly isMP3supported: boolean;
  37017. /**
  37018. * Gets whether or not ogg are supported by your browser.
  37019. */
  37020. readonly isOGGsupported: boolean;
  37021. /**
  37022. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37023. * @ignoreNaming
  37024. */
  37025. WarnedWebAudioUnsupported: boolean;
  37026. /**
  37027. * Defines if the audio engine relies on a custom unlocked button.
  37028. * In this case, the embedded button will not be displayed.
  37029. */
  37030. useCustomUnlockedButton: boolean;
  37031. /**
  37032. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37033. */
  37034. readonly unlocked: boolean;
  37035. /**
  37036. * Event raised when audio has been unlocked on the browser.
  37037. */
  37038. onAudioUnlockedObservable: Observable<AudioEngine>;
  37039. /**
  37040. * Event raised when audio has been locked on the browser.
  37041. */
  37042. onAudioLockedObservable: Observable<AudioEngine>;
  37043. /**
  37044. * Flags the audio engine in Locked state.
  37045. * This happens due to new browser policies preventing audio to autoplay.
  37046. */
  37047. lock(): void;
  37048. /**
  37049. * Unlocks the audio engine once a user action has been done on the dom.
  37050. * This is helpful to resume play once browser policies have been satisfied.
  37051. */
  37052. unlock(): void;
  37053. /**
  37054. * Gets the global volume sets on the master gain.
  37055. * @returns the global volume if set or -1 otherwise
  37056. */
  37057. getGlobalVolume(): number;
  37058. /**
  37059. * Sets the global volume of your experience (sets on the master gain).
  37060. * @param newVolume Defines the new global volume of the application
  37061. */
  37062. setGlobalVolume(newVolume: number): void;
  37063. /**
  37064. * Connect the audio engine to an audio analyser allowing some amazing
  37065. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37067. * @param analyser The analyser to connect to the engine
  37068. */
  37069. connectToAnalyser(analyser: Analyser): void;
  37070. }
  37071. /**
  37072. * This represents the default audio engine used in babylon.
  37073. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37075. */
  37076. export class AudioEngine implements IAudioEngine {
  37077. private _audioContext;
  37078. private _audioContextInitialized;
  37079. private _muteButton;
  37080. private _hostElement;
  37081. /**
  37082. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37083. */
  37084. canUseWebAudio: boolean;
  37085. /**
  37086. * The master gain node defines the global audio volume of your audio engine.
  37087. */
  37088. masterGain: GainNode;
  37089. /**
  37090. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37091. * @ignoreNaming
  37092. */
  37093. WarnedWebAudioUnsupported: boolean;
  37094. /**
  37095. * Gets whether or not mp3 are supported by your browser.
  37096. */
  37097. isMP3supported: boolean;
  37098. /**
  37099. * Gets whether or not ogg are supported by your browser.
  37100. */
  37101. isOGGsupported: boolean;
  37102. /**
  37103. * Gets whether audio has been unlocked on the device.
  37104. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37105. * a user interaction has happened.
  37106. */
  37107. unlocked: boolean;
  37108. /**
  37109. * Defines if the audio engine relies on a custom unlocked button.
  37110. * In this case, the embedded button will not be displayed.
  37111. */
  37112. useCustomUnlockedButton: boolean;
  37113. /**
  37114. * Event raised when audio has been unlocked on the browser.
  37115. */
  37116. onAudioUnlockedObservable: Observable<AudioEngine>;
  37117. /**
  37118. * Event raised when audio has been locked on the browser.
  37119. */
  37120. onAudioLockedObservable: Observable<AudioEngine>;
  37121. /**
  37122. * Gets the current AudioContext if available.
  37123. */
  37124. get audioContext(): Nullable<AudioContext>;
  37125. private _connectedAnalyser;
  37126. /**
  37127. * Instantiates a new audio engine.
  37128. *
  37129. * There should be only one per page as some browsers restrict the number
  37130. * of audio contexts you can create.
  37131. * @param hostElement defines the host element where to display the mute icon if necessary
  37132. */
  37133. constructor(hostElement?: Nullable<HTMLElement>);
  37134. /**
  37135. * Flags the audio engine in Locked state.
  37136. * This happens due to new browser policies preventing audio to autoplay.
  37137. */
  37138. lock(): void;
  37139. /**
  37140. * Unlocks the audio engine once a user action has been done on the dom.
  37141. * This is helpful to resume play once browser policies have been satisfied.
  37142. */
  37143. unlock(): void;
  37144. private _resumeAudioContext;
  37145. private _initializeAudioContext;
  37146. private _tryToRun;
  37147. private _triggerRunningState;
  37148. private _triggerSuspendedState;
  37149. private _displayMuteButton;
  37150. private _moveButtonToTopLeft;
  37151. private _onResize;
  37152. private _hideMuteButton;
  37153. /**
  37154. * Destroy and release the resources associated with the audio ccontext.
  37155. */
  37156. dispose(): void;
  37157. /**
  37158. * Gets the global volume sets on the master gain.
  37159. * @returns the global volume if set or -1 otherwise
  37160. */
  37161. getGlobalVolume(): number;
  37162. /**
  37163. * Sets the global volume of your experience (sets on the master gain).
  37164. * @param newVolume Defines the new global volume of the application
  37165. */
  37166. setGlobalVolume(newVolume: number): void;
  37167. /**
  37168. * Connect the audio engine to an audio analyser allowing some amazing
  37169. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37171. * @param analyser The analyser to connect to the engine
  37172. */
  37173. connectToAnalyser(analyser: Analyser): void;
  37174. }
  37175. }
  37176. declare module "babylonjs/Loading/loadingScreen" {
  37177. /**
  37178. * Interface used to present a loading screen while loading a scene
  37179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37180. */
  37181. export interface ILoadingScreen {
  37182. /**
  37183. * Function called to display the loading screen
  37184. */
  37185. displayLoadingUI: () => void;
  37186. /**
  37187. * Function called to hide the loading screen
  37188. */
  37189. hideLoadingUI: () => void;
  37190. /**
  37191. * Gets or sets the color to use for the background
  37192. */
  37193. loadingUIBackgroundColor: string;
  37194. /**
  37195. * Gets or sets the text to display while loading
  37196. */
  37197. loadingUIText: string;
  37198. }
  37199. /**
  37200. * Class used for the default loading screen
  37201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37202. */
  37203. export class DefaultLoadingScreen implements ILoadingScreen {
  37204. private _renderingCanvas;
  37205. private _loadingText;
  37206. private _loadingDivBackgroundColor;
  37207. private _loadingDiv;
  37208. private _loadingTextDiv;
  37209. /** Gets or sets the logo url to use for the default loading screen */
  37210. static DefaultLogoUrl: string;
  37211. /** Gets or sets the spinner url to use for the default loading screen */
  37212. static DefaultSpinnerUrl: string;
  37213. /**
  37214. * Creates a new default loading screen
  37215. * @param _renderingCanvas defines the canvas used to render the scene
  37216. * @param _loadingText defines the default text to display
  37217. * @param _loadingDivBackgroundColor defines the default background color
  37218. */
  37219. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37220. /**
  37221. * Function called to display the loading screen
  37222. */
  37223. displayLoadingUI(): void;
  37224. /**
  37225. * Function called to hide the loading screen
  37226. */
  37227. hideLoadingUI(): void;
  37228. /**
  37229. * Gets or sets the text to display while loading
  37230. */
  37231. set loadingUIText(text: string);
  37232. get loadingUIText(): string;
  37233. /**
  37234. * Gets or sets the color to use for the background
  37235. */
  37236. get loadingUIBackgroundColor(): string;
  37237. set loadingUIBackgroundColor(color: string);
  37238. private _resizeLoadingUI;
  37239. }
  37240. }
  37241. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37242. /**
  37243. * Interface for any object that can request an animation frame
  37244. */
  37245. export interface ICustomAnimationFrameRequester {
  37246. /**
  37247. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37248. */
  37249. renderFunction?: Function;
  37250. /**
  37251. * Called to request the next frame to render to
  37252. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37253. */
  37254. requestAnimationFrame: Function;
  37255. /**
  37256. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37257. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37258. */
  37259. requestID?: number;
  37260. }
  37261. }
  37262. declare module "babylonjs/Misc/performanceMonitor" {
  37263. /**
  37264. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37265. */
  37266. export class PerformanceMonitor {
  37267. private _enabled;
  37268. private _rollingFrameTime;
  37269. private _lastFrameTimeMs;
  37270. /**
  37271. * constructor
  37272. * @param frameSampleSize The number of samples required to saturate the sliding window
  37273. */
  37274. constructor(frameSampleSize?: number);
  37275. /**
  37276. * Samples current frame
  37277. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37278. */
  37279. sampleFrame(timeMs?: number): void;
  37280. /**
  37281. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37282. */
  37283. get averageFrameTime(): number;
  37284. /**
  37285. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37286. */
  37287. get averageFrameTimeVariance(): number;
  37288. /**
  37289. * Returns the frame time of the most recent frame
  37290. */
  37291. get instantaneousFrameTime(): number;
  37292. /**
  37293. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37294. */
  37295. get averageFPS(): number;
  37296. /**
  37297. * Returns the average framerate in frames per second using the most recent frame time
  37298. */
  37299. get instantaneousFPS(): number;
  37300. /**
  37301. * Returns true if enough samples have been taken to completely fill the sliding window
  37302. */
  37303. get isSaturated(): boolean;
  37304. /**
  37305. * Enables contributions to the sliding window sample set
  37306. */
  37307. enable(): void;
  37308. /**
  37309. * Disables contributions to the sliding window sample set
  37310. * Samples will not be interpolated over the disabled period
  37311. */
  37312. disable(): void;
  37313. /**
  37314. * Returns true if sampling is enabled
  37315. */
  37316. get isEnabled(): boolean;
  37317. /**
  37318. * Resets performance monitor
  37319. */
  37320. reset(): void;
  37321. }
  37322. /**
  37323. * RollingAverage
  37324. *
  37325. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37326. */
  37327. export class RollingAverage {
  37328. /**
  37329. * Current average
  37330. */
  37331. average: number;
  37332. /**
  37333. * Current variance
  37334. */
  37335. variance: number;
  37336. protected _samples: Array<number>;
  37337. protected _sampleCount: number;
  37338. protected _pos: number;
  37339. protected _m2: number;
  37340. /**
  37341. * constructor
  37342. * @param length The number of samples required to saturate the sliding window
  37343. */
  37344. constructor(length: number);
  37345. /**
  37346. * Adds a sample to the sample set
  37347. * @param v The sample value
  37348. */
  37349. add(v: number): void;
  37350. /**
  37351. * Returns previously added values or null if outside of history or outside the sliding window domain
  37352. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37353. * @return Value previously recorded with add() or null if outside of range
  37354. */
  37355. history(i: number): number;
  37356. /**
  37357. * Returns true if enough samples have been taken to completely fill the sliding window
  37358. * @return true if sample-set saturated
  37359. */
  37360. isSaturated(): boolean;
  37361. /**
  37362. * Resets the rolling average (equivalent to 0 samples taken so far)
  37363. */
  37364. reset(): void;
  37365. /**
  37366. * Wraps a value around the sample range boundaries
  37367. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37368. * @return Wrapped position in sample range
  37369. */
  37370. protected _wrapPosition(i: number): number;
  37371. }
  37372. }
  37373. declare module "babylonjs/Misc/perfCounter" {
  37374. /**
  37375. * This class is used to track a performance counter which is number based.
  37376. * The user has access to many properties which give statistics of different nature.
  37377. *
  37378. * The implementer can track two kinds of Performance Counter: time and count.
  37379. * 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.
  37380. * 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.
  37381. */
  37382. export class PerfCounter {
  37383. /**
  37384. * Gets or sets a global boolean to turn on and off all the counters
  37385. */
  37386. static Enabled: boolean;
  37387. /**
  37388. * Returns the smallest value ever
  37389. */
  37390. get min(): number;
  37391. /**
  37392. * Returns the biggest value ever
  37393. */
  37394. get max(): number;
  37395. /**
  37396. * Returns the average value since the performance counter is running
  37397. */
  37398. get average(): number;
  37399. /**
  37400. * Returns the average value of the last second the counter was monitored
  37401. */
  37402. get lastSecAverage(): number;
  37403. /**
  37404. * Returns the current value
  37405. */
  37406. get current(): number;
  37407. /**
  37408. * Gets the accumulated total
  37409. */
  37410. get total(): number;
  37411. /**
  37412. * Gets the total value count
  37413. */
  37414. get count(): number;
  37415. /**
  37416. * Creates a new counter
  37417. */
  37418. constructor();
  37419. /**
  37420. * Call this method to start monitoring a new frame.
  37421. * 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.
  37422. */
  37423. fetchNewFrame(): void;
  37424. /**
  37425. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37426. * @param newCount the count value to add to the monitored count
  37427. * @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.
  37428. */
  37429. addCount(newCount: number, fetchResult: boolean): void;
  37430. /**
  37431. * Start monitoring this performance counter
  37432. */
  37433. beginMonitoring(): void;
  37434. /**
  37435. * Compute the time lapsed since the previous beginMonitoring() call.
  37436. * @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
  37437. */
  37438. endMonitoring(newFrame?: boolean): void;
  37439. private _fetchResult;
  37440. private _startMonitoringTime;
  37441. private _min;
  37442. private _max;
  37443. private _average;
  37444. private _current;
  37445. private _totalValueCount;
  37446. private _totalAccumulated;
  37447. private _lastSecAverage;
  37448. private _lastSecAccumulated;
  37449. private _lastSecTime;
  37450. private _lastSecValueCount;
  37451. }
  37452. }
  37453. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37454. module "babylonjs/Engines/thinEngine" {
  37455. interface ThinEngine {
  37456. /**
  37457. * Sets alpha constants used by some alpha blending modes
  37458. * @param r defines the red component
  37459. * @param g defines the green component
  37460. * @param b defines the blue component
  37461. * @param a defines the alpha component
  37462. */
  37463. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37464. /**
  37465. * Sets the current alpha mode
  37466. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37467. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37469. */
  37470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37471. /**
  37472. * Gets the current alpha mode
  37473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37474. * @returns the current alpha mode
  37475. */
  37476. getAlphaMode(): number;
  37477. /**
  37478. * Sets the current alpha equation
  37479. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37480. */
  37481. setAlphaEquation(equation: number): void;
  37482. /**
  37483. * Gets the current alpha equation.
  37484. * @returns the current alpha equation
  37485. */
  37486. getAlphaEquation(): number;
  37487. }
  37488. }
  37489. }
  37490. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37492. import { Nullable } from "babylonjs/types";
  37493. module "babylonjs/Engines/thinEngine" {
  37494. interface ThinEngine {
  37495. /** @hidden */
  37496. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37497. }
  37498. }
  37499. }
  37500. declare module "babylonjs/Engines/engine" {
  37501. import { Observable } from "babylonjs/Misc/observable";
  37502. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37503. import { Scene } from "babylonjs/scene";
  37504. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37505. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37506. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37507. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37508. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37509. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37510. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37511. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37512. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37514. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37515. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37516. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37517. import "babylonjs/Engines/Extensions/engine.alpha";
  37518. import "babylonjs/Engines/Extensions/engine.readTexture";
  37519. import { Material } from "babylonjs/Materials/material";
  37520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37521. /**
  37522. * Defines the interface used by display changed events
  37523. */
  37524. export interface IDisplayChangedEventArgs {
  37525. /** Gets the vrDisplay object (if any) */
  37526. vrDisplay: Nullable<any>;
  37527. /** Gets a boolean indicating if webVR is supported */
  37528. vrSupported: boolean;
  37529. }
  37530. /**
  37531. * Defines the interface used by objects containing a viewport (like a camera)
  37532. */
  37533. interface IViewportOwnerLike {
  37534. /**
  37535. * Gets or sets the viewport
  37536. */
  37537. viewport: IViewportLike;
  37538. }
  37539. /**
  37540. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37541. */
  37542. export class Engine extends ThinEngine {
  37543. /** Defines that alpha blending is disabled */
  37544. static readonly ALPHA_DISABLE: number;
  37545. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37546. static readonly ALPHA_ADD: number;
  37547. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37548. static readonly ALPHA_COMBINE: number;
  37549. /** Defines that alpha blending to DEST - SRC * DEST */
  37550. static readonly ALPHA_SUBTRACT: number;
  37551. /** Defines that alpha blending to SRC * DEST */
  37552. static readonly ALPHA_MULTIPLY: number;
  37553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37554. static readonly ALPHA_MAXIMIZED: number;
  37555. /** Defines that alpha blending to SRC + DEST */
  37556. static readonly ALPHA_ONEONE: number;
  37557. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37558. static readonly ALPHA_PREMULTIPLIED: number;
  37559. /**
  37560. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37561. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37562. */
  37563. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37564. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37565. static readonly ALPHA_INTERPOLATE: number;
  37566. /**
  37567. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37568. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37569. */
  37570. static readonly ALPHA_SCREENMODE: number;
  37571. /** Defines that the ressource is not delayed*/
  37572. static readonly DELAYLOADSTATE_NONE: number;
  37573. /** Defines that the ressource was successfully delay loaded */
  37574. static readonly DELAYLOADSTATE_LOADED: number;
  37575. /** Defines that the ressource is currently delay loading */
  37576. static readonly DELAYLOADSTATE_LOADING: number;
  37577. /** Defines that the ressource is delayed and has not started loading */
  37578. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37579. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37580. static readonly NEVER: number;
  37581. /** 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 */
  37582. static readonly ALWAYS: number;
  37583. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37584. static readonly LESS: number;
  37585. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37586. static readonly EQUAL: number;
  37587. /** 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 */
  37588. static readonly LEQUAL: number;
  37589. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37590. static readonly GREATER: number;
  37591. /** 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 */
  37592. static readonly GEQUAL: number;
  37593. /** 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 */
  37594. static readonly NOTEQUAL: number;
  37595. /** Passed to stencilOperation to specify that stencil value must be kept */
  37596. static readonly KEEP: number;
  37597. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37598. static readonly REPLACE: number;
  37599. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37600. static readonly INCR: number;
  37601. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37602. static readonly DECR: number;
  37603. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37604. static readonly INVERT: number;
  37605. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37606. static readonly INCR_WRAP: number;
  37607. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37608. static readonly DECR_WRAP: number;
  37609. /** Texture is not repeating outside of 0..1 UVs */
  37610. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37611. /** Texture is repeating outside of 0..1 UVs */
  37612. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37613. /** Texture is repeating and mirrored */
  37614. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37615. /** ALPHA */
  37616. static readonly TEXTUREFORMAT_ALPHA: number;
  37617. /** LUMINANCE */
  37618. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37619. /** LUMINANCE_ALPHA */
  37620. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37621. /** RGB */
  37622. static readonly TEXTUREFORMAT_RGB: number;
  37623. /** RGBA */
  37624. static readonly TEXTUREFORMAT_RGBA: number;
  37625. /** RED */
  37626. static readonly TEXTUREFORMAT_RED: number;
  37627. /** RED (2nd reference) */
  37628. static readonly TEXTUREFORMAT_R: number;
  37629. /** RG */
  37630. static readonly TEXTUREFORMAT_RG: number;
  37631. /** RED_INTEGER */
  37632. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37633. /** RED_INTEGER (2nd reference) */
  37634. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37635. /** RG_INTEGER */
  37636. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37637. /** RGB_INTEGER */
  37638. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37639. /** RGBA_INTEGER */
  37640. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37641. /** UNSIGNED_BYTE */
  37642. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37643. /** UNSIGNED_BYTE (2nd reference) */
  37644. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37645. /** FLOAT */
  37646. static readonly TEXTURETYPE_FLOAT: number;
  37647. /** HALF_FLOAT */
  37648. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37649. /** BYTE */
  37650. static readonly TEXTURETYPE_BYTE: number;
  37651. /** SHORT */
  37652. static readonly TEXTURETYPE_SHORT: number;
  37653. /** UNSIGNED_SHORT */
  37654. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37655. /** INT */
  37656. static readonly TEXTURETYPE_INT: number;
  37657. /** UNSIGNED_INT */
  37658. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37659. /** UNSIGNED_SHORT_4_4_4_4 */
  37660. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37661. /** UNSIGNED_SHORT_5_5_5_1 */
  37662. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37663. /** UNSIGNED_SHORT_5_6_5 */
  37664. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37665. /** UNSIGNED_INT_2_10_10_10_REV */
  37666. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37667. /** UNSIGNED_INT_24_8 */
  37668. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37669. /** UNSIGNED_INT_10F_11F_11F_REV */
  37670. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37671. /** UNSIGNED_INT_5_9_9_9_REV */
  37672. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37673. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37674. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37675. /** nearest is mag = nearest and min = nearest and mip = linear */
  37676. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37678. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37679. /** Trilinear is mag = linear and min = linear and mip = linear */
  37680. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37681. /** nearest is mag = nearest and min = nearest and mip = linear */
  37682. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37683. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37684. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37685. /** Trilinear is mag = linear and min = linear and mip = linear */
  37686. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37687. /** mag = nearest and min = nearest and mip = nearest */
  37688. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37689. /** mag = nearest and min = linear and mip = nearest */
  37690. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37691. /** mag = nearest and min = linear and mip = linear */
  37692. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37693. /** mag = nearest and min = linear and mip = none */
  37694. static readonly TEXTURE_NEAREST_LINEAR: number;
  37695. /** mag = nearest and min = nearest and mip = none */
  37696. static readonly TEXTURE_NEAREST_NEAREST: number;
  37697. /** mag = linear and min = nearest and mip = nearest */
  37698. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37699. /** mag = linear and min = nearest and mip = linear */
  37700. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37701. /** mag = linear and min = linear and mip = none */
  37702. static readonly TEXTURE_LINEAR_LINEAR: number;
  37703. /** mag = linear and min = nearest and mip = none */
  37704. static readonly TEXTURE_LINEAR_NEAREST: number;
  37705. /** Explicit coordinates mode */
  37706. static readonly TEXTURE_EXPLICIT_MODE: number;
  37707. /** Spherical coordinates mode */
  37708. static readonly TEXTURE_SPHERICAL_MODE: number;
  37709. /** Planar coordinates mode */
  37710. static readonly TEXTURE_PLANAR_MODE: number;
  37711. /** Cubic coordinates mode */
  37712. static readonly TEXTURE_CUBIC_MODE: number;
  37713. /** Projection coordinates mode */
  37714. static readonly TEXTURE_PROJECTION_MODE: number;
  37715. /** Skybox coordinates mode */
  37716. static readonly TEXTURE_SKYBOX_MODE: number;
  37717. /** Inverse Cubic coordinates mode */
  37718. static readonly TEXTURE_INVCUBIC_MODE: number;
  37719. /** Equirectangular coordinates mode */
  37720. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37721. /** Equirectangular Fixed coordinates mode */
  37722. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37723. /** Equirectangular Fixed Mirrored coordinates mode */
  37724. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37725. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37726. static readonly SCALEMODE_FLOOR: number;
  37727. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37728. static readonly SCALEMODE_NEAREST: number;
  37729. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37730. static readonly SCALEMODE_CEILING: number;
  37731. /**
  37732. * Returns the current npm package of the sdk
  37733. */
  37734. static get NpmPackage(): string;
  37735. /**
  37736. * Returns the current version of the framework
  37737. */
  37738. static get Version(): string;
  37739. /** Gets the list of created engines */
  37740. static get Instances(): Engine[];
  37741. /**
  37742. * Gets the latest created engine
  37743. */
  37744. static get LastCreatedEngine(): Nullable<Engine>;
  37745. /**
  37746. * Gets the latest created scene
  37747. */
  37748. static get LastCreatedScene(): Nullable<Scene>;
  37749. /**
  37750. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37751. * @param flag defines which part of the materials must be marked as dirty
  37752. * @param predicate defines a predicate used to filter which materials should be affected
  37753. */
  37754. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37755. /**
  37756. * Method called to create the default loading screen.
  37757. * This can be overriden in your own app.
  37758. * @param canvas The rendering canvas element
  37759. * @returns The loading screen
  37760. */
  37761. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37762. /**
  37763. * Method called to create the default rescale post process on each engine.
  37764. */
  37765. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37766. /**
  37767. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37768. **/
  37769. enableOfflineSupport: boolean;
  37770. /**
  37771. * 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)
  37772. **/
  37773. disableManifestCheck: boolean;
  37774. /**
  37775. * Gets the list of created scenes
  37776. */
  37777. scenes: Scene[];
  37778. /**
  37779. * Event raised when a new scene is created
  37780. */
  37781. onNewSceneAddedObservable: Observable<Scene>;
  37782. /**
  37783. * Gets the list of created postprocesses
  37784. */
  37785. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37786. /**
  37787. * Gets a boolean indicating if the pointer is currently locked
  37788. */
  37789. isPointerLock: boolean;
  37790. /**
  37791. * Observable event triggered each time the rendering canvas is resized
  37792. */
  37793. onResizeObservable: Observable<Engine>;
  37794. /**
  37795. * Observable event triggered each time the canvas loses focus
  37796. */
  37797. onCanvasBlurObservable: Observable<Engine>;
  37798. /**
  37799. * Observable event triggered each time the canvas gains focus
  37800. */
  37801. onCanvasFocusObservable: Observable<Engine>;
  37802. /**
  37803. * Observable event triggered each time the canvas receives pointerout event
  37804. */
  37805. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37806. /**
  37807. * Observable raised when the engine begins a new frame
  37808. */
  37809. onBeginFrameObservable: Observable<Engine>;
  37810. /**
  37811. * If set, will be used to request the next animation frame for the render loop
  37812. */
  37813. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37814. /**
  37815. * Observable raised when the engine ends the current frame
  37816. */
  37817. onEndFrameObservable: Observable<Engine>;
  37818. /**
  37819. * Observable raised when the engine is about to compile a shader
  37820. */
  37821. onBeforeShaderCompilationObservable: Observable<Engine>;
  37822. /**
  37823. * Observable raised when the engine has jsut compiled a shader
  37824. */
  37825. onAfterShaderCompilationObservable: Observable<Engine>;
  37826. /**
  37827. * Gets the audio engine
  37828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37829. * @ignorenaming
  37830. */
  37831. static audioEngine: IAudioEngine;
  37832. /**
  37833. * Default AudioEngine factory responsible of creating the Audio Engine.
  37834. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37835. */
  37836. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37837. /**
  37838. * Default offline support factory responsible of creating a tool used to store data locally.
  37839. * By default, this will create a Database object if the workload has been embedded.
  37840. */
  37841. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37842. private _loadingScreen;
  37843. private _pointerLockRequested;
  37844. private _rescalePostProcess;
  37845. private _deterministicLockstep;
  37846. private _lockstepMaxSteps;
  37847. private _timeStep;
  37848. protected get _supportsHardwareTextureRescaling(): boolean;
  37849. private _fps;
  37850. private _deltaTime;
  37851. /** @hidden */
  37852. _drawCalls: PerfCounter;
  37853. /** 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 */
  37854. canvasTabIndex: number;
  37855. /**
  37856. * Turn this value on if you want to pause FPS computation when in background
  37857. */
  37858. disablePerformanceMonitorInBackground: boolean;
  37859. private _performanceMonitor;
  37860. /**
  37861. * Gets the performance monitor attached to this engine
  37862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37863. */
  37864. get performanceMonitor(): PerformanceMonitor;
  37865. private _onFocus;
  37866. private _onBlur;
  37867. private _onCanvasPointerOut;
  37868. private _onCanvasBlur;
  37869. private _onCanvasFocus;
  37870. private _onFullscreenChange;
  37871. private _onPointerLockChange;
  37872. /**
  37873. * Gets the HTML element used to attach event listeners
  37874. * @returns a HTML element
  37875. */
  37876. getInputElement(): Nullable<HTMLElement>;
  37877. /**
  37878. * Creates a new engine
  37879. * @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
  37880. * @param antialias defines enable antialiasing (default: false)
  37881. * @param options defines further options to be sent to the getContext() function
  37882. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37883. */
  37884. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37885. /**
  37886. * Gets current aspect ratio
  37887. * @param viewportOwner defines the camera to use to get the aspect ratio
  37888. * @param useScreen defines if screen size must be used (or the current render target if any)
  37889. * @returns a number defining the aspect ratio
  37890. */
  37891. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37892. /**
  37893. * Gets current screen aspect ratio
  37894. * @returns a number defining the aspect ratio
  37895. */
  37896. getScreenAspectRatio(): number;
  37897. /**
  37898. * Gets the client rect of the HTML canvas attached with the current webGL context
  37899. * @returns a client rectanglee
  37900. */
  37901. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37902. /**
  37903. * Gets the client rect of the HTML element used for events
  37904. * @returns a client rectanglee
  37905. */
  37906. getInputElementClientRect(): Nullable<ClientRect>;
  37907. /**
  37908. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37909. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37910. * @returns true if engine is in deterministic lock step mode
  37911. */
  37912. isDeterministicLockStep(): boolean;
  37913. /**
  37914. * Gets the max steps when engine is running in deterministic lock step
  37915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37916. * @returns the max steps
  37917. */
  37918. getLockstepMaxSteps(): number;
  37919. /**
  37920. * Returns the time in ms between steps when using deterministic lock step.
  37921. * @returns time step in (ms)
  37922. */
  37923. getTimeStep(): number;
  37924. /**
  37925. * Force the mipmap generation for the given render target texture
  37926. * @param texture defines the render target texture to use
  37927. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37928. */
  37929. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37930. /** States */
  37931. /**
  37932. * Set various states to the webGL context
  37933. * @param culling defines backface culling state
  37934. * @param zOffset defines the value to apply to zOffset (0 by default)
  37935. * @param force defines if states must be applied even if cache is up to date
  37936. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37937. */
  37938. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37939. /**
  37940. * Set the z offset to apply to current rendering
  37941. * @param value defines the offset to apply
  37942. */
  37943. setZOffset(value: number): void;
  37944. /**
  37945. * Gets the current value of the zOffset
  37946. * @returns the current zOffset state
  37947. */
  37948. getZOffset(): number;
  37949. /**
  37950. * Enable or disable depth buffering
  37951. * @param enable defines the state to set
  37952. */
  37953. setDepthBuffer(enable: boolean): void;
  37954. /**
  37955. * Gets a boolean indicating if depth writing is enabled
  37956. * @returns the current depth writing state
  37957. */
  37958. getDepthWrite(): boolean;
  37959. /**
  37960. * Enable or disable depth writing
  37961. * @param enable defines the state to set
  37962. */
  37963. setDepthWrite(enable: boolean): void;
  37964. /**
  37965. * Gets a boolean indicating if stencil buffer is enabled
  37966. * @returns the current stencil buffer state
  37967. */
  37968. getStencilBuffer(): boolean;
  37969. /**
  37970. * Enable or disable the stencil buffer
  37971. * @param enable defines if the stencil buffer must be enabled or disabled
  37972. */
  37973. setStencilBuffer(enable: boolean): void;
  37974. /**
  37975. * Gets the current stencil mask
  37976. * @returns a number defining the new stencil mask to use
  37977. */
  37978. getStencilMask(): number;
  37979. /**
  37980. * Sets the current stencil mask
  37981. * @param mask defines the new stencil mask to use
  37982. */
  37983. setStencilMask(mask: number): void;
  37984. /**
  37985. * Gets the current stencil function
  37986. * @returns a number defining the stencil function to use
  37987. */
  37988. getStencilFunction(): number;
  37989. /**
  37990. * Gets the current stencil reference value
  37991. * @returns a number defining the stencil reference value to use
  37992. */
  37993. getStencilFunctionReference(): number;
  37994. /**
  37995. * Gets the current stencil mask
  37996. * @returns a number defining the stencil mask to use
  37997. */
  37998. getStencilFunctionMask(): number;
  37999. /**
  38000. * Sets the current stencil function
  38001. * @param stencilFunc defines the new stencil function to use
  38002. */
  38003. setStencilFunction(stencilFunc: number): void;
  38004. /**
  38005. * Sets the current stencil reference
  38006. * @param reference defines the new stencil reference to use
  38007. */
  38008. setStencilFunctionReference(reference: number): void;
  38009. /**
  38010. * Sets the current stencil mask
  38011. * @param mask defines the new stencil mask to use
  38012. */
  38013. setStencilFunctionMask(mask: number): void;
  38014. /**
  38015. * Gets the current stencil operation when stencil fails
  38016. * @returns a number defining stencil operation to use when stencil fails
  38017. */
  38018. getStencilOperationFail(): number;
  38019. /**
  38020. * Gets the current stencil operation when depth fails
  38021. * @returns a number defining stencil operation to use when depth fails
  38022. */
  38023. getStencilOperationDepthFail(): number;
  38024. /**
  38025. * Gets the current stencil operation when stencil passes
  38026. * @returns a number defining stencil operation to use when stencil passes
  38027. */
  38028. getStencilOperationPass(): number;
  38029. /**
  38030. * Sets the stencil operation to use when stencil fails
  38031. * @param operation defines the stencil operation to use when stencil fails
  38032. */
  38033. setStencilOperationFail(operation: number): void;
  38034. /**
  38035. * Sets the stencil operation to use when depth fails
  38036. * @param operation defines the stencil operation to use when depth fails
  38037. */
  38038. setStencilOperationDepthFail(operation: number): void;
  38039. /**
  38040. * Sets the stencil operation to use when stencil passes
  38041. * @param operation defines the stencil operation to use when stencil passes
  38042. */
  38043. setStencilOperationPass(operation: number): void;
  38044. /**
  38045. * Sets a boolean indicating if the dithering state is enabled or disabled
  38046. * @param value defines the dithering state
  38047. */
  38048. setDitheringState(value: boolean): void;
  38049. /**
  38050. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38051. * @param value defines the rasterizer state
  38052. */
  38053. setRasterizerState(value: boolean): void;
  38054. /**
  38055. * Gets the current depth function
  38056. * @returns a number defining the depth function
  38057. */
  38058. getDepthFunction(): Nullable<number>;
  38059. /**
  38060. * Sets the current depth function
  38061. * @param depthFunc defines the function to use
  38062. */
  38063. setDepthFunction(depthFunc: number): void;
  38064. /**
  38065. * Sets the current depth function to GREATER
  38066. */
  38067. setDepthFunctionToGreater(): void;
  38068. /**
  38069. * Sets the current depth function to GEQUAL
  38070. */
  38071. setDepthFunctionToGreaterOrEqual(): void;
  38072. /**
  38073. * Sets the current depth function to LESS
  38074. */
  38075. setDepthFunctionToLess(): void;
  38076. /**
  38077. * Sets the current depth function to LEQUAL
  38078. */
  38079. setDepthFunctionToLessOrEqual(): void;
  38080. private _cachedStencilBuffer;
  38081. private _cachedStencilFunction;
  38082. private _cachedStencilMask;
  38083. private _cachedStencilOperationPass;
  38084. private _cachedStencilOperationFail;
  38085. private _cachedStencilOperationDepthFail;
  38086. private _cachedStencilReference;
  38087. /**
  38088. * Caches the the state of the stencil buffer
  38089. */
  38090. cacheStencilState(): void;
  38091. /**
  38092. * Restores the state of the stencil buffer
  38093. */
  38094. restoreStencilState(): void;
  38095. /**
  38096. * Directly set the WebGL Viewport
  38097. * @param x defines the x coordinate of the viewport (in screen space)
  38098. * @param y defines the y coordinate of the viewport (in screen space)
  38099. * @param width defines the width of the viewport (in screen space)
  38100. * @param height defines the height of the viewport (in screen space)
  38101. * @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
  38102. */
  38103. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38104. /**
  38105. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38106. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38107. * @param y defines the y-coordinate of the corner of the clear rectangle
  38108. * @param width defines the width of the clear rectangle
  38109. * @param height defines the height of the clear rectangle
  38110. * @param clearColor defines the clear color
  38111. */
  38112. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38113. /**
  38114. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38115. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38116. * @param y defines the y-coordinate of the corner of the clear rectangle
  38117. * @param width defines the width of the clear rectangle
  38118. * @param height defines the height of the clear rectangle
  38119. */
  38120. enableScissor(x: number, y: number, width: number, height: number): void;
  38121. /**
  38122. * Disable previously set scissor test rectangle
  38123. */
  38124. disableScissor(): void;
  38125. protected _reportDrawCall(): void;
  38126. /**
  38127. * Initializes a webVR display and starts listening to display change events
  38128. * The onVRDisplayChangedObservable will be notified upon these changes
  38129. * @returns The onVRDisplayChangedObservable
  38130. */
  38131. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38132. /** @hidden */
  38133. _prepareVRComponent(): void;
  38134. /** @hidden */
  38135. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38136. /** @hidden */
  38137. _submitVRFrame(): void;
  38138. /**
  38139. * Call this function to leave webVR mode
  38140. * Will do nothing if webVR is not supported or if there is no webVR device
  38141. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38142. */
  38143. disableVR(): void;
  38144. /**
  38145. * Gets a boolean indicating that the system is in VR mode and is presenting
  38146. * @returns true if VR mode is engaged
  38147. */
  38148. isVRPresenting(): boolean;
  38149. /** @hidden */
  38150. _requestVRFrame(): void;
  38151. /** @hidden */
  38152. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38153. /**
  38154. * Gets the source code of the vertex shader associated with a specific webGL program
  38155. * @param program defines the program to use
  38156. * @returns a string containing the source code of the vertex shader associated with the program
  38157. */
  38158. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38159. /**
  38160. * Gets the source code of the fragment shader associated with a specific webGL program
  38161. * @param program defines the program to use
  38162. * @returns a string containing the source code of the fragment shader associated with the program
  38163. */
  38164. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38165. /**
  38166. * Sets a depth stencil texture from a render target to the according uniform.
  38167. * @param channel The texture channel
  38168. * @param uniform The uniform to set
  38169. * @param texture The render target texture containing the depth stencil texture to apply
  38170. */
  38171. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38172. /**
  38173. * Sets a texture to the webGL context from a postprocess
  38174. * @param channel defines the channel to use
  38175. * @param postProcess defines the source postprocess
  38176. */
  38177. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38178. /**
  38179. * Binds the output of the passed in post process to the texture channel specified
  38180. * @param channel The channel the texture should be bound to
  38181. * @param postProcess The post process which's output should be bound
  38182. */
  38183. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38184. protected _rebuildBuffers(): void;
  38185. /** @hidden */
  38186. _renderFrame(): void;
  38187. _renderLoop(): void;
  38188. /** @hidden */
  38189. _renderViews(): boolean;
  38190. /**
  38191. * Toggle full screen mode
  38192. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38193. */
  38194. switchFullscreen(requestPointerLock: boolean): void;
  38195. /**
  38196. * Enters full screen mode
  38197. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38198. */
  38199. enterFullscreen(requestPointerLock: boolean): void;
  38200. /**
  38201. * Exits full screen mode
  38202. */
  38203. exitFullscreen(): void;
  38204. /**
  38205. * Enters Pointerlock mode
  38206. */
  38207. enterPointerlock(): void;
  38208. /**
  38209. * Exits Pointerlock mode
  38210. */
  38211. exitPointerlock(): void;
  38212. /**
  38213. * Begin a new frame
  38214. */
  38215. beginFrame(): void;
  38216. /**
  38217. * Enf the current frame
  38218. */
  38219. endFrame(): void;
  38220. resize(): void;
  38221. /**
  38222. * Force a specific size of the canvas
  38223. * @param width defines the new canvas' width
  38224. * @param height defines the new canvas' height
  38225. * @returns true if the size was changed
  38226. */
  38227. setSize(width: number, height: number): boolean;
  38228. /**
  38229. * Updates a dynamic vertex buffer.
  38230. * @param vertexBuffer the vertex buffer to update
  38231. * @param data the data used to update the vertex buffer
  38232. * @param byteOffset the byte offset of the data
  38233. * @param byteLength the byte length of the data
  38234. */
  38235. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38236. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38237. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38238. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38239. _releaseTexture(texture: InternalTexture): void;
  38240. /**
  38241. * @hidden
  38242. * Rescales a texture
  38243. * @param source input texutre
  38244. * @param destination destination texture
  38245. * @param scene scene to use to render the resize
  38246. * @param internalFormat format to use when resizing
  38247. * @param onComplete callback to be called when resize has completed
  38248. */
  38249. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38250. /**
  38251. * Gets the current framerate
  38252. * @returns a number representing the framerate
  38253. */
  38254. getFps(): number;
  38255. /**
  38256. * Gets the time spent between current and previous frame
  38257. * @returns a number representing the delta time in ms
  38258. */
  38259. getDeltaTime(): number;
  38260. private _measureFps;
  38261. /** @hidden */
  38262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38263. /**
  38264. * Update a dynamic index buffer
  38265. * @param indexBuffer defines the target index buffer
  38266. * @param indices defines the data to update
  38267. * @param offset defines the offset in the target index buffer where update should start
  38268. */
  38269. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38270. /**
  38271. * Updates the sample count of a render target texture
  38272. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38273. * @param texture defines the texture to update
  38274. * @param samples defines the sample count to set
  38275. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38276. */
  38277. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38278. /**
  38279. * Updates a depth texture Comparison Mode and Function.
  38280. * If the comparison Function is equal to 0, the mode will be set to none.
  38281. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38282. * @param texture The texture to set the comparison function for
  38283. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38284. */
  38285. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38286. /**
  38287. * Creates a webGL buffer to use with instanciation
  38288. * @param capacity defines the size of the buffer
  38289. * @returns the webGL buffer
  38290. */
  38291. createInstancesBuffer(capacity: number): DataBuffer;
  38292. /**
  38293. * Delete a webGL buffer used with instanciation
  38294. * @param buffer defines the webGL buffer to delete
  38295. */
  38296. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38297. private _clientWaitAsync;
  38298. /** @hidden */
  38299. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38300. dispose(): void;
  38301. private _disableTouchAction;
  38302. /**
  38303. * Display the loading screen
  38304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38305. */
  38306. displayLoadingUI(): void;
  38307. /**
  38308. * Hide the loading screen
  38309. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38310. */
  38311. hideLoadingUI(): void;
  38312. /**
  38313. * Gets the current loading screen object
  38314. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38315. */
  38316. get loadingScreen(): ILoadingScreen;
  38317. /**
  38318. * Sets the current loading screen object
  38319. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38320. */
  38321. set loadingScreen(loadingScreen: ILoadingScreen);
  38322. /**
  38323. * Sets the current loading screen text
  38324. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38325. */
  38326. set loadingUIText(text: string);
  38327. /**
  38328. * Sets the current loading screen background color
  38329. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38330. */
  38331. set loadingUIBackgroundColor(color: string);
  38332. /** Pointerlock and fullscreen */
  38333. /**
  38334. * Ask the browser to promote the current element to pointerlock mode
  38335. * @param element defines the DOM element to promote
  38336. */
  38337. static _RequestPointerlock(element: HTMLElement): void;
  38338. /**
  38339. * Asks the browser to exit pointerlock mode
  38340. */
  38341. static _ExitPointerlock(): void;
  38342. /**
  38343. * Ask the browser to promote the current element to fullscreen rendering mode
  38344. * @param element defines the DOM element to promote
  38345. */
  38346. static _RequestFullscreen(element: HTMLElement): void;
  38347. /**
  38348. * Asks the browser to exit fullscreen mode
  38349. */
  38350. static _ExitFullscreen(): void;
  38351. }
  38352. }
  38353. declare module "babylonjs/Engines/engineStore" {
  38354. import { Nullable } from "babylonjs/types";
  38355. import { Engine } from "babylonjs/Engines/engine";
  38356. import { Scene } from "babylonjs/scene";
  38357. /**
  38358. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38359. * during the life time of the application.
  38360. */
  38361. export class EngineStore {
  38362. /** Gets the list of created engines */
  38363. static Instances: import("babylonjs/Engines/engine").Engine[];
  38364. /** @hidden */
  38365. static _LastCreatedScene: Nullable<Scene>;
  38366. /**
  38367. * Gets the latest created engine
  38368. */
  38369. static get LastCreatedEngine(): Nullable<Engine>;
  38370. /**
  38371. * Gets the latest created scene
  38372. */
  38373. static get LastCreatedScene(): Nullable<Scene>;
  38374. /**
  38375. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38376. * @ignorenaming
  38377. */
  38378. static UseFallbackTexture: boolean;
  38379. /**
  38380. * Texture content used if a texture cannot loaded
  38381. * @ignorenaming
  38382. */
  38383. static FallbackTexture: string;
  38384. }
  38385. }
  38386. declare module "babylonjs/Misc/promise" {
  38387. /**
  38388. * Helper class that provides a small promise polyfill
  38389. */
  38390. export class PromisePolyfill {
  38391. /**
  38392. * Static function used to check if the polyfill is required
  38393. * If this is the case then the function will inject the polyfill to window.Promise
  38394. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38395. */
  38396. static Apply(force?: boolean): void;
  38397. }
  38398. }
  38399. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38400. /**
  38401. * Interface for screenshot methods with describe argument called `size` as object with options
  38402. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38403. */
  38404. export interface IScreenshotSize {
  38405. /**
  38406. * number in pixels for canvas height
  38407. */
  38408. height?: number;
  38409. /**
  38410. * multiplier allowing render at a higher or lower resolution
  38411. * If value is defined then height and width will be ignored and taken from camera
  38412. */
  38413. precision?: number;
  38414. /**
  38415. * number in pixels for canvas width
  38416. */
  38417. width?: number;
  38418. }
  38419. }
  38420. declare module "babylonjs/Misc/tools" {
  38421. import { Nullable, float } from "babylonjs/types";
  38422. import { DomManagement } from "babylonjs/Misc/domManagement";
  38423. import { WebRequest } from "babylonjs/Misc/webRequest";
  38424. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38425. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38426. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38427. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38428. import { Camera } from "babylonjs/Cameras/camera";
  38429. import { Engine } from "babylonjs/Engines/engine";
  38430. interface IColor4Like {
  38431. r: float;
  38432. g: float;
  38433. b: float;
  38434. a: float;
  38435. }
  38436. /**
  38437. * Class containing a set of static utilities functions
  38438. */
  38439. export class Tools {
  38440. /**
  38441. * Gets or sets the base URL to use to load assets
  38442. */
  38443. static get BaseUrl(): string;
  38444. static set BaseUrl(value: string);
  38445. /**
  38446. * Enable/Disable Custom HTTP Request Headers globally.
  38447. * default = false
  38448. * @see CustomRequestHeaders
  38449. */
  38450. static UseCustomRequestHeaders: boolean;
  38451. /**
  38452. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38453. * i.e. when loading files, where the server/service expects an Authorization header
  38454. */
  38455. static CustomRequestHeaders: {
  38456. [key: string]: string;
  38457. };
  38458. /**
  38459. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38460. */
  38461. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38462. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38463. /**
  38464. * Default behaviour for cors in the application.
  38465. * It can be a string if the expected behavior is identical in the entire app.
  38466. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38467. */
  38468. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38469. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38470. /**
  38471. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38472. * @ignorenaming
  38473. */
  38474. static get UseFallbackTexture(): boolean;
  38475. static set UseFallbackTexture(value: boolean);
  38476. /**
  38477. * Use this object to register external classes like custom textures or material
  38478. * to allow the laoders to instantiate them
  38479. */
  38480. static get RegisteredExternalClasses(): {
  38481. [key: string]: Object;
  38482. };
  38483. static set RegisteredExternalClasses(classes: {
  38484. [key: string]: Object;
  38485. });
  38486. /**
  38487. * Texture content used if a texture cannot loaded
  38488. * @ignorenaming
  38489. */
  38490. static get fallbackTexture(): string;
  38491. static set fallbackTexture(value: string);
  38492. /**
  38493. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38494. * @param u defines the coordinate on X axis
  38495. * @param v defines the coordinate on Y axis
  38496. * @param width defines the width of the source data
  38497. * @param height defines the height of the source data
  38498. * @param pixels defines the source byte array
  38499. * @param color defines the output color
  38500. */
  38501. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38502. /**
  38503. * Interpolates between a and b via alpha
  38504. * @param a The lower value (returned when alpha = 0)
  38505. * @param b The upper value (returned when alpha = 1)
  38506. * @param alpha The interpolation-factor
  38507. * @return The mixed value
  38508. */
  38509. static Mix(a: number, b: number, alpha: number): number;
  38510. /**
  38511. * Tries to instantiate a new object from a given class name
  38512. * @param className defines the class name to instantiate
  38513. * @returns the new object or null if the system was not able to do the instantiation
  38514. */
  38515. static Instantiate(className: string): any;
  38516. /**
  38517. * Provides a slice function that will work even on IE
  38518. * @param data defines the array to slice
  38519. * @param start defines the start of the data (optional)
  38520. * @param end defines the end of the data (optional)
  38521. * @returns the new sliced array
  38522. */
  38523. static Slice<T>(data: T, start?: number, end?: number): T;
  38524. /**
  38525. * Polyfill for setImmediate
  38526. * @param action defines the action to execute after the current execution block
  38527. */
  38528. static SetImmediate(action: () => void): void;
  38529. /**
  38530. * Function indicating if a number is an exponent of 2
  38531. * @param value defines the value to test
  38532. * @returns true if the value is an exponent of 2
  38533. */
  38534. static IsExponentOfTwo(value: number): boolean;
  38535. private static _tmpFloatArray;
  38536. /**
  38537. * Returns the nearest 32-bit single precision float representation of a Number
  38538. * @param value A Number. If the parameter is of a different type, it will get converted
  38539. * to a number or to NaN if it cannot be converted
  38540. * @returns number
  38541. */
  38542. static FloatRound(value: number): number;
  38543. /**
  38544. * Extracts the filename from a path
  38545. * @param path defines the path to use
  38546. * @returns the filename
  38547. */
  38548. static GetFilename(path: string): string;
  38549. /**
  38550. * Extracts the "folder" part of a path (everything before the filename).
  38551. * @param uri The URI to extract the info from
  38552. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38553. * @returns The "folder" part of the path
  38554. */
  38555. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38556. /**
  38557. * Extracts text content from a DOM element hierarchy
  38558. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38559. */
  38560. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38561. /**
  38562. * Convert an angle in radians to degrees
  38563. * @param angle defines the angle to convert
  38564. * @returns the angle in degrees
  38565. */
  38566. static ToDegrees(angle: number): number;
  38567. /**
  38568. * Convert an angle in degrees to radians
  38569. * @param angle defines the angle to convert
  38570. * @returns the angle in radians
  38571. */
  38572. static ToRadians(angle: number): number;
  38573. /**
  38574. * Returns an array if obj is not an array
  38575. * @param obj defines the object to evaluate as an array
  38576. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38577. * @returns either obj directly if obj is an array or a new array containing obj
  38578. */
  38579. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38580. /**
  38581. * Gets the pointer prefix to use
  38582. * @param engine defines the engine we are finding the prefix for
  38583. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38584. */
  38585. static GetPointerPrefix(engine: Engine): string;
  38586. /**
  38587. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38588. * @param url define the url we are trying
  38589. * @param element define the dom element where to configure the cors policy
  38590. */
  38591. static SetCorsBehavior(url: string | string[], element: {
  38592. crossOrigin: string | null;
  38593. }): void;
  38594. /**
  38595. * Removes unwanted characters from an url
  38596. * @param url defines the url to clean
  38597. * @returns the cleaned url
  38598. */
  38599. static CleanUrl(url: string): string;
  38600. /**
  38601. * Gets or sets a function used to pre-process url before using them to load assets
  38602. */
  38603. static get PreprocessUrl(): (url: string) => string;
  38604. static set PreprocessUrl(processor: (url: string) => string);
  38605. /**
  38606. * Loads an image as an HTMLImageElement.
  38607. * @param input url string, ArrayBuffer, or Blob to load
  38608. * @param onLoad callback called when the image successfully loads
  38609. * @param onError callback called when the image fails to load
  38610. * @param offlineProvider offline provider for caching
  38611. * @param mimeType optional mime type
  38612. * @returns the HTMLImageElement of the loaded image
  38613. */
  38614. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38615. /**
  38616. * Loads a file from a url
  38617. * @param url url string, ArrayBuffer, or Blob to load
  38618. * @param onSuccess callback called when the file successfully loads
  38619. * @param onProgress callback called while file is loading (if the server supports this mode)
  38620. * @param offlineProvider defines the offline provider for caching
  38621. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38622. * @param onError callback called when the file fails to load
  38623. * @returns a file request object
  38624. */
  38625. 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;
  38626. /**
  38627. * Loads a file from a url
  38628. * @param url the file url to load
  38629. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38630. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38631. */
  38632. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38633. /**
  38634. * Load a script (identified by an url). When the url returns, the
  38635. * content of this file is added into a new script element, attached to the DOM (body element)
  38636. * @param scriptUrl defines the url of the script to laod
  38637. * @param onSuccess defines the callback called when the script is loaded
  38638. * @param onError defines the callback to call if an error occurs
  38639. * @param scriptId defines the id of the script element
  38640. */
  38641. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38642. /**
  38643. * Load an asynchronous script (identified by an url). When the url returns, the
  38644. * content of this file is added into a new script element, attached to the DOM (body element)
  38645. * @param scriptUrl defines the url of the script to laod
  38646. * @param scriptId defines the id of the script element
  38647. * @returns a promise request object
  38648. */
  38649. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38650. /**
  38651. * Loads a file from a blob
  38652. * @param fileToLoad defines the blob to use
  38653. * @param callback defines the callback to call when data is loaded
  38654. * @param progressCallback defines the callback to call during loading process
  38655. * @returns a file request object
  38656. */
  38657. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38658. /**
  38659. * Reads a file from a File object
  38660. * @param file defines the file to load
  38661. * @param onSuccess defines the callback to call when data is loaded
  38662. * @param onProgress defines the callback to call during loading process
  38663. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38664. * @param onError defines the callback to call when an error occurs
  38665. * @returns a file request object
  38666. */
  38667. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38668. /**
  38669. * Creates a data url from a given string content
  38670. * @param content defines the content to convert
  38671. * @returns the new data url link
  38672. */
  38673. static FileAsURL(content: string): string;
  38674. /**
  38675. * Format the given number to a specific decimal format
  38676. * @param value defines the number to format
  38677. * @param decimals defines the number of decimals to use
  38678. * @returns the formatted string
  38679. */
  38680. static Format(value: number, decimals?: number): string;
  38681. /**
  38682. * Tries to copy an object by duplicating every property
  38683. * @param source defines the source object
  38684. * @param destination defines the target object
  38685. * @param doNotCopyList defines a list of properties to avoid
  38686. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38687. */
  38688. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38689. /**
  38690. * Gets a boolean indicating if the given object has no own property
  38691. * @param obj defines the object to test
  38692. * @returns true if object has no own property
  38693. */
  38694. static IsEmpty(obj: any): boolean;
  38695. /**
  38696. * Function used to register events at window level
  38697. * @param windowElement defines the Window object to use
  38698. * @param events defines the events to register
  38699. */
  38700. static RegisterTopRootEvents(windowElement: Window, events: {
  38701. name: string;
  38702. handler: Nullable<(e: FocusEvent) => any>;
  38703. }[]): void;
  38704. /**
  38705. * Function used to unregister events from window level
  38706. * @param windowElement defines the Window object to use
  38707. * @param events defines the events to unregister
  38708. */
  38709. static UnregisterTopRootEvents(windowElement: Window, events: {
  38710. name: string;
  38711. handler: Nullable<(e: FocusEvent) => any>;
  38712. }[]): void;
  38713. /**
  38714. * @ignore
  38715. */
  38716. static _ScreenshotCanvas: HTMLCanvasElement;
  38717. /**
  38718. * Dumps the current bound framebuffer
  38719. * @param width defines the rendering width
  38720. * @param height defines the rendering height
  38721. * @param engine defines the hosting engine
  38722. * @param successCallback defines the callback triggered once the data are available
  38723. * @param mimeType defines the mime type of the result
  38724. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38725. */
  38726. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38727. /**
  38728. * Converts the canvas data to blob.
  38729. * This acts as a polyfill for browsers not supporting the to blob function.
  38730. * @param canvas Defines the canvas to extract the data from
  38731. * @param successCallback Defines the callback triggered once the data are available
  38732. * @param mimeType Defines the mime type of the result
  38733. */
  38734. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38735. /**
  38736. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38737. * @param successCallback defines the callback triggered once the data are available
  38738. * @param mimeType defines the mime type of the result
  38739. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38740. */
  38741. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38742. /**
  38743. * Downloads a blob in the browser
  38744. * @param blob defines the blob to download
  38745. * @param fileName defines the name of the downloaded file
  38746. */
  38747. static Download(blob: Blob, fileName: string): void;
  38748. /**
  38749. * Captures a screenshot of the current rendering
  38750. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38751. * @param engine defines the rendering engine
  38752. * @param camera defines the source camera
  38753. * @param size This parameter can be set to a single number or to an object with the
  38754. * following (optional) properties: precision, width, height. If a single number is passed,
  38755. * it will be used for both width and height. If an object is passed, the screenshot size
  38756. * will be derived from the parameters. The precision property is a multiplier allowing
  38757. * rendering at a higher or lower resolution
  38758. * @param successCallback defines the callback receives a single parameter which contains the
  38759. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38760. * src parameter of an <img> to display it
  38761. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38762. * Check your browser for supported MIME types
  38763. */
  38764. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38765. /**
  38766. * Captures a screenshot of the current rendering
  38767. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38768. * @param engine defines the rendering engine
  38769. * @param camera defines the source camera
  38770. * @param size This parameter can be set to a single number or to an object with the
  38771. * following (optional) properties: precision, width, height. If a single number is passed,
  38772. * it will be used for both width and height. If an object is passed, the screenshot size
  38773. * will be derived from the parameters. The precision property is a multiplier allowing
  38774. * rendering at a higher or lower resolution
  38775. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38776. * Check your browser for supported MIME types
  38777. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38778. * to the src parameter of an <img> to display it
  38779. */
  38780. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38781. /**
  38782. * Generates an image screenshot from the specified camera.
  38783. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38784. * @param engine The engine to use for rendering
  38785. * @param camera The camera to use for rendering
  38786. * @param size This parameter can be set to a single number or to an object with the
  38787. * following (optional) properties: precision, width, height. If a single number is passed,
  38788. * it will be used for both width and height. If an object is passed, the screenshot size
  38789. * will be derived from the parameters. The precision property is a multiplier allowing
  38790. * rendering at a higher or lower resolution
  38791. * @param successCallback The callback receives a single parameter which contains the
  38792. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38793. * src parameter of an <img> to display it
  38794. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38795. * Check your browser for supported MIME types
  38796. * @param samples Texture samples (default: 1)
  38797. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38798. * @param fileName A name for for the downloaded file.
  38799. */
  38800. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38801. /**
  38802. * Generates an image screenshot from the specified camera.
  38803. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38804. * @param engine The engine to use for rendering
  38805. * @param camera The camera to use for rendering
  38806. * @param size This parameter can be set to a single number or to an object with the
  38807. * following (optional) properties: precision, width, height. If a single number is passed,
  38808. * it will be used for both width and height. If an object is passed, the screenshot size
  38809. * will be derived from the parameters. The precision property is a multiplier allowing
  38810. * rendering at a higher or lower resolution
  38811. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38812. * Check your browser for supported MIME types
  38813. * @param samples Texture samples (default: 1)
  38814. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38815. * @param fileName A name for for the downloaded file.
  38816. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38817. * to the src parameter of an <img> to display it
  38818. */
  38819. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38820. /**
  38821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38822. * Be aware Math.random() could cause collisions, but:
  38823. * "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"
  38824. * @returns a pseudo random id
  38825. */
  38826. static RandomId(): string;
  38827. /**
  38828. * Test if the given uri is a base64 string
  38829. * @param uri The uri to test
  38830. * @return True if the uri is a base64 string or false otherwise
  38831. */
  38832. static IsBase64(uri: string): boolean;
  38833. /**
  38834. * Decode the given base64 uri.
  38835. * @param uri The uri to decode
  38836. * @return The decoded base64 data.
  38837. */
  38838. static DecodeBase64(uri: string): ArrayBuffer;
  38839. /**
  38840. * Gets the absolute url.
  38841. * @param url the input url
  38842. * @return the absolute url
  38843. */
  38844. static GetAbsoluteUrl(url: string): string;
  38845. /**
  38846. * No log
  38847. */
  38848. static readonly NoneLogLevel: number;
  38849. /**
  38850. * Only message logs
  38851. */
  38852. static readonly MessageLogLevel: number;
  38853. /**
  38854. * Only warning logs
  38855. */
  38856. static readonly WarningLogLevel: number;
  38857. /**
  38858. * Only error logs
  38859. */
  38860. static readonly ErrorLogLevel: number;
  38861. /**
  38862. * All logs
  38863. */
  38864. static readonly AllLogLevel: number;
  38865. /**
  38866. * Gets a value indicating the number of loading errors
  38867. * @ignorenaming
  38868. */
  38869. static get errorsCount(): number;
  38870. /**
  38871. * Callback called when a new log is added
  38872. */
  38873. static OnNewCacheEntry: (entry: string) => void;
  38874. /**
  38875. * Log a message to the console
  38876. * @param message defines the message to log
  38877. */
  38878. static Log(message: string): void;
  38879. /**
  38880. * Write a warning message to the console
  38881. * @param message defines the message to log
  38882. */
  38883. static Warn(message: string): void;
  38884. /**
  38885. * Write an error message to the console
  38886. * @param message defines the message to log
  38887. */
  38888. static Error(message: string): void;
  38889. /**
  38890. * Gets current log cache (list of logs)
  38891. */
  38892. static get LogCache(): string;
  38893. /**
  38894. * Clears the log cache
  38895. */
  38896. static ClearLogCache(): void;
  38897. /**
  38898. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38899. */
  38900. static set LogLevels(level: number);
  38901. /**
  38902. * Checks if the window object exists
  38903. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38904. */
  38905. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38906. /**
  38907. * No performance log
  38908. */
  38909. static readonly PerformanceNoneLogLevel: number;
  38910. /**
  38911. * Use user marks to log performance
  38912. */
  38913. static readonly PerformanceUserMarkLogLevel: number;
  38914. /**
  38915. * Log performance to the console
  38916. */
  38917. static readonly PerformanceConsoleLogLevel: number;
  38918. private static _performance;
  38919. /**
  38920. * Sets the current performance log level
  38921. */
  38922. static set PerformanceLogLevel(level: number);
  38923. private static _StartPerformanceCounterDisabled;
  38924. private static _EndPerformanceCounterDisabled;
  38925. private static _StartUserMark;
  38926. private static _EndUserMark;
  38927. private static _StartPerformanceConsole;
  38928. private static _EndPerformanceConsole;
  38929. /**
  38930. * Starts a performance counter
  38931. */
  38932. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38933. /**
  38934. * Ends a specific performance coutner
  38935. */
  38936. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38937. /**
  38938. * Gets either window.performance.now() if supported or Date.now() else
  38939. */
  38940. static get Now(): number;
  38941. /**
  38942. * This method will return the name of the class used to create the instance of the given object.
  38943. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38944. * @param object the object to get the class name from
  38945. * @param isType defines if the object is actually a type
  38946. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38947. */
  38948. static GetClassName(object: any, isType?: boolean): string;
  38949. /**
  38950. * Gets the first element of an array satisfying a given predicate
  38951. * @param array defines the array to browse
  38952. * @param predicate defines the predicate to use
  38953. * @returns null if not found or the element
  38954. */
  38955. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38956. /**
  38957. * This method will return the name of the full name of the class, including its owning module (if any).
  38958. * 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).
  38959. * @param object the object to get the class name from
  38960. * @param isType defines if the object is actually a type
  38961. * @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.
  38962. * @ignorenaming
  38963. */
  38964. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38965. /**
  38966. * Returns a promise that resolves after the given amount of time.
  38967. * @param delay Number of milliseconds to delay
  38968. * @returns Promise that resolves after the given amount of time
  38969. */
  38970. static DelayAsync(delay: number): Promise<void>;
  38971. /**
  38972. * Utility function to detect if the current user agent is Safari
  38973. * @returns whether or not the current user agent is safari
  38974. */
  38975. static IsSafari(): boolean;
  38976. }
  38977. /**
  38978. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38979. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38980. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38981. * @param name The name of the class, case should be preserved
  38982. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38983. */
  38984. export function className(name: string, module?: string): (target: Object) => void;
  38985. /**
  38986. * An implementation of a loop for asynchronous functions.
  38987. */
  38988. export class AsyncLoop {
  38989. /**
  38990. * Defines the number of iterations for the loop
  38991. */
  38992. iterations: number;
  38993. /**
  38994. * Defines the current index of the loop.
  38995. */
  38996. index: number;
  38997. private _done;
  38998. private _fn;
  38999. private _successCallback;
  39000. /**
  39001. * Constructor.
  39002. * @param iterations the number of iterations.
  39003. * @param func the function to run each iteration
  39004. * @param successCallback the callback that will be called upon succesful execution
  39005. * @param offset starting offset.
  39006. */
  39007. constructor(
  39008. /**
  39009. * Defines the number of iterations for the loop
  39010. */
  39011. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39012. /**
  39013. * Execute the next iteration. Must be called after the last iteration was finished.
  39014. */
  39015. executeNext(): void;
  39016. /**
  39017. * Break the loop and run the success callback.
  39018. */
  39019. breakLoop(): void;
  39020. /**
  39021. * Create and run an async loop.
  39022. * @param iterations the number of iterations.
  39023. * @param fn the function to run each iteration
  39024. * @param successCallback the callback that will be called upon succesful execution
  39025. * @param offset starting offset.
  39026. * @returns the created async loop object
  39027. */
  39028. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39029. /**
  39030. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39031. * @param iterations total number of iterations
  39032. * @param syncedIterations number of synchronous iterations in each async iteration.
  39033. * @param fn the function to call each iteration.
  39034. * @param callback a success call back that will be called when iterating stops.
  39035. * @param breakFunction a break condition (optional)
  39036. * @param timeout timeout settings for the setTimeout function. default - 0.
  39037. * @returns the created async loop object
  39038. */
  39039. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39040. }
  39041. }
  39042. declare module "babylonjs/Misc/stringDictionary" {
  39043. import { Nullable } from "babylonjs/types";
  39044. /**
  39045. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39046. * The underlying implementation relies on an associative array to ensure the best performances.
  39047. * The value can be anything including 'null' but except 'undefined'
  39048. */
  39049. export class StringDictionary<T> {
  39050. /**
  39051. * This will clear this dictionary and copy the content from the 'source' one.
  39052. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39053. * @param source the dictionary to take the content from and copy to this dictionary
  39054. */
  39055. copyFrom(source: StringDictionary<T>): void;
  39056. /**
  39057. * Get a value based from its key
  39058. * @param key the given key to get the matching value from
  39059. * @return the value if found, otherwise undefined is returned
  39060. */
  39061. get(key: string): T | undefined;
  39062. /**
  39063. * Get a value from its key or add it if it doesn't exist.
  39064. * This method will ensure you that a given key/data will be present in the dictionary.
  39065. * @param key the given key to get the matching value from
  39066. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39067. * The factory will only be invoked if there's no data for the given key.
  39068. * @return the value corresponding to the key.
  39069. */
  39070. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39071. /**
  39072. * Get a value from its key if present in the dictionary otherwise add it
  39073. * @param key the key to get the value from
  39074. * @param val if there's no such key/value pair in the dictionary add it with this value
  39075. * @return the value corresponding to the key
  39076. */
  39077. getOrAdd(key: string, val: T): T;
  39078. /**
  39079. * Check if there's a given key in the dictionary
  39080. * @param key the key to check for
  39081. * @return true if the key is present, false otherwise
  39082. */
  39083. contains(key: string): boolean;
  39084. /**
  39085. * Add a new key and its corresponding value
  39086. * @param key the key to add
  39087. * @param value the value corresponding to the key
  39088. * @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
  39089. */
  39090. add(key: string, value: T): boolean;
  39091. /**
  39092. * Update a specific value associated to a key
  39093. * @param key defines the key to use
  39094. * @param value defines the value to store
  39095. * @returns true if the value was updated (or false if the key was not found)
  39096. */
  39097. set(key: string, value: T): boolean;
  39098. /**
  39099. * Get the element of the given key and remove it from the dictionary
  39100. * @param key defines the key to search
  39101. * @returns the value associated with the key or null if not found
  39102. */
  39103. getAndRemove(key: string): Nullable<T>;
  39104. /**
  39105. * Remove a key/value from the dictionary.
  39106. * @param key the key to remove
  39107. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39108. */
  39109. remove(key: string): boolean;
  39110. /**
  39111. * Clear the whole content of the dictionary
  39112. */
  39113. clear(): void;
  39114. /**
  39115. * Gets the current count
  39116. */
  39117. get count(): number;
  39118. /**
  39119. * Execute a callback on each key/val of the dictionary.
  39120. * Note that you can remove any element in this dictionary in the callback implementation
  39121. * @param callback the callback to execute on a given key/value pair
  39122. */
  39123. forEach(callback: (key: string, val: T) => void): void;
  39124. /**
  39125. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39126. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39127. * Note that you can remove any element in this dictionary in the callback implementation
  39128. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39129. * @returns the first item
  39130. */
  39131. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39132. private _count;
  39133. private _data;
  39134. }
  39135. }
  39136. declare module "babylonjs/Collisions/collisionCoordinator" {
  39137. import { Nullable } from "babylonjs/types";
  39138. import { Scene } from "babylonjs/scene";
  39139. import { Vector3 } from "babylonjs/Maths/math.vector";
  39140. import { Collider } from "babylonjs/Collisions/collider";
  39141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39142. /** @hidden */
  39143. export interface ICollisionCoordinator {
  39144. createCollider(): Collider;
  39145. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39146. init(scene: Scene): void;
  39147. }
  39148. /** @hidden */
  39149. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39150. private _scene;
  39151. private _scaledPosition;
  39152. private _scaledVelocity;
  39153. private _finalPosition;
  39154. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39155. createCollider(): Collider;
  39156. init(scene: Scene): void;
  39157. private _collideWithWorld;
  39158. }
  39159. }
  39160. declare module "babylonjs/Inputs/scene.inputManager" {
  39161. import { Nullable } from "babylonjs/types";
  39162. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39163. import { Vector2 } from "babylonjs/Maths/math.vector";
  39164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39165. import { Scene } from "babylonjs/scene";
  39166. /**
  39167. * Class used to manage all inputs for the scene.
  39168. */
  39169. export class InputManager {
  39170. /** The distance in pixel that you have to move to prevent some events */
  39171. static DragMovementThreshold: number;
  39172. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39173. static LongPressDelay: number;
  39174. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39175. static DoubleClickDelay: number;
  39176. /** If you need to check double click without raising a single click at first click, enable this flag */
  39177. static ExclusiveDoubleClickMode: boolean;
  39178. private _wheelEventName;
  39179. private _onPointerMove;
  39180. private _onPointerDown;
  39181. private _onPointerUp;
  39182. private _initClickEvent;
  39183. private _initActionManager;
  39184. private _delayedSimpleClick;
  39185. private _delayedSimpleClickTimeout;
  39186. private _previousDelayedSimpleClickTimeout;
  39187. private _meshPickProceed;
  39188. private _previousButtonPressed;
  39189. private _currentPickResult;
  39190. private _previousPickResult;
  39191. private _totalPointersPressed;
  39192. private _doubleClickOccured;
  39193. private _pointerOverMesh;
  39194. private _pickedDownMesh;
  39195. private _pickedUpMesh;
  39196. private _pointerX;
  39197. private _pointerY;
  39198. private _unTranslatedPointerX;
  39199. private _unTranslatedPointerY;
  39200. private _startingPointerPosition;
  39201. private _previousStartingPointerPosition;
  39202. private _startingPointerTime;
  39203. private _previousStartingPointerTime;
  39204. private _pointerCaptures;
  39205. private _onKeyDown;
  39206. private _onKeyUp;
  39207. private _onCanvasFocusObserver;
  39208. private _onCanvasBlurObserver;
  39209. private _scene;
  39210. /**
  39211. * Creates a new InputManager
  39212. * @param scene defines the hosting scene
  39213. */
  39214. constructor(scene: Scene);
  39215. /**
  39216. * Gets the mesh that is currently under the pointer
  39217. */
  39218. get meshUnderPointer(): Nullable<AbstractMesh>;
  39219. /**
  39220. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39221. */
  39222. get unTranslatedPointer(): Vector2;
  39223. /**
  39224. * Gets or sets the current on-screen X position of the pointer
  39225. */
  39226. get pointerX(): number;
  39227. set pointerX(value: number);
  39228. /**
  39229. * Gets or sets the current on-screen Y position of the pointer
  39230. */
  39231. get pointerY(): number;
  39232. set pointerY(value: number);
  39233. private _updatePointerPosition;
  39234. private _processPointerMove;
  39235. private _setRayOnPointerInfo;
  39236. private _checkPrePointerObservable;
  39237. /**
  39238. * Use this method to simulate a pointer move on a mesh
  39239. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39240. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39241. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39242. */
  39243. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39244. /**
  39245. * Use this method to simulate a pointer down on a mesh
  39246. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39247. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39248. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39249. */
  39250. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39251. private _processPointerDown;
  39252. /** @hidden */
  39253. _isPointerSwiping(): boolean;
  39254. /**
  39255. * Use this method to simulate a pointer up on a mesh
  39256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39259. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39260. */
  39261. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39262. private _processPointerUp;
  39263. /**
  39264. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39265. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39266. * @returns true if the pointer was captured
  39267. */
  39268. isPointerCaptured(pointerId?: number): boolean;
  39269. /**
  39270. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39271. * @param attachUp defines if you want to attach events to pointerup
  39272. * @param attachDown defines if you want to attach events to pointerdown
  39273. * @param attachMove defines if you want to attach events to pointermove
  39274. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39275. */
  39276. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39277. /**
  39278. * Detaches all event handlers
  39279. */
  39280. detachControl(): void;
  39281. /**
  39282. * Force the value of meshUnderPointer
  39283. * @param mesh defines the mesh to use
  39284. */
  39285. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39286. /**
  39287. * Gets the mesh under the pointer
  39288. * @returns a Mesh or null if no mesh is under the pointer
  39289. */
  39290. getPointerOverMesh(): Nullable<AbstractMesh>;
  39291. }
  39292. }
  39293. declare module "babylonjs/Animations/animationGroup" {
  39294. import { Animatable } from "babylonjs/Animations/animatable";
  39295. import { Animation } from "babylonjs/Animations/animation";
  39296. import { Scene, IDisposable } from "babylonjs/scene";
  39297. import { Observable } from "babylonjs/Misc/observable";
  39298. import { Nullable } from "babylonjs/types";
  39299. import "babylonjs/Animations/animatable";
  39300. /**
  39301. * This class defines the direct association between an animation and a target
  39302. */
  39303. export class TargetedAnimation {
  39304. /**
  39305. * Animation to perform
  39306. */
  39307. animation: Animation;
  39308. /**
  39309. * Target to animate
  39310. */
  39311. target: any;
  39312. /**
  39313. * Returns the string "TargetedAnimation"
  39314. * @returns "TargetedAnimation"
  39315. */
  39316. getClassName(): string;
  39317. /**
  39318. * Serialize the object
  39319. * @returns the JSON object representing the current entity
  39320. */
  39321. serialize(): any;
  39322. }
  39323. /**
  39324. * Use this class to create coordinated animations on multiple targets
  39325. */
  39326. export class AnimationGroup implements IDisposable {
  39327. /** The name of the animation group */
  39328. name: string;
  39329. private _scene;
  39330. private _targetedAnimations;
  39331. private _animatables;
  39332. private _from;
  39333. private _to;
  39334. private _isStarted;
  39335. private _isPaused;
  39336. private _speedRatio;
  39337. private _loopAnimation;
  39338. private _isAdditive;
  39339. /**
  39340. * Gets or sets the unique id of the node
  39341. */
  39342. uniqueId: number;
  39343. /**
  39344. * This observable will notify when one animation have ended
  39345. */
  39346. onAnimationEndObservable: Observable<TargetedAnimation>;
  39347. /**
  39348. * Observer raised when one animation loops
  39349. */
  39350. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39351. /**
  39352. * Observer raised when all animations have looped
  39353. */
  39354. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39355. /**
  39356. * This observable will notify when all animations have ended.
  39357. */
  39358. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39359. /**
  39360. * This observable will notify when all animations have paused.
  39361. */
  39362. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39363. /**
  39364. * This observable will notify when all animations are playing.
  39365. */
  39366. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39367. /**
  39368. * Gets the first frame
  39369. */
  39370. get from(): number;
  39371. /**
  39372. * Gets the last frame
  39373. */
  39374. get to(): number;
  39375. /**
  39376. * Define if the animations are started
  39377. */
  39378. get isStarted(): boolean;
  39379. /**
  39380. * Gets a value indicating that the current group is playing
  39381. */
  39382. get isPlaying(): boolean;
  39383. /**
  39384. * Gets or sets the speed ratio to use for all animations
  39385. */
  39386. get speedRatio(): number;
  39387. /**
  39388. * Gets or sets the speed ratio to use for all animations
  39389. */
  39390. set speedRatio(value: number);
  39391. /**
  39392. * Gets or sets if all animations should loop or not
  39393. */
  39394. get loopAnimation(): boolean;
  39395. set loopAnimation(value: boolean);
  39396. /**
  39397. * Gets or sets if all animations should be evaluated additively
  39398. */
  39399. get isAdditive(): boolean;
  39400. set isAdditive(value: boolean);
  39401. /**
  39402. * Gets the targeted animations for this animation group
  39403. */
  39404. get targetedAnimations(): Array<TargetedAnimation>;
  39405. /**
  39406. * returning the list of animatables controlled by this animation group.
  39407. */
  39408. get animatables(): Array<Animatable>;
  39409. /**
  39410. * Gets the list of target animations
  39411. */
  39412. get children(): TargetedAnimation[];
  39413. /**
  39414. * Instantiates a new Animation Group.
  39415. * This helps managing several animations at once.
  39416. * @see http://doc.babylonjs.com/how_to/group
  39417. * @param name Defines the name of the group
  39418. * @param scene Defines the scene the group belongs to
  39419. */
  39420. constructor(
  39421. /** The name of the animation group */
  39422. name: string, scene?: Nullable<Scene>);
  39423. /**
  39424. * Add an animation (with its target) in the group
  39425. * @param animation defines the animation we want to add
  39426. * @param target defines the target of the animation
  39427. * @returns the TargetedAnimation object
  39428. */
  39429. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39430. /**
  39431. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39432. * It can add constant keys at begin or end
  39433. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39434. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39435. * @returns the animation group
  39436. */
  39437. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39438. private _animationLoopCount;
  39439. private _animationLoopFlags;
  39440. private _processLoop;
  39441. /**
  39442. * Start all animations on given targets
  39443. * @param loop defines if animations must loop
  39444. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39445. * @param from defines the from key (optional)
  39446. * @param to defines the to key (optional)
  39447. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39448. * @returns the current animation group
  39449. */
  39450. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39451. /**
  39452. * Pause all animations
  39453. * @returns the animation group
  39454. */
  39455. pause(): AnimationGroup;
  39456. /**
  39457. * Play all animations to initial state
  39458. * This function will start() the animations if they were not started or will restart() them if they were paused
  39459. * @param loop defines if animations must loop
  39460. * @returns the animation group
  39461. */
  39462. play(loop?: boolean): AnimationGroup;
  39463. /**
  39464. * Reset all animations to initial state
  39465. * @returns the animation group
  39466. */
  39467. reset(): AnimationGroup;
  39468. /**
  39469. * Restart animations from key 0
  39470. * @returns the animation group
  39471. */
  39472. restart(): AnimationGroup;
  39473. /**
  39474. * Stop all animations
  39475. * @returns the animation group
  39476. */
  39477. stop(): AnimationGroup;
  39478. /**
  39479. * Set animation weight for all animatables
  39480. * @param weight defines the weight to use
  39481. * @return the animationGroup
  39482. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39483. */
  39484. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39485. /**
  39486. * Synchronize and normalize all animatables with a source animatable
  39487. * @param root defines the root animatable to synchronize with
  39488. * @return the animationGroup
  39489. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39490. */
  39491. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39492. /**
  39493. * Goes to a specific frame in this animation group
  39494. * @param frame the frame number to go to
  39495. * @return the animationGroup
  39496. */
  39497. goToFrame(frame: number): AnimationGroup;
  39498. /**
  39499. * Dispose all associated resources
  39500. */
  39501. dispose(): void;
  39502. private _checkAnimationGroupEnded;
  39503. /**
  39504. * Clone the current animation group and returns a copy
  39505. * @param newName defines the name of the new group
  39506. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39507. * @returns the new aniamtion group
  39508. */
  39509. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39510. /**
  39511. * Serializes the animationGroup to an object
  39512. * @returns Serialized object
  39513. */
  39514. serialize(): any;
  39515. /**
  39516. * Returns a new AnimationGroup object parsed from the source provided.
  39517. * @param parsedAnimationGroup defines the source
  39518. * @param scene defines the scene that will receive the animationGroup
  39519. * @returns a new AnimationGroup
  39520. */
  39521. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39522. /**
  39523. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39524. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39525. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39526. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39527. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39528. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39529. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39530. */
  39531. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39532. /**
  39533. * Returns the string "AnimationGroup"
  39534. * @returns "AnimationGroup"
  39535. */
  39536. getClassName(): string;
  39537. /**
  39538. * Creates a detailled string about the object
  39539. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39540. * @returns a string representing the object
  39541. */
  39542. toString(fullDetails?: boolean): string;
  39543. }
  39544. }
  39545. declare module "babylonjs/scene" {
  39546. import { Nullable } from "babylonjs/types";
  39547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39548. import { Observable } from "babylonjs/Misc/observable";
  39549. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39550. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39551. import { Geometry } from "babylonjs/Meshes/geometry";
  39552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39555. import { Mesh } from "babylonjs/Meshes/mesh";
  39556. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39557. import { Bone } from "babylonjs/Bones/bone";
  39558. import { Skeleton } from "babylonjs/Bones/skeleton";
  39559. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39560. import { Camera } from "babylonjs/Cameras/camera";
  39561. import { AbstractScene } from "babylonjs/abstractScene";
  39562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39564. import { Material } from "babylonjs/Materials/material";
  39565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39566. import { Effect } from "babylonjs/Materials/effect";
  39567. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39568. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39569. import { Light } from "babylonjs/Lights/light";
  39570. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39571. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39572. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39573. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39575. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39576. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39577. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39578. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39579. import { Engine } from "babylonjs/Engines/engine";
  39580. import { Node } from "babylonjs/node";
  39581. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39582. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39583. import { WebRequest } from "babylonjs/Misc/webRequest";
  39584. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39585. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39586. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39587. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39588. import { Plane } from "babylonjs/Maths/math.plane";
  39589. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39590. import { Ray } from "babylonjs/Culling/ray";
  39591. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39592. import { Animation } from "babylonjs/Animations/animation";
  39593. import { Animatable } from "babylonjs/Animations/animatable";
  39594. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39595. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39596. import { Collider } from "babylonjs/Collisions/collider";
  39597. /**
  39598. * Define an interface for all classes that will hold resources
  39599. */
  39600. export interface IDisposable {
  39601. /**
  39602. * Releases all held resources
  39603. */
  39604. dispose(): void;
  39605. }
  39606. /** Interface defining initialization parameters for Scene class */
  39607. export interface SceneOptions {
  39608. /**
  39609. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39610. * It will improve performance when the number of geometries becomes important.
  39611. */
  39612. useGeometryUniqueIdsMap?: boolean;
  39613. /**
  39614. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39615. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39616. */
  39617. useMaterialMeshMap?: boolean;
  39618. /**
  39619. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39620. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39621. */
  39622. useClonedMeshMap?: boolean;
  39623. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39624. virtual?: boolean;
  39625. }
  39626. /**
  39627. * Represents a scene to be rendered by the engine.
  39628. * @see http://doc.babylonjs.com/features/scene
  39629. */
  39630. export class Scene extends AbstractScene implements IAnimatable {
  39631. /** The fog is deactivated */
  39632. static readonly FOGMODE_NONE: number;
  39633. /** The fog density is following an exponential function */
  39634. static readonly FOGMODE_EXP: number;
  39635. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39636. static readonly FOGMODE_EXP2: number;
  39637. /** The fog density is following a linear function. */
  39638. static readonly FOGMODE_LINEAR: number;
  39639. /**
  39640. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39642. */
  39643. static MinDeltaTime: number;
  39644. /**
  39645. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39646. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39647. */
  39648. static MaxDeltaTime: number;
  39649. /**
  39650. * Factory used to create the default material.
  39651. * @param name The name of the material to create
  39652. * @param scene The scene to create the material for
  39653. * @returns The default material
  39654. */
  39655. static DefaultMaterialFactory(scene: Scene): Material;
  39656. /**
  39657. * Factory used to create the a collision coordinator.
  39658. * @returns The collision coordinator
  39659. */
  39660. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39661. /** @hidden */
  39662. _inputManager: InputManager;
  39663. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39664. cameraToUseForPointers: Nullable<Camera>;
  39665. /** @hidden */
  39666. readonly _isScene: boolean;
  39667. /** @hidden */
  39668. _blockEntityCollection: boolean;
  39669. /**
  39670. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39671. */
  39672. autoClear: boolean;
  39673. /**
  39674. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39675. */
  39676. autoClearDepthAndStencil: boolean;
  39677. /**
  39678. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39679. */
  39680. clearColor: Color4;
  39681. /**
  39682. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39683. */
  39684. ambientColor: Color3;
  39685. /**
  39686. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39687. * It should only be one of the following (if not the default embedded one):
  39688. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39689. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39690. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39691. * The material properties need to be setup according to the type of texture in use.
  39692. */
  39693. environmentBRDFTexture: BaseTexture;
  39694. /** @hidden */
  39695. protected _environmentTexture: Nullable<BaseTexture>;
  39696. /**
  39697. * Texture used in all pbr material as the reflection texture.
  39698. * As in the majority of the scene they are the same (exception for multi room and so on),
  39699. * this is easier to reference from here than from all the materials.
  39700. */
  39701. get environmentTexture(): Nullable<BaseTexture>;
  39702. /**
  39703. * Texture used in all pbr material as the reflection texture.
  39704. * As in the majority of the scene they are the same (exception for multi room and so on),
  39705. * this is easier to set here than in all the materials.
  39706. */
  39707. set environmentTexture(value: Nullable<BaseTexture>);
  39708. /** @hidden */
  39709. protected _environmentIntensity: number;
  39710. /**
  39711. * Intensity of the environment in all pbr material.
  39712. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39713. * As in the majority of the scene they are the same (exception for multi room and so on),
  39714. * this is easier to reference from here than from all the materials.
  39715. */
  39716. get environmentIntensity(): number;
  39717. /**
  39718. * Intensity of the environment in all pbr material.
  39719. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39720. * As in the majority of the scene they are the same (exception for multi room and so on),
  39721. * this is easier to set here than in all the materials.
  39722. */
  39723. set environmentIntensity(value: number);
  39724. /** @hidden */
  39725. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39726. /**
  39727. * Default image processing configuration used either in the rendering
  39728. * Forward main pass or through the imageProcessingPostProcess if present.
  39729. * As in the majority of the scene they are the same (exception for multi camera),
  39730. * this is easier to reference from here than from all the materials and post process.
  39731. *
  39732. * No setter as we it is a shared configuration, you can set the values instead.
  39733. */
  39734. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39735. private _forceWireframe;
  39736. /**
  39737. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39738. */
  39739. set forceWireframe(value: boolean);
  39740. get forceWireframe(): boolean;
  39741. private _skipFrustumClipping;
  39742. /**
  39743. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39744. */
  39745. set skipFrustumClipping(value: boolean);
  39746. get skipFrustumClipping(): boolean;
  39747. private _forcePointsCloud;
  39748. /**
  39749. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39750. */
  39751. set forcePointsCloud(value: boolean);
  39752. get forcePointsCloud(): boolean;
  39753. /**
  39754. * Gets or sets the active clipplane 1
  39755. */
  39756. clipPlane: Nullable<Plane>;
  39757. /**
  39758. * Gets or sets the active clipplane 2
  39759. */
  39760. clipPlane2: Nullable<Plane>;
  39761. /**
  39762. * Gets or sets the active clipplane 3
  39763. */
  39764. clipPlane3: Nullable<Plane>;
  39765. /**
  39766. * Gets or sets the active clipplane 4
  39767. */
  39768. clipPlane4: Nullable<Plane>;
  39769. /**
  39770. * Gets or sets the active clipplane 5
  39771. */
  39772. clipPlane5: Nullable<Plane>;
  39773. /**
  39774. * Gets or sets the active clipplane 6
  39775. */
  39776. clipPlane6: Nullable<Plane>;
  39777. /**
  39778. * Gets or sets a boolean indicating if animations are enabled
  39779. */
  39780. animationsEnabled: boolean;
  39781. private _animationPropertiesOverride;
  39782. /**
  39783. * Gets or sets the animation properties override
  39784. */
  39785. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39786. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39787. /**
  39788. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39789. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39790. */
  39791. useConstantAnimationDeltaTime: boolean;
  39792. /**
  39793. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39794. * Please note that it requires to run a ray cast through the scene on every frame
  39795. */
  39796. constantlyUpdateMeshUnderPointer: boolean;
  39797. /**
  39798. * Defines the HTML cursor to use when hovering over interactive elements
  39799. */
  39800. hoverCursor: string;
  39801. /**
  39802. * Defines the HTML default cursor to use (empty by default)
  39803. */
  39804. defaultCursor: string;
  39805. /**
  39806. * Defines whether cursors are handled by the scene.
  39807. */
  39808. doNotHandleCursors: boolean;
  39809. /**
  39810. * This is used to call preventDefault() on pointer down
  39811. * in order to block unwanted artifacts like system double clicks
  39812. */
  39813. preventDefaultOnPointerDown: boolean;
  39814. /**
  39815. * This is used to call preventDefault() on pointer up
  39816. * in order to block unwanted artifacts like system double clicks
  39817. */
  39818. preventDefaultOnPointerUp: boolean;
  39819. /**
  39820. * Gets or sets user defined metadata
  39821. */
  39822. metadata: any;
  39823. /**
  39824. * For internal use only. Please do not use.
  39825. */
  39826. reservedDataStore: any;
  39827. /**
  39828. * Gets the name of the plugin used to load this scene (null by default)
  39829. */
  39830. loadingPluginName: string;
  39831. /**
  39832. * Use this array to add regular expressions used to disable offline support for specific urls
  39833. */
  39834. disableOfflineSupportExceptionRules: RegExp[];
  39835. /**
  39836. * An event triggered when the scene is disposed.
  39837. */
  39838. onDisposeObservable: Observable<Scene>;
  39839. private _onDisposeObserver;
  39840. /** Sets a function to be executed when this scene is disposed. */
  39841. set onDispose(callback: () => void);
  39842. /**
  39843. * An event triggered before rendering the scene (right after animations and physics)
  39844. */
  39845. onBeforeRenderObservable: Observable<Scene>;
  39846. private _onBeforeRenderObserver;
  39847. /** Sets a function to be executed before rendering this scene */
  39848. set beforeRender(callback: Nullable<() => void>);
  39849. /**
  39850. * An event triggered after rendering the scene
  39851. */
  39852. onAfterRenderObservable: Observable<Scene>;
  39853. /**
  39854. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39855. */
  39856. onAfterRenderCameraObservable: Observable<Camera>;
  39857. private _onAfterRenderObserver;
  39858. /** Sets a function to be executed after rendering this scene */
  39859. set afterRender(callback: Nullable<() => void>);
  39860. /**
  39861. * An event triggered before animating the scene
  39862. */
  39863. onBeforeAnimationsObservable: Observable<Scene>;
  39864. /**
  39865. * An event triggered after animations processing
  39866. */
  39867. onAfterAnimationsObservable: Observable<Scene>;
  39868. /**
  39869. * An event triggered before draw calls are ready to be sent
  39870. */
  39871. onBeforeDrawPhaseObservable: Observable<Scene>;
  39872. /**
  39873. * An event triggered after draw calls have been sent
  39874. */
  39875. onAfterDrawPhaseObservable: Observable<Scene>;
  39876. /**
  39877. * An event triggered when the scene is ready
  39878. */
  39879. onReadyObservable: Observable<Scene>;
  39880. /**
  39881. * An event triggered before rendering a camera
  39882. */
  39883. onBeforeCameraRenderObservable: Observable<Camera>;
  39884. private _onBeforeCameraRenderObserver;
  39885. /** Sets a function to be executed before rendering a camera*/
  39886. set beforeCameraRender(callback: () => void);
  39887. /**
  39888. * An event triggered after rendering a camera
  39889. */
  39890. onAfterCameraRenderObservable: Observable<Camera>;
  39891. private _onAfterCameraRenderObserver;
  39892. /** Sets a function to be executed after rendering a camera*/
  39893. set afterCameraRender(callback: () => void);
  39894. /**
  39895. * An event triggered when active meshes evaluation is about to start
  39896. */
  39897. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39898. /**
  39899. * An event triggered when active meshes evaluation is done
  39900. */
  39901. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39902. /**
  39903. * An event triggered when particles rendering is about to start
  39904. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39905. */
  39906. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39907. /**
  39908. * An event triggered when particles rendering is done
  39909. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39910. */
  39911. onAfterParticlesRenderingObservable: Observable<Scene>;
  39912. /**
  39913. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39914. */
  39915. onDataLoadedObservable: Observable<Scene>;
  39916. /**
  39917. * An event triggered when a camera is created
  39918. */
  39919. onNewCameraAddedObservable: Observable<Camera>;
  39920. /**
  39921. * An event triggered when a camera is removed
  39922. */
  39923. onCameraRemovedObservable: Observable<Camera>;
  39924. /**
  39925. * An event triggered when a light is created
  39926. */
  39927. onNewLightAddedObservable: Observable<Light>;
  39928. /**
  39929. * An event triggered when a light is removed
  39930. */
  39931. onLightRemovedObservable: Observable<Light>;
  39932. /**
  39933. * An event triggered when a geometry is created
  39934. */
  39935. onNewGeometryAddedObservable: Observable<Geometry>;
  39936. /**
  39937. * An event triggered when a geometry is removed
  39938. */
  39939. onGeometryRemovedObservable: Observable<Geometry>;
  39940. /**
  39941. * An event triggered when a transform node is created
  39942. */
  39943. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39944. /**
  39945. * An event triggered when a transform node is removed
  39946. */
  39947. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39948. /**
  39949. * An event triggered when a mesh is created
  39950. */
  39951. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39952. /**
  39953. * An event triggered when a mesh is removed
  39954. */
  39955. onMeshRemovedObservable: Observable<AbstractMesh>;
  39956. /**
  39957. * An event triggered when a skeleton is created
  39958. */
  39959. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39960. /**
  39961. * An event triggered when a skeleton is removed
  39962. */
  39963. onSkeletonRemovedObservable: Observable<Skeleton>;
  39964. /**
  39965. * An event triggered when a material is created
  39966. */
  39967. onNewMaterialAddedObservable: Observable<Material>;
  39968. /**
  39969. * An event triggered when a material is removed
  39970. */
  39971. onMaterialRemovedObservable: Observable<Material>;
  39972. /**
  39973. * An event triggered when a texture is created
  39974. */
  39975. onNewTextureAddedObservable: Observable<BaseTexture>;
  39976. /**
  39977. * An event triggered when a texture is removed
  39978. */
  39979. onTextureRemovedObservable: Observable<BaseTexture>;
  39980. /**
  39981. * An event triggered when render targets are about to be rendered
  39982. * Can happen multiple times per frame.
  39983. */
  39984. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39985. /**
  39986. * An event triggered when render targets were rendered.
  39987. * Can happen multiple times per frame.
  39988. */
  39989. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39990. /**
  39991. * An event triggered before calculating deterministic simulation step
  39992. */
  39993. onBeforeStepObservable: Observable<Scene>;
  39994. /**
  39995. * An event triggered after calculating deterministic simulation step
  39996. */
  39997. onAfterStepObservable: Observable<Scene>;
  39998. /**
  39999. * An event triggered when the activeCamera property is updated
  40000. */
  40001. onActiveCameraChanged: Observable<Scene>;
  40002. /**
  40003. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40004. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40005. * 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)
  40006. */
  40007. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40008. /**
  40009. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40010. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40011. * 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)
  40012. */
  40013. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40014. /**
  40015. * This Observable will when a mesh has been imported into the scene.
  40016. */
  40017. onMeshImportedObservable: Observable<AbstractMesh>;
  40018. /**
  40019. * This Observable will when an animation file has been imported into the scene.
  40020. */
  40021. onAnimationFileImportedObservable: Observable<Scene>;
  40022. /**
  40023. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40024. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40025. */
  40026. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40027. /** @hidden */
  40028. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40029. /**
  40030. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40031. */
  40032. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40033. /**
  40034. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40035. */
  40036. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40037. /**
  40038. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40039. */
  40040. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40041. /** Callback called when a pointer move is detected */
  40042. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40043. /** Callback called when a pointer down is detected */
  40044. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40045. /** Callback called when a pointer up is detected */
  40046. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40047. /** Callback called when a pointer pick is detected */
  40048. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40049. /**
  40050. * 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).
  40051. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40052. */
  40053. onPrePointerObservable: Observable<PointerInfoPre>;
  40054. /**
  40055. * Observable event triggered each time an input event is received from the rendering canvas
  40056. */
  40057. onPointerObservable: Observable<PointerInfo>;
  40058. /**
  40059. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40060. */
  40061. get unTranslatedPointer(): Vector2;
  40062. /**
  40063. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40064. */
  40065. static get DragMovementThreshold(): number;
  40066. static set DragMovementThreshold(value: number);
  40067. /**
  40068. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40069. */
  40070. static get LongPressDelay(): number;
  40071. static set LongPressDelay(value: number);
  40072. /**
  40073. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40074. */
  40075. static get DoubleClickDelay(): number;
  40076. static set DoubleClickDelay(value: number);
  40077. /** If you need to check double click without raising a single click at first click, enable this flag */
  40078. static get ExclusiveDoubleClickMode(): boolean;
  40079. static set ExclusiveDoubleClickMode(value: boolean);
  40080. /** @hidden */
  40081. _mirroredCameraPosition: Nullable<Vector3>;
  40082. /**
  40083. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40084. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40085. */
  40086. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40087. /**
  40088. * Observable event triggered each time an keyboard event is received from the hosting window
  40089. */
  40090. onKeyboardObservable: Observable<KeyboardInfo>;
  40091. private _useRightHandedSystem;
  40092. /**
  40093. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40094. */
  40095. set useRightHandedSystem(value: boolean);
  40096. get useRightHandedSystem(): boolean;
  40097. private _timeAccumulator;
  40098. private _currentStepId;
  40099. private _currentInternalStep;
  40100. /**
  40101. * Sets the step Id used by deterministic lock step
  40102. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40103. * @param newStepId defines the step Id
  40104. */
  40105. setStepId(newStepId: number): void;
  40106. /**
  40107. * Gets the step Id used by deterministic lock step
  40108. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40109. * @returns the step Id
  40110. */
  40111. getStepId(): number;
  40112. /**
  40113. * Gets the internal step used by deterministic lock step
  40114. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40115. * @returns the internal step
  40116. */
  40117. getInternalStep(): number;
  40118. private _fogEnabled;
  40119. /**
  40120. * Gets or sets a boolean indicating if fog is enabled on this scene
  40121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40122. * (Default is true)
  40123. */
  40124. set fogEnabled(value: boolean);
  40125. get fogEnabled(): boolean;
  40126. private _fogMode;
  40127. /**
  40128. * Gets or sets the fog mode to use
  40129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40130. * | mode | value |
  40131. * | --- | --- |
  40132. * | FOGMODE_NONE | 0 |
  40133. * | FOGMODE_EXP | 1 |
  40134. * | FOGMODE_EXP2 | 2 |
  40135. * | FOGMODE_LINEAR | 3 |
  40136. */
  40137. set fogMode(value: number);
  40138. get fogMode(): number;
  40139. /**
  40140. * Gets or sets the fog color to use
  40141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40142. * (Default is Color3(0.2, 0.2, 0.3))
  40143. */
  40144. fogColor: Color3;
  40145. /**
  40146. * Gets or sets the fog density to use
  40147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40148. * (Default is 0.1)
  40149. */
  40150. fogDensity: number;
  40151. /**
  40152. * Gets or sets the fog start distance to use
  40153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40154. * (Default is 0)
  40155. */
  40156. fogStart: number;
  40157. /**
  40158. * Gets or sets the fog end distance to use
  40159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40160. * (Default is 1000)
  40161. */
  40162. fogEnd: number;
  40163. private _shadowsEnabled;
  40164. /**
  40165. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40166. */
  40167. set shadowsEnabled(value: boolean);
  40168. get shadowsEnabled(): boolean;
  40169. private _lightsEnabled;
  40170. /**
  40171. * Gets or sets a boolean indicating if lights are enabled on this scene
  40172. */
  40173. set lightsEnabled(value: boolean);
  40174. get lightsEnabled(): boolean;
  40175. /** All of the active cameras added to this scene. */
  40176. activeCameras: Camera[];
  40177. /** @hidden */
  40178. _activeCamera: Nullable<Camera>;
  40179. /** Gets or sets the current active camera */
  40180. get activeCamera(): Nullable<Camera>;
  40181. set activeCamera(value: Nullable<Camera>);
  40182. private _defaultMaterial;
  40183. /** The default material used on meshes when no material is affected */
  40184. get defaultMaterial(): Material;
  40185. /** The default material used on meshes when no material is affected */
  40186. set defaultMaterial(value: Material);
  40187. private _texturesEnabled;
  40188. /**
  40189. * Gets or sets a boolean indicating if textures are enabled on this scene
  40190. */
  40191. set texturesEnabled(value: boolean);
  40192. get texturesEnabled(): boolean;
  40193. /**
  40194. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40195. */
  40196. physicsEnabled: boolean;
  40197. /**
  40198. * Gets or sets a boolean indicating if particles are enabled on this scene
  40199. */
  40200. particlesEnabled: boolean;
  40201. /**
  40202. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40203. */
  40204. spritesEnabled: boolean;
  40205. private _skeletonsEnabled;
  40206. /**
  40207. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40208. */
  40209. set skeletonsEnabled(value: boolean);
  40210. get skeletonsEnabled(): boolean;
  40211. /**
  40212. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40213. */
  40214. lensFlaresEnabled: boolean;
  40215. /**
  40216. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40218. */
  40219. collisionsEnabled: boolean;
  40220. private _collisionCoordinator;
  40221. /** @hidden */
  40222. get collisionCoordinator(): ICollisionCoordinator;
  40223. /**
  40224. * Defines the gravity applied to this scene (used only for collisions)
  40225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40226. */
  40227. gravity: Vector3;
  40228. /**
  40229. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40230. */
  40231. postProcessesEnabled: boolean;
  40232. /**
  40233. * The list of postprocesses added to the scene
  40234. */
  40235. postProcesses: PostProcess[];
  40236. /**
  40237. * Gets the current postprocess manager
  40238. */
  40239. postProcessManager: PostProcessManager;
  40240. /**
  40241. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40242. */
  40243. renderTargetsEnabled: boolean;
  40244. /**
  40245. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40246. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40247. */
  40248. dumpNextRenderTargets: boolean;
  40249. /**
  40250. * The list of user defined render targets added to the scene
  40251. */
  40252. customRenderTargets: RenderTargetTexture[];
  40253. /**
  40254. * Defines if texture loading must be delayed
  40255. * If true, textures will only be loaded when they need to be rendered
  40256. */
  40257. useDelayedTextureLoading: boolean;
  40258. /**
  40259. * Gets the list of meshes imported to the scene through SceneLoader
  40260. */
  40261. importedMeshesFiles: String[];
  40262. /**
  40263. * Gets or sets a boolean indicating if probes are enabled on this scene
  40264. */
  40265. probesEnabled: boolean;
  40266. /**
  40267. * Gets or sets the current offline provider to use to store scene data
  40268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40269. */
  40270. offlineProvider: IOfflineProvider;
  40271. /**
  40272. * Gets or sets the action manager associated with the scene
  40273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40274. */
  40275. actionManager: AbstractActionManager;
  40276. private _meshesForIntersections;
  40277. /**
  40278. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40279. */
  40280. proceduralTexturesEnabled: boolean;
  40281. private _engine;
  40282. private _totalVertices;
  40283. /** @hidden */
  40284. _activeIndices: PerfCounter;
  40285. /** @hidden */
  40286. _activeParticles: PerfCounter;
  40287. /** @hidden */
  40288. _activeBones: PerfCounter;
  40289. private _animationRatio;
  40290. /** @hidden */
  40291. _animationTimeLast: number;
  40292. /** @hidden */
  40293. _animationTime: number;
  40294. /**
  40295. * Gets or sets a general scale for animation speed
  40296. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40297. */
  40298. animationTimeScale: number;
  40299. /** @hidden */
  40300. _cachedMaterial: Nullable<Material>;
  40301. /** @hidden */
  40302. _cachedEffect: Nullable<Effect>;
  40303. /** @hidden */
  40304. _cachedVisibility: Nullable<number>;
  40305. private _renderId;
  40306. private _frameId;
  40307. private _executeWhenReadyTimeoutId;
  40308. private _intermediateRendering;
  40309. private _viewUpdateFlag;
  40310. private _projectionUpdateFlag;
  40311. /** @hidden */
  40312. _toBeDisposed: Nullable<IDisposable>[];
  40313. private _activeRequests;
  40314. /** @hidden */
  40315. _pendingData: any[];
  40316. private _isDisposed;
  40317. /**
  40318. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40319. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40320. */
  40321. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40322. private _activeMeshes;
  40323. private _processedMaterials;
  40324. private _renderTargets;
  40325. /** @hidden */
  40326. _activeParticleSystems: SmartArray<IParticleSystem>;
  40327. private _activeSkeletons;
  40328. private _softwareSkinnedMeshes;
  40329. private _renderingManager;
  40330. /** @hidden */
  40331. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40332. private _transformMatrix;
  40333. private _sceneUbo;
  40334. /** @hidden */
  40335. _viewMatrix: Matrix;
  40336. private _projectionMatrix;
  40337. /** @hidden */
  40338. _forcedViewPosition: Nullable<Vector3>;
  40339. /** @hidden */
  40340. _frustumPlanes: Plane[];
  40341. /**
  40342. * Gets the list of frustum planes (built from the active camera)
  40343. */
  40344. get frustumPlanes(): Plane[];
  40345. /**
  40346. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40347. * This is useful if there are more lights that the maximum simulteanous authorized
  40348. */
  40349. requireLightSorting: boolean;
  40350. /** @hidden */
  40351. readonly useMaterialMeshMap: boolean;
  40352. /** @hidden */
  40353. readonly useClonedMeshMap: boolean;
  40354. private _externalData;
  40355. private _uid;
  40356. /**
  40357. * @hidden
  40358. * Backing store of defined scene components.
  40359. */
  40360. _components: ISceneComponent[];
  40361. /**
  40362. * @hidden
  40363. * Backing store of defined scene components.
  40364. */
  40365. _serializableComponents: ISceneSerializableComponent[];
  40366. /**
  40367. * List of components to register on the next registration step.
  40368. */
  40369. private _transientComponents;
  40370. /**
  40371. * Registers the transient components if needed.
  40372. */
  40373. private _registerTransientComponents;
  40374. /**
  40375. * @hidden
  40376. * Add a component to the scene.
  40377. * Note that the ccomponent could be registered on th next frame if this is called after
  40378. * the register component stage.
  40379. * @param component Defines the component to add to the scene
  40380. */
  40381. _addComponent(component: ISceneComponent): void;
  40382. /**
  40383. * @hidden
  40384. * Gets a component from the scene.
  40385. * @param name defines the name of the component to retrieve
  40386. * @returns the component or null if not present
  40387. */
  40388. _getComponent(name: string): Nullable<ISceneComponent>;
  40389. /**
  40390. * @hidden
  40391. * Defines the actions happening before camera updates.
  40392. */
  40393. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40394. /**
  40395. * @hidden
  40396. * Defines the actions happening before clear the canvas.
  40397. */
  40398. _beforeClearStage: Stage<SimpleStageAction>;
  40399. /**
  40400. * @hidden
  40401. * Defines the actions when collecting render targets for the frame.
  40402. */
  40403. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40404. /**
  40405. * @hidden
  40406. * Defines the actions happening for one camera in the frame.
  40407. */
  40408. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40409. /**
  40410. * @hidden
  40411. * Defines the actions happening during the per mesh ready checks.
  40412. */
  40413. _isReadyForMeshStage: Stage<MeshStageAction>;
  40414. /**
  40415. * @hidden
  40416. * Defines the actions happening before evaluate active mesh checks.
  40417. */
  40418. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40419. /**
  40420. * @hidden
  40421. * Defines the actions happening during the evaluate sub mesh checks.
  40422. */
  40423. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40424. /**
  40425. * @hidden
  40426. * Defines the actions happening during the active mesh stage.
  40427. */
  40428. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40429. /**
  40430. * @hidden
  40431. * Defines the actions happening during the per camera render target step.
  40432. */
  40433. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40434. /**
  40435. * @hidden
  40436. * Defines the actions happening just before the active camera is drawing.
  40437. */
  40438. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40439. /**
  40440. * @hidden
  40441. * Defines the actions happening just before a render target is drawing.
  40442. */
  40443. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40444. /**
  40445. * @hidden
  40446. * Defines the actions happening just before a rendering group is drawing.
  40447. */
  40448. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40449. /**
  40450. * @hidden
  40451. * Defines the actions happening just before a mesh is drawing.
  40452. */
  40453. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40454. /**
  40455. * @hidden
  40456. * Defines the actions happening just after a mesh has been drawn.
  40457. */
  40458. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40459. /**
  40460. * @hidden
  40461. * Defines the actions happening just after a rendering group has been drawn.
  40462. */
  40463. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40464. /**
  40465. * @hidden
  40466. * Defines the actions happening just after the active camera has been drawn.
  40467. */
  40468. _afterCameraDrawStage: Stage<CameraStageAction>;
  40469. /**
  40470. * @hidden
  40471. * Defines the actions happening just after a render target has been drawn.
  40472. */
  40473. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40474. /**
  40475. * @hidden
  40476. * Defines the actions happening just after rendering all cameras and computing intersections.
  40477. */
  40478. _afterRenderStage: Stage<SimpleStageAction>;
  40479. /**
  40480. * @hidden
  40481. * Defines the actions happening when a pointer move event happens.
  40482. */
  40483. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40484. /**
  40485. * @hidden
  40486. * Defines the actions happening when a pointer down event happens.
  40487. */
  40488. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40489. /**
  40490. * @hidden
  40491. * Defines the actions happening when a pointer up event happens.
  40492. */
  40493. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40494. /**
  40495. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40496. */
  40497. private geometriesByUniqueId;
  40498. /**
  40499. * Creates a new Scene
  40500. * @param engine defines the engine to use to render this scene
  40501. * @param options defines the scene options
  40502. */
  40503. constructor(engine: Engine, options?: SceneOptions);
  40504. /**
  40505. * Gets a string idenfifying the name of the class
  40506. * @returns "Scene" string
  40507. */
  40508. getClassName(): string;
  40509. private _defaultMeshCandidates;
  40510. /**
  40511. * @hidden
  40512. */
  40513. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40514. private _defaultSubMeshCandidates;
  40515. /**
  40516. * @hidden
  40517. */
  40518. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40519. /**
  40520. * Sets the default candidate providers for the scene.
  40521. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40522. * and getCollidingSubMeshCandidates to their default function
  40523. */
  40524. setDefaultCandidateProviders(): void;
  40525. /**
  40526. * Gets the mesh that is currently under the pointer
  40527. */
  40528. get meshUnderPointer(): Nullable<AbstractMesh>;
  40529. /**
  40530. * Gets or sets the current on-screen X position of the pointer
  40531. */
  40532. get pointerX(): number;
  40533. set pointerX(value: number);
  40534. /**
  40535. * Gets or sets the current on-screen Y position of the pointer
  40536. */
  40537. get pointerY(): number;
  40538. set pointerY(value: number);
  40539. /**
  40540. * Gets the cached material (ie. the latest rendered one)
  40541. * @returns the cached material
  40542. */
  40543. getCachedMaterial(): Nullable<Material>;
  40544. /**
  40545. * Gets the cached effect (ie. the latest rendered one)
  40546. * @returns the cached effect
  40547. */
  40548. getCachedEffect(): Nullable<Effect>;
  40549. /**
  40550. * Gets the cached visibility state (ie. the latest rendered one)
  40551. * @returns the cached visibility state
  40552. */
  40553. getCachedVisibility(): Nullable<number>;
  40554. /**
  40555. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40556. * @param material defines the current material
  40557. * @param effect defines the current effect
  40558. * @param visibility defines the current visibility state
  40559. * @returns true if one parameter is not cached
  40560. */
  40561. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40562. /**
  40563. * Gets the engine associated with the scene
  40564. * @returns an Engine
  40565. */
  40566. getEngine(): Engine;
  40567. /**
  40568. * Gets the total number of vertices rendered per frame
  40569. * @returns the total number of vertices rendered per frame
  40570. */
  40571. getTotalVertices(): number;
  40572. /**
  40573. * Gets the performance counter for total vertices
  40574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40575. */
  40576. get totalVerticesPerfCounter(): PerfCounter;
  40577. /**
  40578. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40579. * @returns the total number of active indices rendered per frame
  40580. */
  40581. getActiveIndices(): number;
  40582. /**
  40583. * Gets the performance counter for active indices
  40584. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40585. */
  40586. get totalActiveIndicesPerfCounter(): PerfCounter;
  40587. /**
  40588. * Gets the total number of active particles rendered per frame
  40589. * @returns the total number of active particles rendered per frame
  40590. */
  40591. getActiveParticles(): number;
  40592. /**
  40593. * Gets the performance counter for active particles
  40594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40595. */
  40596. get activeParticlesPerfCounter(): PerfCounter;
  40597. /**
  40598. * Gets the total number of active bones rendered per frame
  40599. * @returns the total number of active bones rendered per frame
  40600. */
  40601. getActiveBones(): number;
  40602. /**
  40603. * Gets the performance counter for active bones
  40604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40605. */
  40606. get activeBonesPerfCounter(): PerfCounter;
  40607. /**
  40608. * Gets the array of active meshes
  40609. * @returns an array of AbstractMesh
  40610. */
  40611. getActiveMeshes(): SmartArray<AbstractMesh>;
  40612. /**
  40613. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40614. * @returns a number
  40615. */
  40616. getAnimationRatio(): number;
  40617. /**
  40618. * Gets an unique Id for the current render phase
  40619. * @returns a number
  40620. */
  40621. getRenderId(): number;
  40622. /**
  40623. * Gets an unique Id for the current frame
  40624. * @returns a number
  40625. */
  40626. getFrameId(): number;
  40627. /** Call this function if you want to manually increment the render Id*/
  40628. incrementRenderId(): void;
  40629. private _createUbo;
  40630. /**
  40631. * Use this method to simulate a pointer move on a mesh
  40632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40635. * @returns the current scene
  40636. */
  40637. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40638. /**
  40639. * Use this method to simulate a pointer down on a mesh
  40640. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40641. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40642. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40643. * @returns the current scene
  40644. */
  40645. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40646. /**
  40647. * Use this method to simulate a pointer up on a mesh
  40648. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40649. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40650. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40651. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40652. * @returns the current scene
  40653. */
  40654. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40655. /**
  40656. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40657. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40658. * @returns true if the pointer was captured
  40659. */
  40660. isPointerCaptured(pointerId?: number): boolean;
  40661. /**
  40662. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40663. * @param attachUp defines if you want to attach events to pointerup
  40664. * @param attachDown defines if you want to attach events to pointerdown
  40665. * @param attachMove defines if you want to attach events to pointermove
  40666. */
  40667. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40668. /** Detaches all event handlers*/
  40669. detachControl(): void;
  40670. /**
  40671. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40672. * Delay loaded resources are not taking in account
  40673. * @return true if all required resources are ready
  40674. */
  40675. isReady(): boolean;
  40676. /** Resets all cached information relative to material (including effect and visibility) */
  40677. resetCachedMaterial(): void;
  40678. /**
  40679. * Registers a function to be called before every frame render
  40680. * @param func defines the function to register
  40681. */
  40682. registerBeforeRender(func: () => void): void;
  40683. /**
  40684. * Unregisters a function called before every frame render
  40685. * @param func defines the function to unregister
  40686. */
  40687. unregisterBeforeRender(func: () => void): void;
  40688. /**
  40689. * Registers a function to be called after every frame render
  40690. * @param func defines the function to register
  40691. */
  40692. registerAfterRender(func: () => void): void;
  40693. /**
  40694. * Unregisters a function called after every frame render
  40695. * @param func defines the function to unregister
  40696. */
  40697. unregisterAfterRender(func: () => void): void;
  40698. private _executeOnceBeforeRender;
  40699. /**
  40700. * The provided function will run before render once and will be disposed afterwards.
  40701. * A timeout delay can be provided so that the function will be executed in N ms.
  40702. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40703. * @param func The function to be executed.
  40704. * @param timeout optional delay in ms
  40705. */
  40706. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40707. /** @hidden */
  40708. _addPendingData(data: any): void;
  40709. /** @hidden */
  40710. _removePendingData(data: any): void;
  40711. /**
  40712. * Returns the number of items waiting to be loaded
  40713. * @returns the number of items waiting to be loaded
  40714. */
  40715. getWaitingItemsCount(): number;
  40716. /**
  40717. * Returns a boolean indicating if the scene is still loading data
  40718. */
  40719. get isLoading(): boolean;
  40720. /**
  40721. * Registers a function to be executed when the scene is ready
  40722. * @param {Function} func - the function to be executed
  40723. */
  40724. executeWhenReady(func: () => void): void;
  40725. /**
  40726. * Returns a promise that resolves when the scene is ready
  40727. * @returns A promise that resolves when the scene is ready
  40728. */
  40729. whenReadyAsync(): Promise<void>;
  40730. /** @hidden */
  40731. _checkIsReady(): void;
  40732. /**
  40733. * Gets all animatable attached to the scene
  40734. */
  40735. get animatables(): Animatable[];
  40736. /**
  40737. * Resets the last animation time frame.
  40738. * Useful to override when animations start running when loading a scene for the first time.
  40739. */
  40740. resetLastAnimationTimeFrame(): void;
  40741. /**
  40742. * Gets the current view matrix
  40743. * @returns a Matrix
  40744. */
  40745. getViewMatrix(): Matrix;
  40746. /**
  40747. * Gets the current projection matrix
  40748. * @returns a Matrix
  40749. */
  40750. getProjectionMatrix(): Matrix;
  40751. /**
  40752. * Gets the current transform matrix
  40753. * @returns a Matrix made of View * Projection
  40754. */
  40755. getTransformMatrix(): Matrix;
  40756. /**
  40757. * Sets the current transform matrix
  40758. * @param viewL defines the View matrix to use
  40759. * @param projectionL defines the Projection matrix to use
  40760. * @param viewR defines the right View matrix to use (if provided)
  40761. * @param projectionR defines the right Projection matrix to use (if provided)
  40762. */
  40763. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40764. /**
  40765. * Gets the uniform buffer used to store scene data
  40766. * @returns a UniformBuffer
  40767. */
  40768. getSceneUniformBuffer(): UniformBuffer;
  40769. /**
  40770. * Gets an unique (relatively to the current scene) Id
  40771. * @returns an unique number for the scene
  40772. */
  40773. getUniqueId(): number;
  40774. /**
  40775. * Add a mesh to the list of scene's meshes
  40776. * @param newMesh defines the mesh to add
  40777. * @param recursive if all child meshes should also be added to the scene
  40778. */
  40779. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40780. /**
  40781. * Remove a mesh for the list of scene's meshes
  40782. * @param toRemove defines the mesh to remove
  40783. * @param recursive if all child meshes should also be removed from the scene
  40784. * @returns the index where the mesh was in the mesh list
  40785. */
  40786. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40787. /**
  40788. * Add a transform node to the list of scene's transform nodes
  40789. * @param newTransformNode defines the transform node to add
  40790. */
  40791. addTransformNode(newTransformNode: TransformNode): void;
  40792. /**
  40793. * Remove a transform node for the list of scene's transform nodes
  40794. * @param toRemove defines the transform node to remove
  40795. * @returns the index where the transform node was in the transform node list
  40796. */
  40797. removeTransformNode(toRemove: TransformNode): number;
  40798. /**
  40799. * Remove a skeleton for the list of scene's skeletons
  40800. * @param toRemove defines the skeleton to remove
  40801. * @returns the index where the skeleton was in the skeleton list
  40802. */
  40803. removeSkeleton(toRemove: Skeleton): number;
  40804. /**
  40805. * Remove a morph target for the list of scene's morph targets
  40806. * @param toRemove defines the morph target to remove
  40807. * @returns the index where the morph target was in the morph target list
  40808. */
  40809. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40810. /**
  40811. * Remove a light for the list of scene's lights
  40812. * @param toRemove defines the light to remove
  40813. * @returns the index where the light was in the light list
  40814. */
  40815. removeLight(toRemove: Light): number;
  40816. /**
  40817. * Remove a camera for the list of scene's cameras
  40818. * @param toRemove defines the camera to remove
  40819. * @returns the index where the camera was in the camera list
  40820. */
  40821. removeCamera(toRemove: Camera): number;
  40822. /**
  40823. * Remove a particle system for the list of scene's particle systems
  40824. * @param toRemove defines the particle system to remove
  40825. * @returns the index where the particle system was in the particle system list
  40826. */
  40827. removeParticleSystem(toRemove: IParticleSystem): number;
  40828. /**
  40829. * Remove a animation for the list of scene's animations
  40830. * @param toRemove defines the animation to remove
  40831. * @returns the index where the animation was in the animation list
  40832. */
  40833. removeAnimation(toRemove: Animation): number;
  40834. /**
  40835. * Will stop the animation of the given target
  40836. * @param target - the target
  40837. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40838. * @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)
  40839. */
  40840. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40841. /**
  40842. * Removes the given animation group from this scene.
  40843. * @param toRemove The animation group to remove
  40844. * @returns The index of the removed animation group
  40845. */
  40846. removeAnimationGroup(toRemove: AnimationGroup): number;
  40847. /**
  40848. * Removes the given multi-material from this scene.
  40849. * @param toRemove The multi-material to remove
  40850. * @returns The index of the removed multi-material
  40851. */
  40852. removeMultiMaterial(toRemove: MultiMaterial): number;
  40853. /**
  40854. * Removes the given material from this scene.
  40855. * @param toRemove The material to remove
  40856. * @returns The index of the removed material
  40857. */
  40858. removeMaterial(toRemove: Material): number;
  40859. /**
  40860. * Removes the given action manager from this scene.
  40861. * @param toRemove The action manager to remove
  40862. * @returns The index of the removed action manager
  40863. */
  40864. removeActionManager(toRemove: AbstractActionManager): number;
  40865. /**
  40866. * Removes the given texture from this scene.
  40867. * @param toRemove The texture to remove
  40868. * @returns The index of the removed texture
  40869. */
  40870. removeTexture(toRemove: BaseTexture): number;
  40871. /**
  40872. * Adds the given light to this scene
  40873. * @param newLight The light to add
  40874. */
  40875. addLight(newLight: Light): void;
  40876. /**
  40877. * Sorts the list list based on light priorities
  40878. */
  40879. sortLightsByPriority(): void;
  40880. /**
  40881. * Adds the given camera to this scene
  40882. * @param newCamera The camera to add
  40883. */
  40884. addCamera(newCamera: Camera): void;
  40885. /**
  40886. * Adds the given skeleton to this scene
  40887. * @param newSkeleton The skeleton to add
  40888. */
  40889. addSkeleton(newSkeleton: Skeleton): void;
  40890. /**
  40891. * Adds the given particle system to this scene
  40892. * @param newParticleSystem The particle system to add
  40893. */
  40894. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40895. /**
  40896. * Adds the given animation to this scene
  40897. * @param newAnimation The animation to add
  40898. */
  40899. addAnimation(newAnimation: Animation): void;
  40900. /**
  40901. * Adds the given animation group to this scene.
  40902. * @param newAnimationGroup The animation group to add
  40903. */
  40904. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40905. /**
  40906. * Adds the given multi-material to this scene
  40907. * @param newMultiMaterial The multi-material to add
  40908. */
  40909. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40910. /**
  40911. * Adds the given material to this scene
  40912. * @param newMaterial The material to add
  40913. */
  40914. addMaterial(newMaterial: Material): void;
  40915. /**
  40916. * Adds the given morph target to this scene
  40917. * @param newMorphTargetManager The morph target to add
  40918. */
  40919. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40920. /**
  40921. * Adds the given geometry to this scene
  40922. * @param newGeometry The geometry to add
  40923. */
  40924. addGeometry(newGeometry: Geometry): void;
  40925. /**
  40926. * Adds the given action manager to this scene
  40927. * @param newActionManager The action manager to add
  40928. */
  40929. addActionManager(newActionManager: AbstractActionManager): void;
  40930. /**
  40931. * Adds the given texture to this scene.
  40932. * @param newTexture The texture to add
  40933. */
  40934. addTexture(newTexture: BaseTexture): void;
  40935. /**
  40936. * Switch active camera
  40937. * @param newCamera defines the new active camera
  40938. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40939. */
  40940. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40941. /**
  40942. * sets the active camera of the scene using its ID
  40943. * @param id defines the camera's ID
  40944. * @return the new active camera or null if none found.
  40945. */
  40946. setActiveCameraByID(id: string): Nullable<Camera>;
  40947. /**
  40948. * sets the active camera of the scene using its name
  40949. * @param name defines the camera's name
  40950. * @returns the new active camera or null if none found.
  40951. */
  40952. setActiveCameraByName(name: string): Nullable<Camera>;
  40953. /**
  40954. * get an animation group using its name
  40955. * @param name defines the material's name
  40956. * @return the animation group or null if none found.
  40957. */
  40958. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40959. /**
  40960. * Get a material using its unique id
  40961. * @param uniqueId defines the material's unique id
  40962. * @return the material or null if none found.
  40963. */
  40964. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40965. /**
  40966. * get a material using its id
  40967. * @param id defines the material's ID
  40968. * @return the material or null if none found.
  40969. */
  40970. getMaterialByID(id: string): Nullable<Material>;
  40971. /**
  40972. * Gets a the last added material using a given id
  40973. * @param id defines the material's ID
  40974. * @return the last material with the given id or null if none found.
  40975. */
  40976. getLastMaterialByID(id: string): Nullable<Material>;
  40977. /**
  40978. * Gets a material using its name
  40979. * @param name defines the material's name
  40980. * @return the material or null if none found.
  40981. */
  40982. getMaterialByName(name: string): Nullable<Material>;
  40983. /**
  40984. * Get a texture using its unique id
  40985. * @param uniqueId defines the texture's unique id
  40986. * @return the texture or null if none found.
  40987. */
  40988. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40989. /**
  40990. * Gets a camera using its id
  40991. * @param id defines the id to look for
  40992. * @returns the camera or null if not found
  40993. */
  40994. getCameraByID(id: string): Nullable<Camera>;
  40995. /**
  40996. * Gets a camera using its unique id
  40997. * @param uniqueId defines the unique id to look for
  40998. * @returns the camera or null if not found
  40999. */
  41000. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41001. /**
  41002. * Gets a camera using its name
  41003. * @param name defines the camera's name
  41004. * @return the camera or null if none found.
  41005. */
  41006. getCameraByName(name: string): Nullable<Camera>;
  41007. /**
  41008. * Gets a bone using its id
  41009. * @param id defines the bone's id
  41010. * @return the bone or null if not found
  41011. */
  41012. getBoneByID(id: string): Nullable<Bone>;
  41013. /**
  41014. * Gets a bone using its id
  41015. * @param name defines the bone's name
  41016. * @return the bone or null if not found
  41017. */
  41018. getBoneByName(name: string): Nullable<Bone>;
  41019. /**
  41020. * Gets a light node using its name
  41021. * @param name defines the the light's name
  41022. * @return the light or null if none found.
  41023. */
  41024. getLightByName(name: string): Nullable<Light>;
  41025. /**
  41026. * Gets a light node using its id
  41027. * @param id defines the light's id
  41028. * @return the light or null if none found.
  41029. */
  41030. getLightByID(id: string): Nullable<Light>;
  41031. /**
  41032. * Gets a light node using its scene-generated unique ID
  41033. * @param uniqueId defines the light's unique id
  41034. * @return the light or null if none found.
  41035. */
  41036. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41037. /**
  41038. * Gets a particle system by id
  41039. * @param id defines the particle system id
  41040. * @return the corresponding system or null if none found
  41041. */
  41042. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41043. /**
  41044. * Gets a geometry using its ID
  41045. * @param id defines the geometry's id
  41046. * @return the geometry or null if none found.
  41047. */
  41048. getGeometryByID(id: string): Nullable<Geometry>;
  41049. private _getGeometryByUniqueID;
  41050. /**
  41051. * Add a new geometry to this scene
  41052. * @param geometry defines the geometry to be added to the scene.
  41053. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41054. * @return a boolean defining if the geometry was added or not
  41055. */
  41056. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41057. /**
  41058. * Removes an existing geometry
  41059. * @param geometry defines the geometry to be removed from the scene
  41060. * @return a boolean defining if the geometry was removed or not
  41061. */
  41062. removeGeometry(geometry: Geometry): boolean;
  41063. /**
  41064. * Gets the list of geometries attached to the scene
  41065. * @returns an array of Geometry
  41066. */
  41067. getGeometries(): Geometry[];
  41068. /**
  41069. * Gets the first added mesh found of a given ID
  41070. * @param id defines the id to search for
  41071. * @return the mesh found or null if not found at all
  41072. */
  41073. getMeshByID(id: string): Nullable<AbstractMesh>;
  41074. /**
  41075. * Gets a list of meshes using their id
  41076. * @param id defines the id to search for
  41077. * @returns a list of meshes
  41078. */
  41079. getMeshesByID(id: string): Array<AbstractMesh>;
  41080. /**
  41081. * Gets the first added transform node found of a given ID
  41082. * @param id defines the id to search for
  41083. * @return the found transform node or null if not found at all.
  41084. */
  41085. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41086. /**
  41087. * Gets a transform node with its auto-generated unique id
  41088. * @param uniqueId efines the unique id to search for
  41089. * @return the found transform node or null if not found at all.
  41090. */
  41091. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41092. /**
  41093. * Gets a list of transform nodes using their id
  41094. * @param id defines the id to search for
  41095. * @returns a list of transform nodes
  41096. */
  41097. getTransformNodesByID(id: string): Array<TransformNode>;
  41098. /**
  41099. * Gets a mesh with its auto-generated unique id
  41100. * @param uniqueId defines the unique id to search for
  41101. * @return the found mesh or null if not found at all.
  41102. */
  41103. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41104. /**
  41105. * Gets a the last added mesh using a given id
  41106. * @param id defines the id to search for
  41107. * @return the found mesh or null if not found at all.
  41108. */
  41109. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41110. /**
  41111. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41112. * @param id defines the id to search for
  41113. * @return the found node or null if not found at all
  41114. */
  41115. getLastEntryByID(id: string): Nullable<Node>;
  41116. /**
  41117. * Gets a node (Mesh, Camera, Light) using a given id
  41118. * @param id defines the id to search for
  41119. * @return the found node or null if not found at all
  41120. */
  41121. getNodeByID(id: string): Nullable<Node>;
  41122. /**
  41123. * Gets a node (Mesh, Camera, Light) using a given name
  41124. * @param name defines the name to search for
  41125. * @return the found node or null if not found at all.
  41126. */
  41127. getNodeByName(name: string): Nullable<Node>;
  41128. /**
  41129. * Gets a mesh using a given name
  41130. * @param name defines the name to search for
  41131. * @return the found mesh or null if not found at all.
  41132. */
  41133. getMeshByName(name: string): Nullable<AbstractMesh>;
  41134. /**
  41135. * Gets a transform node using a given name
  41136. * @param name defines the name to search for
  41137. * @return the found transform node or null if not found at all.
  41138. */
  41139. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41140. /**
  41141. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41142. * @param id defines the id to search for
  41143. * @return the found skeleton or null if not found at all.
  41144. */
  41145. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41146. /**
  41147. * Gets a skeleton using a given auto generated unique id
  41148. * @param uniqueId defines the unique id to search for
  41149. * @return the found skeleton or null if not found at all.
  41150. */
  41151. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41152. /**
  41153. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41154. * @param id defines the id to search for
  41155. * @return the found skeleton or null if not found at all.
  41156. */
  41157. getSkeletonById(id: string): Nullable<Skeleton>;
  41158. /**
  41159. * Gets a skeleton using a given name
  41160. * @param name defines the name to search for
  41161. * @return the found skeleton or null if not found at all.
  41162. */
  41163. getSkeletonByName(name: string): Nullable<Skeleton>;
  41164. /**
  41165. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41166. * @param id defines the id to search for
  41167. * @return the found morph target manager or null if not found at all.
  41168. */
  41169. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41170. /**
  41171. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41172. * @param id defines the id to search for
  41173. * @return the found morph target or null if not found at all.
  41174. */
  41175. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41176. /**
  41177. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41178. * @param name defines the name to search for
  41179. * @return the found morph target or null if not found at all.
  41180. */
  41181. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41182. /**
  41183. * Gets a boolean indicating if the given mesh is active
  41184. * @param mesh defines the mesh to look for
  41185. * @returns true if the mesh is in the active list
  41186. */
  41187. isActiveMesh(mesh: AbstractMesh): boolean;
  41188. /**
  41189. * Return a unique id as a string which can serve as an identifier for the scene
  41190. */
  41191. get uid(): string;
  41192. /**
  41193. * Add an externaly attached data from its key.
  41194. * This method call will fail and return false, if such key already exists.
  41195. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41196. * @param key the unique key that identifies the data
  41197. * @param data the data object to associate to the key for this Engine instance
  41198. * @return true if no such key were already present and the data was added successfully, false otherwise
  41199. */
  41200. addExternalData<T>(key: string, data: T): boolean;
  41201. /**
  41202. * Get an externaly attached data from its key
  41203. * @param key the unique key that identifies the data
  41204. * @return the associated data, if present (can be null), or undefined if not present
  41205. */
  41206. getExternalData<T>(key: string): Nullable<T>;
  41207. /**
  41208. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41209. * @param key the unique key that identifies the data
  41210. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41211. * @return the associated data, can be null if the factory returned null.
  41212. */
  41213. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41214. /**
  41215. * Remove an externaly attached data from the Engine instance
  41216. * @param key the unique key that identifies the data
  41217. * @return true if the data was successfully removed, false if it doesn't exist
  41218. */
  41219. removeExternalData(key: string): boolean;
  41220. private _evaluateSubMesh;
  41221. /**
  41222. * Clear the processed materials smart array preventing retention point in material dispose.
  41223. */
  41224. freeProcessedMaterials(): void;
  41225. private _preventFreeActiveMeshesAndRenderingGroups;
  41226. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41227. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41228. * when disposing several meshes in a row or a hierarchy of meshes.
  41229. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41230. */
  41231. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41232. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41233. /**
  41234. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41235. */
  41236. freeActiveMeshes(): void;
  41237. /**
  41238. * Clear the info related to rendering groups preventing retention points during dispose.
  41239. */
  41240. freeRenderingGroups(): void;
  41241. /** @hidden */
  41242. _isInIntermediateRendering(): boolean;
  41243. /**
  41244. * Lambda returning the list of potentially active meshes.
  41245. */
  41246. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41247. /**
  41248. * Lambda returning the list of potentially active sub meshes.
  41249. */
  41250. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41251. /**
  41252. * Lambda returning the list of potentially intersecting sub meshes.
  41253. */
  41254. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41255. /**
  41256. * Lambda returning the list of potentially colliding sub meshes.
  41257. */
  41258. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41259. private _activeMeshesFrozen;
  41260. private _skipEvaluateActiveMeshesCompletely;
  41261. /**
  41262. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41263. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41264. * @returns the current scene
  41265. */
  41266. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41267. /**
  41268. * Use this function to restart evaluating active meshes on every frame
  41269. * @returns the current scene
  41270. */
  41271. unfreezeActiveMeshes(): Scene;
  41272. private _evaluateActiveMeshes;
  41273. private _activeMesh;
  41274. /**
  41275. * Update the transform matrix to update from the current active camera
  41276. * @param force defines a boolean used to force the update even if cache is up to date
  41277. */
  41278. updateTransformMatrix(force?: boolean): void;
  41279. private _bindFrameBuffer;
  41280. /** @hidden */
  41281. _allowPostProcessClearColor: boolean;
  41282. /** @hidden */
  41283. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41284. private _processSubCameras;
  41285. private _checkIntersections;
  41286. /** @hidden */
  41287. _advancePhysicsEngineStep(step: number): void;
  41288. /**
  41289. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41290. */
  41291. getDeterministicFrameTime: () => number;
  41292. /** @hidden */
  41293. _animate(): void;
  41294. /** Execute all animations (for a frame) */
  41295. animate(): void;
  41296. /**
  41297. * Render the scene
  41298. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41299. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41300. */
  41301. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41302. /**
  41303. * Freeze all materials
  41304. * A frozen material will not be updatable but should be faster to render
  41305. */
  41306. freezeMaterials(): void;
  41307. /**
  41308. * Unfreeze all materials
  41309. * A frozen material will not be updatable but should be faster to render
  41310. */
  41311. unfreezeMaterials(): void;
  41312. /**
  41313. * Releases all held ressources
  41314. */
  41315. dispose(): void;
  41316. /**
  41317. * Gets if the scene is already disposed
  41318. */
  41319. get isDisposed(): boolean;
  41320. /**
  41321. * Call this function to reduce memory footprint of the scene.
  41322. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41323. */
  41324. clearCachedVertexData(): void;
  41325. /**
  41326. * This function will remove the local cached buffer data from texture.
  41327. * It will save memory but will prevent the texture from being rebuilt
  41328. */
  41329. cleanCachedTextureBuffer(): void;
  41330. /**
  41331. * Get the world extend vectors with an optional filter
  41332. *
  41333. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41334. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41335. */
  41336. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41337. min: Vector3;
  41338. max: Vector3;
  41339. };
  41340. /**
  41341. * Creates a ray that can be used to pick in the scene
  41342. * @param x defines the x coordinate of the origin (on-screen)
  41343. * @param y defines the y coordinate of the origin (on-screen)
  41344. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41345. * @param camera defines the camera to use for the picking
  41346. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41347. * @returns a Ray
  41348. */
  41349. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41350. /**
  41351. * Creates a ray that can be used to pick in the scene
  41352. * @param x defines the x coordinate of the origin (on-screen)
  41353. * @param y defines the y coordinate of the origin (on-screen)
  41354. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41355. * @param result defines the ray where to store the picking ray
  41356. * @param camera defines the camera to use for the picking
  41357. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41358. * @returns the current scene
  41359. */
  41360. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41361. /**
  41362. * Creates a ray that can be used to pick in the scene
  41363. * @param x defines the x coordinate of the origin (on-screen)
  41364. * @param y defines the y coordinate of the origin (on-screen)
  41365. * @param camera defines the camera to use for the picking
  41366. * @returns a Ray
  41367. */
  41368. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41369. /**
  41370. * Creates a ray that can be used to pick in the scene
  41371. * @param x defines the x coordinate of the origin (on-screen)
  41372. * @param y defines the y coordinate of the origin (on-screen)
  41373. * @param result defines the ray where to store the picking ray
  41374. * @param camera defines the camera to use for the picking
  41375. * @returns the current scene
  41376. */
  41377. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41378. /** Launch a ray to try to pick a mesh in the scene
  41379. * @param x position on screen
  41380. * @param y position on screen
  41381. * @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
  41382. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41383. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41385. * @returns a PickingInfo
  41386. */
  41387. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41388. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41389. * @param x position on screen
  41390. * @param y position on screen
  41391. * @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
  41392. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41393. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41394. * @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)
  41395. */
  41396. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41397. /** Use the given ray to pick a mesh in the scene
  41398. * @param ray The ray to use to pick meshes
  41399. * @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
  41400. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41402. * @returns a PickingInfo
  41403. */
  41404. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41405. /**
  41406. * Launch a ray to try to pick a mesh in the scene
  41407. * @param x X position on screen
  41408. * @param y Y position on screen
  41409. * @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
  41410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41412. * @returns an array of PickingInfo
  41413. */
  41414. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41415. /**
  41416. * Launch a ray to try to pick a mesh in the scene
  41417. * @param ray Ray to use
  41418. * @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
  41419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41420. * @returns an array of PickingInfo
  41421. */
  41422. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41423. /**
  41424. * Force the value of meshUnderPointer
  41425. * @param mesh defines the mesh to use
  41426. */
  41427. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41428. /**
  41429. * Gets the mesh under the pointer
  41430. * @returns a Mesh or null if no mesh is under the pointer
  41431. */
  41432. getPointerOverMesh(): Nullable<AbstractMesh>;
  41433. /** @hidden */
  41434. _rebuildGeometries(): void;
  41435. /** @hidden */
  41436. _rebuildTextures(): void;
  41437. private _getByTags;
  41438. /**
  41439. * Get a list of meshes by tags
  41440. * @param tagsQuery defines the tags query to use
  41441. * @param forEach defines a predicate used to filter results
  41442. * @returns an array of Mesh
  41443. */
  41444. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41445. /**
  41446. * Get a list of cameras by tags
  41447. * @param tagsQuery defines the tags query to use
  41448. * @param forEach defines a predicate used to filter results
  41449. * @returns an array of Camera
  41450. */
  41451. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41452. /**
  41453. * Get a list of lights by tags
  41454. * @param tagsQuery defines the tags query to use
  41455. * @param forEach defines a predicate used to filter results
  41456. * @returns an array of Light
  41457. */
  41458. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41459. /**
  41460. * Get a list of materials by tags
  41461. * @param tagsQuery defines the tags query to use
  41462. * @param forEach defines a predicate used to filter results
  41463. * @returns an array of Material
  41464. */
  41465. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41466. /**
  41467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41468. * This allowed control for front to back rendering or reversly depending of the special needs.
  41469. *
  41470. * @param renderingGroupId The rendering group id corresponding to its index
  41471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41474. */
  41475. 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;
  41476. /**
  41477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41478. *
  41479. * @param renderingGroupId The rendering group id corresponding to its index
  41480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41481. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41482. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41483. */
  41484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41485. /**
  41486. * Gets the current auto clear configuration for one rendering group of the rendering
  41487. * manager.
  41488. * @param index the rendering group index to get the information for
  41489. * @returns The auto clear setup for the requested rendering group
  41490. */
  41491. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41492. private _blockMaterialDirtyMechanism;
  41493. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41494. get blockMaterialDirtyMechanism(): boolean;
  41495. set blockMaterialDirtyMechanism(value: boolean);
  41496. /**
  41497. * Will flag all materials as dirty to trigger new shader compilation
  41498. * @param flag defines the flag used to specify which material part must be marked as dirty
  41499. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41500. */
  41501. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41502. /** @hidden */
  41503. _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;
  41504. /** @hidden */
  41505. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41506. /** @hidden */
  41507. _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;
  41508. /** @hidden */
  41509. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41510. /** @hidden */
  41511. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41512. /** @hidden */
  41513. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41514. }
  41515. }
  41516. declare module "babylonjs/assetContainer" {
  41517. import { AbstractScene } from "babylonjs/abstractScene";
  41518. import { Scene } from "babylonjs/scene";
  41519. import { Mesh } from "babylonjs/Meshes/mesh";
  41520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41521. import { Skeleton } from "babylonjs/Bones/skeleton";
  41522. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41523. import { Animatable } from "babylonjs/Animations/animatable";
  41524. import { Nullable } from "babylonjs/types";
  41525. import { Node } from "babylonjs/node";
  41526. /**
  41527. * Set of assets to keep when moving a scene into an asset container.
  41528. */
  41529. export class KeepAssets extends AbstractScene {
  41530. }
  41531. /**
  41532. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41533. */
  41534. export class InstantiatedEntries {
  41535. /**
  41536. * List of new root nodes (eg. nodes with no parent)
  41537. */
  41538. rootNodes: TransformNode[];
  41539. /**
  41540. * List of new skeletons
  41541. */
  41542. skeletons: Skeleton[];
  41543. /**
  41544. * List of new animation groups
  41545. */
  41546. animationGroups: AnimationGroup[];
  41547. }
  41548. /**
  41549. * Container with a set of assets that can be added or removed from a scene.
  41550. */
  41551. export class AssetContainer extends AbstractScene {
  41552. private _wasAddedToScene;
  41553. /**
  41554. * The scene the AssetContainer belongs to.
  41555. */
  41556. scene: Scene;
  41557. /**
  41558. * Instantiates an AssetContainer.
  41559. * @param scene The scene the AssetContainer belongs to.
  41560. */
  41561. constructor(scene: Scene);
  41562. /**
  41563. * Instantiate or clone all meshes and add the new ones to the scene.
  41564. * Skeletons and animation groups will all be cloned
  41565. * @param nameFunction defines an optional function used to get new names for clones
  41566. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41567. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41568. */
  41569. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41570. /**
  41571. * Adds all the assets from the container to the scene.
  41572. */
  41573. addAllToScene(): void;
  41574. /**
  41575. * Removes all the assets in the container from the scene
  41576. */
  41577. removeAllFromScene(): void;
  41578. /**
  41579. * Disposes all the assets in the container
  41580. */
  41581. dispose(): void;
  41582. private _moveAssets;
  41583. /**
  41584. * Removes all the assets contained in the scene and adds them to the container.
  41585. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41586. */
  41587. moveAllFromScene(keepAssets?: KeepAssets): void;
  41588. /**
  41589. * 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.
  41590. * @returns the root mesh
  41591. */
  41592. createRootMesh(): Mesh;
  41593. /**
  41594. * Merge animations (direct and animation groups) from this asset container into a scene
  41595. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41596. * @param animatables set of animatables to retarget to a node from the scene
  41597. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41598. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41599. */
  41600. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41601. }
  41602. }
  41603. declare module "babylonjs/abstractScene" {
  41604. import { Scene } from "babylonjs/scene";
  41605. import { Nullable } from "babylonjs/types";
  41606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41607. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41608. import { Geometry } from "babylonjs/Meshes/geometry";
  41609. import { Skeleton } from "babylonjs/Bones/skeleton";
  41610. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41611. import { AssetContainer } from "babylonjs/assetContainer";
  41612. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41613. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41615. import { Material } from "babylonjs/Materials/material";
  41616. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41618. import { Camera } from "babylonjs/Cameras/camera";
  41619. import { Light } from "babylonjs/Lights/light";
  41620. import { Node } from "babylonjs/node";
  41621. import { Animation } from "babylonjs/Animations/animation";
  41622. /**
  41623. * Defines how the parser contract is defined.
  41624. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41625. */
  41626. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41627. /**
  41628. * Defines how the individual parser contract is defined.
  41629. * These parser can parse an individual asset
  41630. */
  41631. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41632. /**
  41633. * Base class of the scene acting as a container for the different elements composing a scene.
  41634. * This class is dynamically extended by the different components of the scene increasing
  41635. * flexibility and reducing coupling
  41636. */
  41637. export abstract class AbstractScene {
  41638. /**
  41639. * Stores the list of available parsers in the application.
  41640. */
  41641. private static _BabylonFileParsers;
  41642. /**
  41643. * Stores the list of available individual parsers in the application.
  41644. */
  41645. private static _IndividualBabylonFileParsers;
  41646. /**
  41647. * Adds a parser in the list of available ones
  41648. * @param name Defines the name of the parser
  41649. * @param parser Defines the parser to add
  41650. */
  41651. static AddParser(name: string, parser: BabylonFileParser): void;
  41652. /**
  41653. * Gets a general parser from the list of avaialble ones
  41654. * @param name Defines the name of the parser
  41655. * @returns the requested parser or null
  41656. */
  41657. static GetParser(name: string): Nullable<BabylonFileParser>;
  41658. /**
  41659. * Adds n individual parser in the list of available ones
  41660. * @param name Defines the name of the parser
  41661. * @param parser Defines the parser to add
  41662. */
  41663. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41664. /**
  41665. * Gets an individual parser from the list of avaialble ones
  41666. * @param name Defines the name of the parser
  41667. * @returns the requested parser or null
  41668. */
  41669. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41670. /**
  41671. * Parser json data and populate both a scene and its associated container object
  41672. * @param jsonData Defines the data to parse
  41673. * @param scene Defines the scene to parse the data for
  41674. * @param container Defines the container attached to the parsing sequence
  41675. * @param rootUrl Defines the root url of the data
  41676. */
  41677. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41678. /**
  41679. * Gets the list of root nodes (ie. nodes with no parent)
  41680. */
  41681. rootNodes: Node[];
  41682. /** All of the cameras added to this scene
  41683. * @see http://doc.babylonjs.com/babylon101/cameras
  41684. */
  41685. cameras: Camera[];
  41686. /**
  41687. * All of the lights added to this scene
  41688. * @see http://doc.babylonjs.com/babylon101/lights
  41689. */
  41690. lights: Light[];
  41691. /**
  41692. * All of the (abstract) meshes added to this scene
  41693. */
  41694. meshes: AbstractMesh[];
  41695. /**
  41696. * The list of skeletons added to the scene
  41697. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41698. */
  41699. skeletons: Skeleton[];
  41700. /**
  41701. * All of the particle systems added to this scene
  41702. * @see http://doc.babylonjs.com/babylon101/particles
  41703. */
  41704. particleSystems: IParticleSystem[];
  41705. /**
  41706. * Gets a list of Animations associated with the scene
  41707. */
  41708. animations: Animation[];
  41709. /**
  41710. * All of the animation groups added to this scene
  41711. * @see http://doc.babylonjs.com/how_to/group
  41712. */
  41713. animationGroups: AnimationGroup[];
  41714. /**
  41715. * All of the multi-materials added to this scene
  41716. * @see http://doc.babylonjs.com/how_to/multi_materials
  41717. */
  41718. multiMaterials: MultiMaterial[];
  41719. /**
  41720. * All of the materials added to this scene
  41721. * In the context of a Scene, it is not supposed to be modified manually.
  41722. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41723. * Note also that the order of the Material within the array is not significant and might change.
  41724. * @see http://doc.babylonjs.com/babylon101/materials
  41725. */
  41726. materials: Material[];
  41727. /**
  41728. * The list of morph target managers added to the scene
  41729. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41730. */
  41731. morphTargetManagers: MorphTargetManager[];
  41732. /**
  41733. * The list of geometries used in the scene.
  41734. */
  41735. geometries: Geometry[];
  41736. /**
  41737. * All of the tranform nodes added to this scene
  41738. * In the context of a Scene, it is not supposed to be modified manually.
  41739. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41740. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41741. * @see http://doc.babylonjs.com/how_to/transformnode
  41742. */
  41743. transformNodes: TransformNode[];
  41744. /**
  41745. * ActionManagers available on the scene.
  41746. */
  41747. actionManagers: AbstractActionManager[];
  41748. /**
  41749. * Textures to keep.
  41750. */
  41751. textures: BaseTexture[];
  41752. /**
  41753. * Environment texture for the scene
  41754. */
  41755. environmentTexture: Nullable<BaseTexture>;
  41756. /**
  41757. * @returns all meshes, lights, cameras, transformNodes and bones
  41758. */
  41759. getNodes(): Array<Node>;
  41760. }
  41761. }
  41762. declare module "babylonjs/Audio/sound" {
  41763. import { Observable } from "babylonjs/Misc/observable";
  41764. import { Vector3 } from "babylonjs/Maths/math.vector";
  41765. import { Nullable } from "babylonjs/types";
  41766. import { Scene } from "babylonjs/scene";
  41767. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41768. /**
  41769. * Interface used to define options for Sound class
  41770. */
  41771. export interface ISoundOptions {
  41772. /**
  41773. * Does the sound autoplay once loaded.
  41774. */
  41775. autoplay?: boolean;
  41776. /**
  41777. * Does the sound loop after it finishes playing once.
  41778. */
  41779. loop?: boolean;
  41780. /**
  41781. * Sound's volume
  41782. */
  41783. volume?: number;
  41784. /**
  41785. * Is it a spatial sound?
  41786. */
  41787. spatialSound?: boolean;
  41788. /**
  41789. * Maximum distance to hear that sound
  41790. */
  41791. maxDistance?: number;
  41792. /**
  41793. * Uses user defined attenuation function
  41794. */
  41795. useCustomAttenuation?: boolean;
  41796. /**
  41797. * Define the roll off factor of spatial sounds.
  41798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41799. */
  41800. rolloffFactor?: number;
  41801. /**
  41802. * Define the reference distance the sound should be heard perfectly.
  41803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41804. */
  41805. refDistance?: number;
  41806. /**
  41807. * Define the distance attenuation model the sound will follow.
  41808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41809. */
  41810. distanceModel?: string;
  41811. /**
  41812. * Defines the playback speed (1 by default)
  41813. */
  41814. playbackRate?: number;
  41815. /**
  41816. * Defines if the sound is from a streaming source
  41817. */
  41818. streaming?: boolean;
  41819. /**
  41820. * Defines an optional length (in seconds) inside the sound file
  41821. */
  41822. length?: number;
  41823. /**
  41824. * Defines an optional offset (in seconds) inside the sound file
  41825. */
  41826. offset?: number;
  41827. /**
  41828. * If true, URLs will not be required to state the audio file codec to use.
  41829. */
  41830. skipCodecCheck?: boolean;
  41831. }
  41832. /**
  41833. * Defines a sound that can be played in the application.
  41834. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41836. */
  41837. export class Sound {
  41838. /**
  41839. * The name of the sound in the scene.
  41840. */
  41841. name: string;
  41842. /**
  41843. * Does the sound autoplay once loaded.
  41844. */
  41845. autoplay: boolean;
  41846. /**
  41847. * Does the sound loop after it finishes playing once.
  41848. */
  41849. loop: boolean;
  41850. /**
  41851. * Does the sound use a custom attenuation curve to simulate the falloff
  41852. * happening when the source gets further away from the camera.
  41853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41854. */
  41855. useCustomAttenuation: boolean;
  41856. /**
  41857. * The sound track id this sound belongs to.
  41858. */
  41859. soundTrackId: number;
  41860. /**
  41861. * Is this sound currently played.
  41862. */
  41863. isPlaying: boolean;
  41864. /**
  41865. * Is this sound currently paused.
  41866. */
  41867. isPaused: boolean;
  41868. /**
  41869. * Does this sound enables spatial sound.
  41870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41871. */
  41872. spatialSound: boolean;
  41873. /**
  41874. * Define the reference distance the sound should be heard perfectly.
  41875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41876. */
  41877. refDistance: number;
  41878. /**
  41879. * Define the roll off factor of spatial sounds.
  41880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41881. */
  41882. rolloffFactor: number;
  41883. /**
  41884. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41886. */
  41887. maxDistance: number;
  41888. /**
  41889. * Define the distance attenuation model the sound will follow.
  41890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41891. */
  41892. distanceModel: string;
  41893. /**
  41894. * @hidden
  41895. * Back Compat
  41896. **/
  41897. onended: () => any;
  41898. /**
  41899. * Gets or sets an object used to store user defined information for the sound.
  41900. */
  41901. metadata: any;
  41902. /**
  41903. * Observable event when the current playing sound finishes.
  41904. */
  41905. onEndedObservable: Observable<Sound>;
  41906. private _panningModel;
  41907. private _playbackRate;
  41908. private _streaming;
  41909. private _startTime;
  41910. private _startOffset;
  41911. private _position;
  41912. /** @hidden */
  41913. _positionInEmitterSpace: boolean;
  41914. private _localDirection;
  41915. private _volume;
  41916. private _isReadyToPlay;
  41917. private _isDirectional;
  41918. private _readyToPlayCallback;
  41919. private _audioBuffer;
  41920. private _soundSource;
  41921. private _streamingSource;
  41922. private _soundPanner;
  41923. private _soundGain;
  41924. private _inputAudioNode;
  41925. private _outputAudioNode;
  41926. private _coneInnerAngle;
  41927. private _coneOuterAngle;
  41928. private _coneOuterGain;
  41929. private _scene;
  41930. private _connectedTransformNode;
  41931. private _customAttenuationFunction;
  41932. private _registerFunc;
  41933. private _isOutputConnected;
  41934. private _htmlAudioElement;
  41935. private _urlType;
  41936. private _length?;
  41937. private _offset?;
  41938. /** @hidden */
  41939. static _SceneComponentInitialization: (scene: Scene) => void;
  41940. /**
  41941. * Create a sound and attach it to a scene
  41942. * @param name Name of your sound
  41943. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41944. * @param scene defines the scene the sound belongs to
  41945. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41946. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41947. */
  41948. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41949. /**
  41950. * Release the sound and its associated resources
  41951. */
  41952. dispose(): void;
  41953. /**
  41954. * Gets if the sounds is ready to be played or not.
  41955. * @returns true if ready, otherwise false
  41956. */
  41957. isReady(): boolean;
  41958. private _soundLoaded;
  41959. /**
  41960. * Sets the data of the sound from an audiobuffer
  41961. * @param audioBuffer The audioBuffer containing the data
  41962. */
  41963. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41964. /**
  41965. * Updates the current sounds options such as maxdistance, loop...
  41966. * @param options A JSON object containing values named as the object properties
  41967. */
  41968. updateOptions(options: ISoundOptions): void;
  41969. private _createSpatialParameters;
  41970. private _updateSpatialParameters;
  41971. /**
  41972. * Switch the panning model to HRTF:
  41973. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41975. */
  41976. switchPanningModelToHRTF(): void;
  41977. /**
  41978. * Switch the panning model to Equal Power:
  41979. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41981. */
  41982. switchPanningModelToEqualPower(): void;
  41983. private _switchPanningModel;
  41984. /**
  41985. * Connect this sound to a sound track audio node like gain...
  41986. * @param soundTrackAudioNode the sound track audio node to connect to
  41987. */
  41988. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41989. /**
  41990. * Transform this sound into a directional source
  41991. * @param coneInnerAngle Size of the inner cone in degree
  41992. * @param coneOuterAngle Size of the outer cone in degree
  41993. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41994. */
  41995. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41996. /**
  41997. * Gets or sets the inner angle for the directional cone.
  41998. */
  41999. get directionalConeInnerAngle(): number;
  42000. /**
  42001. * Gets or sets the inner angle for the directional cone.
  42002. */
  42003. set directionalConeInnerAngle(value: number);
  42004. /**
  42005. * Gets or sets the outer angle for the directional cone.
  42006. */
  42007. get directionalConeOuterAngle(): number;
  42008. /**
  42009. * Gets or sets the outer angle for the directional cone.
  42010. */
  42011. set directionalConeOuterAngle(value: number);
  42012. /**
  42013. * Sets the position of the emitter if spatial sound is enabled
  42014. * @param newPosition Defines the new posisiton
  42015. */
  42016. setPosition(newPosition: Vector3): void;
  42017. /**
  42018. * Sets the local direction of the emitter if spatial sound is enabled
  42019. * @param newLocalDirection Defines the new local direction
  42020. */
  42021. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42022. private _updateDirection;
  42023. /** @hidden */
  42024. updateDistanceFromListener(): void;
  42025. /**
  42026. * Sets a new custom attenuation function for the sound.
  42027. * @param callback Defines the function used for the attenuation
  42028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42029. */
  42030. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42031. /**
  42032. * Play the sound
  42033. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42034. * @param offset (optional) Start the sound at a specific time in seconds
  42035. * @param length (optional) Sound duration (in seconds)
  42036. */
  42037. play(time?: number, offset?: number, length?: number): void;
  42038. private _onended;
  42039. /**
  42040. * Stop the sound
  42041. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42042. */
  42043. stop(time?: number): void;
  42044. /**
  42045. * Put the sound in pause
  42046. */
  42047. pause(): void;
  42048. /**
  42049. * Sets a dedicated volume for this sounds
  42050. * @param newVolume Define the new volume of the sound
  42051. * @param time Define time for gradual change to new volume
  42052. */
  42053. setVolume(newVolume: number, time?: number): void;
  42054. /**
  42055. * Set the sound play back rate
  42056. * @param newPlaybackRate Define the playback rate the sound should be played at
  42057. */
  42058. setPlaybackRate(newPlaybackRate: number): void;
  42059. /**
  42060. * Gets the volume of the sound.
  42061. * @returns the volume of the sound
  42062. */
  42063. getVolume(): number;
  42064. /**
  42065. * Attach the sound to a dedicated mesh
  42066. * @param transformNode The transform node to connect the sound with
  42067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42068. */
  42069. attachToMesh(transformNode: TransformNode): void;
  42070. /**
  42071. * Detach the sound from the previously attached mesh
  42072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42073. */
  42074. detachFromMesh(): void;
  42075. private _onRegisterAfterWorldMatrixUpdate;
  42076. /**
  42077. * Clone the current sound in the scene.
  42078. * @returns the new sound clone
  42079. */
  42080. clone(): Nullable<Sound>;
  42081. /**
  42082. * Gets the current underlying audio buffer containing the data
  42083. * @returns the audio buffer
  42084. */
  42085. getAudioBuffer(): Nullable<AudioBuffer>;
  42086. /**
  42087. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42088. * @returns the source node
  42089. */
  42090. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42091. /**
  42092. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42093. * @returns the gain node
  42094. */
  42095. getSoundGain(): Nullable<GainNode>;
  42096. /**
  42097. * Serializes the Sound in a JSON representation
  42098. * @returns the JSON representation of the sound
  42099. */
  42100. serialize(): any;
  42101. /**
  42102. * Parse a JSON representation of a sound to innstantiate in a given scene
  42103. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42104. * @param scene Define the scene the new parsed sound should be created in
  42105. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42106. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42107. * @returns the newly parsed sound
  42108. */
  42109. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42110. }
  42111. }
  42112. declare module "babylonjs/Actions/directAudioActions" {
  42113. import { Action } from "babylonjs/Actions/action";
  42114. import { Condition } from "babylonjs/Actions/condition";
  42115. import { Sound } from "babylonjs/Audio/sound";
  42116. /**
  42117. * This defines an action helpful to play a defined sound on a triggered action.
  42118. */
  42119. export class PlaySoundAction extends Action {
  42120. private _sound;
  42121. /**
  42122. * Instantiate the action
  42123. * @param triggerOptions defines the trigger options
  42124. * @param sound defines the sound to play
  42125. * @param condition defines the trigger related conditions
  42126. */
  42127. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42128. /** @hidden */
  42129. _prepare(): void;
  42130. /**
  42131. * Execute the action and play the sound.
  42132. */
  42133. execute(): void;
  42134. /**
  42135. * Serializes the actions and its related information.
  42136. * @param parent defines the object to serialize in
  42137. * @returns the serialized object
  42138. */
  42139. serialize(parent: any): any;
  42140. }
  42141. /**
  42142. * This defines an action helpful to stop a defined sound on a triggered action.
  42143. */
  42144. export class StopSoundAction extends Action {
  42145. private _sound;
  42146. /**
  42147. * Instantiate the action
  42148. * @param triggerOptions defines the trigger options
  42149. * @param sound defines the sound to stop
  42150. * @param condition defines the trigger related conditions
  42151. */
  42152. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42153. /** @hidden */
  42154. _prepare(): void;
  42155. /**
  42156. * Execute the action and stop the sound.
  42157. */
  42158. execute(): void;
  42159. /**
  42160. * Serializes the actions and its related information.
  42161. * @param parent defines the object to serialize in
  42162. * @returns the serialized object
  42163. */
  42164. serialize(parent: any): any;
  42165. }
  42166. }
  42167. declare module "babylonjs/Actions/interpolateValueAction" {
  42168. import { Action } from "babylonjs/Actions/action";
  42169. import { Condition } from "babylonjs/Actions/condition";
  42170. import { Observable } from "babylonjs/Misc/observable";
  42171. /**
  42172. * This defines an action responsible to change the value of a property
  42173. * by interpolating between its current value and the newly set one once triggered.
  42174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42175. */
  42176. export class InterpolateValueAction extends Action {
  42177. /**
  42178. * Defines the path of the property where the value should be interpolated
  42179. */
  42180. propertyPath: string;
  42181. /**
  42182. * Defines the target value at the end of the interpolation.
  42183. */
  42184. value: any;
  42185. /**
  42186. * Defines the time it will take for the property to interpolate to the value.
  42187. */
  42188. duration: number;
  42189. /**
  42190. * Defines if the other scene animations should be stopped when the action has been triggered
  42191. */
  42192. stopOtherAnimations?: boolean;
  42193. /**
  42194. * Defines a callback raised once the interpolation animation has been done.
  42195. */
  42196. onInterpolationDone?: () => void;
  42197. /**
  42198. * Observable triggered once the interpolation animation has been done.
  42199. */
  42200. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42201. private _target;
  42202. private _effectiveTarget;
  42203. private _property;
  42204. /**
  42205. * Instantiate the action
  42206. * @param triggerOptions defines the trigger options
  42207. * @param target defines the object containing the value to interpolate
  42208. * @param propertyPath defines the path to the property in the target object
  42209. * @param value defines the target value at the end of the interpolation
  42210. * @param duration deines the time it will take for the property to interpolate to the value.
  42211. * @param condition defines the trigger related conditions
  42212. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42213. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42214. */
  42215. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42216. /** @hidden */
  42217. _prepare(): void;
  42218. /**
  42219. * Execute the action starts the value interpolation.
  42220. */
  42221. execute(): void;
  42222. /**
  42223. * Serializes the actions and its related information.
  42224. * @param parent defines the object to serialize in
  42225. * @returns the serialized object
  42226. */
  42227. serialize(parent: any): any;
  42228. }
  42229. }
  42230. declare module "babylonjs/Actions/index" {
  42231. export * from "babylonjs/Actions/abstractActionManager";
  42232. export * from "babylonjs/Actions/action";
  42233. export * from "babylonjs/Actions/actionEvent";
  42234. export * from "babylonjs/Actions/actionManager";
  42235. export * from "babylonjs/Actions/condition";
  42236. export * from "babylonjs/Actions/directActions";
  42237. export * from "babylonjs/Actions/directAudioActions";
  42238. export * from "babylonjs/Actions/interpolateValueAction";
  42239. }
  42240. declare module "babylonjs/Animations/index" {
  42241. export * from "babylonjs/Animations/animatable";
  42242. export * from "babylonjs/Animations/animation";
  42243. export * from "babylonjs/Animations/animationGroup";
  42244. export * from "babylonjs/Animations/animationPropertiesOverride";
  42245. export * from "babylonjs/Animations/easing";
  42246. export * from "babylonjs/Animations/runtimeAnimation";
  42247. export * from "babylonjs/Animations/animationEvent";
  42248. export * from "babylonjs/Animations/animationGroup";
  42249. export * from "babylonjs/Animations/animationKey";
  42250. export * from "babylonjs/Animations/animationRange";
  42251. export * from "babylonjs/Animations/animatable.interface";
  42252. }
  42253. declare module "babylonjs/Audio/soundTrack" {
  42254. import { Sound } from "babylonjs/Audio/sound";
  42255. import { Analyser } from "babylonjs/Audio/analyser";
  42256. import { Scene } from "babylonjs/scene";
  42257. /**
  42258. * Options allowed during the creation of a sound track.
  42259. */
  42260. export interface ISoundTrackOptions {
  42261. /**
  42262. * The volume the sound track should take during creation
  42263. */
  42264. volume?: number;
  42265. /**
  42266. * Define if the sound track is the main sound track of the scene
  42267. */
  42268. mainTrack?: boolean;
  42269. }
  42270. /**
  42271. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42272. * It will be also used in a future release to apply effects on a specific track.
  42273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42274. */
  42275. export class SoundTrack {
  42276. /**
  42277. * The unique identifier of the sound track in the scene.
  42278. */
  42279. id: number;
  42280. /**
  42281. * The list of sounds included in the sound track.
  42282. */
  42283. soundCollection: Array<Sound>;
  42284. private _outputAudioNode;
  42285. private _scene;
  42286. private _connectedAnalyser;
  42287. private _options;
  42288. private _isInitialized;
  42289. /**
  42290. * Creates a new sound track.
  42291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42292. * @param scene Define the scene the sound track belongs to
  42293. * @param options
  42294. */
  42295. constructor(scene: Scene, options?: ISoundTrackOptions);
  42296. private _initializeSoundTrackAudioGraph;
  42297. /**
  42298. * Release the sound track and its associated resources
  42299. */
  42300. dispose(): void;
  42301. /**
  42302. * Adds a sound to this sound track
  42303. * @param sound define the cound to add
  42304. * @ignoreNaming
  42305. */
  42306. AddSound(sound: Sound): void;
  42307. /**
  42308. * Removes a sound to this sound track
  42309. * @param sound define the cound to remove
  42310. * @ignoreNaming
  42311. */
  42312. RemoveSound(sound: Sound): void;
  42313. /**
  42314. * Set a global volume for the full sound track.
  42315. * @param newVolume Define the new volume of the sound track
  42316. */
  42317. setVolume(newVolume: number): void;
  42318. /**
  42319. * Switch the panning model to HRTF:
  42320. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42322. */
  42323. switchPanningModelToHRTF(): void;
  42324. /**
  42325. * Switch the panning model to Equal Power:
  42326. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42328. */
  42329. switchPanningModelToEqualPower(): void;
  42330. /**
  42331. * Connect the sound track to an audio analyser allowing some amazing
  42332. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42334. * @param analyser The analyser to connect to the engine
  42335. */
  42336. connectToAnalyser(analyser: Analyser): void;
  42337. }
  42338. }
  42339. declare module "babylonjs/Audio/audioSceneComponent" {
  42340. import { Sound } from "babylonjs/Audio/sound";
  42341. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42342. import { Nullable } from "babylonjs/types";
  42343. import { Vector3 } from "babylonjs/Maths/math.vector";
  42344. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42345. import { Scene } from "babylonjs/scene";
  42346. import { AbstractScene } from "babylonjs/abstractScene";
  42347. import "babylonjs/Audio/audioEngine";
  42348. module "babylonjs/abstractScene" {
  42349. interface AbstractScene {
  42350. /**
  42351. * The list of sounds used in the scene.
  42352. */
  42353. sounds: Nullable<Array<Sound>>;
  42354. }
  42355. }
  42356. module "babylonjs/scene" {
  42357. interface Scene {
  42358. /**
  42359. * @hidden
  42360. * Backing field
  42361. */
  42362. _mainSoundTrack: SoundTrack;
  42363. /**
  42364. * The main sound track played by the scene.
  42365. * It cotains your primary collection of sounds.
  42366. */
  42367. mainSoundTrack: SoundTrack;
  42368. /**
  42369. * The list of sound tracks added to the scene
  42370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42371. */
  42372. soundTracks: Nullable<Array<SoundTrack>>;
  42373. /**
  42374. * Gets a sound using a given name
  42375. * @param name defines the name to search for
  42376. * @return the found sound or null if not found at all.
  42377. */
  42378. getSoundByName(name: string): Nullable<Sound>;
  42379. /**
  42380. * Gets or sets if audio support is enabled
  42381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42382. */
  42383. audioEnabled: boolean;
  42384. /**
  42385. * Gets or sets if audio will be output to headphones
  42386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42387. */
  42388. headphone: boolean;
  42389. /**
  42390. * Gets or sets custom audio listener position provider
  42391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42392. */
  42393. audioListenerPositionProvider: Nullable<() => Vector3>;
  42394. /**
  42395. * Gets or sets a refresh rate when using 3D audio positioning
  42396. */
  42397. audioPositioningRefreshRate: number;
  42398. }
  42399. }
  42400. /**
  42401. * Defines the sound scene component responsible to manage any sounds
  42402. * in a given scene.
  42403. */
  42404. export class AudioSceneComponent implements ISceneSerializableComponent {
  42405. /**
  42406. * The component name helpfull to identify the component in the list of scene components.
  42407. */
  42408. readonly name: string;
  42409. /**
  42410. * The scene the component belongs to.
  42411. */
  42412. scene: Scene;
  42413. private _audioEnabled;
  42414. /**
  42415. * Gets whether audio is enabled or not.
  42416. * Please use related enable/disable method to switch state.
  42417. */
  42418. get audioEnabled(): boolean;
  42419. private _headphone;
  42420. /**
  42421. * Gets whether audio is outputing to headphone or not.
  42422. * Please use the according Switch methods to change output.
  42423. */
  42424. get headphone(): boolean;
  42425. /**
  42426. * Gets or sets a refresh rate when using 3D audio positioning
  42427. */
  42428. audioPositioningRefreshRate: number;
  42429. private _audioListenerPositionProvider;
  42430. /**
  42431. * Gets the current audio listener position provider
  42432. */
  42433. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42434. /**
  42435. * Sets a custom listener position for all sounds in the scene
  42436. * By default, this is the position of the first active camera
  42437. */
  42438. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42439. /**
  42440. * Creates a new instance of the component for the given scene
  42441. * @param scene Defines the scene to register the component in
  42442. */
  42443. constructor(scene: Scene);
  42444. /**
  42445. * Registers the component in a given scene
  42446. */
  42447. register(): void;
  42448. /**
  42449. * Rebuilds the elements related to this component in case of
  42450. * context lost for instance.
  42451. */
  42452. rebuild(): void;
  42453. /**
  42454. * Serializes the component data to the specified json object
  42455. * @param serializationObject The object to serialize to
  42456. */
  42457. serialize(serializationObject: any): void;
  42458. /**
  42459. * Adds all the elements from the container to the scene
  42460. * @param container the container holding the elements
  42461. */
  42462. addFromContainer(container: AbstractScene): void;
  42463. /**
  42464. * Removes all the elements in the container from the scene
  42465. * @param container contains the elements to remove
  42466. * @param dispose if the removed element should be disposed (default: false)
  42467. */
  42468. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42469. /**
  42470. * Disposes the component and the associated ressources.
  42471. */
  42472. dispose(): void;
  42473. /**
  42474. * Disables audio in the associated scene.
  42475. */
  42476. disableAudio(): void;
  42477. /**
  42478. * Enables audio in the associated scene.
  42479. */
  42480. enableAudio(): void;
  42481. /**
  42482. * Switch audio to headphone output.
  42483. */
  42484. switchAudioModeForHeadphones(): void;
  42485. /**
  42486. * Switch audio to normal speakers.
  42487. */
  42488. switchAudioModeForNormalSpeakers(): void;
  42489. private _cachedCameraDirection;
  42490. private _cachedCameraPosition;
  42491. private _lastCheck;
  42492. private _afterRender;
  42493. }
  42494. }
  42495. declare module "babylonjs/Audio/weightedsound" {
  42496. import { Sound } from "babylonjs/Audio/sound";
  42497. /**
  42498. * Wraps one or more Sound objects and selects one with random weight for playback.
  42499. */
  42500. export class WeightedSound {
  42501. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42502. loop: boolean;
  42503. private _coneInnerAngle;
  42504. private _coneOuterAngle;
  42505. private _volume;
  42506. /** A Sound is currently playing. */
  42507. isPlaying: boolean;
  42508. /** A Sound is currently paused. */
  42509. isPaused: boolean;
  42510. private _sounds;
  42511. private _weights;
  42512. private _currentIndex?;
  42513. /**
  42514. * Creates a new WeightedSound from the list of sounds given.
  42515. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42516. * @param sounds Array of Sounds that will be selected from.
  42517. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42518. */
  42519. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42520. /**
  42521. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42522. */
  42523. get directionalConeInnerAngle(): number;
  42524. /**
  42525. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42526. */
  42527. set directionalConeInnerAngle(value: number);
  42528. /**
  42529. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42530. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42531. */
  42532. get directionalConeOuterAngle(): number;
  42533. /**
  42534. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42535. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42536. */
  42537. set directionalConeOuterAngle(value: number);
  42538. /**
  42539. * Playback volume.
  42540. */
  42541. get volume(): number;
  42542. /**
  42543. * Playback volume.
  42544. */
  42545. set volume(value: number);
  42546. private _onended;
  42547. /**
  42548. * Suspend playback
  42549. */
  42550. pause(): void;
  42551. /**
  42552. * Stop playback
  42553. */
  42554. stop(): void;
  42555. /**
  42556. * Start playback.
  42557. * @param startOffset Position the clip head at a specific time in seconds.
  42558. */
  42559. play(startOffset?: number): void;
  42560. }
  42561. }
  42562. declare module "babylonjs/Audio/index" {
  42563. export * from "babylonjs/Audio/analyser";
  42564. export * from "babylonjs/Audio/audioEngine";
  42565. export * from "babylonjs/Audio/audioSceneComponent";
  42566. export * from "babylonjs/Audio/sound";
  42567. export * from "babylonjs/Audio/soundTrack";
  42568. export * from "babylonjs/Audio/weightedsound";
  42569. }
  42570. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42571. import { Behavior } from "babylonjs/Behaviors/behavior";
  42572. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42573. import { BackEase } from "babylonjs/Animations/easing";
  42574. /**
  42575. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42577. */
  42578. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42579. /**
  42580. * Gets the name of the behavior.
  42581. */
  42582. get name(): string;
  42583. /**
  42584. * The easing function used by animations
  42585. */
  42586. static EasingFunction: BackEase;
  42587. /**
  42588. * The easing mode used by animations
  42589. */
  42590. static EasingMode: number;
  42591. /**
  42592. * The duration of the animation, in milliseconds
  42593. */
  42594. transitionDuration: number;
  42595. /**
  42596. * Length of the distance animated by the transition when lower radius is reached
  42597. */
  42598. lowerRadiusTransitionRange: number;
  42599. /**
  42600. * Length of the distance animated by the transition when upper radius is reached
  42601. */
  42602. upperRadiusTransitionRange: number;
  42603. private _autoTransitionRange;
  42604. /**
  42605. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42606. */
  42607. get autoTransitionRange(): boolean;
  42608. /**
  42609. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42610. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42611. */
  42612. set autoTransitionRange(value: boolean);
  42613. private _attachedCamera;
  42614. private _onAfterCheckInputsObserver;
  42615. private _onMeshTargetChangedObserver;
  42616. /**
  42617. * Initializes the behavior.
  42618. */
  42619. init(): void;
  42620. /**
  42621. * Attaches the behavior to its arc rotate camera.
  42622. * @param camera Defines the camera to attach the behavior to
  42623. */
  42624. attach(camera: ArcRotateCamera): void;
  42625. /**
  42626. * Detaches the behavior from its current arc rotate camera.
  42627. */
  42628. detach(): void;
  42629. private _radiusIsAnimating;
  42630. private _radiusBounceTransition;
  42631. private _animatables;
  42632. private _cachedWheelPrecision;
  42633. /**
  42634. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42635. * @param radiusLimit The limit to check against.
  42636. * @return Bool to indicate if at limit.
  42637. */
  42638. private _isRadiusAtLimit;
  42639. /**
  42640. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42641. * @param radiusDelta The delta by which to animate to. Can be negative.
  42642. */
  42643. private _applyBoundRadiusAnimation;
  42644. /**
  42645. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42646. */
  42647. protected _clearAnimationLocks(): void;
  42648. /**
  42649. * Stops and removes all animations that have been applied to the camera
  42650. */
  42651. stopAllAnimations(): void;
  42652. }
  42653. }
  42654. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42655. import { Behavior } from "babylonjs/Behaviors/behavior";
  42656. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42657. import { ExponentialEase } from "babylonjs/Animations/easing";
  42658. import { Nullable } from "babylonjs/types";
  42659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42660. import { Vector3 } from "babylonjs/Maths/math.vector";
  42661. /**
  42662. * 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.
  42663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42664. */
  42665. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42666. /**
  42667. * Gets the name of the behavior.
  42668. */
  42669. get name(): string;
  42670. private _mode;
  42671. private _radiusScale;
  42672. private _positionScale;
  42673. private _defaultElevation;
  42674. private _elevationReturnTime;
  42675. private _elevationReturnWaitTime;
  42676. private _zoomStopsAnimation;
  42677. private _framingTime;
  42678. /**
  42679. * The easing function used by animations
  42680. */
  42681. static EasingFunction: ExponentialEase;
  42682. /**
  42683. * The easing mode used by animations
  42684. */
  42685. static EasingMode: number;
  42686. /**
  42687. * Sets the current mode used by the behavior
  42688. */
  42689. set mode(mode: number);
  42690. /**
  42691. * Gets current mode used by the behavior.
  42692. */
  42693. get mode(): number;
  42694. /**
  42695. * Sets the scale applied to the radius (1 by default)
  42696. */
  42697. set radiusScale(radius: number);
  42698. /**
  42699. * Gets the scale applied to the radius
  42700. */
  42701. get radiusScale(): number;
  42702. /**
  42703. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42704. */
  42705. set positionScale(scale: number);
  42706. /**
  42707. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42708. */
  42709. get positionScale(): number;
  42710. /**
  42711. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42712. * behaviour is triggered, in radians.
  42713. */
  42714. set defaultElevation(elevation: number);
  42715. /**
  42716. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42717. * behaviour is triggered, in radians.
  42718. */
  42719. get defaultElevation(): number;
  42720. /**
  42721. * Sets the time (in milliseconds) taken to return to the default beta position.
  42722. * Negative value indicates camera should not return to default.
  42723. */
  42724. set elevationReturnTime(speed: number);
  42725. /**
  42726. * Gets the time (in milliseconds) taken to return to the default beta position.
  42727. * Negative value indicates camera should not return to default.
  42728. */
  42729. get elevationReturnTime(): number;
  42730. /**
  42731. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42732. */
  42733. set elevationReturnWaitTime(time: number);
  42734. /**
  42735. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42736. */
  42737. get elevationReturnWaitTime(): number;
  42738. /**
  42739. * Sets the flag that indicates if user zooming should stop animation.
  42740. */
  42741. set zoomStopsAnimation(flag: boolean);
  42742. /**
  42743. * Gets the flag that indicates if user zooming should stop animation.
  42744. */
  42745. get zoomStopsAnimation(): boolean;
  42746. /**
  42747. * Sets the transition time when framing the mesh, in milliseconds
  42748. */
  42749. set framingTime(time: number);
  42750. /**
  42751. * Gets the transition time when framing the mesh, in milliseconds
  42752. */
  42753. get framingTime(): number;
  42754. /**
  42755. * Define if the behavior should automatically change the configured
  42756. * camera limits and sensibilities.
  42757. */
  42758. autoCorrectCameraLimitsAndSensibility: boolean;
  42759. private _onPrePointerObservableObserver;
  42760. private _onAfterCheckInputsObserver;
  42761. private _onMeshTargetChangedObserver;
  42762. private _attachedCamera;
  42763. private _isPointerDown;
  42764. private _lastInteractionTime;
  42765. /**
  42766. * Initializes the behavior.
  42767. */
  42768. init(): void;
  42769. /**
  42770. * Attaches the behavior to its arc rotate camera.
  42771. * @param camera Defines the camera to attach the behavior to
  42772. */
  42773. attach(camera: ArcRotateCamera): void;
  42774. /**
  42775. * Detaches the behavior from its current arc rotate camera.
  42776. */
  42777. detach(): void;
  42778. private _animatables;
  42779. private _betaIsAnimating;
  42780. private _betaTransition;
  42781. private _radiusTransition;
  42782. private _vectorTransition;
  42783. /**
  42784. * Targets the given mesh and updates zoom level accordingly.
  42785. * @param mesh The mesh to target.
  42786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42788. */
  42789. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42790. /**
  42791. * Targets the given mesh with its children and updates zoom level accordingly.
  42792. * @param mesh The mesh to target.
  42793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42795. */
  42796. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42797. /**
  42798. * Targets the given meshes with their children and updates zoom level accordingly.
  42799. * @param meshes The mesh to target.
  42800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42802. */
  42803. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42804. /**
  42805. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42806. * @param minimumWorld Determines the smaller position of the bounding box extend
  42807. * @param maximumWorld Determines the bigger position of the bounding box extend
  42808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42810. */
  42811. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42812. /**
  42813. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42814. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42815. * frustum width.
  42816. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42817. * to fully enclose the mesh in the viewing frustum.
  42818. */
  42819. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42820. /**
  42821. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42822. * is automatically returned to its default position (expected to be above ground plane).
  42823. */
  42824. private _maintainCameraAboveGround;
  42825. /**
  42826. * Returns the frustum slope based on the canvas ratio and camera FOV
  42827. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42828. */
  42829. private _getFrustumSlope;
  42830. /**
  42831. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42832. */
  42833. private _clearAnimationLocks;
  42834. /**
  42835. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42836. */
  42837. private _applyUserInteraction;
  42838. /**
  42839. * Stops and removes all animations that have been applied to the camera
  42840. */
  42841. stopAllAnimations(): void;
  42842. /**
  42843. * Gets a value indicating if the user is moving the camera
  42844. */
  42845. get isUserIsMoving(): boolean;
  42846. /**
  42847. * The camera can move all the way towards the mesh.
  42848. */
  42849. static IgnoreBoundsSizeMode: number;
  42850. /**
  42851. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42852. */
  42853. static FitFrustumSidesMode: number;
  42854. }
  42855. }
  42856. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42857. import { Nullable } from "babylonjs/types";
  42858. import { Camera } from "babylonjs/Cameras/camera";
  42859. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42860. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42861. /**
  42862. * Base class for Camera Pointer Inputs.
  42863. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42864. * for example usage.
  42865. */
  42866. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42867. /**
  42868. * Defines the camera the input is attached to.
  42869. */
  42870. abstract camera: Camera;
  42871. /**
  42872. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42873. */
  42874. protected _altKey: boolean;
  42875. protected _ctrlKey: boolean;
  42876. protected _metaKey: boolean;
  42877. protected _shiftKey: boolean;
  42878. /**
  42879. * Which mouse buttons were pressed at time of last mouse event.
  42880. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42881. */
  42882. protected _buttonsPressed: number;
  42883. /**
  42884. * Defines the buttons associated with the input to handle camera move.
  42885. */
  42886. buttons: number[];
  42887. /**
  42888. * Attach the input controls to a specific dom element to get the input from.
  42889. * @param element Defines the element the controls should be listened from
  42890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42891. */
  42892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42893. /**
  42894. * Detach the current controls from the specified dom element.
  42895. * @param element Defines the element to stop listening the inputs from
  42896. */
  42897. detachControl(element: Nullable<HTMLElement>): void;
  42898. /**
  42899. * Gets the class name of the current input.
  42900. * @returns the class name
  42901. */
  42902. getClassName(): string;
  42903. /**
  42904. * Get the friendly name associated with the input class.
  42905. * @returns the input friendly name
  42906. */
  42907. getSimpleName(): string;
  42908. /**
  42909. * Called on pointer POINTERDOUBLETAP event.
  42910. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42911. */
  42912. protected onDoubleTap(type: string): void;
  42913. /**
  42914. * Called on pointer POINTERMOVE event if only a single touch is active.
  42915. * Override this method to provide functionality.
  42916. */
  42917. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42918. /**
  42919. * Called on pointer POINTERMOVE event if multiple touches are active.
  42920. * Override this method to provide functionality.
  42921. */
  42922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42923. /**
  42924. * Called on JS contextmenu event.
  42925. * Override this method to provide functionality.
  42926. */
  42927. protected onContextMenu(evt: PointerEvent): void;
  42928. /**
  42929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42930. * press.
  42931. * Override this method to provide functionality.
  42932. */
  42933. protected onButtonDown(evt: PointerEvent): void;
  42934. /**
  42935. * Called each time a new POINTERUP event occurs. Ie, for each button
  42936. * release.
  42937. * Override this method to provide functionality.
  42938. */
  42939. protected onButtonUp(evt: PointerEvent): void;
  42940. /**
  42941. * Called when window becomes inactive.
  42942. * Override this method to provide functionality.
  42943. */
  42944. protected onLostFocus(): void;
  42945. private _pointerInput;
  42946. private _observer;
  42947. private _onLostFocus;
  42948. private pointA;
  42949. private pointB;
  42950. }
  42951. }
  42952. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42953. import { Nullable } from "babylonjs/types";
  42954. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42955. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42956. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42957. /**
  42958. * Manage the pointers inputs to control an arc rotate camera.
  42959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42960. */
  42961. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42962. /**
  42963. * Defines the camera the input is attached to.
  42964. */
  42965. camera: ArcRotateCamera;
  42966. /**
  42967. * Gets the class name of the current input.
  42968. * @returns the class name
  42969. */
  42970. getClassName(): string;
  42971. /**
  42972. * Defines the buttons associated with the input to handle camera move.
  42973. */
  42974. buttons: number[];
  42975. /**
  42976. * Defines the pointer angular sensibility along the X axis or how fast is
  42977. * the camera rotating.
  42978. */
  42979. angularSensibilityX: number;
  42980. /**
  42981. * Defines the pointer angular sensibility along the Y axis or how fast is
  42982. * the camera rotating.
  42983. */
  42984. angularSensibilityY: number;
  42985. /**
  42986. * Defines the pointer pinch precision or how fast is the camera zooming.
  42987. */
  42988. pinchPrecision: number;
  42989. /**
  42990. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42991. * from 0.
  42992. * It defines the percentage of current camera.radius to use as delta when
  42993. * pinch zoom is used.
  42994. */
  42995. pinchDeltaPercentage: number;
  42996. /**
  42997. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42998. * that any object in the plane at the camera's target point will scale
  42999. * perfectly with finger motion.
  43000. * Overrides pinchDeltaPercentage and pinchPrecision.
  43001. */
  43002. useNaturalPinchZoom: boolean;
  43003. /**
  43004. * Defines the pointer panning sensibility or how fast is the camera moving.
  43005. */
  43006. panningSensibility: number;
  43007. /**
  43008. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43009. */
  43010. multiTouchPanning: boolean;
  43011. /**
  43012. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43013. * zoom (pinch) through multitouch.
  43014. */
  43015. multiTouchPanAndZoom: boolean;
  43016. /**
  43017. * Revers pinch action direction.
  43018. */
  43019. pinchInwards: boolean;
  43020. private _isPanClick;
  43021. private _twoFingerActivityCount;
  43022. private _isPinching;
  43023. /**
  43024. * Called on pointer POINTERMOVE event if only a single touch is active.
  43025. */
  43026. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43027. /**
  43028. * Called on pointer POINTERDOUBLETAP event.
  43029. */
  43030. protected onDoubleTap(type: string): void;
  43031. /**
  43032. * Called on pointer POINTERMOVE event if multiple touches are active.
  43033. */
  43034. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43035. /**
  43036. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43037. * press.
  43038. */
  43039. protected onButtonDown(evt: PointerEvent): void;
  43040. /**
  43041. * Called each time a new POINTERUP event occurs. Ie, for each button
  43042. * release.
  43043. */
  43044. protected onButtonUp(evt: PointerEvent): void;
  43045. /**
  43046. * Called when window becomes inactive.
  43047. */
  43048. protected onLostFocus(): void;
  43049. }
  43050. }
  43051. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43052. import { Nullable } from "babylonjs/types";
  43053. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43054. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43055. /**
  43056. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43058. */
  43059. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43060. /**
  43061. * Defines the camera the input is attached to.
  43062. */
  43063. camera: ArcRotateCamera;
  43064. /**
  43065. * Defines the list of key codes associated with the up action (increase alpha)
  43066. */
  43067. keysUp: number[];
  43068. /**
  43069. * Defines the list of key codes associated with the down action (decrease alpha)
  43070. */
  43071. keysDown: number[];
  43072. /**
  43073. * Defines the list of key codes associated with the left action (increase beta)
  43074. */
  43075. keysLeft: number[];
  43076. /**
  43077. * Defines the list of key codes associated with the right action (decrease beta)
  43078. */
  43079. keysRight: number[];
  43080. /**
  43081. * Defines the list of key codes associated with the reset action.
  43082. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43083. */
  43084. keysReset: number[];
  43085. /**
  43086. * Defines the panning sensibility of the inputs.
  43087. * (How fast is the camera panning)
  43088. */
  43089. panningSensibility: number;
  43090. /**
  43091. * Defines the zooming sensibility of the inputs.
  43092. * (How fast is the camera zooming)
  43093. */
  43094. zoomingSensibility: number;
  43095. /**
  43096. * Defines whether maintaining the alt key down switch the movement mode from
  43097. * orientation to zoom.
  43098. */
  43099. useAltToZoom: boolean;
  43100. /**
  43101. * Rotation speed of the camera
  43102. */
  43103. angularSpeed: number;
  43104. private _keys;
  43105. private _ctrlPressed;
  43106. private _altPressed;
  43107. private _onCanvasBlurObserver;
  43108. private _onKeyboardObserver;
  43109. private _engine;
  43110. private _scene;
  43111. /**
  43112. * Attach the input controls to a specific dom element to get the input from.
  43113. * @param element Defines the element the controls should be listened from
  43114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43115. */
  43116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43117. /**
  43118. * Detach the current controls from the specified dom element.
  43119. * @param element Defines the element to stop listening the inputs from
  43120. */
  43121. detachControl(element: Nullable<HTMLElement>): void;
  43122. /**
  43123. * Update the current camera state depending on the inputs that have been used this frame.
  43124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43125. */
  43126. checkInputs(): void;
  43127. /**
  43128. * Gets the class name of the current intput.
  43129. * @returns the class name
  43130. */
  43131. getClassName(): string;
  43132. /**
  43133. * Get the friendly name associated with the input class.
  43134. * @returns the input friendly name
  43135. */
  43136. getSimpleName(): string;
  43137. }
  43138. }
  43139. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43140. import { Nullable } from "babylonjs/types";
  43141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43142. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43143. /**
  43144. * Manage the mouse wheel inputs to control an arc rotate camera.
  43145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43146. */
  43147. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43148. /**
  43149. * Defines the camera the input is attached to.
  43150. */
  43151. camera: ArcRotateCamera;
  43152. /**
  43153. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43154. */
  43155. wheelPrecision: number;
  43156. /**
  43157. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43158. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43159. */
  43160. wheelDeltaPercentage: number;
  43161. private _wheel;
  43162. private _observer;
  43163. private computeDeltaFromMouseWheelLegacyEvent;
  43164. /**
  43165. * Attach the input controls to a specific dom element to get the input from.
  43166. * @param element Defines the element the controls should be listened from
  43167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43168. */
  43169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43170. /**
  43171. * Detach the current controls from the specified dom element.
  43172. * @param element Defines the element to stop listening the inputs from
  43173. */
  43174. detachControl(element: Nullable<HTMLElement>): void;
  43175. /**
  43176. * Gets the class name of the current intput.
  43177. * @returns the class name
  43178. */
  43179. getClassName(): string;
  43180. /**
  43181. * Get the friendly name associated with the input class.
  43182. * @returns the input friendly name
  43183. */
  43184. getSimpleName(): string;
  43185. }
  43186. }
  43187. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43188. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43189. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43190. /**
  43191. * Default Inputs manager for the ArcRotateCamera.
  43192. * It groups all the default supported inputs for ease of use.
  43193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43194. */
  43195. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43196. /**
  43197. * Instantiates a new ArcRotateCameraInputsManager.
  43198. * @param camera Defines the camera the inputs belong to
  43199. */
  43200. constructor(camera: ArcRotateCamera);
  43201. /**
  43202. * Add mouse wheel input support to the input manager.
  43203. * @returns the current input manager
  43204. */
  43205. addMouseWheel(): ArcRotateCameraInputsManager;
  43206. /**
  43207. * Add pointers input support to the input manager.
  43208. * @returns the current input manager
  43209. */
  43210. addPointers(): ArcRotateCameraInputsManager;
  43211. /**
  43212. * Add keyboard input support to the input manager.
  43213. * @returns the current input manager
  43214. */
  43215. addKeyboard(): ArcRotateCameraInputsManager;
  43216. }
  43217. }
  43218. declare module "babylonjs/Cameras/arcRotateCamera" {
  43219. import { Observable } from "babylonjs/Misc/observable";
  43220. import { Nullable } from "babylonjs/types";
  43221. import { Scene } from "babylonjs/scene";
  43222. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43224. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43225. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43226. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43227. import { Camera } from "babylonjs/Cameras/camera";
  43228. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43229. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43230. import { Collider } from "babylonjs/Collisions/collider";
  43231. /**
  43232. * This represents an orbital type of camera.
  43233. *
  43234. * 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.
  43235. * 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.
  43236. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43237. */
  43238. export class ArcRotateCamera extends TargetCamera {
  43239. /**
  43240. * Defines the rotation angle of the camera along the longitudinal axis.
  43241. */
  43242. alpha: number;
  43243. /**
  43244. * Defines the rotation angle of the camera along the latitudinal axis.
  43245. */
  43246. beta: number;
  43247. /**
  43248. * Defines the radius of the camera from it s target point.
  43249. */
  43250. radius: number;
  43251. protected _target: Vector3;
  43252. protected _targetHost: Nullable<AbstractMesh>;
  43253. /**
  43254. * Defines the target point of the camera.
  43255. * The camera looks towards it form the radius distance.
  43256. */
  43257. get target(): Vector3;
  43258. set target(value: Vector3);
  43259. /**
  43260. * Define the current local position of the camera in the scene
  43261. */
  43262. get position(): Vector3;
  43263. set position(newPosition: Vector3);
  43264. protected _upVector: Vector3;
  43265. protected _upToYMatrix: Matrix;
  43266. protected _YToUpMatrix: Matrix;
  43267. /**
  43268. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43269. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43270. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43271. */
  43272. set upVector(vec: Vector3);
  43273. get upVector(): Vector3;
  43274. /**
  43275. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43276. */
  43277. setMatUp(): void;
  43278. /**
  43279. * Current inertia value on the longitudinal axis.
  43280. * The bigger this number the longer it will take for the camera to stop.
  43281. */
  43282. inertialAlphaOffset: number;
  43283. /**
  43284. * Current inertia value on the latitudinal axis.
  43285. * The bigger this number the longer it will take for the camera to stop.
  43286. */
  43287. inertialBetaOffset: number;
  43288. /**
  43289. * Current inertia value on the radius axis.
  43290. * The bigger this number the longer it will take for the camera to stop.
  43291. */
  43292. inertialRadiusOffset: number;
  43293. /**
  43294. * Minimum allowed angle on the longitudinal axis.
  43295. * This can help limiting how the Camera is able to move in the scene.
  43296. */
  43297. lowerAlphaLimit: Nullable<number>;
  43298. /**
  43299. * Maximum allowed angle on the longitudinal axis.
  43300. * This can help limiting how the Camera is able to move in the scene.
  43301. */
  43302. upperAlphaLimit: Nullable<number>;
  43303. /**
  43304. * Minimum allowed angle on the latitudinal axis.
  43305. * This can help limiting how the Camera is able to move in the scene.
  43306. */
  43307. lowerBetaLimit: number;
  43308. /**
  43309. * Maximum allowed angle on the latitudinal axis.
  43310. * This can help limiting how the Camera is able to move in the scene.
  43311. */
  43312. upperBetaLimit: number;
  43313. /**
  43314. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43315. * This can help limiting how the Camera is able to move in the scene.
  43316. */
  43317. lowerRadiusLimit: Nullable<number>;
  43318. /**
  43319. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43320. * This can help limiting how the Camera is able to move in the scene.
  43321. */
  43322. upperRadiusLimit: Nullable<number>;
  43323. /**
  43324. * Defines the current inertia value used during panning of the camera along the X axis.
  43325. */
  43326. inertialPanningX: number;
  43327. /**
  43328. * Defines the current inertia value used during panning of the camera along the Y axis.
  43329. */
  43330. inertialPanningY: number;
  43331. /**
  43332. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43333. * Basically if your fingers moves away from more than this distance you will be considered
  43334. * in pinch mode.
  43335. */
  43336. pinchToPanMaxDistance: number;
  43337. /**
  43338. * Defines the maximum distance the camera can pan.
  43339. * This could help keeping the cammera always in your scene.
  43340. */
  43341. panningDistanceLimit: Nullable<number>;
  43342. /**
  43343. * Defines the target of the camera before paning.
  43344. */
  43345. panningOriginTarget: Vector3;
  43346. /**
  43347. * Defines the value of the inertia used during panning.
  43348. * 0 would mean stop inertia and one would mean no decelleration at all.
  43349. */
  43350. panningInertia: number;
  43351. /**
  43352. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43353. */
  43354. get angularSensibilityX(): number;
  43355. set angularSensibilityX(value: number);
  43356. /**
  43357. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43358. */
  43359. get angularSensibilityY(): number;
  43360. set angularSensibilityY(value: number);
  43361. /**
  43362. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43363. */
  43364. get pinchPrecision(): number;
  43365. set pinchPrecision(value: number);
  43366. /**
  43367. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43368. * It will be used instead of pinchDeltaPrecision if different from 0.
  43369. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43370. */
  43371. get pinchDeltaPercentage(): number;
  43372. set pinchDeltaPercentage(value: number);
  43373. /**
  43374. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43375. * and pinch delta percentage.
  43376. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43377. * that any object in the plane at the camera's target point will scale
  43378. * perfectly with finger motion.
  43379. */
  43380. get useNaturalPinchZoom(): boolean;
  43381. set useNaturalPinchZoom(value: boolean);
  43382. /**
  43383. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43384. */
  43385. get panningSensibility(): number;
  43386. set panningSensibility(value: number);
  43387. /**
  43388. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43389. */
  43390. get keysUp(): number[];
  43391. set keysUp(value: number[]);
  43392. /**
  43393. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43394. */
  43395. get keysDown(): number[];
  43396. set keysDown(value: number[]);
  43397. /**
  43398. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43399. */
  43400. get keysLeft(): number[];
  43401. set keysLeft(value: number[]);
  43402. /**
  43403. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43404. */
  43405. get keysRight(): number[];
  43406. set keysRight(value: number[]);
  43407. /**
  43408. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43409. */
  43410. get wheelPrecision(): number;
  43411. set wheelPrecision(value: number);
  43412. /**
  43413. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43414. * It will be used instead of pinchDeltaPrecision if different from 0.
  43415. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43416. */
  43417. get wheelDeltaPercentage(): number;
  43418. set wheelDeltaPercentage(value: number);
  43419. /**
  43420. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43421. */
  43422. zoomOnFactor: number;
  43423. /**
  43424. * Defines a screen offset for the camera position.
  43425. */
  43426. targetScreenOffset: Vector2;
  43427. /**
  43428. * Allows the camera to be completely reversed.
  43429. * If false the camera can not arrive upside down.
  43430. */
  43431. allowUpsideDown: boolean;
  43432. /**
  43433. * Define if double tap/click is used to restore the previously saved state of the camera.
  43434. */
  43435. useInputToRestoreState: boolean;
  43436. /** @hidden */
  43437. _viewMatrix: Matrix;
  43438. /** @hidden */
  43439. _useCtrlForPanning: boolean;
  43440. /** @hidden */
  43441. _panningMouseButton: number;
  43442. /**
  43443. * Defines the input associated to the camera.
  43444. */
  43445. inputs: ArcRotateCameraInputsManager;
  43446. /** @hidden */
  43447. _reset: () => void;
  43448. /**
  43449. * Defines the allowed panning axis.
  43450. */
  43451. panningAxis: Vector3;
  43452. protected _localDirection: Vector3;
  43453. protected _transformedDirection: Vector3;
  43454. private _bouncingBehavior;
  43455. /**
  43456. * Gets the bouncing behavior of the camera if it has been enabled.
  43457. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43458. */
  43459. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43460. /**
  43461. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43463. */
  43464. get useBouncingBehavior(): boolean;
  43465. set useBouncingBehavior(value: boolean);
  43466. private _framingBehavior;
  43467. /**
  43468. * Gets the framing behavior of the camera if it has been enabled.
  43469. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43470. */
  43471. get framingBehavior(): Nullable<FramingBehavior>;
  43472. /**
  43473. * Defines if the framing behavior of the camera is enabled on the camera.
  43474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43475. */
  43476. get useFramingBehavior(): boolean;
  43477. set useFramingBehavior(value: boolean);
  43478. private _autoRotationBehavior;
  43479. /**
  43480. * Gets the auto rotation behavior of the camera if it has been enabled.
  43481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43482. */
  43483. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43484. /**
  43485. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43487. */
  43488. get useAutoRotationBehavior(): boolean;
  43489. set useAutoRotationBehavior(value: boolean);
  43490. /**
  43491. * Observable triggered when the mesh target has been changed on the camera.
  43492. */
  43493. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43494. /**
  43495. * Event raised when the camera is colliding with a mesh.
  43496. */
  43497. onCollide: (collidedMesh: AbstractMesh) => void;
  43498. /**
  43499. * Defines whether the camera should check collision with the objects oh the scene.
  43500. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43501. */
  43502. checkCollisions: boolean;
  43503. /**
  43504. * Defines the collision radius of the camera.
  43505. * This simulates a sphere around the camera.
  43506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43507. */
  43508. collisionRadius: Vector3;
  43509. protected _collider: Collider;
  43510. protected _previousPosition: Vector3;
  43511. protected _collisionVelocity: Vector3;
  43512. protected _newPosition: Vector3;
  43513. protected _previousAlpha: number;
  43514. protected _previousBeta: number;
  43515. protected _previousRadius: number;
  43516. protected _collisionTriggered: boolean;
  43517. protected _targetBoundingCenter: Nullable<Vector3>;
  43518. private _computationVector;
  43519. /**
  43520. * Instantiates a new ArcRotateCamera in a given scene
  43521. * @param name Defines the name of the camera
  43522. * @param alpha Defines the camera rotation along the logitudinal axis
  43523. * @param beta Defines the camera rotation along the latitudinal axis
  43524. * @param radius Defines the camera distance from its target
  43525. * @param target Defines the camera target
  43526. * @param scene Defines the scene the camera belongs to
  43527. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43528. */
  43529. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43530. /** @hidden */
  43531. _initCache(): void;
  43532. /** @hidden */
  43533. _updateCache(ignoreParentClass?: boolean): void;
  43534. protected _getTargetPosition(): Vector3;
  43535. private _storedAlpha;
  43536. private _storedBeta;
  43537. private _storedRadius;
  43538. private _storedTarget;
  43539. private _storedTargetScreenOffset;
  43540. /**
  43541. * Stores the current state of the camera (alpha, beta, radius and target)
  43542. * @returns the camera itself
  43543. */
  43544. storeState(): Camera;
  43545. /**
  43546. * @hidden
  43547. * Restored camera state. You must call storeState() first
  43548. */
  43549. _restoreStateValues(): boolean;
  43550. /** @hidden */
  43551. _isSynchronizedViewMatrix(): boolean;
  43552. /**
  43553. * Attached controls to the current camera.
  43554. * @param element Defines the element the controls should be listened from
  43555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43556. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43557. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43558. */
  43559. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43560. /**
  43561. * Detach the current controls from the camera.
  43562. * The camera will stop reacting to inputs.
  43563. * @param element Defines the element to stop listening the inputs from
  43564. */
  43565. detachControl(element: HTMLElement): void;
  43566. /** @hidden */
  43567. _checkInputs(): void;
  43568. protected _checkLimits(): void;
  43569. /**
  43570. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43571. */
  43572. rebuildAnglesAndRadius(): void;
  43573. /**
  43574. * Use a position to define the current camera related information like alpha, beta and radius
  43575. * @param position Defines the position to set the camera at
  43576. */
  43577. setPosition(position: Vector3): void;
  43578. /**
  43579. * Defines the target the camera should look at.
  43580. * This will automatically adapt alpha beta and radius to fit within the new target.
  43581. * @param target Defines the new target as a Vector or a mesh
  43582. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43583. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43584. */
  43585. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43586. /** @hidden */
  43587. _getViewMatrix(): Matrix;
  43588. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43589. /**
  43590. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43591. * @param meshes Defines the mesh to zoom on
  43592. * @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)
  43593. */
  43594. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43595. /**
  43596. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43597. * The target will be changed but the radius
  43598. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43599. * @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)
  43600. */
  43601. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43602. min: Vector3;
  43603. max: Vector3;
  43604. distance: number;
  43605. }, doNotUpdateMaxZ?: boolean): void;
  43606. /**
  43607. * @override
  43608. * Override Camera.createRigCamera
  43609. */
  43610. createRigCamera(name: string, cameraIndex: number): Camera;
  43611. /**
  43612. * @hidden
  43613. * @override
  43614. * Override Camera._updateRigCameras
  43615. */
  43616. _updateRigCameras(): void;
  43617. /**
  43618. * Destroy the camera and release the current resources hold by it.
  43619. */
  43620. dispose(): void;
  43621. /**
  43622. * Gets the current object class name.
  43623. * @return the class name
  43624. */
  43625. getClassName(): string;
  43626. }
  43627. }
  43628. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43629. import { Behavior } from "babylonjs/Behaviors/behavior";
  43630. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43631. /**
  43632. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43633. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43634. */
  43635. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43636. /**
  43637. * Gets the name of the behavior.
  43638. */
  43639. get name(): string;
  43640. private _zoomStopsAnimation;
  43641. private _idleRotationSpeed;
  43642. private _idleRotationWaitTime;
  43643. private _idleRotationSpinupTime;
  43644. /**
  43645. * Sets the flag that indicates if user zooming should stop animation.
  43646. */
  43647. set zoomStopsAnimation(flag: boolean);
  43648. /**
  43649. * Gets the flag that indicates if user zooming should stop animation.
  43650. */
  43651. get zoomStopsAnimation(): boolean;
  43652. /**
  43653. * Sets the default speed at which the camera rotates around the model.
  43654. */
  43655. set idleRotationSpeed(speed: number);
  43656. /**
  43657. * Gets the default speed at which the camera rotates around the model.
  43658. */
  43659. get idleRotationSpeed(): number;
  43660. /**
  43661. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43662. */
  43663. set idleRotationWaitTime(time: number);
  43664. /**
  43665. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43666. */
  43667. get idleRotationWaitTime(): number;
  43668. /**
  43669. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43670. */
  43671. set idleRotationSpinupTime(time: number);
  43672. /**
  43673. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43674. */
  43675. get idleRotationSpinupTime(): number;
  43676. /**
  43677. * Gets a value indicating if the camera is currently rotating because of this behavior
  43678. */
  43679. get rotationInProgress(): boolean;
  43680. private _onPrePointerObservableObserver;
  43681. private _onAfterCheckInputsObserver;
  43682. private _attachedCamera;
  43683. private _isPointerDown;
  43684. private _lastFrameTime;
  43685. private _lastInteractionTime;
  43686. private _cameraRotationSpeed;
  43687. /**
  43688. * Initializes the behavior.
  43689. */
  43690. init(): void;
  43691. /**
  43692. * Attaches the behavior to its arc rotate camera.
  43693. * @param camera Defines the camera to attach the behavior to
  43694. */
  43695. attach(camera: ArcRotateCamera): void;
  43696. /**
  43697. * Detaches the behavior from its current arc rotate camera.
  43698. */
  43699. detach(): void;
  43700. /**
  43701. * Returns true if user is scrolling.
  43702. * @return true if user is scrolling.
  43703. */
  43704. private _userIsZooming;
  43705. private _lastFrameRadius;
  43706. private _shouldAnimationStopForInteraction;
  43707. /**
  43708. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43709. */
  43710. private _applyUserInteraction;
  43711. private _userIsMoving;
  43712. }
  43713. }
  43714. declare module "babylonjs/Behaviors/Cameras/index" {
  43715. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43716. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43717. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43718. }
  43719. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43720. import { Mesh } from "babylonjs/Meshes/mesh";
  43721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43722. import { Behavior } from "babylonjs/Behaviors/behavior";
  43723. /**
  43724. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43725. */
  43726. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43727. private ui;
  43728. /**
  43729. * The name of the behavior
  43730. */
  43731. name: string;
  43732. /**
  43733. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43734. */
  43735. distanceAwayFromFace: number;
  43736. /**
  43737. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43738. */
  43739. distanceAwayFromBottomOfFace: number;
  43740. private _faceVectors;
  43741. private _target;
  43742. private _scene;
  43743. private _onRenderObserver;
  43744. private _tmpMatrix;
  43745. private _tmpVector;
  43746. /**
  43747. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43748. * @param ui The transform node that should be attched to the mesh
  43749. */
  43750. constructor(ui: TransformNode);
  43751. /**
  43752. * Initializes the behavior
  43753. */
  43754. init(): void;
  43755. private _closestFace;
  43756. private _zeroVector;
  43757. private _lookAtTmpMatrix;
  43758. private _lookAtToRef;
  43759. /**
  43760. * Attaches the AttachToBoxBehavior to the passed in mesh
  43761. * @param target The mesh that the specified node will be attached to
  43762. */
  43763. attach(target: Mesh): void;
  43764. /**
  43765. * Detaches the behavior from the mesh
  43766. */
  43767. detach(): void;
  43768. }
  43769. }
  43770. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43771. import { Behavior } from "babylonjs/Behaviors/behavior";
  43772. import { Mesh } from "babylonjs/Meshes/mesh";
  43773. /**
  43774. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43775. */
  43776. export class FadeInOutBehavior implements Behavior<Mesh> {
  43777. /**
  43778. * Time in milliseconds to delay before fading in (Default: 0)
  43779. */
  43780. delay: number;
  43781. /**
  43782. * Time in milliseconds for the mesh to fade in (Default: 300)
  43783. */
  43784. fadeInTime: number;
  43785. private _millisecondsPerFrame;
  43786. private _hovered;
  43787. private _hoverValue;
  43788. private _ownerNode;
  43789. /**
  43790. * Instatiates the FadeInOutBehavior
  43791. */
  43792. constructor();
  43793. /**
  43794. * The name of the behavior
  43795. */
  43796. get name(): string;
  43797. /**
  43798. * Initializes the behavior
  43799. */
  43800. init(): void;
  43801. /**
  43802. * Attaches the fade behavior on the passed in mesh
  43803. * @param ownerNode The mesh that will be faded in/out once attached
  43804. */
  43805. attach(ownerNode: Mesh): void;
  43806. /**
  43807. * Detaches the behavior from the mesh
  43808. */
  43809. detach(): void;
  43810. /**
  43811. * Triggers the mesh to begin fading in or out
  43812. * @param value if the object should fade in or out (true to fade in)
  43813. */
  43814. fadeIn(value: boolean): void;
  43815. private _update;
  43816. private _setAllVisibility;
  43817. }
  43818. }
  43819. declare module "babylonjs/Misc/pivotTools" {
  43820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43821. /**
  43822. * Class containing a set of static utilities functions for managing Pivots
  43823. * @hidden
  43824. */
  43825. export class PivotTools {
  43826. private static _PivotCached;
  43827. private static _OldPivotPoint;
  43828. private static _PivotTranslation;
  43829. private static _PivotTmpVector;
  43830. /** @hidden */
  43831. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43832. /** @hidden */
  43833. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43834. }
  43835. }
  43836. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43837. import { Scene } from "babylonjs/scene";
  43838. import { Vector4 } from "babylonjs/Maths/math.vector";
  43839. import { Mesh } from "babylonjs/Meshes/mesh";
  43840. import { Nullable } from "babylonjs/types";
  43841. import { Plane } from "babylonjs/Maths/math.plane";
  43842. /**
  43843. * Class containing static functions to help procedurally build meshes
  43844. */
  43845. export class PlaneBuilder {
  43846. /**
  43847. * Creates a plane mesh
  43848. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43849. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43850. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43854. * @param name defines the name of the mesh
  43855. * @param options defines the options used to create the mesh
  43856. * @param scene defines the hosting scene
  43857. * @returns the plane mesh
  43858. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43859. */
  43860. static CreatePlane(name: string, options: {
  43861. size?: number;
  43862. width?: number;
  43863. height?: number;
  43864. sideOrientation?: number;
  43865. frontUVs?: Vector4;
  43866. backUVs?: Vector4;
  43867. updatable?: boolean;
  43868. sourcePlane?: Plane;
  43869. }, scene?: Nullable<Scene>): Mesh;
  43870. }
  43871. }
  43872. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43873. import { Behavior } from "babylonjs/Behaviors/behavior";
  43874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43875. import { Observable } from "babylonjs/Misc/observable";
  43876. import { Vector3 } from "babylonjs/Maths/math.vector";
  43877. import { Ray } from "babylonjs/Culling/ray";
  43878. import "babylonjs/Meshes/Builders/planeBuilder";
  43879. /**
  43880. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43881. */
  43882. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43883. private static _AnyMouseID;
  43884. /**
  43885. * Abstract mesh the behavior is set on
  43886. */
  43887. attachedNode: AbstractMesh;
  43888. private _dragPlane;
  43889. private _scene;
  43890. private _pointerObserver;
  43891. private _beforeRenderObserver;
  43892. private static _planeScene;
  43893. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43894. /**
  43895. * 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)
  43896. */
  43897. maxDragAngle: number;
  43898. /**
  43899. * @hidden
  43900. */
  43901. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43902. /**
  43903. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43904. */
  43905. currentDraggingPointerID: number;
  43906. /**
  43907. * The last position where the pointer hit the drag plane in world space
  43908. */
  43909. lastDragPosition: Vector3;
  43910. /**
  43911. * If the behavior is currently in a dragging state
  43912. */
  43913. dragging: boolean;
  43914. /**
  43915. * 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)
  43916. */
  43917. dragDeltaRatio: number;
  43918. /**
  43919. * If the drag plane orientation should be updated during the dragging (Default: true)
  43920. */
  43921. updateDragPlane: boolean;
  43922. private _debugMode;
  43923. private _moving;
  43924. /**
  43925. * Fires each time the attached mesh is dragged with the pointer
  43926. * * delta between last drag position and current drag position in world space
  43927. * * dragDistance along the drag axis
  43928. * * dragPlaneNormal normal of the current drag plane used during the drag
  43929. * * dragPlanePoint in world space where the drag intersects the drag plane
  43930. */
  43931. onDragObservable: Observable<{
  43932. delta: Vector3;
  43933. dragPlanePoint: Vector3;
  43934. dragPlaneNormal: Vector3;
  43935. dragDistance: number;
  43936. pointerId: number;
  43937. }>;
  43938. /**
  43939. * Fires each time a drag begins (eg. mouse down on mesh)
  43940. */
  43941. onDragStartObservable: Observable<{
  43942. dragPlanePoint: Vector3;
  43943. pointerId: number;
  43944. }>;
  43945. /**
  43946. * Fires each time a drag ends (eg. mouse release after drag)
  43947. */
  43948. onDragEndObservable: Observable<{
  43949. dragPlanePoint: Vector3;
  43950. pointerId: number;
  43951. }>;
  43952. /**
  43953. * If the attached mesh should be moved when dragged
  43954. */
  43955. moveAttached: boolean;
  43956. /**
  43957. * If the drag behavior will react to drag events (Default: true)
  43958. */
  43959. enabled: boolean;
  43960. /**
  43961. * If pointer events should start and release the drag (Default: true)
  43962. */
  43963. startAndReleaseDragOnPointerEvents: boolean;
  43964. /**
  43965. * If camera controls should be detached during the drag
  43966. */
  43967. detachCameraControls: boolean;
  43968. /**
  43969. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43970. */
  43971. useObjectOrientationForDragging: boolean;
  43972. private _options;
  43973. /**
  43974. * Gets the options used by the behavior
  43975. */
  43976. get options(): {
  43977. dragAxis?: Vector3;
  43978. dragPlaneNormal?: Vector3;
  43979. };
  43980. /**
  43981. * Sets the options used by the behavior
  43982. */
  43983. set options(options: {
  43984. dragAxis?: Vector3;
  43985. dragPlaneNormal?: Vector3;
  43986. });
  43987. /**
  43988. * Creates a pointer drag behavior that can be attached to a mesh
  43989. * @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)
  43990. */
  43991. constructor(options?: {
  43992. dragAxis?: Vector3;
  43993. dragPlaneNormal?: Vector3;
  43994. });
  43995. /**
  43996. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43997. */
  43998. validateDrag: (targetPosition: Vector3) => boolean;
  43999. /**
  44000. * The name of the behavior
  44001. */
  44002. get name(): string;
  44003. /**
  44004. * Initializes the behavior
  44005. */
  44006. init(): void;
  44007. private _tmpVector;
  44008. private _alternatePickedPoint;
  44009. private _worldDragAxis;
  44010. private _targetPosition;
  44011. private _attachedElement;
  44012. /**
  44013. * Attaches the drag behavior the passed in mesh
  44014. * @param ownerNode The mesh that will be dragged around once attached
  44015. * @param predicate Predicate to use for pick filtering
  44016. */
  44017. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44018. /**
  44019. * Force relase the drag action by code.
  44020. */
  44021. releaseDrag(): void;
  44022. private _startDragRay;
  44023. private _lastPointerRay;
  44024. /**
  44025. * Simulates the start of a pointer drag event on the behavior
  44026. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44027. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44028. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44029. */
  44030. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44031. private _startDrag;
  44032. private _dragDelta;
  44033. private _moveDrag;
  44034. private _pickWithRayOnDragPlane;
  44035. private _pointA;
  44036. private _pointB;
  44037. private _pointC;
  44038. private _lineA;
  44039. private _lineB;
  44040. private _localAxis;
  44041. private _lookAt;
  44042. private _updateDragPlanePosition;
  44043. /**
  44044. * Detaches the behavior from the mesh
  44045. */
  44046. detach(): void;
  44047. }
  44048. }
  44049. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44050. import { Mesh } from "babylonjs/Meshes/mesh";
  44051. import { Behavior } from "babylonjs/Behaviors/behavior";
  44052. /**
  44053. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44054. */
  44055. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44056. private _dragBehaviorA;
  44057. private _dragBehaviorB;
  44058. private _startDistance;
  44059. private _initialScale;
  44060. private _targetScale;
  44061. private _ownerNode;
  44062. private _sceneRenderObserver;
  44063. /**
  44064. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44065. */
  44066. constructor();
  44067. /**
  44068. * The name of the behavior
  44069. */
  44070. get name(): string;
  44071. /**
  44072. * Initializes the behavior
  44073. */
  44074. init(): void;
  44075. private _getCurrentDistance;
  44076. /**
  44077. * Attaches the scale behavior the passed in mesh
  44078. * @param ownerNode The mesh that will be scaled around once attached
  44079. */
  44080. attach(ownerNode: Mesh): void;
  44081. /**
  44082. * Detaches the behavior from the mesh
  44083. */
  44084. detach(): void;
  44085. }
  44086. }
  44087. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44088. import { Behavior } from "babylonjs/Behaviors/behavior";
  44089. import { Mesh } from "babylonjs/Meshes/mesh";
  44090. import { Observable } from "babylonjs/Misc/observable";
  44091. /**
  44092. * 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
  44093. */
  44094. export class SixDofDragBehavior implements Behavior<Mesh> {
  44095. private static _virtualScene;
  44096. private _ownerNode;
  44097. private _sceneRenderObserver;
  44098. private _scene;
  44099. private _targetPosition;
  44100. private _virtualOriginMesh;
  44101. private _virtualDragMesh;
  44102. private _pointerObserver;
  44103. private _moving;
  44104. private _startingOrientation;
  44105. private _attachedElement;
  44106. /**
  44107. * 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)
  44108. */
  44109. private zDragFactor;
  44110. /**
  44111. * If the object should rotate to face the drag origin
  44112. */
  44113. rotateDraggedObject: boolean;
  44114. /**
  44115. * If the behavior is currently in a dragging state
  44116. */
  44117. dragging: boolean;
  44118. /**
  44119. * 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)
  44120. */
  44121. dragDeltaRatio: number;
  44122. /**
  44123. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44124. */
  44125. currentDraggingPointerID: number;
  44126. /**
  44127. * If camera controls should be detached during the drag
  44128. */
  44129. detachCameraControls: boolean;
  44130. /**
  44131. * Fires each time a drag starts
  44132. */
  44133. onDragStartObservable: Observable<{}>;
  44134. /**
  44135. * Fires each time a drag ends (eg. mouse release after drag)
  44136. */
  44137. onDragEndObservable: Observable<{}>;
  44138. /**
  44139. * 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
  44140. */
  44141. constructor();
  44142. /**
  44143. * The name of the behavior
  44144. */
  44145. get name(): string;
  44146. /**
  44147. * Initializes the behavior
  44148. */
  44149. init(): void;
  44150. /**
  44151. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44152. */
  44153. private get _pointerCamera();
  44154. /**
  44155. * Attaches the scale behavior the passed in mesh
  44156. * @param ownerNode The mesh that will be scaled around once attached
  44157. */
  44158. attach(ownerNode: Mesh): void;
  44159. /**
  44160. * Detaches the behavior from the mesh
  44161. */
  44162. detach(): void;
  44163. }
  44164. }
  44165. declare module "babylonjs/Behaviors/Meshes/index" {
  44166. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44167. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44168. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44169. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44170. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44171. }
  44172. declare module "babylonjs/Behaviors/index" {
  44173. export * from "babylonjs/Behaviors/behavior";
  44174. export * from "babylonjs/Behaviors/Cameras/index";
  44175. export * from "babylonjs/Behaviors/Meshes/index";
  44176. }
  44177. declare module "babylonjs/Bones/boneIKController" {
  44178. import { Bone } from "babylonjs/Bones/bone";
  44179. import { Vector3 } from "babylonjs/Maths/math.vector";
  44180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44181. import { Nullable } from "babylonjs/types";
  44182. /**
  44183. * Class used to apply inverse kinematics to bones
  44184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44185. */
  44186. export class BoneIKController {
  44187. private static _tmpVecs;
  44188. private static _tmpQuat;
  44189. private static _tmpMats;
  44190. /**
  44191. * Gets or sets the target mesh
  44192. */
  44193. targetMesh: AbstractMesh;
  44194. /** Gets or sets the mesh used as pole */
  44195. poleTargetMesh: AbstractMesh;
  44196. /**
  44197. * Gets or sets the bone used as pole
  44198. */
  44199. poleTargetBone: Nullable<Bone>;
  44200. /**
  44201. * Gets or sets the target position
  44202. */
  44203. targetPosition: Vector3;
  44204. /**
  44205. * Gets or sets the pole target position
  44206. */
  44207. poleTargetPosition: Vector3;
  44208. /**
  44209. * Gets or sets the pole target local offset
  44210. */
  44211. poleTargetLocalOffset: Vector3;
  44212. /**
  44213. * Gets or sets the pole angle
  44214. */
  44215. poleAngle: number;
  44216. /**
  44217. * Gets or sets the mesh associated with the controller
  44218. */
  44219. mesh: AbstractMesh;
  44220. /**
  44221. * 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)
  44222. */
  44223. slerpAmount: number;
  44224. private _bone1Quat;
  44225. private _bone1Mat;
  44226. private _bone2Ang;
  44227. private _bone1;
  44228. private _bone2;
  44229. private _bone1Length;
  44230. private _bone2Length;
  44231. private _maxAngle;
  44232. private _maxReach;
  44233. private _rightHandedSystem;
  44234. private _bendAxis;
  44235. private _slerping;
  44236. private _adjustRoll;
  44237. /**
  44238. * Gets or sets maximum allowed angle
  44239. */
  44240. get maxAngle(): number;
  44241. set maxAngle(value: number);
  44242. /**
  44243. * Creates a new BoneIKController
  44244. * @param mesh defines the mesh to control
  44245. * @param bone defines the bone to control
  44246. * @param options defines options to set up the controller
  44247. */
  44248. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44249. targetMesh?: AbstractMesh;
  44250. poleTargetMesh?: AbstractMesh;
  44251. poleTargetBone?: Bone;
  44252. poleTargetLocalOffset?: Vector3;
  44253. poleAngle?: number;
  44254. bendAxis?: Vector3;
  44255. maxAngle?: number;
  44256. slerpAmount?: number;
  44257. });
  44258. private _setMaxAngle;
  44259. /**
  44260. * Force the controller to update the bones
  44261. */
  44262. update(): void;
  44263. }
  44264. }
  44265. declare module "babylonjs/Bones/boneLookController" {
  44266. import { Vector3 } from "babylonjs/Maths/math.vector";
  44267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44268. import { Bone } from "babylonjs/Bones/bone";
  44269. import { Space } from "babylonjs/Maths/math.axis";
  44270. /**
  44271. * Class used to make a bone look toward a point in space
  44272. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44273. */
  44274. export class BoneLookController {
  44275. private static _tmpVecs;
  44276. private static _tmpQuat;
  44277. private static _tmpMats;
  44278. /**
  44279. * The target Vector3 that the bone will look at
  44280. */
  44281. target: Vector3;
  44282. /**
  44283. * The mesh that the bone is attached to
  44284. */
  44285. mesh: AbstractMesh;
  44286. /**
  44287. * The bone that will be looking to the target
  44288. */
  44289. bone: Bone;
  44290. /**
  44291. * The up axis of the coordinate system that is used when the bone is rotated
  44292. */
  44293. upAxis: Vector3;
  44294. /**
  44295. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44296. */
  44297. upAxisSpace: Space;
  44298. /**
  44299. * Used to make an adjustment to the yaw of the bone
  44300. */
  44301. adjustYaw: number;
  44302. /**
  44303. * Used to make an adjustment to the pitch of the bone
  44304. */
  44305. adjustPitch: number;
  44306. /**
  44307. * Used to make an adjustment to the roll of the bone
  44308. */
  44309. adjustRoll: number;
  44310. /**
  44311. * 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)
  44312. */
  44313. slerpAmount: number;
  44314. private _minYaw;
  44315. private _maxYaw;
  44316. private _minPitch;
  44317. private _maxPitch;
  44318. private _minYawSin;
  44319. private _minYawCos;
  44320. private _maxYawSin;
  44321. private _maxYawCos;
  44322. private _midYawConstraint;
  44323. private _minPitchTan;
  44324. private _maxPitchTan;
  44325. private _boneQuat;
  44326. private _slerping;
  44327. private _transformYawPitch;
  44328. private _transformYawPitchInv;
  44329. private _firstFrameSkipped;
  44330. private _yawRange;
  44331. private _fowardAxis;
  44332. /**
  44333. * Gets or sets the minimum yaw angle that the bone can look to
  44334. */
  44335. get minYaw(): number;
  44336. set minYaw(value: number);
  44337. /**
  44338. * Gets or sets the maximum yaw angle that the bone can look to
  44339. */
  44340. get maxYaw(): number;
  44341. set maxYaw(value: number);
  44342. /**
  44343. * Gets or sets the minimum pitch angle that the bone can look to
  44344. */
  44345. get minPitch(): number;
  44346. set minPitch(value: number);
  44347. /**
  44348. * Gets or sets the maximum pitch angle that the bone can look to
  44349. */
  44350. get maxPitch(): number;
  44351. set maxPitch(value: number);
  44352. /**
  44353. * Create a BoneLookController
  44354. * @param mesh the mesh that the bone belongs to
  44355. * @param bone the bone that will be looking to the target
  44356. * @param target the target Vector3 to look at
  44357. * @param options optional settings:
  44358. * * maxYaw: the maximum angle the bone will yaw to
  44359. * * minYaw: the minimum angle the bone will yaw to
  44360. * * maxPitch: the maximum angle the bone will pitch to
  44361. * * minPitch: the minimum angle the bone will yaw to
  44362. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44363. * * upAxis: the up axis of the coordinate system
  44364. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44365. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44366. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44367. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44368. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44369. * * adjustRoll: used to make an adjustment to the roll of the bone
  44370. **/
  44371. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44372. maxYaw?: number;
  44373. minYaw?: number;
  44374. maxPitch?: number;
  44375. minPitch?: number;
  44376. slerpAmount?: number;
  44377. upAxis?: Vector3;
  44378. upAxisSpace?: Space;
  44379. yawAxis?: Vector3;
  44380. pitchAxis?: Vector3;
  44381. adjustYaw?: number;
  44382. adjustPitch?: number;
  44383. adjustRoll?: number;
  44384. });
  44385. /**
  44386. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44387. */
  44388. update(): void;
  44389. private _getAngleDiff;
  44390. private _getAngleBetween;
  44391. private _isAngleBetween;
  44392. }
  44393. }
  44394. declare module "babylonjs/Bones/index" {
  44395. export * from "babylonjs/Bones/bone";
  44396. export * from "babylonjs/Bones/boneIKController";
  44397. export * from "babylonjs/Bones/boneLookController";
  44398. export * from "babylonjs/Bones/skeleton";
  44399. }
  44400. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44401. import { Nullable } from "babylonjs/types";
  44402. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44404. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44405. /**
  44406. * Manage the gamepad inputs to control an arc rotate camera.
  44407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44408. */
  44409. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44410. /**
  44411. * Defines the camera the input is attached to.
  44412. */
  44413. camera: ArcRotateCamera;
  44414. /**
  44415. * Defines the gamepad the input is gathering event from.
  44416. */
  44417. gamepad: Nullable<Gamepad>;
  44418. /**
  44419. * Defines the gamepad rotation sensiblity.
  44420. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44421. */
  44422. gamepadRotationSensibility: number;
  44423. /**
  44424. * Defines the gamepad move sensiblity.
  44425. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44426. */
  44427. gamepadMoveSensibility: number;
  44428. private _yAxisScale;
  44429. /**
  44430. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44431. */
  44432. get invertYAxis(): boolean;
  44433. set invertYAxis(value: boolean);
  44434. private _onGamepadConnectedObserver;
  44435. private _onGamepadDisconnectedObserver;
  44436. /**
  44437. * Attach the input controls to a specific dom element to get the input from.
  44438. * @param element Defines the element the controls should be listened from
  44439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44440. */
  44441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44442. /**
  44443. * Detach the current controls from the specified dom element.
  44444. * @param element Defines the element to stop listening the inputs from
  44445. */
  44446. detachControl(element: Nullable<HTMLElement>): void;
  44447. /**
  44448. * Update the current camera state depending on the inputs that have been used this frame.
  44449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44450. */
  44451. checkInputs(): void;
  44452. /**
  44453. * Gets the class name of the current intput.
  44454. * @returns the class name
  44455. */
  44456. getClassName(): string;
  44457. /**
  44458. * Get the friendly name associated with the input class.
  44459. * @returns the input friendly name
  44460. */
  44461. getSimpleName(): string;
  44462. }
  44463. }
  44464. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44465. import { Nullable } from "babylonjs/types";
  44466. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44467. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44468. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44469. interface ArcRotateCameraInputsManager {
  44470. /**
  44471. * Add orientation input support to the input manager.
  44472. * @returns the current input manager
  44473. */
  44474. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44475. }
  44476. }
  44477. /**
  44478. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44480. */
  44481. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44482. /**
  44483. * Defines the camera the input is attached to.
  44484. */
  44485. camera: ArcRotateCamera;
  44486. /**
  44487. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44488. */
  44489. alphaCorrection: number;
  44490. /**
  44491. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44492. */
  44493. gammaCorrection: number;
  44494. private _alpha;
  44495. private _gamma;
  44496. private _dirty;
  44497. private _deviceOrientationHandler;
  44498. /**
  44499. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44500. */
  44501. constructor();
  44502. /**
  44503. * Attach the input controls to a specific dom element to get the input from.
  44504. * @param element Defines the element the controls should be listened from
  44505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44506. */
  44507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44508. /** @hidden */
  44509. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44510. /**
  44511. * Update the current camera state depending on the inputs that have been used this frame.
  44512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44513. */
  44514. checkInputs(): void;
  44515. /**
  44516. * Detach the current controls from the specified dom element.
  44517. * @param element Defines the element to stop listening the inputs from
  44518. */
  44519. detachControl(element: Nullable<HTMLElement>): void;
  44520. /**
  44521. * Gets the class name of the current intput.
  44522. * @returns the class name
  44523. */
  44524. getClassName(): string;
  44525. /**
  44526. * Get the friendly name associated with the input class.
  44527. * @returns the input friendly name
  44528. */
  44529. getSimpleName(): string;
  44530. }
  44531. }
  44532. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44535. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44536. /**
  44537. * Listen to mouse events to control the camera.
  44538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44539. */
  44540. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44541. /**
  44542. * Defines the camera the input is attached to.
  44543. */
  44544. camera: FlyCamera;
  44545. /**
  44546. * Defines if touch is enabled. (Default is true.)
  44547. */
  44548. touchEnabled: boolean;
  44549. /**
  44550. * Defines the buttons associated with the input to handle camera rotation.
  44551. */
  44552. buttons: number[];
  44553. /**
  44554. * Assign buttons for Yaw control.
  44555. */
  44556. buttonsYaw: number[];
  44557. /**
  44558. * Assign buttons for Pitch control.
  44559. */
  44560. buttonsPitch: number[];
  44561. /**
  44562. * Assign buttons for Roll control.
  44563. */
  44564. buttonsRoll: number[];
  44565. /**
  44566. * Detect if any button is being pressed while mouse is moved.
  44567. * -1 = Mouse locked.
  44568. * 0 = Left button.
  44569. * 1 = Middle Button.
  44570. * 2 = Right Button.
  44571. */
  44572. activeButton: number;
  44573. /**
  44574. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44575. * Higher values reduce its sensitivity.
  44576. */
  44577. angularSensibility: number;
  44578. private _mousemoveCallback;
  44579. private _observer;
  44580. private _rollObserver;
  44581. private previousPosition;
  44582. private noPreventDefault;
  44583. private element;
  44584. /**
  44585. * Listen to mouse events to control the camera.
  44586. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44588. */
  44589. constructor(touchEnabled?: boolean);
  44590. /**
  44591. * Attach the mouse control to the HTML DOM element.
  44592. * @param element Defines the element that listens to the input events.
  44593. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44594. */
  44595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44596. /**
  44597. * Detach the current controls from the specified dom element.
  44598. * @param element Defines the element to stop listening the inputs from
  44599. */
  44600. detachControl(element: Nullable<HTMLElement>): void;
  44601. /**
  44602. * Gets the class name of the current input.
  44603. * @returns the class name.
  44604. */
  44605. getClassName(): string;
  44606. /**
  44607. * Get the friendly name associated with the input class.
  44608. * @returns the input's friendly name.
  44609. */
  44610. getSimpleName(): string;
  44611. private _pointerInput;
  44612. private _onMouseMove;
  44613. /**
  44614. * Rotate camera by mouse offset.
  44615. */
  44616. private rotateCamera;
  44617. }
  44618. }
  44619. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44620. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44621. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44622. /**
  44623. * Default Inputs manager for the FlyCamera.
  44624. * It groups all the default supported inputs for ease of use.
  44625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44626. */
  44627. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44628. /**
  44629. * Instantiates a new FlyCameraInputsManager.
  44630. * @param camera Defines the camera the inputs belong to.
  44631. */
  44632. constructor(camera: FlyCamera);
  44633. /**
  44634. * Add keyboard input support to the input manager.
  44635. * @returns the new FlyCameraKeyboardMoveInput().
  44636. */
  44637. addKeyboard(): FlyCameraInputsManager;
  44638. /**
  44639. * Add mouse input support to the input manager.
  44640. * @param touchEnabled Enable touch screen support.
  44641. * @returns the new FlyCameraMouseInput().
  44642. */
  44643. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44644. }
  44645. }
  44646. declare module "babylonjs/Cameras/flyCamera" {
  44647. import { Scene } from "babylonjs/scene";
  44648. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44650. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44651. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44652. /**
  44653. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44654. * such as in a 3D Space Shooter or a Flight Simulator.
  44655. */
  44656. export class FlyCamera extends TargetCamera {
  44657. /**
  44658. * Define the collision ellipsoid of the camera.
  44659. * This is helpful for simulating a camera body, like a player's body.
  44660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44661. */
  44662. ellipsoid: Vector3;
  44663. /**
  44664. * Define an offset for the position of the ellipsoid around the camera.
  44665. * This can be helpful if the camera is attached away from the player's body center,
  44666. * such as at its head.
  44667. */
  44668. ellipsoidOffset: Vector3;
  44669. /**
  44670. * Enable or disable collisions of the camera with the rest of the scene objects.
  44671. */
  44672. checkCollisions: boolean;
  44673. /**
  44674. * Enable or disable gravity on the camera.
  44675. */
  44676. applyGravity: boolean;
  44677. /**
  44678. * Define the current direction the camera is moving to.
  44679. */
  44680. cameraDirection: Vector3;
  44681. /**
  44682. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44683. * This overrides and empties cameraRotation.
  44684. */
  44685. rotationQuaternion: Quaternion;
  44686. /**
  44687. * Track Roll to maintain the wanted Rolling when looking around.
  44688. */
  44689. _trackRoll: number;
  44690. /**
  44691. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44692. */
  44693. rollCorrect: number;
  44694. /**
  44695. * Mimic a banked turn, Rolling the camera when Yawing.
  44696. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44697. */
  44698. bankedTurn: boolean;
  44699. /**
  44700. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44701. */
  44702. bankedTurnLimit: number;
  44703. /**
  44704. * Value of 0 disables the banked Roll.
  44705. * Value of 1 is equal to the Yaw angle in radians.
  44706. */
  44707. bankedTurnMultiplier: number;
  44708. /**
  44709. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44710. */
  44711. inputs: FlyCameraInputsManager;
  44712. /**
  44713. * Gets the input sensibility for mouse input.
  44714. * Higher values reduce sensitivity.
  44715. */
  44716. get angularSensibility(): number;
  44717. /**
  44718. * Sets the input sensibility for a mouse input.
  44719. * Higher values reduce sensitivity.
  44720. */
  44721. set angularSensibility(value: number);
  44722. /**
  44723. * Get the keys for camera movement forward.
  44724. */
  44725. get keysForward(): number[];
  44726. /**
  44727. * Set the keys for camera movement forward.
  44728. */
  44729. set keysForward(value: number[]);
  44730. /**
  44731. * Get the keys for camera movement backward.
  44732. */
  44733. get keysBackward(): number[];
  44734. set keysBackward(value: number[]);
  44735. /**
  44736. * Get the keys for camera movement up.
  44737. */
  44738. get keysUp(): number[];
  44739. /**
  44740. * Set the keys for camera movement up.
  44741. */
  44742. set keysUp(value: number[]);
  44743. /**
  44744. * Get the keys for camera movement down.
  44745. */
  44746. get keysDown(): number[];
  44747. /**
  44748. * Set the keys for camera movement down.
  44749. */
  44750. set keysDown(value: number[]);
  44751. /**
  44752. * Get the keys for camera movement left.
  44753. */
  44754. get keysLeft(): number[];
  44755. /**
  44756. * Set the keys for camera movement left.
  44757. */
  44758. set keysLeft(value: number[]);
  44759. /**
  44760. * Set the keys for camera movement right.
  44761. */
  44762. get keysRight(): number[];
  44763. /**
  44764. * Set the keys for camera movement right.
  44765. */
  44766. set keysRight(value: number[]);
  44767. /**
  44768. * Event raised when the camera collides with a mesh in the scene.
  44769. */
  44770. onCollide: (collidedMesh: AbstractMesh) => void;
  44771. private _collider;
  44772. private _needMoveForGravity;
  44773. private _oldPosition;
  44774. private _diffPosition;
  44775. private _newPosition;
  44776. /** @hidden */
  44777. _localDirection: Vector3;
  44778. /** @hidden */
  44779. _transformedDirection: Vector3;
  44780. /**
  44781. * Instantiates a FlyCamera.
  44782. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44783. * such as in a 3D Space Shooter or a Flight Simulator.
  44784. * @param name Define the name of the camera in the scene.
  44785. * @param position Define the starting position of the camera in the scene.
  44786. * @param scene Define the scene the camera belongs to.
  44787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44788. */
  44789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44790. /**
  44791. * Attach a control to the HTML DOM element.
  44792. * @param element Defines the element that listens to the input events.
  44793. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44794. */
  44795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44796. /**
  44797. * Detach a control from the HTML DOM element.
  44798. * The camera will stop reacting to that input.
  44799. * @param element Defines the element that listens to the input events.
  44800. */
  44801. detachControl(element: HTMLElement): void;
  44802. private _collisionMask;
  44803. /**
  44804. * Get the mask that the camera ignores in collision events.
  44805. */
  44806. get collisionMask(): number;
  44807. /**
  44808. * Set the mask that the camera ignores in collision events.
  44809. */
  44810. set collisionMask(mask: number);
  44811. /** @hidden */
  44812. _collideWithWorld(displacement: Vector3): void;
  44813. /** @hidden */
  44814. private _onCollisionPositionChange;
  44815. /** @hidden */
  44816. _checkInputs(): void;
  44817. /** @hidden */
  44818. _decideIfNeedsToMove(): boolean;
  44819. /** @hidden */
  44820. _updatePosition(): void;
  44821. /**
  44822. * Restore the Roll to its target value at the rate specified.
  44823. * @param rate - Higher means slower restoring.
  44824. * @hidden
  44825. */
  44826. restoreRoll(rate: number): void;
  44827. /**
  44828. * Destroy the camera and release the current resources held by it.
  44829. */
  44830. dispose(): void;
  44831. /**
  44832. * Get the current object class name.
  44833. * @returns the class name.
  44834. */
  44835. getClassName(): string;
  44836. }
  44837. }
  44838. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44839. import { Nullable } from "babylonjs/types";
  44840. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44841. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44842. /**
  44843. * Listen to keyboard events to control the camera.
  44844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44845. */
  44846. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44847. /**
  44848. * Defines the camera the input is attached to.
  44849. */
  44850. camera: FlyCamera;
  44851. /**
  44852. * The list of keyboard keys used to control the forward move of the camera.
  44853. */
  44854. keysForward: number[];
  44855. /**
  44856. * The list of keyboard keys used to control the backward move of the camera.
  44857. */
  44858. keysBackward: number[];
  44859. /**
  44860. * The list of keyboard keys used to control the forward move of the camera.
  44861. */
  44862. keysUp: number[];
  44863. /**
  44864. * The list of keyboard keys used to control the backward move of the camera.
  44865. */
  44866. keysDown: number[];
  44867. /**
  44868. * The list of keyboard keys used to control the right strafe move of the camera.
  44869. */
  44870. keysRight: number[];
  44871. /**
  44872. * The list of keyboard keys used to control the left strafe move of the camera.
  44873. */
  44874. keysLeft: number[];
  44875. private _keys;
  44876. private _onCanvasBlurObserver;
  44877. private _onKeyboardObserver;
  44878. private _engine;
  44879. private _scene;
  44880. /**
  44881. * Attach the input controls to a specific dom element to get the input from.
  44882. * @param element Defines the element the controls should be listened from
  44883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44884. */
  44885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44886. /**
  44887. * Detach the current controls from the specified dom element.
  44888. * @param element Defines the element to stop listening the inputs from
  44889. */
  44890. detachControl(element: Nullable<HTMLElement>): void;
  44891. /**
  44892. * Gets the class name of the current intput.
  44893. * @returns the class name
  44894. */
  44895. getClassName(): string;
  44896. /** @hidden */
  44897. _onLostFocus(e: FocusEvent): void;
  44898. /**
  44899. * Get the friendly name associated with the input class.
  44900. * @returns the input friendly name
  44901. */
  44902. getSimpleName(): string;
  44903. /**
  44904. * Update the current camera state depending on the inputs that have been used this frame.
  44905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44906. */
  44907. checkInputs(): void;
  44908. }
  44909. }
  44910. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44911. import { Nullable } from "babylonjs/types";
  44912. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44914. /**
  44915. * Manage the mouse wheel inputs to control a follow camera.
  44916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44917. */
  44918. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44919. /**
  44920. * Defines the camera the input is attached to.
  44921. */
  44922. camera: FollowCamera;
  44923. /**
  44924. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44925. */
  44926. axisControlRadius: boolean;
  44927. /**
  44928. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44929. */
  44930. axisControlHeight: boolean;
  44931. /**
  44932. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44933. */
  44934. axisControlRotation: boolean;
  44935. /**
  44936. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44937. * relation to mouseWheel events.
  44938. */
  44939. wheelPrecision: number;
  44940. /**
  44941. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44942. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44943. */
  44944. wheelDeltaPercentage: number;
  44945. private _wheel;
  44946. private _observer;
  44947. /**
  44948. * Attach the input controls to a specific dom element to get the input from.
  44949. * @param element Defines the element the controls should be listened from
  44950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44951. */
  44952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44953. /**
  44954. * Detach the current controls from the specified dom element.
  44955. * @param element Defines the element to stop listening the inputs from
  44956. */
  44957. detachControl(element: Nullable<HTMLElement>): void;
  44958. /**
  44959. * Gets the class name of the current intput.
  44960. * @returns the class name
  44961. */
  44962. getClassName(): string;
  44963. /**
  44964. * Get the friendly name associated with the input class.
  44965. * @returns the input friendly name
  44966. */
  44967. getSimpleName(): string;
  44968. }
  44969. }
  44970. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44971. import { Nullable } from "babylonjs/types";
  44972. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44973. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44974. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44975. /**
  44976. * Manage the pointers inputs to control an follow camera.
  44977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44978. */
  44979. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44980. /**
  44981. * Defines the camera the input is attached to.
  44982. */
  44983. camera: FollowCamera;
  44984. /**
  44985. * Gets the class name of the current input.
  44986. * @returns the class name
  44987. */
  44988. getClassName(): string;
  44989. /**
  44990. * Defines the pointer angular sensibility along the X axis or how fast is
  44991. * the camera rotating.
  44992. * A negative number will reverse the axis direction.
  44993. */
  44994. angularSensibilityX: number;
  44995. /**
  44996. * Defines the pointer angular sensibility along the Y axis or how fast is
  44997. * the camera rotating.
  44998. * A negative number will reverse the axis direction.
  44999. */
  45000. angularSensibilityY: number;
  45001. /**
  45002. * Defines the pointer pinch precision or how fast is the camera zooming.
  45003. * A negative number will reverse the axis direction.
  45004. */
  45005. pinchPrecision: number;
  45006. /**
  45007. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45008. * from 0.
  45009. * It defines the percentage of current camera.radius to use as delta when
  45010. * pinch zoom is used.
  45011. */
  45012. pinchDeltaPercentage: number;
  45013. /**
  45014. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45015. */
  45016. axisXControlRadius: boolean;
  45017. /**
  45018. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45019. */
  45020. axisXControlHeight: boolean;
  45021. /**
  45022. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45023. */
  45024. axisXControlRotation: boolean;
  45025. /**
  45026. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45027. */
  45028. axisYControlRadius: boolean;
  45029. /**
  45030. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45031. */
  45032. axisYControlHeight: boolean;
  45033. /**
  45034. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45035. */
  45036. axisYControlRotation: boolean;
  45037. /**
  45038. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45039. */
  45040. axisPinchControlRadius: boolean;
  45041. /**
  45042. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45043. */
  45044. axisPinchControlHeight: boolean;
  45045. /**
  45046. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45047. */
  45048. axisPinchControlRotation: boolean;
  45049. /**
  45050. * Log error messages if basic misconfiguration has occurred.
  45051. */
  45052. warningEnable: boolean;
  45053. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45054. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45055. private _warningCounter;
  45056. private _warning;
  45057. }
  45058. }
  45059. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45060. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45061. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45062. /**
  45063. * Default Inputs manager for the FollowCamera.
  45064. * It groups all the default supported inputs for ease of use.
  45065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45066. */
  45067. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45068. /**
  45069. * Instantiates a new FollowCameraInputsManager.
  45070. * @param camera Defines the camera the inputs belong to
  45071. */
  45072. constructor(camera: FollowCamera);
  45073. /**
  45074. * Add keyboard input support to the input manager.
  45075. * @returns the current input manager
  45076. */
  45077. addKeyboard(): FollowCameraInputsManager;
  45078. /**
  45079. * Add mouse wheel input support to the input manager.
  45080. * @returns the current input manager
  45081. */
  45082. addMouseWheel(): FollowCameraInputsManager;
  45083. /**
  45084. * Add pointers input support to the input manager.
  45085. * @returns the current input manager
  45086. */
  45087. addPointers(): FollowCameraInputsManager;
  45088. /**
  45089. * Add orientation input support to the input manager.
  45090. * @returns the current input manager
  45091. */
  45092. addVRDeviceOrientation(): FollowCameraInputsManager;
  45093. }
  45094. }
  45095. declare module "babylonjs/Cameras/followCamera" {
  45096. import { Nullable } from "babylonjs/types";
  45097. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45098. import { Scene } from "babylonjs/scene";
  45099. import { Vector3 } from "babylonjs/Maths/math.vector";
  45100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45101. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45102. /**
  45103. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45104. * an arc rotate version arcFollowCamera are available.
  45105. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45106. */
  45107. export class FollowCamera extends TargetCamera {
  45108. /**
  45109. * Distance the follow camera should follow an object at
  45110. */
  45111. radius: number;
  45112. /**
  45113. * Minimum allowed distance of the camera to the axis of rotation
  45114. * (The camera can not get closer).
  45115. * This can help limiting how the Camera is able to move in the scene.
  45116. */
  45117. lowerRadiusLimit: Nullable<number>;
  45118. /**
  45119. * Maximum allowed distance of the camera to the axis of rotation
  45120. * (The camera can not get further).
  45121. * This can help limiting how the Camera is able to move in the scene.
  45122. */
  45123. upperRadiusLimit: Nullable<number>;
  45124. /**
  45125. * Define a rotation offset between the camera and the object it follows
  45126. */
  45127. rotationOffset: number;
  45128. /**
  45129. * Minimum allowed angle to camera position relative to target object.
  45130. * This can help limiting how the Camera is able to move in the scene.
  45131. */
  45132. lowerRotationOffsetLimit: Nullable<number>;
  45133. /**
  45134. * Maximum allowed angle to camera position relative to target object.
  45135. * This can help limiting how the Camera is able to move in the scene.
  45136. */
  45137. upperRotationOffsetLimit: Nullable<number>;
  45138. /**
  45139. * Define a height offset between the camera and the object it follows.
  45140. * It can help following an object from the top (like a car chaing a plane)
  45141. */
  45142. heightOffset: number;
  45143. /**
  45144. * Minimum allowed height of camera position relative to target object.
  45145. * This can help limiting how the Camera is able to move in the scene.
  45146. */
  45147. lowerHeightOffsetLimit: Nullable<number>;
  45148. /**
  45149. * Maximum allowed height of camera position relative to target object.
  45150. * This can help limiting how the Camera is able to move in the scene.
  45151. */
  45152. upperHeightOffsetLimit: Nullable<number>;
  45153. /**
  45154. * Define how fast the camera can accelerate to follow it s target.
  45155. */
  45156. cameraAcceleration: number;
  45157. /**
  45158. * Define the speed limit of the camera following an object.
  45159. */
  45160. maxCameraSpeed: number;
  45161. /**
  45162. * Define the target of the camera.
  45163. */
  45164. lockedTarget: Nullable<AbstractMesh>;
  45165. /**
  45166. * Defines the input associated with the camera.
  45167. */
  45168. inputs: FollowCameraInputsManager;
  45169. /**
  45170. * Instantiates the follow camera.
  45171. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45172. * @param name Define the name of the camera in the scene
  45173. * @param position Define the position of the camera
  45174. * @param scene Define the scene the camera belong to
  45175. * @param lockedTarget Define the target of the camera
  45176. */
  45177. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45178. private _follow;
  45179. /**
  45180. * Attached controls to the current camera.
  45181. * @param element Defines the element the controls should be listened from
  45182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45183. */
  45184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45185. /**
  45186. * Detach the current controls from the camera.
  45187. * The camera will stop reacting to inputs.
  45188. * @param element Defines the element to stop listening the inputs from
  45189. */
  45190. detachControl(element: HTMLElement): void;
  45191. /** @hidden */
  45192. _checkInputs(): void;
  45193. private _checkLimits;
  45194. /**
  45195. * Gets the camera class name.
  45196. * @returns the class name
  45197. */
  45198. getClassName(): string;
  45199. }
  45200. /**
  45201. * Arc Rotate version of the follow camera.
  45202. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45203. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45204. */
  45205. export class ArcFollowCamera extends TargetCamera {
  45206. /** The longitudinal angle of the camera */
  45207. alpha: number;
  45208. /** The latitudinal angle of the camera */
  45209. beta: number;
  45210. /** The radius of the camera from its target */
  45211. radius: number;
  45212. /** Define the camera target (the mesh it should follow) */
  45213. target: Nullable<AbstractMesh>;
  45214. private _cartesianCoordinates;
  45215. /**
  45216. * Instantiates a new ArcFollowCamera
  45217. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45218. * @param name Define the name of the camera
  45219. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45220. * @param beta Define the rotation angle of the camera around the elevation axis
  45221. * @param radius Define the radius of the camera from its target point
  45222. * @param target Define the target of the camera
  45223. * @param scene Define the scene the camera belongs to
  45224. */
  45225. constructor(name: string,
  45226. /** The longitudinal angle of the camera */
  45227. alpha: number,
  45228. /** The latitudinal angle of the camera */
  45229. beta: number,
  45230. /** The radius of the camera from its target */
  45231. radius: number,
  45232. /** Define the camera target (the mesh it should follow) */
  45233. target: Nullable<AbstractMesh>, scene: Scene);
  45234. private _follow;
  45235. /** @hidden */
  45236. _checkInputs(): void;
  45237. /**
  45238. * Returns the class name of the object.
  45239. * It is mostly used internally for serialization purposes.
  45240. */
  45241. getClassName(): string;
  45242. }
  45243. }
  45244. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45245. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45246. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45247. import { Nullable } from "babylonjs/types";
  45248. /**
  45249. * Manage the keyboard inputs to control the movement of a follow camera.
  45250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45251. */
  45252. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45253. /**
  45254. * Defines the camera the input is attached to.
  45255. */
  45256. camera: FollowCamera;
  45257. /**
  45258. * Defines the list of key codes associated with the up action (increase heightOffset)
  45259. */
  45260. keysHeightOffsetIncr: number[];
  45261. /**
  45262. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45263. */
  45264. keysHeightOffsetDecr: number[];
  45265. /**
  45266. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45267. */
  45268. keysHeightOffsetModifierAlt: boolean;
  45269. /**
  45270. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45271. */
  45272. keysHeightOffsetModifierCtrl: boolean;
  45273. /**
  45274. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45275. */
  45276. keysHeightOffsetModifierShift: boolean;
  45277. /**
  45278. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45279. */
  45280. keysRotationOffsetIncr: number[];
  45281. /**
  45282. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45283. */
  45284. keysRotationOffsetDecr: number[];
  45285. /**
  45286. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45287. */
  45288. keysRotationOffsetModifierAlt: boolean;
  45289. /**
  45290. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45291. */
  45292. keysRotationOffsetModifierCtrl: boolean;
  45293. /**
  45294. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45295. */
  45296. keysRotationOffsetModifierShift: boolean;
  45297. /**
  45298. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45299. */
  45300. keysRadiusIncr: number[];
  45301. /**
  45302. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45303. */
  45304. keysRadiusDecr: number[];
  45305. /**
  45306. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45307. */
  45308. keysRadiusModifierAlt: boolean;
  45309. /**
  45310. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45311. */
  45312. keysRadiusModifierCtrl: boolean;
  45313. /**
  45314. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45315. */
  45316. keysRadiusModifierShift: boolean;
  45317. /**
  45318. * Defines the rate of change of heightOffset.
  45319. */
  45320. heightSensibility: number;
  45321. /**
  45322. * Defines the rate of change of rotationOffset.
  45323. */
  45324. rotationSensibility: number;
  45325. /**
  45326. * Defines the rate of change of radius.
  45327. */
  45328. radiusSensibility: number;
  45329. private _keys;
  45330. private _ctrlPressed;
  45331. private _altPressed;
  45332. private _shiftPressed;
  45333. private _onCanvasBlurObserver;
  45334. private _onKeyboardObserver;
  45335. private _engine;
  45336. private _scene;
  45337. /**
  45338. * Attach the input controls to a specific dom element to get the input from.
  45339. * @param element Defines the element the controls should be listened from
  45340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45341. */
  45342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45343. /**
  45344. * Detach the current controls from the specified dom element.
  45345. * @param element Defines the element to stop listening the inputs from
  45346. */
  45347. detachControl(element: Nullable<HTMLElement>): void;
  45348. /**
  45349. * Update the current camera state depending on the inputs that have been used this frame.
  45350. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45351. */
  45352. checkInputs(): void;
  45353. /**
  45354. * Gets the class name of the current input.
  45355. * @returns the class name
  45356. */
  45357. getClassName(): string;
  45358. /**
  45359. * Get the friendly name associated with the input class.
  45360. * @returns the input friendly name
  45361. */
  45362. getSimpleName(): string;
  45363. /**
  45364. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45365. * allow modification of the heightOffset value.
  45366. */
  45367. private _modifierHeightOffset;
  45368. /**
  45369. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45370. * allow modification of the rotationOffset value.
  45371. */
  45372. private _modifierRotationOffset;
  45373. /**
  45374. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45375. * allow modification of the radius value.
  45376. */
  45377. private _modifierRadius;
  45378. }
  45379. }
  45380. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45381. import { Nullable } from "babylonjs/types";
  45382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45384. import { Observable } from "babylonjs/Misc/observable";
  45385. module "babylonjs/Cameras/freeCameraInputsManager" {
  45386. interface FreeCameraInputsManager {
  45387. /**
  45388. * @hidden
  45389. */
  45390. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45391. /**
  45392. * Add orientation input support to the input manager.
  45393. * @returns the current input manager
  45394. */
  45395. addDeviceOrientation(): FreeCameraInputsManager;
  45396. }
  45397. }
  45398. /**
  45399. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45400. * Screen rotation is taken into account.
  45401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45402. */
  45403. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45404. private _camera;
  45405. private _screenOrientationAngle;
  45406. private _constantTranform;
  45407. private _screenQuaternion;
  45408. private _alpha;
  45409. private _beta;
  45410. private _gamma;
  45411. /**
  45412. * Can be used to detect if a device orientation sensor is available on a device
  45413. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45414. * @returns a promise that will resolve on orientation change
  45415. */
  45416. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45417. /**
  45418. * @hidden
  45419. */
  45420. _onDeviceOrientationChangedObservable: Observable<void>;
  45421. /**
  45422. * Instantiates a new input
  45423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45424. */
  45425. constructor();
  45426. /**
  45427. * Define the camera controlled by the input.
  45428. */
  45429. get camera(): FreeCamera;
  45430. set camera(camera: FreeCamera);
  45431. /**
  45432. * Attach the input controls to a specific dom element to get the input from.
  45433. * @param element Defines the element the controls should be listened from
  45434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45435. */
  45436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45437. private _orientationChanged;
  45438. private _deviceOrientation;
  45439. /**
  45440. * Detach the current controls from the specified dom element.
  45441. * @param element Defines the element to stop listening the inputs from
  45442. */
  45443. detachControl(element: Nullable<HTMLElement>): void;
  45444. /**
  45445. * Update the current camera state depending on the inputs that have been used this frame.
  45446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45447. */
  45448. checkInputs(): void;
  45449. /**
  45450. * Gets the class name of the current intput.
  45451. * @returns the class name
  45452. */
  45453. getClassName(): string;
  45454. /**
  45455. * Get the friendly name associated with the input class.
  45456. * @returns the input friendly name
  45457. */
  45458. getSimpleName(): string;
  45459. }
  45460. }
  45461. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45462. import { Nullable } from "babylonjs/types";
  45463. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45464. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45465. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45466. /**
  45467. * Manage the gamepad inputs to control a free camera.
  45468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45469. */
  45470. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45471. /**
  45472. * Define the camera the input is attached to.
  45473. */
  45474. camera: FreeCamera;
  45475. /**
  45476. * Define the Gamepad controlling the input
  45477. */
  45478. gamepad: Nullable<Gamepad>;
  45479. /**
  45480. * Defines the gamepad rotation sensiblity.
  45481. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45482. */
  45483. gamepadAngularSensibility: number;
  45484. /**
  45485. * Defines the gamepad move sensiblity.
  45486. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45487. */
  45488. gamepadMoveSensibility: number;
  45489. private _yAxisScale;
  45490. /**
  45491. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45492. */
  45493. get invertYAxis(): boolean;
  45494. set invertYAxis(value: boolean);
  45495. private _onGamepadConnectedObserver;
  45496. private _onGamepadDisconnectedObserver;
  45497. private _cameraTransform;
  45498. private _deltaTransform;
  45499. private _vector3;
  45500. private _vector2;
  45501. /**
  45502. * Attach the input controls to a specific dom element to get the input from.
  45503. * @param element Defines the element the controls should be listened from
  45504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45505. */
  45506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45507. /**
  45508. * Detach the current controls from the specified dom element.
  45509. * @param element Defines the element to stop listening the inputs from
  45510. */
  45511. detachControl(element: Nullable<HTMLElement>): void;
  45512. /**
  45513. * Update the current camera state depending on the inputs that have been used this frame.
  45514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45515. */
  45516. checkInputs(): void;
  45517. /**
  45518. * Gets the class name of the current intput.
  45519. * @returns the class name
  45520. */
  45521. getClassName(): string;
  45522. /**
  45523. * Get the friendly name associated with the input class.
  45524. * @returns the input friendly name
  45525. */
  45526. getSimpleName(): string;
  45527. }
  45528. }
  45529. declare module "babylonjs/Misc/virtualJoystick" {
  45530. import { Nullable } from "babylonjs/types";
  45531. import { Vector3 } from "babylonjs/Maths/math.vector";
  45532. /**
  45533. * Defines the potential axis of a Joystick
  45534. */
  45535. export enum JoystickAxis {
  45536. /** X axis */
  45537. X = 0,
  45538. /** Y axis */
  45539. Y = 1,
  45540. /** Z axis */
  45541. Z = 2
  45542. }
  45543. /**
  45544. * Represents the different customization options available
  45545. * for VirtualJoystick
  45546. */
  45547. interface VirtualJoystickCustomizations {
  45548. /**
  45549. * Size of the joystick's puck
  45550. */
  45551. puckSize: number;
  45552. /**
  45553. * Size of the joystick's container
  45554. */
  45555. containerSize: number;
  45556. /**
  45557. * Color of the joystick && puck
  45558. */
  45559. color: string;
  45560. /**
  45561. * Image URL for the joystick's puck
  45562. */
  45563. puckImage?: string;
  45564. /**
  45565. * Image URL for the joystick's container
  45566. */
  45567. containerImage?: string;
  45568. /**
  45569. * Defines the unmoving position of the joystick container
  45570. */
  45571. position?: {
  45572. x: number;
  45573. y: number;
  45574. };
  45575. /**
  45576. * Defines whether or not the joystick container is always visible
  45577. */
  45578. alwaysVisible: boolean;
  45579. /**
  45580. * Defines whether or not to limit the movement of the puck to the joystick's container
  45581. */
  45582. limitToContainer: boolean;
  45583. }
  45584. /**
  45585. * Class used to define virtual joystick (used in touch mode)
  45586. */
  45587. export class VirtualJoystick {
  45588. /**
  45589. * Gets or sets a boolean indicating that left and right values must be inverted
  45590. */
  45591. reverseLeftRight: boolean;
  45592. /**
  45593. * Gets or sets a boolean indicating that up and down values must be inverted
  45594. */
  45595. reverseUpDown: boolean;
  45596. /**
  45597. * Gets the offset value for the position (ie. the change of the position value)
  45598. */
  45599. deltaPosition: Vector3;
  45600. /**
  45601. * Gets a boolean indicating if the virtual joystick was pressed
  45602. */
  45603. pressed: boolean;
  45604. /**
  45605. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45606. */
  45607. static Canvas: Nullable<HTMLCanvasElement>;
  45608. /**
  45609. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45610. */
  45611. limitToContainer: boolean;
  45612. private static _globalJoystickIndex;
  45613. private static _alwaysVisibleSticks;
  45614. private static vjCanvasContext;
  45615. private static vjCanvasWidth;
  45616. private static vjCanvasHeight;
  45617. private static halfWidth;
  45618. private static _GetDefaultOptions;
  45619. private _action;
  45620. private _axisTargetedByLeftAndRight;
  45621. private _axisTargetedByUpAndDown;
  45622. private _joystickSensibility;
  45623. private _inversedSensibility;
  45624. private _joystickPointerID;
  45625. private _joystickColor;
  45626. private _joystickPointerPos;
  45627. private _joystickPreviousPointerPos;
  45628. private _joystickPointerStartPos;
  45629. private _deltaJoystickVector;
  45630. private _leftJoystick;
  45631. private _touches;
  45632. private _joystickPosition;
  45633. private _alwaysVisible;
  45634. private _puckImage;
  45635. private _containerImage;
  45636. private _joystickPuckSize;
  45637. private _joystickContainerSize;
  45638. private _clearPuckSize;
  45639. private _clearContainerSize;
  45640. private _clearPuckSizeOffset;
  45641. private _clearContainerSizeOffset;
  45642. private _onPointerDownHandlerRef;
  45643. private _onPointerMoveHandlerRef;
  45644. private _onPointerUpHandlerRef;
  45645. private _onResize;
  45646. /**
  45647. * Creates a new virtual joystick
  45648. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45649. * @param customizations Defines the options we want to customize the VirtualJoystick
  45650. */
  45651. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45652. /**
  45653. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45654. * @param newJoystickSensibility defines the new sensibility
  45655. */
  45656. setJoystickSensibility(newJoystickSensibility: number): void;
  45657. private _onPointerDown;
  45658. private _onPointerMove;
  45659. private _onPointerUp;
  45660. /**
  45661. * Change the color of the virtual joystick
  45662. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45663. */
  45664. setJoystickColor(newColor: string): void;
  45665. /**
  45666. * Size of the joystick's container
  45667. */
  45668. set containerSize(newSize: number);
  45669. get containerSize(): number;
  45670. /**
  45671. * Size of the joystick's puck
  45672. */
  45673. set puckSize(newSize: number);
  45674. get puckSize(): number;
  45675. /**
  45676. * Clears the set position of the joystick
  45677. */
  45678. clearPosition(): void;
  45679. /**
  45680. * Defines whether or not the joystick container is always visible
  45681. */
  45682. set alwaysVisible(value: boolean);
  45683. get alwaysVisible(): boolean;
  45684. /**
  45685. * Sets the constant position of the Joystick container
  45686. * @param x X axis coordinate
  45687. * @param y Y axis coordinate
  45688. */
  45689. setPosition(x: number, y: number): void;
  45690. /**
  45691. * Defines a callback to call when the joystick is touched
  45692. * @param action defines the callback
  45693. */
  45694. setActionOnTouch(action: () => any): void;
  45695. /**
  45696. * Defines which axis you'd like to control for left & right
  45697. * @param axis defines the axis to use
  45698. */
  45699. setAxisForLeftRight(axis: JoystickAxis): void;
  45700. /**
  45701. * Defines which axis you'd like to control for up & down
  45702. * @param axis defines the axis to use
  45703. */
  45704. setAxisForUpDown(axis: JoystickAxis): void;
  45705. /**
  45706. * Clears the canvas from the previous puck / container draw
  45707. */
  45708. private _clearPreviousDraw;
  45709. /**
  45710. * Loads `urlPath` to be used for the container's image
  45711. * @param urlPath defines the urlPath of an image to use
  45712. */
  45713. setContainerImage(urlPath: string): void;
  45714. /**
  45715. * Loads `urlPath` to be used for the puck's image
  45716. * @param urlPath defines the urlPath of an image to use
  45717. */
  45718. setPuckImage(urlPath: string): void;
  45719. /**
  45720. * Draws the Virtual Joystick's container
  45721. */
  45722. private _drawContainer;
  45723. /**
  45724. * Draws the Virtual Joystick's puck
  45725. */
  45726. private _drawPuck;
  45727. private _drawVirtualJoystick;
  45728. /**
  45729. * Release internal HTML canvas
  45730. */
  45731. releaseCanvas(): void;
  45732. }
  45733. }
  45734. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45735. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45736. import { Nullable } from "babylonjs/types";
  45737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45738. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45739. module "babylonjs/Cameras/freeCameraInputsManager" {
  45740. interface FreeCameraInputsManager {
  45741. /**
  45742. * Add virtual joystick input support to the input manager.
  45743. * @returns the current input manager
  45744. */
  45745. addVirtualJoystick(): FreeCameraInputsManager;
  45746. }
  45747. }
  45748. /**
  45749. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45751. */
  45752. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45753. /**
  45754. * Defines the camera the input is attached to.
  45755. */
  45756. camera: FreeCamera;
  45757. private _leftjoystick;
  45758. private _rightjoystick;
  45759. /**
  45760. * Gets the left stick of the virtual joystick.
  45761. * @returns The virtual Joystick
  45762. */
  45763. getLeftJoystick(): VirtualJoystick;
  45764. /**
  45765. * Gets the right stick of the virtual joystick.
  45766. * @returns The virtual Joystick
  45767. */
  45768. getRightJoystick(): VirtualJoystick;
  45769. /**
  45770. * Update the current camera state depending on the inputs that have been used this frame.
  45771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45772. */
  45773. checkInputs(): void;
  45774. /**
  45775. * Attach the input controls to a specific dom element to get the input from.
  45776. * @param element Defines the element the controls should be listened from
  45777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45778. */
  45779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45780. /**
  45781. * Detach the current controls from the specified dom element.
  45782. * @param element Defines the element to stop listening the inputs from
  45783. */
  45784. detachControl(element: Nullable<HTMLElement>): void;
  45785. /**
  45786. * Gets the class name of the current intput.
  45787. * @returns the class name
  45788. */
  45789. getClassName(): string;
  45790. /**
  45791. * Get the friendly name associated with the input class.
  45792. * @returns the input friendly name
  45793. */
  45794. getSimpleName(): string;
  45795. }
  45796. }
  45797. declare module "babylonjs/Cameras/Inputs/index" {
  45798. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45799. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45800. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45801. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45802. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45803. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45804. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45805. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45806. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45807. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45808. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45809. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45810. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45811. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45812. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45813. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45814. }
  45815. declare module "babylonjs/Cameras/touchCamera" {
  45816. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45817. import { Scene } from "babylonjs/scene";
  45818. import { Vector3 } from "babylonjs/Maths/math.vector";
  45819. /**
  45820. * This represents a FPS type of camera controlled by touch.
  45821. * This is like a universal camera minus the Gamepad controls.
  45822. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45823. */
  45824. export class TouchCamera extends FreeCamera {
  45825. /**
  45826. * Defines the touch sensibility for rotation.
  45827. * The higher the faster.
  45828. */
  45829. get touchAngularSensibility(): number;
  45830. set touchAngularSensibility(value: number);
  45831. /**
  45832. * Defines the touch sensibility for move.
  45833. * The higher the faster.
  45834. */
  45835. get touchMoveSensibility(): number;
  45836. set touchMoveSensibility(value: number);
  45837. /**
  45838. * Instantiates a new touch camera.
  45839. * This represents a FPS type of camera controlled by touch.
  45840. * This is like a universal camera minus the Gamepad controls.
  45841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45842. * @param name Define the name of the camera in the scene
  45843. * @param position Define the start position of the camera in the scene
  45844. * @param scene Define the scene the camera belongs to
  45845. */
  45846. constructor(name: string, position: Vector3, scene: Scene);
  45847. /**
  45848. * Gets the current object class name.
  45849. * @return the class name
  45850. */
  45851. getClassName(): string;
  45852. /** @hidden */
  45853. _setupInputs(): void;
  45854. }
  45855. }
  45856. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45858. import { Scene } from "babylonjs/scene";
  45859. import { Vector3 } from "babylonjs/Maths/math.vector";
  45860. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45861. import { Axis } from "babylonjs/Maths/math.axis";
  45862. /**
  45863. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45864. * being tilted forward or back and left or right.
  45865. */
  45866. export class DeviceOrientationCamera extends FreeCamera {
  45867. private _initialQuaternion;
  45868. private _quaternionCache;
  45869. private _tmpDragQuaternion;
  45870. private _disablePointerInputWhenUsingDeviceOrientation;
  45871. /**
  45872. * Creates a new device orientation camera
  45873. * @param name The name of the camera
  45874. * @param position The start position camera
  45875. * @param scene The scene the camera belongs to
  45876. */
  45877. constructor(name: string, position: Vector3, scene: Scene);
  45878. /**
  45879. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45880. */
  45881. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45882. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45883. private _dragFactor;
  45884. /**
  45885. * Enabled turning on the y axis when the orientation sensor is active
  45886. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45887. */
  45888. enableHorizontalDragging(dragFactor?: number): void;
  45889. /**
  45890. * Gets the current instance class name ("DeviceOrientationCamera").
  45891. * This helps avoiding instanceof at run time.
  45892. * @returns the class name
  45893. */
  45894. getClassName(): string;
  45895. /**
  45896. * @hidden
  45897. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45898. */
  45899. _checkInputs(): void;
  45900. /**
  45901. * Reset the camera to its default orientation on the specified axis only.
  45902. * @param axis The axis to reset
  45903. */
  45904. resetToCurrentRotation(axis?: Axis): void;
  45905. }
  45906. }
  45907. declare module "babylonjs/Gamepads/xboxGamepad" {
  45908. import { Observable } from "babylonjs/Misc/observable";
  45909. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45910. /**
  45911. * Defines supported buttons for XBox360 compatible gamepads
  45912. */
  45913. export enum Xbox360Button {
  45914. /** A */
  45915. A = 0,
  45916. /** B */
  45917. B = 1,
  45918. /** X */
  45919. X = 2,
  45920. /** Y */
  45921. Y = 3,
  45922. /** Left button */
  45923. LB = 4,
  45924. /** Right button */
  45925. RB = 5,
  45926. /** Back */
  45927. Back = 8,
  45928. /** Start */
  45929. Start = 9,
  45930. /** Left stick */
  45931. LeftStick = 10,
  45932. /** Right stick */
  45933. RightStick = 11
  45934. }
  45935. /** Defines values for XBox360 DPad */
  45936. export enum Xbox360Dpad {
  45937. /** Up */
  45938. Up = 12,
  45939. /** Down */
  45940. Down = 13,
  45941. /** Left */
  45942. Left = 14,
  45943. /** Right */
  45944. Right = 15
  45945. }
  45946. /**
  45947. * Defines a XBox360 gamepad
  45948. */
  45949. export class Xbox360Pad extends Gamepad {
  45950. private _leftTrigger;
  45951. private _rightTrigger;
  45952. private _onlefttriggerchanged;
  45953. private _onrighttriggerchanged;
  45954. private _onbuttondown;
  45955. private _onbuttonup;
  45956. private _ondpaddown;
  45957. private _ondpadup;
  45958. /** Observable raised when a button is pressed */
  45959. onButtonDownObservable: Observable<Xbox360Button>;
  45960. /** Observable raised when a button is released */
  45961. onButtonUpObservable: Observable<Xbox360Button>;
  45962. /** Observable raised when a pad is pressed */
  45963. onPadDownObservable: Observable<Xbox360Dpad>;
  45964. /** Observable raised when a pad is released */
  45965. onPadUpObservable: Observable<Xbox360Dpad>;
  45966. private _buttonA;
  45967. private _buttonB;
  45968. private _buttonX;
  45969. private _buttonY;
  45970. private _buttonBack;
  45971. private _buttonStart;
  45972. private _buttonLB;
  45973. private _buttonRB;
  45974. private _buttonLeftStick;
  45975. private _buttonRightStick;
  45976. private _dPadUp;
  45977. private _dPadDown;
  45978. private _dPadLeft;
  45979. private _dPadRight;
  45980. private _isXboxOnePad;
  45981. /**
  45982. * Creates a new XBox360 gamepad object
  45983. * @param id defines the id of this gamepad
  45984. * @param index defines its index
  45985. * @param gamepad defines the internal HTML gamepad object
  45986. * @param xboxOne defines if it is a XBox One gamepad
  45987. */
  45988. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45989. /**
  45990. * Defines the callback to call when left trigger is pressed
  45991. * @param callback defines the callback to use
  45992. */
  45993. onlefttriggerchanged(callback: (value: number) => void): void;
  45994. /**
  45995. * Defines the callback to call when right trigger is pressed
  45996. * @param callback defines the callback to use
  45997. */
  45998. onrighttriggerchanged(callback: (value: number) => void): void;
  45999. /**
  46000. * Gets the left trigger value
  46001. */
  46002. get leftTrigger(): number;
  46003. /**
  46004. * Sets the left trigger value
  46005. */
  46006. set leftTrigger(newValue: number);
  46007. /**
  46008. * Gets the right trigger value
  46009. */
  46010. get rightTrigger(): number;
  46011. /**
  46012. * Sets the right trigger value
  46013. */
  46014. set rightTrigger(newValue: number);
  46015. /**
  46016. * Defines the callback to call when a button is pressed
  46017. * @param callback defines the callback to use
  46018. */
  46019. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46020. /**
  46021. * Defines the callback to call when a button is released
  46022. * @param callback defines the callback to use
  46023. */
  46024. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46025. /**
  46026. * Defines the callback to call when a pad is pressed
  46027. * @param callback defines the callback to use
  46028. */
  46029. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46030. /**
  46031. * Defines the callback to call when a pad is released
  46032. * @param callback defines the callback to use
  46033. */
  46034. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46035. private _setButtonValue;
  46036. private _setDPadValue;
  46037. /**
  46038. * Gets the value of the `A` button
  46039. */
  46040. get buttonA(): number;
  46041. /**
  46042. * Sets the value of the `A` button
  46043. */
  46044. set buttonA(value: number);
  46045. /**
  46046. * Gets the value of the `B` button
  46047. */
  46048. get buttonB(): number;
  46049. /**
  46050. * Sets the value of the `B` button
  46051. */
  46052. set buttonB(value: number);
  46053. /**
  46054. * Gets the value of the `X` button
  46055. */
  46056. get buttonX(): number;
  46057. /**
  46058. * Sets the value of the `X` button
  46059. */
  46060. set buttonX(value: number);
  46061. /**
  46062. * Gets the value of the `Y` button
  46063. */
  46064. get buttonY(): number;
  46065. /**
  46066. * Sets the value of the `Y` button
  46067. */
  46068. set buttonY(value: number);
  46069. /**
  46070. * Gets the value of the `Start` button
  46071. */
  46072. get buttonStart(): number;
  46073. /**
  46074. * Sets the value of the `Start` button
  46075. */
  46076. set buttonStart(value: number);
  46077. /**
  46078. * Gets the value of the `Back` button
  46079. */
  46080. get buttonBack(): number;
  46081. /**
  46082. * Sets the value of the `Back` button
  46083. */
  46084. set buttonBack(value: number);
  46085. /**
  46086. * Gets the value of the `Left` button
  46087. */
  46088. get buttonLB(): number;
  46089. /**
  46090. * Sets the value of the `Left` button
  46091. */
  46092. set buttonLB(value: number);
  46093. /**
  46094. * Gets the value of the `Right` button
  46095. */
  46096. get buttonRB(): number;
  46097. /**
  46098. * Sets the value of the `Right` button
  46099. */
  46100. set buttonRB(value: number);
  46101. /**
  46102. * Gets the value of the Left joystick
  46103. */
  46104. get buttonLeftStick(): number;
  46105. /**
  46106. * Sets the value of the Left joystick
  46107. */
  46108. set buttonLeftStick(value: number);
  46109. /**
  46110. * Gets the value of the Right joystick
  46111. */
  46112. get buttonRightStick(): number;
  46113. /**
  46114. * Sets the value of the Right joystick
  46115. */
  46116. set buttonRightStick(value: number);
  46117. /**
  46118. * Gets the value of D-pad up
  46119. */
  46120. get dPadUp(): number;
  46121. /**
  46122. * Sets the value of D-pad up
  46123. */
  46124. set dPadUp(value: number);
  46125. /**
  46126. * Gets the value of D-pad down
  46127. */
  46128. get dPadDown(): number;
  46129. /**
  46130. * Sets the value of D-pad down
  46131. */
  46132. set dPadDown(value: number);
  46133. /**
  46134. * Gets the value of D-pad left
  46135. */
  46136. get dPadLeft(): number;
  46137. /**
  46138. * Sets the value of D-pad left
  46139. */
  46140. set dPadLeft(value: number);
  46141. /**
  46142. * Gets the value of D-pad right
  46143. */
  46144. get dPadRight(): number;
  46145. /**
  46146. * Sets the value of D-pad right
  46147. */
  46148. set dPadRight(value: number);
  46149. /**
  46150. * Force the gamepad to synchronize with device values
  46151. */
  46152. update(): void;
  46153. /**
  46154. * Disposes the gamepad
  46155. */
  46156. dispose(): void;
  46157. }
  46158. }
  46159. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46160. import { Observable } from "babylonjs/Misc/observable";
  46161. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46162. /**
  46163. * Defines supported buttons for DualShock compatible gamepads
  46164. */
  46165. export enum DualShockButton {
  46166. /** Cross */
  46167. Cross = 0,
  46168. /** Circle */
  46169. Circle = 1,
  46170. /** Square */
  46171. Square = 2,
  46172. /** Triangle */
  46173. Triangle = 3,
  46174. /** L1 */
  46175. L1 = 4,
  46176. /** R1 */
  46177. R1 = 5,
  46178. /** Share */
  46179. Share = 8,
  46180. /** Options */
  46181. Options = 9,
  46182. /** Left stick */
  46183. LeftStick = 10,
  46184. /** Right stick */
  46185. RightStick = 11
  46186. }
  46187. /** Defines values for DualShock DPad */
  46188. export enum DualShockDpad {
  46189. /** Up */
  46190. Up = 12,
  46191. /** Down */
  46192. Down = 13,
  46193. /** Left */
  46194. Left = 14,
  46195. /** Right */
  46196. Right = 15
  46197. }
  46198. /**
  46199. * Defines a DualShock gamepad
  46200. */
  46201. export class DualShockPad extends Gamepad {
  46202. private _leftTrigger;
  46203. private _rightTrigger;
  46204. private _onlefttriggerchanged;
  46205. private _onrighttriggerchanged;
  46206. private _onbuttondown;
  46207. private _onbuttonup;
  46208. private _ondpaddown;
  46209. private _ondpadup;
  46210. /** Observable raised when a button is pressed */
  46211. onButtonDownObservable: Observable<DualShockButton>;
  46212. /** Observable raised when a button is released */
  46213. onButtonUpObservable: Observable<DualShockButton>;
  46214. /** Observable raised when a pad is pressed */
  46215. onPadDownObservable: Observable<DualShockDpad>;
  46216. /** Observable raised when a pad is released */
  46217. onPadUpObservable: Observable<DualShockDpad>;
  46218. private _buttonCross;
  46219. private _buttonCircle;
  46220. private _buttonSquare;
  46221. private _buttonTriangle;
  46222. private _buttonShare;
  46223. private _buttonOptions;
  46224. private _buttonL1;
  46225. private _buttonR1;
  46226. private _buttonLeftStick;
  46227. private _buttonRightStick;
  46228. private _dPadUp;
  46229. private _dPadDown;
  46230. private _dPadLeft;
  46231. private _dPadRight;
  46232. /**
  46233. * Creates a new DualShock gamepad object
  46234. * @param id defines the id of this gamepad
  46235. * @param index defines its index
  46236. * @param gamepad defines the internal HTML gamepad object
  46237. */
  46238. constructor(id: string, index: number, gamepad: any);
  46239. /**
  46240. * Defines the callback to call when left trigger is pressed
  46241. * @param callback defines the callback to use
  46242. */
  46243. onlefttriggerchanged(callback: (value: number) => void): void;
  46244. /**
  46245. * Defines the callback to call when right trigger is pressed
  46246. * @param callback defines the callback to use
  46247. */
  46248. onrighttriggerchanged(callback: (value: number) => void): void;
  46249. /**
  46250. * Gets the left trigger value
  46251. */
  46252. get leftTrigger(): number;
  46253. /**
  46254. * Sets the left trigger value
  46255. */
  46256. set leftTrigger(newValue: number);
  46257. /**
  46258. * Gets the right trigger value
  46259. */
  46260. get rightTrigger(): number;
  46261. /**
  46262. * Sets the right trigger value
  46263. */
  46264. set rightTrigger(newValue: number);
  46265. /**
  46266. * Defines the callback to call when a button is pressed
  46267. * @param callback defines the callback to use
  46268. */
  46269. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46270. /**
  46271. * Defines the callback to call when a button is released
  46272. * @param callback defines the callback to use
  46273. */
  46274. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46275. /**
  46276. * Defines the callback to call when a pad is pressed
  46277. * @param callback defines the callback to use
  46278. */
  46279. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46280. /**
  46281. * Defines the callback to call when a pad is released
  46282. * @param callback defines the callback to use
  46283. */
  46284. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46285. private _setButtonValue;
  46286. private _setDPadValue;
  46287. /**
  46288. * Gets the value of the `Cross` button
  46289. */
  46290. get buttonCross(): number;
  46291. /**
  46292. * Sets the value of the `Cross` button
  46293. */
  46294. set buttonCross(value: number);
  46295. /**
  46296. * Gets the value of the `Circle` button
  46297. */
  46298. get buttonCircle(): number;
  46299. /**
  46300. * Sets the value of the `Circle` button
  46301. */
  46302. set buttonCircle(value: number);
  46303. /**
  46304. * Gets the value of the `Square` button
  46305. */
  46306. get buttonSquare(): number;
  46307. /**
  46308. * Sets the value of the `Square` button
  46309. */
  46310. set buttonSquare(value: number);
  46311. /**
  46312. * Gets the value of the `Triangle` button
  46313. */
  46314. get buttonTriangle(): number;
  46315. /**
  46316. * Sets the value of the `Triangle` button
  46317. */
  46318. set buttonTriangle(value: number);
  46319. /**
  46320. * Gets the value of the `Options` button
  46321. */
  46322. get buttonOptions(): number;
  46323. /**
  46324. * Sets the value of the `Options` button
  46325. */
  46326. set buttonOptions(value: number);
  46327. /**
  46328. * Gets the value of the `Share` button
  46329. */
  46330. get buttonShare(): number;
  46331. /**
  46332. * Sets the value of the `Share` button
  46333. */
  46334. set buttonShare(value: number);
  46335. /**
  46336. * Gets the value of the `L1` button
  46337. */
  46338. get buttonL1(): number;
  46339. /**
  46340. * Sets the value of the `L1` button
  46341. */
  46342. set buttonL1(value: number);
  46343. /**
  46344. * Gets the value of the `R1` button
  46345. */
  46346. get buttonR1(): number;
  46347. /**
  46348. * Sets the value of the `R1` button
  46349. */
  46350. set buttonR1(value: number);
  46351. /**
  46352. * Gets the value of the Left joystick
  46353. */
  46354. get buttonLeftStick(): number;
  46355. /**
  46356. * Sets the value of the Left joystick
  46357. */
  46358. set buttonLeftStick(value: number);
  46359. /**
  46360. * Gets the value of the Right joystick
  46361. */
  46362. get buttonRightStick(): number;
  46363. /**
  46364. * Sets the value of the Right joystick
  46365. */
  46366. set buttonRightStick(value: number);
  46367. /**
  46368. * Gets the value of D-pad up
  46369. */
  46370. get dPadUp(): number;
  46371. /**
  46372. * Sets the value of D-pad up
  46373. */
  46374. set dPadUp(value: number);
  46375. /**
  46376. * Gets the value of D-pad down
  46377. */
  46378. get dPadDown(): number;
  46379. /**
  46380. * Sets the value of D-pad down
  46381. */
  46382. set dPadDown(value: number);
  46383. /**
  46384. * Gets the value of D-pad left
  46385. */
  46386. get dPadLeft(): number;
  46387. /**
  46388. * Sets the value of D-pad left
  46389. */
  46390. set dPadLeft(value: number);
  46391. /**
  46392. * Gets the value of D-pad right
  46393. */
  46394. get dPadRight(): number;
  46395. /**
  46396. * Sets the value of D-pad right
  46397. */
  46398. set dPadRight(value: number);
  46399. /**
  46400. * Force the gamepad to synchronize with device values
  46401. */
  46402. update(): void;
  46403. /**
  46404. * Disposes the gamepad
  46405. */
  46406. dispose(): void;
  46407. }
  46408. }
  46409. declare module "babylonjs/Gamepads/gamepadManager" {
  46410. import { Observable } from "babylonjs/Misc/observable";
  46411. import { Nullable } from "babylonjs/types";
  46412. import { Scene } from "babylonjs/scene";
  46413. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46414. /**
  46415. * Manager for handling gamepads
  46416. */
  46417. export class GamepadManager {
  46418. private _scene?;
  46419. private _babylonGamepads;
  46420. private _oneGamepadConnected;
  46421. /** @hidden */
  46422. _isMonitoring: boolean;
  46423. private _gamepadEventSupported;
  46424. private _gamepadSupport?;
  46425. /**
  46426. * observable to be triggered when the gamepad controller has been connected
  46427. */
  46428. onGamepadConnectedObservable: Observable<Gamepad>;
  46429. /**
  46430. * observable to be triggered when the gamepad controller has been disconnected
  46431. */
  46432. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46433. private _onGamepadConnectedEvent;
  46434. private _onGamepadDisconnectedEvent;
  46435. /**
  46436. * Initializes the gamepad manager
  46437. * @param _scene BabylonJS scene
  46438. */
  46439. constructor(_scene?: Scene | undefined);
  46440. /**
  46441. * The gamepads in the game pad manager
  46442. */
  46443. get gamepads(): Gamepad[];
  46444. /**
  46445. * Get the gamepad controllers based on type
  46446. * @param type The type of gamepad controller
  46447. * @returns Nullable gamepad
  46448. */
  46449. getGamepadByType(type?: number): Nullable<Gamepad>;
  46450. /**
  46451. * Disposes the gamepad manager
  46452. */
  46453. dispose(): void;
  46454. private _addNewGamepad;
  46455. private _startMonitoringGamepads;
  46456. private _stopMonitoringGamepads;
  46457. /** @hidden */
  46458. _checkGamepadsStatus(): void;
  46459. private _updateGamepadObjects;
  46460. }
  46461. }
  46462. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46463. import { Nullable } from "babylonjs/types";
  46464. import { Scene } from "babylonjs/scene";
  46465. import { ISceneComponent } from "babylonjs/sceneComponent";
  46466. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46467. module "babylonjs/scene" {
  46468. interface Scene {
  46469. /** @hidden */
  46470. _gamepadManager: Nullable<GamepadManager>;
  46471. /**
  46472. * Gets the gamepad manager associated with the scene
  46473. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46474. */
  46475. gamepadManager: GamepadManager;
  46476. }
  46477. }
  46478. module "babylonjs/Cameras/freeCameraInputsManager" {
  46479. /**
  46480. * Interface representing a free camera inputs manager
  46481. */
  46482. interface FreeCameraInputsManager {
  46483. /**
  46484. * Adds gamepad input support to the FreeCameraInputsManager.
  46485. * @returns the FreeCameraInputsManager
  46486. */
  46487. addGamepad(): FreeCameraInputsManager;
  46488. }
  46489. }
  46490. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46491. /**
  46492. * Interface representing an arc rotate camera inputs manager
  46493. */
  46494. interface ArcRotateCameraInputsManager {
  46495. /**
  46496. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46497. * @returns the camera inputs manager
  46498. */
  46499. addGamepad(): ArcRotateCameraInputsManager;
  46500. }
  46501. }
  46502. /**
  46503. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46504. */
  46505. export class GamepadSystemSceneComponent implements ISceneComponent {
  46506. /**
  46507. * The component name helpfull to identify the component in the list of scene components.
  46508. */
  46509. readonly name: string;
  46510. /**
  46511. * The scene the component belongs to.
  46512. */
  46513. scene: Scene;
  46514. /**
  46515. * Creates a new instance of the component for the given scene
  46516. * @param scene Defines the scene to register the component in
  46517. */
  46518. constructor(scene: Scene);
  46519. /**
  46520. * Registers the component in a given scene
  46521. */
  46522. register(): void;
  46523. /**
  46524. * Rebuilds the elements related to this component in case of
  46525. * context lost for instance.
  46526. */
  46527. rebuild(): void;
  46528. /**
  46529. * Disposes the component and the associated ressources
  46530. */
  46531. dispose(): void;
  46532. private _beforeCameraUpdate;
  46533. }
  46534. }
  46535. declare module "babylonjs/Cameras/universalCamera" {
  46536. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46537. import { Scene } from "babylonjs/scene";
  46538. import { Vector3 } from "babylonjs/Maths/math.vector";
  46539. import "babylonjs/Gamepads/gamepadSceneComponent";
  46540. /**
  46541. * 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,
  46542. * which still works and will still be found in many Playgrounds.
  46543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46544. */
  46545. export class UniversalCamera extends TouchCamera {
  46546. /**
  46547. * Defines the gamepad rotation sensiblity.
  46548. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46549. */
  46550. get gamepadAngularSensibility(): number;
  46551. set gamepadAngularSensibility(value: number);
  46552. /**
  46553. * Defines the gamepad move sensiblity.
  46554. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46555. */
  46556. get gamepadMoveSensibility(): number;
  46557. set gamepadMoveSensibility(value: number);
  46558. /**
  46559. * 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,
  46560. * which still works and will still be found in many Playgrounds.
  46561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46562. * @param name Define the name of the camera in the scene
  46563. * @param position Define the start position of the camera in the scene
  46564. * @param scene Define the scene the camera belongs to
  46565. */
  46566. constructor(name: string, position: Vector3, scene: Scene);
  46567. /**
  46568. * Gets the current object class name.
  46569. * @return the class name
  46570. */
  46571. getClassName(): string;
  46572. }
  46573. }
  46574. declare module "babylonjs/Cameras/gamepadCamera" {
  46575. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46576. import { Scene } from "babylonjs/scene";
  46577. import { Vector3 } from "babylonjs/Maths/math.vector";
  46578. /**
  46579. * This represents a FPS type of camera. This is only here for back compat purpose.
  46580. * Please use the UniversalCamera instead as both are identical.
  46581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46582. */
  46583. export class GamepadCamera extends UniversalCamera {
  46584. /**
  46585. * Instantiates a new Gamepad Camera
  46586. * This represents a FPS type of camera. This is only here for back compat purpose.
  46587. * Please use the UniversalCamera instead as both are identical.
  46588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46589. * @param name Define the name of the camera in the scene
  46590. * @param position Define the start position of the camera in the scene
  46591. * @param scene Define the scene the camera belongs to
  46592. */
  46593. constructor(name: string, position: Vector3, scene: Scene);
  46594. /**
  46595. * Gets the current object class name.
  46596. * @return the class name
  46597. */
  46598. getClassName(): string;
  46599. }
  46600. }
  46601. declare module "babylonjs/Shaders/pass.fragment" {
  46602. /** @hidden */
  46603. export var passPixelShader: {
  46604. name: string;
  46605. shader: string;
  46606. };
  46607. }
  46608. declare module "babylonjs/Shaders/passCube.fragment" {
  46609. /** @hidden */
  46610. export var passCubePixelShader: {
  46611. name: string;
  46612. shader: string;
  46613. };
  46614. }
  46615. declare module "babylonjs/PostProcesses/passPostProcess" {
  46616. import { Nullable } from "babylonjs/types";
  46617. import { Camera } from "babylonjs/Cameras/camera";
  46618. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46619. import { Engine } from "babylonjs/Engines/engine";
  46620. import "babylonjs/Shaders/pass.fragment";
  46621. import "babylonjs/Shaders/passCube.fragment";
  46622. /**
  46623. * PassPostProcess which produces an output the same as it's input
  46624. */
  46625. export class PassPostProcess extends PostProcess {
  46626. /**
  46627. * Creates the PassPostProcess
  46628. * @param name The name of the effect.
  46629. * @param options The required width/height ratio to downsize to before computing the render pass.
  46630. * @param camera The camera to apply the render pass to.
  46631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46632. * @param engine The engine which the post process will be applied. (default: current engine)
  46633. * @param reusable If the post process can be reused on the same frame. (default: false)
  46634. * @param textureType The type of texture to be used when performing the post processing.
  46635. * @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)
  46636. */
  46637. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46638. }
  46639. /**
  46640. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46641. */
  46642. export class PassCubePostProcess extends PostProcess {
  46643. private _face;
  46644. /**
  46645. * Gets or sets the cube face to display.
  46646. * * 0 is +X
  46647. * * 1 is -X
  46648. * * 2 is +Y
  46649. * * 3 is -Y
  46650. * * 4 is +Z
  46651. * * 5 is -Z
  46652. */
  46653. get face(): number;
  46654. set face(value: number);
  46655. /**
  46656. * Creates the PassCubePostProcess
  46657. * @param name The name of the effect.
  46658. * @param options The required width/height ratio to downsize to before computing the render pass.
  46659. * @param camera The camera to apply the render pass to.
  46660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46661. * @param engine The engine which the post process will be applied. (default: current engine)
  46662. * @param reusable If the post process can be reused on the same frame. (default: false)
  46663. * @param textureType The type of texture to be used when performing the post processing.
  46664. * @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)
  46665. */
  46666. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46667. }
  46668. }
  46669. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46670. /** @hidden */
  46671. export var anaglyphPixelShader: {
  46672. name: string;
  46673. shader: string;
  46674. };
  46675. }
  46676. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46677. import { Engine } from "babylonjs/Engines/engine";
  46678. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46679. import { Camera } from "babylonjs/Cameras/camera";
  46680. import "babylonjs/Shaders/anaglyph.fragment";
  46681. /**
  46682. * Postprocess used to generate anaglyphic rendering
  46683. */
  46684. export class AnaglyphPostProcess extends PostProcess {
  46685. private _passedProcess;
  46686. /**
  46687. * Creates a new AnaglyphPostProcess
  46688. * @param name defines postprocess name
  46689. * @param options defines creation options or target ratio scale
  46690. * @param rigCameras defines cameras using this postprocess
  46691. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46692. * @param engine defines hosting engine
  46693. * @param reusable defines if the postprocess will be reused multiple times per frame
  46694. */
  46695. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46696. }
  46697. }
  46698. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46699. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46701. import { Scene } from "babylonjs/scene";
  46702. import { Vector3 } from "babylonjs/Maths/math.vector";
  46703. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46704. /**
  46705. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46706. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46707. */
  46708. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46709. /**
  46710. * Creates a new AnaglyphArcRotateCamera
  46711. * @param name defines camera name
  46712. * @param alpha defines alpha angle (in radians)
  46713. * @param beta defines beta angle (in radians)
  46714. * @param radius defines radius
  46715. * @param target defines camera target
  46716. * @param interaxialDistance defines distance between each color axis
  46717. * @param scene defines the hosting scene
  46718. */
  46719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46720. /**
  46721. * Gets camera class name
  46722. * @returns AnaglyphArcRotateCamera
  46723. */
  46724. getClassName(): string;
  46725. }
  46726. }
  46727. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46729. import { Scene } from "babylonjs/scene";
  46730. import { Vector3 } from "babylonjs/Maths/math.vector";
  46731. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46732. /**
  46733. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46734. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46735. */
  46736. export class AnaglyphFreeCamera extends FreeCamera {
  46737. /**
  46738. * Creates a new AnaglyphFreeCamera
  46739. * @param name defines camera name
  46740. * @param position defines initial position
  46741. * @param interaxialDistance defines distance between each color axis
  46742. * @param scene defines the hosting scene
  46743. */
  46744. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46745. /**
  46746. * Gets camera class name
  46747. * @returns AnaglyphFreeCamera
  46748. */
  46749. getClassName(): string;
  46750. }
  46751. }
  46752. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46753. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46754. import { Scene } from "babylonjs/scene";
  46755. import { Vector3 } from "babylonjs/Maths/math.vector";
  46756. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46757. /**
  46758. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46759. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46760. */
  46761. export class AnaglyphGamepadCamera extends GamepadCamera {
  46762. /**
  46763. * Creates a new AnaglyphGamepadCamera
  46764. * @param name defines camera name
  46765. * @param position defines initial position
  46766. * @param interaxialDistance defines distance between each color axis
  46767. * @param scene defines the hosting scene
  46768. */
  46769. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46770. /**
  46771. * Gets camera class name
  46772. * @returns AnaglyphGamepadCamera
  46773. */
  46774. getClassName(): string;
  46775. }
  46776. }
  46777. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46778. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46779. import { Scene } from "babylonjs/scene";
  46780. import { Vector3 } from "babylonjs/Maths/math.vector";
  46781. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46782. /**
  46783. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46784. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46785. */
  46786. export class AnaglyphUniversalCamera extends UniversalCamera {
  46787. /**
  46788. * Creates a new AnaglyphUniversalCamera
  46789. * @param name defines camera name
  46790. * @param position defines initial position
  46791. * @param interaxialDistance defines distance between each color axis
  46792. * @param scene defines the hosting scene
  46793. */
  46794. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46795. /**
  46796. * Gets camera class name
  46797. * @returns AnaglyphUniversalCamera
  46798. */
  46799. getClassName(): string;
  46800. }
  46801. }
  46802. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46803. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46805. import { Scene } from "babylonjs/scene";
  46806. import { Vector3 } from "babylonjs/Maths/math.vector";
  46807. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46808. /**
  46809. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46810. * @see http://doc.babylonjs.com/features/cameras
  46811. */
  46812. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46813. /**
  46814. * Creates a new StereoscopicArcRotateCamera
  46815. * @param name defines camera name
  46816. * @param alpha defines alpha angle (in radians)
  46817. * @param beta defines beta angle (in radians)
  46818. * @param radius defines radius
  46819. * @param target defines camera target
  46820. * @param interaxialDistance defines distance between each color axis
  46821. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46822. * @param scene defines the hosting scene
  46823. */
  46824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46825. /**
  46826. * Gets camera class name
  46827. * @returns StereoscopicArcRotateCamera
  46828. */
  46829. getClassName(): string;
  46830. }
  46831. }
  46832. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46834. import { Scene } from "babylonjs/scene";
  46835. import { Vector3 } from "babylonjs/Maths/math.vector";
  46836. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46837. /**
  46838. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46839. * @see http://doc.babylonjs.com/features/cameras
  46840. */
  46841. export class StereoscopicFreeCamera extends FreeCamera {
  46842. /**
  46843. * Creates a new StereoscopicFreeCamera
  46844. * @param name defines camera name
  46845. * @param position defines initial position
  46846. * @param interaxialDistance defines distance between each color axis
  46847. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46848. * @param scene defines the hosting scene
  46849. */
  46850. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46851. /**
  46852. * Gets camera class name
  46853. * @returns StereoscopicFreeCamera
  46854. */
  46855. getClassName(): string;
  46856. }
  46857. }
  46858. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46859. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46860. import { Scene } from "babylonjs/scene";
  46861. import { Vector3 } from "babylonjs/Maths/math.vector";
  46862. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46863. /**
  46864. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46865. * @see http://doc.babylonjs.com/features/cameras
  46866. */
  46867. export class StereoscopicGamepadCamera extends GamepadCamera {
  46868. /**
  46869. * Creates a new StereoscopicGamepadCamera
  46870. * @param name defines camera name
  46871. * @param position defines initial position
  46872. * @param interaxialDistance defines distance between each color axis
  46873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46874. * @param scene defines the hosting scene
  46875. */
  46876. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46877. /**
  46878. * Gets camera class name
  46879. * @returns StereoscopicGamepadCamera
  46880. */
  46881. getClassName(): string;
  46882. }
  46883. }
  46884. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46885. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46886. import { Scene } from "babylonjs/scene";
  46887. import { Vector3 } from "babylonjs/Maths/math.vector";
  46888. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46889. /**
  46890. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46891. * @see http://doc.babylonjs.com/features/cameras
  46892. */
  46893. export class StereoscopicUniversalCamera extends UniversalCamera {
  46894. /**
  46895. * Creates a new StereoscopicUniversalCamera
  46896. * @param name defines camera name
  46897. * @param position defines initial position
  46898. * @param interaxialDistance defines distance between each color axis
  46899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46900. * @param scene defines the hosting scene
  46901. */
  46902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46903. /**
  46904. * Gets camera class name
  46905. * @returns StereoscopicUniversalCamera
  46906. */
  46907. getClassName(): string;
  46908. }
  46909. }
  46910. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46911. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46912. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46913. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46914. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46915. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46916. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46917. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46918. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46919. }
  46920. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46921. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46922. import { Scene } from "babylonjs/scene";
  46923. import { Vector3 } from "babylonjs/Maths/math.vector";
  46924. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46925. /**
  46926. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46927. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46928. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46929. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46930. */
  46931. export class VirtualJoysticksCamera extends FreeCamera {
  46932. /**
  46933. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46934. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46935. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46936. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46937. * @param name Define the name of the camera in the scene
  46938. * @param position Define the start position of the camera in the scene
  46939. * @param scene Define the scene the camera belongs to
  46940. */
  46941. constructor(name: string, position: Vector3, scene: Scene);
  46942. /**
  46943. * Gets the current object class name.
  46944. * @return the class name
  46945. */
  46946. getClassName(): string;
  46947. }
  46948. }
  46949. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46950. import { Matrix } from "babylonjs/Maths/math.vector";
  46951. /**
  46952. * This represents all the required metrics to create a VR camera.
  46953. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46954. */
  46955. export class VRCameraMetrics {
  46956. /**
  46957. * Define the horizontal resolution off the screen.
  46958. */
  46959. hResolution: number;
  46960. /**
  46961. * Define the vertical resolution off the screen.
  46962. */
  46963. vResolution: number;
  46964. /**
  46965. * Define the horizontal screen size.
  46966. */
  46967. hScreenSize: number;
  46968. /**
  46969. * Define the vertical screen size.
  46970. */
  46971. vScreenSize: number;
  46972. /**
  46973. * Define the vertical screen center position.
  46974. */
  46975. vScreenCenter: number;
  46976. /**
  46977. * Define the distance of the eyes to the screen.
  46978. */
  46979. eyeToScreenDistance: number;
  46980. /**
  46981. * Define the distance between both lenses
  46982. */
  46983. lensSeparationDistance: number;
  46984. /**
  46985. * Define the distance between both viewer's eyes.
  46986. */
  46987. interpupillaryDistance: number;
  46988. /**
  46989. * Define the distortion factor of the VR postprocess.
  46990. * Please, touch with care.
  46991. */
  46992. distortionK: number[];
  46993. /**
  46994. * Define the chromatic aberration correction factors for the VR post process.
  46995. */
  46996. chromaAbCorrection: number[];
  46997. /**
  46998. * Define the scale factor of the post process.
  46999. * The smaller the better but the slower.
  47000. */
  47001. postProcessScaleFactor: number;
  47002. /**
  47003. * Define an offset for the lens center.
  47004. */
  47005. lensCenterOffset: number;
  47006. /**
  47007. * Define if the current vr camera should compensate the distortion of the lense or not.
  47008. */
  47009. compensateDistortion: boolean;
  47010. /**
  47011. * Defines if multiview should be enabled when rendering (Default: false)
  47012. */
  47013. multiviewEnabled: boolean;
  47014. /**
  47015. * Gets the rendering aspect ratio based on the provided resolutions.
  47016. */
  47017. get aspectRatio(): number;
  47018. /**
  47019. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47020. */
  47021. get aspectRatioFov(): number;
  47022. /**
  47023. * @hidden
  47024. */
  47025. get leftHMatrix(): Matrix;
  47026. /**
  47027. * @hidden
  47028. */
  47029. get rightHMatrix(): Matrix;
  47030. /**
  47031. * @hidden
  47032. */
  47033. get leftPreViewMatrix(): Matrix;
  47034. /**
  47035. * @hidden
  47036. */
  47037. get rightPreViewMatrix(): Matrix;
  47038. /**
  47039. * Get the default VRMetrics based on the most generic setup.
  47040. * @returns the default vr metrics
  47041. */
  47042. static GetDefault(): VRCameraMetrics;
  47043. }
  47044. }
  47045. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47046. /** @hidden */
  47047. export var vrDistortionCorrectionPixelShader: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47053. import { Camera } from "babylonjs/Cameras/camera";
  47054. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47056. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47057. /**
  47058. * VRDistortionCorrectionPostProcess used for mobile VR
  47059. */
  47060. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47061. private _isRightEye;
  47062. private _distortionFactors;
  47063. private _postProcessScaleFactor;
  47064. private _lensCenterOffset;
  47065. private _scaleIn;
  47066. private _scaleFactor;
  47067. private _lensCenter;
  47068. /**
  47069. * Initializes the VRDistortionCorrectionPostProcess
  47070. * @param name The name of the effect.
  47071. * @param camera The camera to apply the render pass to.
  47072. * @param isRightEye If this is for the right eye distortion
  47073. * @param vrMetrics All the required metrics for the VR camera
  47074. */
  47075. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47076. }
  47077. }
  47078. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47079. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47081. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47082. import { Scene } from "babylonjs/scene";
  47083. import { Vector3 } from "babylonjs/Maths/math.vector";
  47084. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47085. import "babylonjs/Cameras/RigModes/vrRigMode";
  47086. /**
  47087. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47088. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47089. */
  47090. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47091. /**
  47092. * Creates a new VRDeviceOrientationArcRotateCamera
  47093. * @param name defines camera name
  47094. * @param alpha defines the camera rotation along the logitudinal axis
  47095. * @param beta defines the camera rotation along the latitudinal axis
  47096. * @param radius defines the camera distance from its target
  47097. * @param target defines the camera target
  47098. * @param scene defines the scene the camera belongs to
  47099. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47100. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47101. */
  47102. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47103. /**
  47104. * Gets camera class name
  47105. * @returns VRDeviceOrientationArcRotateCamera
  47106. */
  47107. getClassName(): string;
  47108. }
  47109. }
  47110. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47111. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47112. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47113. import { Scene } from "babylonjs/scene";
  47114. import { Vector3 } from "babylonjs/Maths/math.vector";
  47115. import "babylonjs/Cameras/RigModes/vrRigMode";
  47116. /**
  47117. * Camera used to simulate VR rendering (based on FreeCamera)
  47118. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47119. */
  47120. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47121. /**
  47122. * Creates a new VRDeviceOrientationFreeCamera
  47123. * @param name defines camera name
  47124. * @param position defines the start position of the camera
  47125. * @param scene defines the scene the camera belongs to
  47126. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47127. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47128. */
  47129. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47130. /**
  47131. * Gets camera class name
  47132. * @returns VRDeviceOrientationFreeCamera
  47133. */
  47134. getClassName(): string;
  47135. }
  47136. }
  47137. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47138. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47139. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47140. import { Scene } from "babylonjs/scene";
  47141. import { Vector3 } from "babylonjs/Maths/math.vector";
  47142. import "babylonjs/Gamepads/gamepadSceneComponent";
  47143. /**
  47144. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47146. */
  47147. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47148. /**
  47149. * Creates a new VRDeviceOrientationGamepadCamera
  47150. * @param name defines camera name
  47151. * @param position defines the start position of the camera
  47152. * @param scene defines the scene the camera belongs to
  47153. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47154. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47155. */
  47156. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47157. /**
  47158. * Gets camera class name
  47159. * @returns VRDeviceOrientationGamepadCamera
  47160. */
  47161. getClassName(): string;
  47162. }
  47163. }
  47164. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47165. import { Scene } from "babylonjs/scene";
  47166. import { Texture } from "babylonjs/Materials/Textures/texture";
  47167. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47168. /**
  47169. * A class extending Texture allowing drawing on a texture
  47170. * @see http://doc.babylonjs.com/how_to/dynamictexture
  47171. */
  47172. export class DynamicTexture extends Texture {
  47173. private _generateMipMaps;
  47174. private _canvas;
  47175. private _context;
  47176. /**
  47177. * Creates a DynamicTexture
  47178. * @param name defines the name of the texture
  47179. * @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
  47180. * @param scene defines the scene where you want the texture
  47181. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47182. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47183. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47184. */
  47185. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47186. /**
  47187. * Get the current class name of the texture useful for serialization or dynamic coding.
  47188. * @returns "DynamicTexture"
  47189. */
  47190. getClassName(): string;
  47191. /**
  47192. * Gets the current state of canRescale
  47193. */
  47194. get canRescale(): boolean;
  47195. private _recreate;
  47196. /**
  47197. * Scales the texture
  47198. * @param ratio the scale factor to apply to both width and height
  47199. */
  47200. scale(ratio: number): void;
  47201. /**
  47202. * Resizes the texture
  47203. * @param width the new width
  47204. * @param height the new height
  47205. */
  47206. scaleTo(width: number, height: number): void;
  47207. /**
  47208. * Gets the context of the canvas used by the texture
  47209. * @returns the canvas context of the dynamic texture
  47210. */
  47211. getContext(): CanvasRenderingContext2D;
  47212. /**
  47213. * Clears the texture
  47214. */
  47215. clear(): void;
  47216. /**
  47217. * Updates the texture
  47218. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47219. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47220. */
  47221. update(invertY?: boolean, premulAlpha?: boolean): void;
  47222. /**
  47223. * Draws text onto the texture
  47224. * @param text defines the text to be drawn
  47225. * @param x defines the placement of the text from the left
  47226. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47227. * @param font defines the font to be used with font-style, font-size, font-name
  47228. * @param color defines the color used for the text
  47229. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47230. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47231. * @param update defines whether texture is immediately update (default is true)
  47232. */
  47233. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47234. /**
  47235. * Clones the texture
  47236. * @returns the clone of the texture.
  47237. */
  47238. clone(): DynamicTexture;
  47239. /**
  47240. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47241. * @returns a serialized dynamic texture object
  47242. */
  47243. serialize(): any;
  47244. private _IsCanvasElement;
  47245. /** @hidden */
  47246. _rebuild(): void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47250. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47251. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47252. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47253. /** @hidden */
  47254. export var imageProcessingPixelShader: {
  47255. name: string;
  47256. shader: string;
  47257. };
  47258. }
  47259. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47260. import { Nullable } from "babylonjs/types";
  47261. import { Color4 } from "babylonjs/Maths/math.color";
  47262. import { Camera } from "babylonjs/Cameras/camera";
  47263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47264. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47265. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47267. import { Engine } from "babylonjs/Engines/engine";
  47268. import "babylonjs/Shaders/imageProcessing.fragment";
  47269. import "babylonjs/Shaders/postprocess.vertex";
  47270. /**
  47271. * ImageProcessingPostProcess
  47272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47273. */
  47274. export class ImageProcessingPostProcess extends PostProcess {
  47275. /**
  47276. * Default configuration related to image processing available in the PBR Material.
  47277. */
  47278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47279. /**
  47280. * Gets the image processing configuration used either in this material.
  47281. */
  47282. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47283. /**
  47284. * Sets the Default image processing configuration used either in the this material.
  47285. *
  47286. * If sets to null, the scene one is in use.
  47287. */
  47288. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47289. /**
  47290. * Keep track of the image processing observer to allow dispose and replace.
  47291. */
  47292. private _imageProcessingObserver;
  47293. /**
  47294. * Attaches a new image processing configuration to the PBR Material.
  47295. * @param configuration
  47296. */
  47297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47298. /**
  47299. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47300. */
  47301. get colorCurves(): Nullable<ColorCurves>;
  47302. /**
  47303. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47304. */
  47305. set colorCurves(value: Nullable<ColorCurves>);
  47306. /**
  47307. * Gets wether the color curves effect is enabled.
  47308. */
  47309. get colorCurvesEnabled(): boolean;
  47310. /**
  47311. * Sets wether the color curves effect is enabled.
  47312. */
  47313. set colorCurvesEnabled(value: boolean);
  47314. /**
  47315. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47316. */
  47317. get colorGradingTexture(): Nullable<BaseTexture>;
  47318. /**
  47319. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47320. */
  47321. set colorGradingTexture(value: Nullable<BaseTexture>);
  47322. /**
  47323. * Gets wether the color grading effect is enabled.
  47324. */
  47325. get colorGradingEnabled(): boolean;
  47326. /**
  47327. * Gets wether the color grading effect is enabled.
  47328. */
  47329. set colorGradingEnabled(value: boolean);
  47330. /**
  47331. * Gets exposure used in the effect.
  47332. */
  47333. get exposure(): number;
  47334. /**
  47335. * Sets exposure used in the effect.
  47336. */
  47337. set exposure(value: number);
  47338. /**
  47339. * Gets wether tonemapping is enabled or not.
  47340. */
  47341. get toneMappingEnabled(): boolean;
  47342. /**
  47343. * Sets wether tonemapping is enabled or not
  47344. */
  47345. set toneMappingEnabled(value: boolean);
  47346. /**
  47347. * Gets the type of tone mapping effect.
  47348. */
  47349. get toneMappingType(): number;
  47350. /**
  47351. * Sets the type of tone mapping effect.
  47352. */
  47353. set toneMappingType(value: number);
  47354. /**
  47355. * Gets contrast used in the effect.
  47356. */
  47357. get contrast(): number;
  47358. /**
  47359. * Sets contrast used in the effect.
  47360. */
  47361. set contrast(value: number);
  47362. /**
  47363. * Gets Vignette stretch size.
  47364. */
  47365. get vignetteStretch(): number;
  47366. /**
  47367. * Sets Vignette stretch size.
  47368. */
  47369. set vignetteStretch(value: number);
  47370. /**
  47371. * Gets Vignette centre X Offset.
  47372. */
  47373. get vignetteCentreX(): number;
  47374. /**
  47375. * Sets Vignette centre X Offset.
  47376. */
  47377. set vignetteCentreX(value: number);
  47378. /**
  47379. * Gets Vignette centre Y Offset.
  47380. */
  47381. get vignetteCentreY(): number;
  47382. /**
  47383. * Sets Vignette centre Y Offset.
  47384. */
  47385. set vignetteCentreY(value: number);
  47386. /**
  47387. * Gets Vignette weight or intensity of the vignette effect.
  47388. */
  47389. get vignetteWeight(): number;
  47390. /**
  47391. * Sets Vignette weight or intensity of the vignette effect.
  47392. */
  47393. set vignetteWeight(value: number);
  47394. /**
  47395. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47396. * if vignetteEnabled is set to true.
  47397. */
  47398. get vignetteColor(): Color4;
  47399. /**
  47400. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47401. * if vignetteEnabled is set to true.
  47402. */
  47403. set vignetteColor(value: Color4);
  47404. /**
  47405. * Gets Camera field of view used by the Vignette effect.
  47406. */
  47407. get vignetteCameraFov(): number;
  47408. /**
  47409. * Sets Camera field of view used by the Vignette effect.
  47410. */
  47411. set vignetteCameraFov(value: number);
  47412. /**
  47413. * Gets the vignette blend mode allowing different kind of effect.
  47414. */
  47415. get vignetteBlendMode(): number;
  47416. /**
  47417. * Sets the vignette blend mode allowing different kind of effect.
  47418. */
  47419. set vignetteBlendMode(value: number);
  47420. /**
  47421. * Gets wether the vignette effect is enabled.
  47422. */
  47423. get vignetteEnabled(): boolean;
  47424. /**
  47425. * Sets wether the vignette effect is enabled.
  47426. */
  47427. set vignetteEnabled(value: boolean);
  47428. private _fromLinearSpace;
  47429. /**
  47430. * Gets wether the input of the processing is in Gamma or Linear Space.
  47431. */
  47432. get fromLinearSpace(): boolean;
  47433. /**
  47434. * Sets wether the input of the processing is in Gamma or Linear Space.
  47435. */
  47436. set fromLinearSpace(value: boolean);
  47437. /**
  47438. * Defines cache preventing GC.
  47439. */
  47440. private _defines;
  47441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47442. /**
  47443. * "ImageProcessingPostProcess"
  47444. * @returns "ImageProcessingPostProcess"
  47445. */
  47446. getClassName(): string;
  47447. protected _updateParameters(): void;
  47448. dispose(camera?: Camera): void;
  47449. }
  47450. }
  47451. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47452. import { Scene } from "babylonjs/scene";
  47453. import { Color3 } from "babylonjs/Maths/math.color";
  47454. import { Mesh } from "babylonjs/Meshes/mesh";
  47455. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47456. import { Nullable } from "babylonjs/types";
  47457. /**
  47458. * Class containing static functions to help procedurally build meshes
  47459. */
  47460. export class GroundBuilder {
  47461. /**
  47462. * Creates a ground mesh
  47463. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47464. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47466. * @param name defines the name of the mesh
  47467. * @param options defines the options used to create the mesh
  47468. * @param scene defines the hosting scene
  47469. * @returns the ground mesh
  47470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47471. */
  47472. static CreateGround(name: string, options: {
  47473. width?: number;
  47474. height?: number;
  47475. subdivisions?: number;
  47476. subdivisionsX?: number;
  47477. subdivisionsY?: number;
  47478. updatable?: boolean;
  47479. }, scene: any): Mesh;
  47480. /**
  47481. * Creates a tiled ground mesh
  47482. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47483. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47484. * * 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
  47485. * * 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
  47486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47487. * @param name defines the name of the mesh
  47488. * @param options defines the options used to create the mesh
  47489. * @param scene defines the hosting scene
  47490. * @returns the tiled ground mesh
  47491. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47492. */
  47493. static CreateTiledGround(name: string, options: {
  47494. xmin: number;
  47495. zmin: number;
  47496. xmax: number;
  47497. zmax: number;
  47498. subdivisions?: {
  47499. w: number;
  47500. h: number;
  47501. };
  47502. precision?: {
  47503. w: number;
  47504. h: number;
  47505. };
  47506. updatable?: boolean;
  47507. }, scene?: Nullable<Scene>): Mesh;
  47508. /**
  47509. * Creates a ground mesh from a height map
  47510. * * The parameter `url` sets the URL of the height map image resource.
  47511. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47512. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47513. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47514. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47515. * * 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.
  47516. * * 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).
  47517. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47519. * @param name defines the name of the mesh
  47520. * @param url defines the url to the height map
  47521. * @param options defines the options used to create the mesh
  47522. * @param scene defines the hosting scene
  47523. * @returns the ground mesh
  47524. * @see https://doc.babylonjs.com/babylon101/height_map
  47525. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47526. */
  47527. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47528. width?: number;
  47529. height?: number;
  47530. subdivisions?: number;
  47531. minHeight?: number;
  47532. maxHeight?: number;
  47533. colorFilter?: Color3;
  47534. alphaFilter?: number;
  47535. updatable?: boolean;
  47536. onReady?: (mesh: GroundMesh) => void;
  47537. }, scene?: Nullable<Scene>): GroundMesh;
  47538. }
  47539. }
  47540. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47541. import { Vector4 } from "babylonjs/Maths/math.vector";
  47542. import { Mesh } from "babylonjs/Meshes/mesh";
  47543. /**
  47544. * Class containing static functions to help procedurally build meshes
  47545. */
  47546. export class TorusBuilder {
  47547. /**
  47548. * Creates a torus mesh
  47549. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47550. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47551. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47555. * @param name defines the name of the mesh
  47556. * @param options defines the options used to create the mesh
  47557. * @param scene defines the hosting scene
  47558. * @returns the torus mesh
  47559. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47560. */
  47561. static CreateTorus(name: string, options: {
  47562. diameter?: number;
  47563. thickness?: number;
  47564. tessellation?: number;
  47565. updatable?: boolean;
  47566. sideOrientation?: number;
  47567. frontUVs?: Vector4;
  47568. backUVs?: Vector4;
  47569. }, scene: any): Mesh;
  47570. }
  47571. }
  47572. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47573. import { Vector4 } from "babylonjs/Maths/math.vector";
  47574. import { Color4 } from "babylonjs/Maths/math.color";
  47575. import { Mesh } from "babylonjs/Meshes/mesh";
  47576. /**
  47577. * Class containing static functions to help procedurally build meshes
  47578. */
  47579. export class CylinderBuilder {
  47580. /**
  47581. * Creates a cylinder or a cone mesh
  47582. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47583. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47584. * * 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.
  47585. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47586. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47587. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47588. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47589. * * 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).
  47590. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47591. * * 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).
  47592. * * 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
  47593. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47594. * * 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
  47595. * * 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.
  47596. * * If `enclose` is false, a ring surface is one element.
  47597. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47598. * * 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
  47599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47602. * @param name defines the name of the mesh
  47603. * @param options defines the options used to create the mesh
  47604. * @param scene defines the hosting scene
  47605. * @returns the cylinder mesh
  47606. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47607. */
  47608. static CreateCylinder(name: string, options: {
  47609. height?: number;
  47610. diameterTop?: number;
  47611. diameterBottom?: number;
  47612. diameter?: number;
  47613. tessellation?: number;
  47614. subdivisions?: number;
  47615. arc?: number;
  47616. faceColors?: Color4[];
  47617. faceUV?: Vector4[];
  47618. updatable?: boolean;
  47619. hasRings?: boolean;
  47620. enclose?: boolean;
  47621. cap?: number;
  47622. sideOrientation?: number;
  47623. frontUVs?: Vector4;
  47624. backUVs?: Vector4;
  47625. }, scene: any): Mesh;
  47626. }
  47627. }
  47628. declare module "babylonjs/XR/webXRTypes" {
  47629. import { Nullable } from "babylonjs/types";
  47630. import { IDisposable } from "babylonjs/scene";
  47631. /**
  47632. * States of the webXR experience
  47633. */
  47634. export enum WebXRState {
  47635. /**
  47636. * Transitioning to being in XR mode
  47637. */
  47638. ENTERING_XR = 0,
  47639. /**
  47640. * Transitioning to non XR mode
  47641. */
  47642. EXITING_XR = 1,
  47643. /**
  47644. * In XR mode and presenting
  47645. */
  47646. IN_XR = 2,
  47647. /**
  47648. * Not entered XR mode
  47649. */
  47650. NOT_IN_XR = 3
  47651. }
  47652. /**
  47653. * Abstraction of the XR render target
  47654. */
  47655. export interface WebXRRenderTarget extends IDisposable {
  47656. /**
  47657. * xrpresent context of the canvas which can be used to display/mirror xr content
  47658. */
  47659. canvasContext: WebGLRenderingContext;
  47660. /**
  47661. * xr layer for the canvas
  47662. */
  47663. xrLayer: Nullable<XRWebGLLayer>;
  47664. /**
  47665. * Initializes the xr layer for the session
  47666. * @param xrSession xr session
  47667. * @returns a promise that will resolve once the XR Layer has been created
  47668. */
  47669. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47670. }
  47671. }
  47672. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47673. import { Nullable } from "babylonjs/types";
  47674. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47675. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47676. /**
  47677. * COnfiguration object for WebXR output canvas
  47678. */
  47679. export class WebXRManagedOutputCanvasOptions {
  47680. /**
  47681. * An optional canvas in case you wish to create it yourself and provide it here.
  47682. * If not provided, a new canvas will be created
  47683. */
  47684. canvasElement?: HTMLCanvasElement;
  47685. /**
  47686. * Options for this XR Layer output
  47687. */
  47688. canvasOptions?: XRWebGLLayerOptions;
  47689. /**
  47690. * CSS styling for a newly created canvas (if not provided)
  47691. */
  47692. newCanvasCssStyle?: string;
  47693. /**
  47694. * Get the default values of the configuration object
  47695. * @returns default values of this configuration object
  47696. */
  47697. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47698. }
  47699. /**
  47700. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47701. */
  47702. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47703. private _options;
  47704. private _canvas;
  47705. private _engine;
  47706. /**
  47707. * Rendering context of the canvas which can be used to display/mirror xr content
  47708. */
  47709. canvasContext: WebGLRenderingContext;
  47710. /**
  47711. * xr layer for the canvas
  47712. */
  47713. xrLayer: Nullable<XRWebGLLayer>;
  47714. /**
  47715. * Initializes the canvas to be added/removed upon entering/exiting xr
  47716. * @param _xrSessionManager The XR Session manager
  47717. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47718. */
  47719. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47720. /**
  47721. * Disposes of the object
  47722. */
  47723. dispose(): void;
  47724. /**
  47725. * Initializes the xr layer for the session
  47726. * @param xrSession xr session
  47727. * @returns a promise that will resolve once the XR Layer has been created
  47728. */
  47729. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47730. private _addCanvas;
  47731. private _removeCanvas;
  47732. private _setManagedOutputCanvas;
  47733. }
  47734. }
  47735. declare module "babylonjs/XR/webXRSessionManager" {
  47736. import { Observable } from "babylonjs/Misc/observable";
  47737. import { Nullable } from "babylonjs/types";
  47738. import { IDisposable, Scene } from "babylonjs/scene";
  47739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47740. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47741. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47742. /**
  47743. * Manages an XRSession to work with Babylon's engine
  47744. * @see https://doc.babylonjs.com/how_to/webxr
  47745. */
  47746. export class WebXRSessionManager implements IDisposable {
  47747. /** The scene which the session should be created for */
  47748. scene: Scene;
  47749. private _referenceSpace;
  47750. private _rttProvider;
  47751. private _sessionEnded;
  47752. private _xrNavigator;
  47753. private baseLayer;
  47754. /**
  47755. * The base reference space from which the session started. good if you want to reset your
  47756. * reference space
  47757. */
  47758. baseReferenceSpace: XRReferenceSpace;
  47759. /**
  47760. * Current XR frame
  47761. */
  47762. currentFrame: Nullable<XRFrame>;
  47763. /** WebXR timestamp updated every frame */
  47764. currentTimestamp: number;
  47765. /**
  47766. * Used just in case of a failure to initialize an immersive session.
  47767. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47768. */
  47769. defaultHeightCompensation: number;
  47770. /**
  47771. * Fires every time a new xrFrame arrives which can be used to update the camera
  47772. */
  47773. onXRFrameObservable: Observable<XRFrame>;
  47774. /**
  47775. * Fires when the reference space changed
  47776. */
  47777. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47778. /**
  47779. * Fires when the xr session is ended either by the device or manually done
  47780. */
  47781. onXRSessionEnded: Observable<any>;
  47782. /**
  47783. * Fires when the xr session is ended either by the device or manually done
  47784. */
  47785. onXRSessionInit: Observable<XRSession>;
  47786. /**
  47787. * Underlying xr session
  47788. */
  47789. session: XRSession;
  47790. /**
  47791. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47792. * or get the offset the player is currently at.
  47793. */
  47794. viewerReferenceSpace: XRReferenceSpace;
  47795. /**
  47796. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47797. * @param scene The scene which the session should be created for
  47798. */
  47799. constructor(
  47800. /** The scene which the session should be created for */
  47801. scene: Scene);
  47802. /**
  47803. * The current reference space used in this session. This reference space can constantly change!
  47804. * It is mainly used to offset the camera's position.
  47805. */
  47806. get referenceSpace(): XRReferenceSpace;
  47807. /**
  47808. * Set a new reference space and triggers the observable
  47809. */
  47810. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47811. /**
  47812. * Disposes of the session manager
  47813. */
  47814. dispose(): void;
  47815. /**
  47816. * Stops the xrSession and restores the render loop
  47817. * @returns Promise which resolves after it exits XR
  47818. */
  47819. exitXRAsync(): Promise<void>;
  47820. /**
  47821. * Gets the correct render target texture to be rendered this frame for this eye
  47822. * @param eye the eye for which to get the render target
  47823. * @returns the render target for the specified eye
  47824. */
  47825. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47826. /**
  47827. * Creates a WebXRRenderTarget object for the XR session
  47828. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47829. * @param options optional options to provide when creating a new render target
  47830. * @returns a WebXR render target to which the session can render
  47831. */
  47832. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47833. /**
  47834. * Initializes the manager
  47835. * After initialization enterXR can be called to start an XR session
  47836. * @returns Promise which resolves after it is initialized
  47837. */
  47838. initializeAsync(): Promise<void>;
  47839. /**
  47840. * Initializes an xr session
  47841. * @param xrSessionMode mode to initialize
  47842. * @param xrSessionInit defines optional and required values to pass to the session builder
  47843. * @returns a promise which will resolve once the session has been initialized
  47844. */
  47845. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47846. /**
  47847. * Checks if a session would be supported for the creation options specified
  47848. * @param sessionMode session mode to check if supported eg. immersive-vr
  47849. * @returns A Promise that resolves to true if supported and false if not
  47850. */
  47851. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47852. /**
  47853. * Resets the reference space to the one started the session
  47854. */
  47855. resetReferenceSpace(): void;
  47856. /**
  47857. * Starts rendering to the xr layer
  47858. */
  47859. runXRRenderLoop(): void;
  47860. /**
  47861. * Sets the reference space on the xr session
  47862. * @param referenceSpaceType space to set
  47863. * @returns a promise that will resolve once the reference space has been set
  47864. */
  47865. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47866. /**
  47867. * Updates the render state of the session
  47868. * @param state state to set
  47869. * @returns a promise that resolves once the render state has been updated
  47870. */
  47871. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47872. /**
  47873. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47874. * @param sessionMode defines the session to test
  47875. * @returns a promise with boolean as final value
  47876. */
  47877. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47878. private _createRenderTargetTexture;
  47879. }
  47880. }
  47881. declare module "babylonjs/XR/webXRCamera" {
  47882. import { Matrix } from "babylonjs/Maths/math.vector";
  47883. import { Scene } from "babylonjs/scene";
  47884. import { Camera } from "babylonjs/Cameras/camera";
  47885. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47886. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47887. /**
  47888. * WebXR Camera which holds the views for the xrSession
  47889. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47890. */
  47891. export class WebXRCamera extends FreeCamera {
  47892. private _xrSessionManager;
  47893. private _firstFrame;
  47894. private _referenceQuaternion;
  47895. private _referencedPosition;
  47896. private _xrInvPositionCache;
  47897. private _xrInvQuaternionCache;
  47898. /**
  47899. * Should position compensation execute on first frame.
  47900. * This is used when copying the position from a native (non XR) camera
  47901. */
  47902. compensateOnFirstFrame: boolean;
  47903. /**
  47904. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47905. * @param name the name of the camera
  47906. * @param scene the scene to add the camera to
  47907. * @param _xrSessionManager a constructed xr session manager
  47908. */
  47909. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47910. /**
  47911. * Return the user's height, unrelated to the current ground.
  47912. * This will be the y position of this camera, when ground level is 0.
  47913. */
  47914. get realWorldHeight(): number;
  47915. /** @hidden */
  47916. _updateForDualEyeDebugging(): void;
  47917. /**
  47918. * Sets this camera's transformation based on a non-vr camera
  47919. * @param otherCamera the non-vr camera to copy the transformation from
  47920. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47921. */
  47922. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47923. /**
  47924. * Gets the current instance class name ("WebXRCamera").
  47925. * @returns the class name
  47926. */
  47927. getClassName(): string;
  47928. /**
  47929. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47930. */
  47931. _getViewMatrix(): Matrix;
  47932. private _updateFromXRSession;
  47933. private _updateNumberOfRigCameras;
  47934. private _updateReferenceSpace;
  47935. private _updateReferenceSpaceOffset;
  47936. }
  47937. }
  47938. declare module "babylonjs/XR/webXRFeaturesManager" {
  47939. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47940. import { IDisposable } from "babylonjs/scene";
  47941. /**
  47942. * Defining the interface required for a (webxr) feature
  47943. */
  47944. export interface IWebXRFeature extends IDisposable {
  47945. /**
  47946. * Is this feature attached
  47947. */
  47948. attached: boolean;
  47949. /**
  47950. * Should auto-attach be disabled?
  47951. */
  47952. disableAutoAttach: boolean;
  47953. /**
  47954. * Attach the feature to the session
  47955. * Will usually be called by the features manager
  47956. *
  47957. * @param force should attachment be forced (even when already attached)
  47958. * @returns true if successful.
  47959. */
  47960. attach(force?: boolean): boolean;
  47961. /**
  47962. * Detach the feature from the session
  47963. * Will usually be called by the features manager
  47964. *
  47965. * @returns true if successful.
  47966. */
  47967. detach(): boolean;
  47968. }
  47969. /**
  47970. * A list of the currently available features without referencing them
  47971. */
  47972. export class WebXRFeatureName {
  47973. /**
  47974. * The name of the anchor system feature
  47975. */
  47976. static ANCHOR_SYSTEM: string;
  47977. /**
  47978. * The name of the background remover feature
  47979. */
  47980. static BACKGROUND_REMOVER: string;
  47981. /**
  47982. * The name of the hit test feature
  47983. */
  47984. static HIT_TEST: string;
  47985. /**
  47986. * physics impostors for xr controllers feature
  47987. */
  47988. static PHYSICS_CONTROLLERS: string;
  47989. /**
  47990. * The name of the plane detection feature
  47991. */
  47992. static PLANE_DETECTION: string;
  47993. /**
  47994. * The name of the pointer selection feature
  47995. */
  47996. static POINTER_SELECTION: string;
  47997. /**
  47998. * The name of the teleportation feature
  47999. */
  48000. static TELEPORTATION: string;
  48001. }
  48002. /**
  48003. * Defining the constructor of a feature. Used to register the modules.
  48004. */
  48005. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48006. /**
  48007. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48008. * It is mainly used in AR sessions.
  48009. *
  48010. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48011. */
  48012. export class WebXRFeaturesManager implements IDisposable {
  48013. private _xrSessionManager;
  48014. private static readonly _AvailableFeatures;
  48015. private _features;
  48016. /**
  48017. * constructs a new features manages.
  48018. *
  48019. * @param _xrSessionManager an instance of WebXRSessionManager
  48020. */
  48021. constructor(_xrSessionManager: WebXRSessionManager);
  48022. /**
  48023. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48024. * Mainly used internally.
  48025. *
  48026. * @param featureName the name of the feature to register
  48027. * @param constructorFunction the function used to construct the module
  48028. * @param version the (babylon) version of the module
  48029. * @param stable is that a stable version of this module
  48030. */
  48031. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48032. /**
  48033. * Returns a constructor of a specific feature.
  48034. *
  48035. * @param featureName the name of the feature to construct
  48036. * @param version the version of the feature to load
  48037. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48038. * @param options optional options provided to the module.
  48039. * @returns a function that, when called, will return a new instance of this feature
  48040. */
  48041. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48042. /**
  48043. * Can be used to return the list of features currently registered
  48044. *
  48045. * @returns an Array of available features
  48046. */
  48047. static GetAvailableFeatures(): string[];
  48048. /**
  48049. * Gets the versions available for a specific feature
  48050. * @param featureName the name of the feature
  48051. * @returns an array with the available versions
  48052. */
  48053. static GetAvailableVersions(featureName: string): string[];
  48054. /**
  48055. * Return the latest unstable version of this feature
  48056. * @param featureName the name of the feature to search
  48057. * @returns the version number. if not found will return -1
  48058. */
  48059. static GetLatestVersionOfFeature(featureName: string): number;
  48060. /**
  48061. * Return the latest stable version of this feature
  48062. * @param featureName the name of the feature to search
  48063. * @returns the version number. if not found will return -1
  48064. */
  48065. static GetStableVersionOfFeature(featureName: string): number;
  48066. /**
  48067. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48068. * Can be used during a session to start a feature
  48069. * @param featureName the name of feature to attach
  48070. */
  48071. attachFeature(featureName: string): void;
  48072. /**
  48073. * Can be used inside a session or when the session ends to detach a specific feature
  48074. * @param featureName the name of the feature to detach
  48075. */
  48076. detachFeature(featureName: string): void;
  48077. /**
  48078. * Used to disable an already-enabled feature
  48079. * The feature will be disposed and will be recreated once enabled.
  48080. * @param featureName the feature to disable
  48081. * @returns true if disable was successful
  48082. */
  48083. disableFeature(featureName: string | {
  48084. Name: string;
  48085. }): boolean;
  48086. /**
  48087. * dispose this features manager
  48088. */
  48089. dispose(): void;
  48090. /**
  48091. * 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.
  48092. * 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.
  48093. *
  48094. * @param featureName the name of the feature to load or the class of the feature
  48095. * @param version optional version to load. if not provided the latest version will be enabled
  48096. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48097. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48098. * @returns a new constructed feature or throws an error if feature not found.
  48099. */
  48100. enableFeature(featureName: string | {
  48101. Name: string;
  48102. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48103. /**
  48104. * get the implementation of an enabled feature.
  48105. * @param featureName the name of the feature to load
  48106. * @returns the feature class, if found
  48107. */
  48108. getEnabledFeature(featureName: string): IWebXRFeature;
  48109. /**
  48110. * Get the list of enabled features
  48111. * @returns an array of enabled features
  48112. */
  48113. getEnabledFeatures(): string[];
  48114. }
  48115. }
  48116. declare module "babylonjs/XR/webXRExperienceHelper" {
  48117. import { Observable } from "babylonjs/Misc/observable";
  48118. import { IDisposable, Scene } from "babylonjs/scene";
  48119. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48120. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48121. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48122. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48123. /**
  48124. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48125. * @see https://doc.babylonjs.com/how_to/webxr
  48126. */
  48127. export class WebXRExperienceHelper implements IDisposable {
  48128. private scene;
  48129. private _nonVRCamera;
  48130. private _originalSceneAutoClear;
  48131. private _supported;
  48132. /**
  48133. * Camera used to render xr content
  48134. */
  48135. camera: WebXRCamera;
  48136. /** A features manager for this xr session */
  48137. featuresManager: WebXRFeaturesManager;
  48138. /**
  48139. * Observers registered here will be triggered after the camera's initial transformation is set
  48140. * This can be used to set a different ground level or an extra rotation.
  48141. *
  48142. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48143. * to the position set after this observable is done executing.
  48144. */
  48145. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48146. /**
  48147. * Fires when the state of the experience helper has changed
  48148. */
  48149. onStateChangedObservable: Observable<WebXRState>;
  48150. /** Session manager used to keep track of xr session */
  48151. sessionManager: WebXRSessionManager;
  48152. /**
  48153. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48154. */
  48155. state: WebXRState;
  48156. /**
  48157. * Creates a WebXRExperienceHelper
  48158. * @param scene The scene the helper should be created in
  48159. */
  48160. private constructor();
  48161. /**
  48162. * Creates the experience helper
  48163. * @param scene the scene to attach the experience helper to
  48164. * @returns a promise for the experience helper
  48165. */
  48166. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48167. /**
  48168. * Disposes of the experience helper
  48169. */
  48170. dispose(): void;
  48171. /**
  48172. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48173. * @param sessionMode options for the XR session
  48174. * @param referenceSpaceType frame of reference of the XR session
  48175. * @param renderTarget the output canvas that will be used to enter XR mode
  48176. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48177. * @returns promise that resolves after xr mode has entered
  48178. */
  48179. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48180. /**
  48181. * Exits XR mode and returns the scene to its original state
  48182. * @returns promise that resolves after xr mode has exited
  48183. */
  48184. exitXRAsync(): Promise<void>;
  48185. private _nonXRToXRCamera;
  48186. private _setState;
  48187. }
  48188. }
  48189. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48190. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48191. import { Observable } from "babylonjs/Misc/observable";
  48192. import { IDisposable } from "babylonjs/scene";
  48193. /**
  48194. * X-Y values for axes in WebXR
  48195. */
  48196. export interface IWebXRMotionControllerAxesValue {
  48197. /**
  48198. * The value of the x axis
  48199. */
  48200. x: number;
  48201. /**
  48202. * The value of the y-axis
  48203. */
  48204. y: number;
  48205. }
  48206. /**
  48207. * changed / previous values for the values of this component
  48208. */
  48209. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48210. /**
  48211. * current (this frame) value
  48212. */
  48213. current: T;
  48214. /**
  48215. * previous (last change) value
  48216. */
  48217. previous: T;
  48218. }
  48219. /**
  48220. * Represents changes in the component between current frame and last values recorded
  48221. */
  48222. export interface IWebXRMotionControllerComponentChanges {
  48223. /**
  48224. * will be populated with previous and current values if axes changed
  48225. */
  48226. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48227. /**
  48228. * will be populated with previous and current values if pressed changed
  48229. */
  48230. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48231. /**
  48232. * will be populated with previous and current values if touched changed
  48233. */
  48234. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48235. /**
  48236. * will be populated with previous and current values if value changed
  48237. */
  48238. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48239. }
  48240. /**
  48241. * This class represents a single component (for example button or thumbstick) of a motion controller
  48242. */
  48243. export class WebXRControllerComponent implements IDisposable {
  48244. /**
  48245. * the id of this component
  48246. */
  48247. id: string;
  48248. /**
  48249. * the type of the component
  48250. */
  48251. type: MotionControllerComponentType;
  48252. private _buttonIndex;
  48253. private _axesIndices;
  48254. private _axes;
  48255. private _changes;
  48256. private _currentValue;
  48257. private _hasChanges;
  48258. private _pressed;
  48259. private _touched;
  48260. /**
  48261. * button component type
  48262. */
  48263. static BUTTON_TYPE: MotionControllerComponentType;
  48264. /**
  48265. * squeeze component type
  48266. */
  48267. static SQUEEZE_TYPE: MotionControllerComponentType;
  48268. /**
  48269. * Thumbstick component type
  48270. */
  48271. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48272. /**
  48273. * Touchpad component type
  48274. */
  48275. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48276. /**
  48277. * trigger component type
  48278. */
  48279. static TRIGGER_TYPE: MotionControllerComponentType;
  48280. /**
  48281. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48282. * the axes data changes
  48283. */
  48284. onAxisValueChangedObservable: Observable<{
  48285. x: number;
  48286. y: number;
  48287. }>;
  48288. /**
  48289. * Observers registered here will be triggered when the state of a button changes
  48290. * State change is either pressed / touched / value
  48291. */
  48292. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48293. /**
  48294. * Creates a new component for a motion controller.
  48295. * It is created by the motion controller itself
  48296. *
  48297. * @param id the id of this component
  48298. * @param type the type of the component
  48299. * @param _buttonIndex index in the buttons array of the gamepad
  48300. * @param _axesIndices indices of the values in the axes array of the gamepad
  48301. */
  48302. constructor(
  48303. /**
  48304. * the id of this component
  48305. */
  48306. id: string,
  48307. /**
  48308. * the type of the component
  48309. */
  48310. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48311. /**
  48312. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48313. */
  48314. get axes(): IWebXRMotionControllerAxesValue;
  48315. /**
  48316. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48317. */
  48318. get changes(): IWebXRMotionControllerComponentChanges;
  48319. /**
  48320. * Return whether or not the component changed the last frame
  48321. */
  48322. get hasChanges(): boolean;
  48323. /**
  48324. * is the button currently pressed
  48325. */
  48326. get pressed(): boolean;
  48327. /**
  48328. * is the button currently touched
  48329. */
  48330. get touched(): boolean;
  48331. /**
  48332. * Get the current value of this component
  48333. */
  48334. get value(): number;
  48335. /**
  48336. * Dispose this component
  48337. */
  48338. dispose(): void;
  48339. /**
  48340. * Are there axes correlating to this component
  48341. * @return true is axes data is available
  48342. */
  48343. isAxes(): boolean;
  48344. /**
  48345. * Is this component a button (hence - pressable)
  48346. * @returns true if can be pressed
  48347. */
  48348. isButton(): boolean;
  48349. /**
  48350. * update this component using the gamepad object it is in. Called on every frame
  48351. * @param nativeController the native gamepad controller object
  48352. */
  48353. update(nativeController: IMinimalMotionControllerObject): void;
  48354. }
  48355. }
  48356. declare module "babylonjs/Loading/sceneLoader" {
  48357. import { Observable } from "babylonjs/Misc/observable";
  48358. import { Nullable } from "babylonjs/types";
  48359. import { Scene } from "babylonjs/scene";
  48360. import { Engine } from "babylonjs/Engines/engine";
  48361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48362. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48363. import { AssetContainer } from "babylonjs/assetContainer";
  48364. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48365. import { Skeleton } from "babylonjs/Bones/skeleton";
  48366. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48367. import { WebRequest } from "babylonjs/Misc/webRequest";
  48368. /**
  48369. * Interface used to represent data loading progression
  48370. */
  48371. export interface ISceneLoaderProgressEvent {
  48372. /**
  48373. * Defines if data length to load can be evaluated
  48374. */
  48375. readonly lengthComputable: boolean;
  48376. /**
  48377. * Defines the loaded data length
  48378. */
  48379. readonly loaded: number;
  48380. /**
  48381. * Defines the data length to load
  48382. */
  48383. readonly total: number;
  48384. }
  48385. /**
  48386. * Interface used by SceneLoader plugins to define supported file extensions
  48387. */
  48388. export interface ISceneLoaderPluginExtensions {
  48389. /**
  48390. * Defines the list of supported extensions
  48391. */
  48392. [extension: string]: {
  48393. isBinary: boolean;
  48394. };
  48395. }
  48396. /**
  48397. * Interface used by SceneLoader plugin factory
  48398. */
  48399. export interface ISceneLoaderPluginFactory {
  48400. /**
  48401. * Defines the name of the factory
  48402. */
  48403. name: string;
  48404. /**
  48405. * Function called to create a new plugin
  48406. * @return the new plugin
  48407. */
  48408. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48409. /**
  48410. * The callback that returns true if the data can be directly loaded.
  48411. * @param data string containing the file data
  48412. * @returns if the data can be loaded directly
  48413. */
  48414. canDirectLoad?(data: string): boolean;
  48415. }
  48416. /**
  48417. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48418. */
  48419. export interface ISceneLoaderPluginBase {
  48420. /**
  48421. * The friendly name of this plugin.
  48422. */
  48423. name: string;
  48424. /**
  48425. * The file extensions supported by this plugin.
  48426. */
  48427. extensions: string | ISceneLoaderPluginExtensions;
  48428. /**
  48429. * The callback called when loading from a url.
  48430. * @param scene scene loading this url
  48431. * @param url url to load
  48432. * @param onSuccess callback called when the file successfully loads
  48433. * @param onProgress callback called while file is loading (if the server supports this mode)
  48434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48435. * @param onError callback called when the file fails to load
  48436. * @returns a file request object
  48437. */
  48438. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48439. /**
  48440. * The callback called when loading from a file object.
  48441. * @param scene scene loading this file
  48442. * @param file defines the file to load
  48443. * @param onSuccess defines the callback to call when data is loaded
  48444. * @param onProgress defines the callback to call during loading process
  48445. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48446. * @param onError defines the callback to call when an error occurs
  48447. * @returns a file request object
  48448. */
  48449. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48450. /**
  48451. * The callback that returns true if the data can be directly loaded.
  48452. * @param data string containing the file data
  48453. * @returns if the data can be loaded directly
  48454. */
  48455. canDirectLoad?(data: string): boolean;
  48456. /**
  48457. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48458. * @param scene scene loading this data
  48459. * @param data string containing the data
  48460. * @returns data to pass to the plugin
  48461. */
  48462. directLoad?(scene: Scene, data: string): any;
  48463. /**
  48464. * The callback that allows custom handling of the root url based on the response url.
  48465. * @param rootUrl the original root url
  48466. * @param responseURL the response url if available
  48467. * @returns the new root url
  48468. */
  48469. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48470. }
  48471. /**
  48472. * Interface used to define a SceneLoader plugin
  48473. */
  48474. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48475. /**
  48476. * Import meshes into a scene.
  48477. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48478. * @param scene The scene to import into
  48479. * @param data The data to import
  48480. * @param rootUrl The root url for scene and resources
  48481. * @param meshes The meshes array to import into
  48482. * @param particleSystems The particle systems array to import into
  48483. * @param skeletons The skeletons array to import into
  48484. * @param onError The callback when import fails
  48485. * @returns True if successful or false otherwise
  48486. */
  48487. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48488. /**
  48489. * Load into a scene.
  48490. * @param scene The scene to load into
  48491. * @param data The data to import
  48492. * @param rootUrl The root url for scene and resources
  48493. * @param onError The callback when import fails
  48494. * @returns True if successful or false otherwise
  48495. */
  48496. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48497. /**
  48498. * Load into an asset container.
  48499. * @param scene The scene to load into
  48500. * @param data The data to import
  48501. * @param rootUrl The root url for scene and resources
  48502. * @param onError The callback when import fails
  48503. * @returns The loaded asset container
  48504. */
  48505. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48506. }
  48507. /**
  48508. * Interface used to define an async SceneLoader plugin
  48509. */
  48510. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48511. /**
  48512. * Import meshes into a scene.
  48513. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48514. * @param scene The scene to import into
  48515. * @param data The data to import
  48516. * @param rootUrl The root url for scene and resources
  48517. * @param onProgress The callback when the load progresses
  48518. * @param fileName Defines the name of the file to load
  48519. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48520. */
  48521. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48522. meshes: AbstractMesh[];
  48523. particleSystems: IParticleSystem[];
  48524. skeletons: Skeleton[];
  48525. animationGroups: AnimationGroup[];
  48526. }>;
  48527. /**
  48528. * Load into a scene.
  48529. * @param scene The scene to load into
  48530. * @param data The data to import
  48531. * @param rootUrl The root url for scene and resources
  48532. * @param onProgress The callback when the load progresses
  48533. * @param fileName Defines the name of the file to load
  48534. * @returns Nothing
  48535. */
  48536. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48537. /**
  48538. * Load into an asset container.
  48539. * @param scene The scene to load into
  48540. * @param data The data to import
  48541. * @param rootUrl The root url for scene and resources
  48542. * @param onProgress The callback when the load progresses
  48543. * @param fileName Defines the name of the file to load
  48544. * @returns The loaded asset container
  48545. */
  48546. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48547. }
  48548. /**
  48549. * Mode that determines how to handle old animation groups before loading new ones.
  48550. */
  48551. export enum SceneLoaderAnimationGroupLoadingMode {
  48552. /**
  48553. * Reset all old animations to initial state then dispose them.
  48554. */
  48555. Clean = 0,
  48556. /**
  48557. * Stop all old animations.
  48558. */
  48559. Stop = 1,
  48560. /**
  48561. * Restart old animations from first frame.
  48562. */
  48563. Sync = 2,
  48564. /**
  48565. * Old animations remains untouched.
  48566. */
  48567. NoSync = 3
  48568. }
  48569. /**
  48570. * Class used to load scene from various file formats using registered plugins
  48571. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48572. */
  48573. export class SceneLoader {
  48574. /**
  48575. * No logging while loading
  48576. */
  48577. static readonly NO_LOGGING: number;
  48578. /**
  48579. * Minimal logging while loading
  48580. */
  48581. static readonly MINIMAL_LOGGING: number;
  48582. /**
  48583. * Summary logging while loading
  48584. */
  48585. static readonly SUMMARY_LOGGING: number;
  48586. /**
  48587. * Detailled logging while loading
  48588. */
  48589. static readonly DETAILED_LOGGING: number;
  48590. /**
  48591. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48592. */
  48593. static get ForceFullSceneLoadingForIncremental(): boolean;
  48594. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48595. /**
  48596. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48597. */
  48598. static get ShowLoadingScreen(): boolean;
  48599. static set ShowLoadingScreen(value: boolean);
  48600. /**
  48601. * Defines the current logging level (while loading the scene)
  48602. * @ignorenaming
  48603. */
  48604. static get loggingLevel(): number;
  48605. static set loggingLevel(value: number);
  48606. /**
  48607. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48608. */
  48609. static get CleanBoneMatrixWeights(): boolean;
  48610. static set CleanBoneMatrixWeights(value: boolean);
  48611. /**
  48612. * Event raised when a plugin is used to load a scene
  48613. */
  48614. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48615. private static _registeredPlugins;
  48616. private static _getDefaultPlugin;
  48617. private static _getPluginForExtension;
  48618. private static _getPluginForDirectLoad;
  48619. private static _getPluginForFilename;
  48620. private static _getDirectLoad;
  48621. private static _loadData;
  48622. private static _getFileInfo;
  48623. /**
  48624. * Gets a plugin that can load the given extension
  48625. * @param extension defines the extension to load
  48626. * @returns a plugin or null if none works
  48627. */
  48628. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48629. /**
  48630. * Gets a boolean indicating that the given extension can be loaded
  48631. * @param extension defines the extension to load
  48632. * @returns true if the extension is supported
  48633. */
  48634. static IsPluginForExtensionAvailable(extension: string): boolean;
  48635. /**
  48636. * Adds a new plugin to the list of registered plugins
  48637. * @param plugin defines the plugin to add
  48638. */
  48639. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48640. /**
  48641. * Import meshes into a scene
  48642. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48643. * @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)
  48644. * @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)
  48645. * @param scene the instance of BABYLON.Scene to append to
  48646. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48647. * @param onProgress a callback with a progress event for each file being loaded
  48648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48649. * @param pluginExtension the extension used to determine the plugin
  48650. * @returns The loaded plugin
  48651. */
  48652. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48653. /**
  48654. * Import meshes into a scene
  48655. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48656. * @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)
  48657. * @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)
  48658. * @param scene the instance of BABYLON.Scene to append to
  48659. * @param onProgress a callback with a progress event for each file being loaded
  48660. * @param pluginExtension the extension used to determine the plugin
  48661. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48662. */
  48663. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48664. meshes: AbstractMesh[];
  48665. particleSystems: IParticleSystem[];
  48666. skeletons: Skeleton[];
  48667. animationGroups: AnimationGroup[];
  48668. }>;
  48669. /**
  48670. * Load a scene
  48671. * @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)
  48672. * @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)
  48673. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48674. * @param onSuccess a callback with the scene when import succeeds
  48675. * @param onProgress a callback with a progress event for each file being loaded
  48676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48677. * @param pluginExtension the extension used to determine the plugin
  48678. * @returns The loaded plugin
  48679. */
  48680. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48681. /**
  48682. * Load a scene
  48683. * @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)
  48684. * @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)
  48685. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48686. * @param onProgress a callback with a progress event for each file being loaded
  48687. * @param pluginExtension the extension used to determine the plugin
  48688. * @returns The loaded scene
  48689. */
  48690. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48691. /**
  48692. * Append a scene
  48693. * @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)
  48694. * @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)
  48695. * @param scene is the instance of BABYLON.Scene to append to
  48696. * @param onSuccess a callback with the scene when import succeeds
  48697. * @param onProgress a callback with a progress event for each file being loaded
  48698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48699. * @param pluginExtension the extension used to determine the plugin
  48700. * @returns The loaded plugin
  48701. */
  48702. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48703. /**
  48704. * Append a scene
  48705. * @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)
  48706. * @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)
  48707. * @param scene is the instance of BABYLON.Scene to append to
  48708. * @param onProgress a callback with a progress event for each file being loaded
  48709. * @param pluginExtension the extension used to determine the plugin
  48710. * @returns The given scene
  48711. */
  48712. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48713. /**
  48714. * Load a scene into an asset container
  48715. * @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)
  48716. * @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)
  48717. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48718. * @param onSuccess a callback with the scene when import succeeds
  48719. * @param onProgress a callback with a progress event for each file being loaded
  48720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48721. * @param pluginExtension the extension used to determine the plugin
  48722. * @returns The loaded plugin
  48723. */
  48724. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48725. /**
  48726. * Load a scene into an asset container
  48727. * @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)
  48728. * @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)
  48729. * @param scene is the instance of Scene to append to
  48730. * @param onProgress a callback with a progress event for each file being loaded
  48731. * @param pluginExtension the extension used to determine the plugin
  48732. * @returns The loaded asset container
  48733. */
  48734. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48735. /**
  48736. * Import animations from a file into a scene
  48737. * @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)
  48738. * @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)
  48739. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48740. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48741. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48742. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48743. * @param onSuccess a callback with the scene when import succeeds
  48744. * @param onProgress a callback with a progress event for each file being loaded
  48745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48746. */
  48747. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  48748. /**
  48749. * Import animations from a file into a scene
  48750. * @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)
  48751. * @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)
  48752. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48753. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48754. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48755. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48756. * @param onSuccess a callback with the scene when import succeeds
  48757. * @param onProgress a callback with a progress event for each file being loaded
  48758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48759. * @returns the updated scene with imported animations
  48760. */
  48761. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  48762. }
  48763. }
  48764. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48765. import { IDisposable, Scene } from "babylonjs/scene";
  48766. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48767. import { Observable } from "babylonjs/Misc/observable";
  48768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48769. import { Nullable } from "babylonjs/types";
  48770. /**
  48771. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48772. */
  48773. export type MotionControllerHandedness = "none" | "left" | "right";
  48774. /**
  48775. * The type of components available in motion controllers.
  48776. * This is not the name of the component.
  48777. */
  48778. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48779. /**
  48780. * The state of a controller component
  48781. */
  48782. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48783. /**
  48784. * The schema of motion controller layout.
  48785. * No object will be initialized using this interface
  48786. * This is used just to define the profile.
  48787. */
  48788. export interface IMotionControllerLayout {
  48789. /**
  48790. * Path to load the assets. Usually relative to the base path
  48791. */
  48792. assetPath: string;
  48793. /**
  48794. * Available components (unsorted)
  48795. */
  48796. components: {
  48797. /**
  48798. * A map of component Ids
  48799. */
  48800. [componentId: string]: {
  48801. /**
  48802. * The type of input the component outputs
  48803. */
  48804. type: MotionControllerComponentType;
  48805. /**
  48806. * The indices of this component in the gamepad object
  48807. */
  48808. gamepadIndices: {
  48809. /**
  48810. * Index of button
  48811. */
  48812. button?: number;
  48813. /**
  48814. * If available, index of x-axis
  48815. */
  48816. xAxis?: number;
  48817. /**
  48818. * If available, index of y-axis
  48819. */
  48820. yAxis?: number;
  48821. };
  48822. /**
  48823. * The mesh's root node name
  48824. */
  48825. rootNodeName: string;
  48826. /**
  48827. * Animation definitions for this model
  48828. */
  48829. visualResponses: {
  48830. [stateKey: string]: {
  48831. /**
  48832. * What property will be animated
  48833. */
  48834. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48835. /**
  48836. * What states influence this visual response
  48837. */
  48838. states: MotionControllerComponentStateType[];
  48839. /**
  48840. * Type of animation - movement or visibility
  48841. */
  48842. valueNodeProperty: "transform" | "visibility";
  48843. /**
  48844. * Base node name to move. Its position will be calculated according to the min and max nodes
  48845. */
  48846. valueNodeName?: string;
  48847. /**
  48848. * Minimum movement node
  48849. */
  48850. minNodeName?: string;
  48851. /**
  48852. * Max movement node
  48853. */
  48854. maxNodeName?: string;
  48855. };
  48856. };
  48857. /**
  48858. * If touch enabled, what is the name of node to display user feedback
  48859. */
  48860. touchPointNodeName?: string;
  48861. };
  48862. };
  48863. /**
  48864. * Is it xr standard mapping or not
  48865. */
  48866. gamepadMapping: "" | "xr-standard";
  48867. /**
  48868. * Base root node of this entire model
  48869. */
  48870. rootNodeName: string;
  48871. /**
  48872. * Defines the main button component id
  48873. */
  48874. selectComponentId: string;
  48875. }
  48876. /**
  48877. * A definition for the layout map in the input profile
  48878. */
  48879. export interface IMotionControllerLayoutMap {
  48880. /**
  48881. * Layouts with handedness type as a key
  48882. */
  48883. [handedness: string]: IMotionControllerLayout;
  48884. }
  48885. /**
  48886. * The XR Input profile schema
  48887. * Profiles can be found here:
  48888. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48889. */
  48890. export interface IMotionControllerProfile {
  48891. /**
  48892. * fallback profiles for this profileId
  48893. */
  48894. fallbackProfileIds: string[];
  48895. /**
  48896. * The layout map, with handedness as key
  48897. */
  48898. layouts: IMotionControllerLayoutMap;
  48899. /**
  48900. * The id of this profile
  48901. * correlates to the profile(s) in the xrInput.profiles array
  48902. */
  48903. profileId: string;
  48904. }
  48905. /**
  48906. * A helper-interface for the 3 meshes needed for controller button animation
  48907. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48908. */
  48909. export interface IMotionControllerButtonMeshMap {
  48910. /**
  48911. * the mesh that defines the pressed value mesh position.
  48912. * This is used to find the max-position of this button
  48913. */
  48914. pressedMesh: AbstractMesh;
  48915. /**
  48916. * the mesh that defines the unpressed value mesh position.
  48917. * This is used to find the min (or initial) position of this button
  48918. */
  48919. unpressedMesh: AbstractMesh;
  48920. /**
  48921. * The mesh that will be changed when value changes
  48922. */
  48923. valueMesh: AbstractMesh;
  48924. }
  48925. /**
  48926. * A helper-interface for the 3 meshes needed for controller axis animation.
  48927. * This will be expanded when touchpad animations are fully supported
  48928. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48929. */
  48930. export interface IMotionControllerMeshMap {
  48931. /**
  48932. * the mesh that defines the maximum value mesh position.
  48933. */
  48934. maxMesh?: AbstractMesh;
  48935. /**
  48936. * the mesh that defines the minimum value mesh position.
  48937. */
  48938. minMesh?: AbstractMesh;
  48939. /**
  48940. * The mesh that will be changed when axis value changes
  48941. */
  48942. valueMesh: AbstractMesh;
  48943. }
  48944. /**
  48945. * The elements needed for change-detection of the gamepad objects in motion controllers
  48946. */
  48947. export interface IMinimalMotionControllerObject {
  48948. /**
  48949. * Available axes of this controller
  48950. */
  48951. axes: number[];
  48952. /**
  48953. * An array of available buttons
  48954. */
  48955. buttons: Array<{
  48956. /**
  48957. * Value of the button/trigger
  48958. */
  48959. value: number;
  48960. /**
  48961. * If the button/trigger is currently touched
  48962. */
  48963. touched: boolean;
  48964. /**
  48965. * If the button/trigger is currently pressed
  48966. */
  48967. pressed: boolean;
  48968. }>;
  48969. /**
  48970. * EXPERIMENTAL haptic support.
  48971. */
  48972. hapticActuators?: Array<{
  48973. pulse: (value: number, duration: number) => Promise<boolean>;
  48974. }>;
  48975. }
  48976. /**
  48977. * An Abstract Motion controller
  48978. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48979. * Each component has an observable to check for changes in value and state
  48980. */
  48981. export abstract class WebXRAbstractMotionController implements IDisposable {
  48982. protected scene: Scene;
  48983. protected layout: IMotionControllerLayout;
  48984. /**
  48985. * The gamepad object correlating to this controller
  48986. */
  48987. gamepadObject: IMinimalMotionControllerObject;
  48988. /**
  48989. * handedness (left/right/none) of this controller
  48990. */
  48991. handedness: MotionControllerHandedness;
  48992. private _initComponent;
  48993. private _modelReady;
  48994. /**
  48995. * A map of components (WebXRControllerComponent) in this motion controller
  48996. * Components have a ComponentType and can also have both button and axis definitions
  48997. */
  48998. readonly components: {
  48999. [id: string]: WebXRControllerComponent;
  49000. };
  49001. /**
  49002. * Disable the model's animation. Can be set at any time.
  49003. */
  49004. disableAnimation: boolean;
  49005. /**
  49006. * Observers registered here will be triggered when the model of this controller is done loading
  49007. */
  49008. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49009. /**
  49010. * The profile id of this motion controller
  49011. */
  49012. abstract profileId: string;
  49013. /**
  49014. * The root mesh of the model. It is null if the model was not yet initialized
  49015. */
  49016. rootMesh: Nullable<AbstractMesh>;
  49017. /**
  49018. * constructs a new abstract motion controller
  49019. * @param scene the scene to which the model of the controller will be added
  49020. * @param layout The profile layout to load
  49021. * @param gamepadObject The gamepad object correlating to this controller
  49022. * @param handedness handedness (left/right/none) of this controller
  49023. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49024. */
  49025. constructor(scene: Scene, layout: IMotionControllerLayout,
  49026. /**
  49027. * The gamepad object correlating to this controller
  49028. */
  49029. gamepadObject: IMinimalMotionControllerObject,
  49030. /**
  49031. * handedness (left/right/none) of this controller
  49032. */
  49033. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49034. /**
  49035. * Dispose this controller, the model mesh and all its components
  49036. */
  49037. dispose(): void;
  49038. /**
  49039. * Returns all components of specific type
  49040. * @param type the type to search for
  49041. * @return an array of components with this type
  49042. */
  49043. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49044. /**
  49045. * get a component based an its component id as defined in layout.components
  49046. * @param id the id of the component
  49047. * @returns the component correlates to the id or undefined if not found
  49048. */
  49049. getComponent(id: string): WebXRControllerComponent;
  49050. /**
  49051. * Get the list of components available in this motion controller
  49052. * @returns an array of strings correlating to available components
  49053. */
  49054. getComponentIds(): string[];
  49055. /**
  49056. * Get the first component of specific type
  49057. * @param type type of component to find
  49058. * @return a controller component or null if not found
  49059. */
  49060. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49061. /**
  49062. * Get the main (Select) component of this controller as defined in the layout
  49063. * @returns the main component of this controller
  49064. */
  49065. getMainComponent(): WebXRControllerComponent;
  49066. /**
  49067. * Loads the model correlating to this controller
  49068. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49069. * @returns A promise fulfilled with the result of the model loading
  49070. */
  49071. loadModel(): Promise<boolean>;
  49072. /**
  49073. * Update this model using the current XRFrame
  49074. * @param xrFrame the current xr frame to use and update the model
  49075. */
  49076. updateFromXRFrame(xrFrame: XRFrame): void;
  49077. /**
  49078. * Backwards compatibility due to a deeply-integrated typo
  49079. */
  49080. get handness(): XREye;
  49081. /**
  49082. * Pulse (vibrate) this controller
  49083. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49084. * Consecutive calls to this function will cancel the last pulse call
  49085. *
  49086. * @param value the strength of the pulse in 0.0...1.0 range
  49087. * @param duration Duration of the pulse in milliseconds
  49088. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49089. * @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
  49090. */
  49091. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49092. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49093. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49094. /**
  49095. * Moves the axis on the controller mesh based on its current state
  49096. * @param axis the index of the axis
  49097. * @param axisValue the value of the axis which determines the meshes new position
  49098. * @hidden
  49099. */
  49100. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49101. /**
  49102. * Update the model itself with the current frame data
  49103. * @param xrFrame the frame to use for updating the model mesh
  49104. */
  49105. protected updateModel(xrFrame: XRFrame): void;
  49106. /**
  49107. * Get the filename and path for this controller's model
  49108. * @returns a map of filename and path
  49109. */
  49110. protected abstract _getFilenameAndPath(): {
  49111. filename: string;
  49112. path: string;
  49113. };
  49114. /**
  49115. * This function is called before the mesh is loaded. It checks for loading constraints.
  49116. * For example, this function can check if the GLB loader is available
  49117. * If this function returns false, the generic controller will be loaded instead
  49118. * @returns Is the client ready to load the mesh
  49119. */
  49120. protected abstract _getModelLoadingConstraints(): boolean;
  49121. /**
  49122. * This function will be called after the model was successfully loaded and can be used
  49123. * for mesh transformations before it is available for the user
  49124. * @param meshes the loaded meshes
  49125. */
  49126. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49127. /**
  49128. * Set the root mesh for this controller. Important for the WebXR controller class
  49129. * @param meshes the loaded meshes
  49130. */
  49131. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49132. /**
  49133. * A function executed each frame that updates the mesh (if needed)
  49134. * @param xrFrame the current xrFrame
  49135. */
  49136. protected abstract _updateModel(xrFrame: XRFrame): void;
  49137. private _getGenericFilenameAndPath;
  49138. private _getGenericParentMesh;
  49139. }
  49140. }
  49141. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49142. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49144. import { Scene } from "babylonjs/scene";
  49145. /**
  49146. * A generic trigger-only motion controller for WebXR
  49147. */
  49148. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49149. /**
  49150. * Static version of the profile id of this controller
  49151. */
  49152. static ProfileId: string;
  49153. profileId: string;
  49154. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49155. protected _getFilenameAndPath(): {
  49156. filename: string;
  49157. path: string;
  49158. };
  49159. protected _getModelLoadingConstraints(): boolean;
  49160. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49161. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49162. protected _updateModel(): void;
  49163. }
  49164. }
  49165. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49166. import { Vector4 } from "babylonjs/Maths/math.vector";
  49167. import { Mesh } from "babylonjs/Meshes/mesh";
  49168. import { Scene } from "babylonjs/scene";
  49169. import { Nullable } from "babylonjs/types";
  49170. /**
  49171. * Class containing static functions to help procedurally build meshes
  49172. */
  49173. export class SphereBuilder {
  49174. /**
  49175. * Creates a sphere mesh
  49176. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49177. * * 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`)
  49178. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49179. * * 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
  49180. * * 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)
  49181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49184. * @param name defines the name of the mesh
  49185. * @param options defines the options used to create the mesh
  49186. * @param scene defines the hosting scene
  49187. * @returns the sphere mesh
  49188. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49189. */
  49190. static CreateSphere(name: string, options: {
  49191. segments?: number;
  49192. diameter?: number;
  49193. diameterX?: number;
  49194. diameterY?: number;
  49195. diameterZ?: number;
  49196. arc?: number;
  49197. slice?: number;
  49198. sideOrientation?: number;
  49199. frontUVs?: Vector4;
  49200. backUVs?: Vector4;
  49201. updatable?: boolean;
  49202. }, scene?: Nullable<Scene>): Mesh;
  49203. }
  49204. }
  49205. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49207. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49208. import { Scene } from "babylonjs/scene";
  49209. /**
  49210. * A profiled motion controller has its profile loaded from an online repository.
  49211. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49212. */
  49213. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49214. private _repositoryUrl;
  49215. private _buttonMeshMapping;
  49216. private _touchDots;
  49217. /**
  49218. * The profile ID of this controller. Will be populated when the controller initializes.
  49219. */
  49220. profileId: string;
  49221. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49222. dispose(): void;
  49223. protected _getFilenameAndPath(): {
  49224. filename: string;
  49225. path: string;
  49226. };
  49227. protected _getModelLoadingConstraints(): boolean;
  49228. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49229. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49230. protected _updateModel(_xrFrame: XRFrame): void;
  49231. }
  49232. }
  49233. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49234. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49235. import { Scene } from "babylonjs/scene";
  49236. /**
  49237. * A construction function type to create a new controller based on an xrInput object
  49238. */
  49239. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49240. /**
  49241. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49242. *
  49243. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49244. * it should be replaced with auto-loaded controllers.
  49245. *
  49246. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49247. */
  49248. export class WebXRMotionControllerManager {
  49249. private static _AvailableControllers;
  49250. private static _Fallbacks;
  49251. private static _ProfileLoadingPromises;
  49252. private static _ProfilesList;
  49253. /**
  49254. * The base URL of the online controller repository. Can be changed at any time.
  49255. */
  49256. static BaseRepositoryUrl: string;
  49257. /**
  49258. * Which repository gets priority - local or online
  49259. */
  49260. static PrioritizeOnlineRepository: boolean;
  49261. /**
  49262. * Use the online repository, or use only locally-defined controllers
  49263. */
  49264. static UseOnlineRepository: boolean;
  49265. /**
  49266. * Clear the cache used for profile loading and reload when requested again
  49267. */
  49268. static ClearProfilesCache(): void;
  49269. /**
  49270. * Register the default fallbacks.
  49271. * This function is called automatically when this file is imported.
  49272. */
  49273. static DefaultFallbacks(): void;
  49274. /**
  49275. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49276. * @param profileId the profile to which a fallback needs to be found
  49277. * @return an array with corresponding fallback profiles
  49278. */
  49279. static FindFallbackWithProfileId(profileId: string): string[];
  49280. /**
  49281. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49282. * The order of search:
  49283. *
  49284. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49285. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49286. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49287. * 4) return the generic trigger controller if none were found
  49288. *
  49289. * @param xrInput the xrInput to which a new controller is initialized
  49290. * @param scene the scene to which the model will be added
  49291. * @param forceProfile force a certain profile for this controller
  49292. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49293. */
  49294. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49295. /**
  49296. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49297. *
  49298. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49299. *
  49300. * @param type the profile type to register
  49301. * @param constructFunction the function to be called when loading this profile
  49302. */
  49303. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49304. /**
  49305. * Register a fallback to a specific profile.
  49306. * @param profileId the profileId that will receive the fallbacks
  49307. * @param fallbacks A list of fallback profiles
  49308. */
  49309. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49310. /**
  49311. * Will update the list of profiles available in the repository
  49312. * @return a promise that resolves to a map of profiles available online
  49313. */
  49314. static UpdateProfilesList(): Promise<{
  49315. [profile: string]: string;
  49316. }>;
  49317. private static _LoadProfileFromRepository;
  49318. private static _LoadProfilesFromAvailableControllers;
  49319. }
  49320. }
  49321. declare module "babylonjs/XR/webXRInputSource" {
  49322. import { Observable } from "babylonjs/Misc/observable";
  49323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49324. import { Ray } from "babylonjs/Culling/ray";
  49325. import { Scene } from "babylonjs/scene";
  49326. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49327. /**
  49328. * Configuration options for the WebXR controller creation
  49329. */
  49330. export interface IWebXRControllerOptions {
  49331. /**
  49332. * Should the controller mesh be animated when a user interacts with it
  49333. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49334. */
  49335. disableMotionControllerAnimation?: boolean;
  49336. /**
  49337. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49338. */
  49339. doNotLoadControllerMesh?: boolean;
  49340. /**
  49341. * Force a specific controller type for this controller.
  49342. * This can be used when creating your own profile or when testing different controllers
  49343. */
  49344. forceControllerProfile?: string;
  49345. /**
  49346. * Defines a rendering group ID for meshes that will be loaded.
  49347. * This is for the default controllers only.
  49348. */
  49349. renderingGroupId?: number;
  49350. }
  49351. /**
  49352. * Represents an XR controller
  49353. */
  49354. export class WebXRInputSource {
  49355. private _scene;
  49356. /** The underlying input source for the controller */
  49357. inputSource: XRInputSource;
  49358. private _options;
  49359. private _tmpVector;
  49360. private _uniqueId;
  49361. /**
  49362. * 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
  49363. */
  49364. grip?: AbstractMesh;
  49365. /**
  49366. * If available, this is the gamepad object related to this controller.
  49367. * Using this object it is possible to get click events and trackpad changes of the
  49368. * webxr controller that is currently being used.
  49369. */
  49370. motionController?: WebXRAbstractMotionController;
  49371. /**
  49372. * Event that fires when the controller is removed/disposed.
  49373. * The object provided as event data is this controller, after associated assets were disposed.
  49374. * uniqueId is still available.
  49375. */
  49376. onDisposeObservable: Observable<WebXRInputSource>;
  49377. /**
  49378. * Will be triggered when the mesh associated with the motion controller is done loading.
  49379. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49380. * A shortened version of controller -> motion controller -> on mesh loaded.
  49381. */
  49382. onMeshLoadedObservable: Observable<AbstractMesh>;
  49383. /**
  49384. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49385. */
  49386. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49387. /**
  49388. * Pointer which can be used to select objects or attach a visible laser to
  49389. */
  49390. pointer: AbstractMesh;
  49391. /**
  49392. * Creates the controller
  49393. * @see https://doc.babylonjs.com/how_to/webxr
  49394. * @param _scene the scene which the controller should be associated to
  49395. * @param inputSource the underlying input source for the controller
  49396. * @param _options options for this controller creation
  49397. */
  49398. constructor(_scene: Scene,
  49399. /** The underlying input source for the controller */
  49400. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49401. /**
  49402. * Get this controllers unique id
  49403. */
  49404. get uniqueId(): string;
  49405. /**
  49406. * Disposes of the object
  49407. */
  49408. dispose(): void;
  49409. /**
  49410. * Gets a world space ray coming from the pointer or grip
  49411. * @param result the resulting ray
  49412. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49413. */
  49414. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49415. /**
  49416. * Updates the controller pose based on the given XRFrame
  49417. * @param xrFrame xr frame to update the pose with
  49418. * @param referenceSpace reference space to use
  49419. */
  49420. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49421. }
  49422. }
  49423. declare module "babylonjs/XR/webXRInput" {
  49424. import { Observable } from "babylonjs/Misc/observable";
  49425. import { IDisposable } from "babylonjs/scene";
  49426. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49427. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49428. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49429. /**
  49430. * The schema for initialization options of the XR Input class
  49431. */
  49432. export interface IWebXRInputOptions {
  49433. /**
  49434. * If set to true no model will be automatically loaded
  49435. */
  49436. doNotLoadControllerMeshes?: boolean;
  49437. /**
  49438. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49439. * If not found, the xr input profile data will be used.
  49440. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49441. */
  49442. forceInputProfile?: string;
  49443. /**
  49444. * Do not send a request to the controller repository to load the profile.
  49445. *
  49446. * Instead, use the controllers available in babylon itself.
  49447. */
  49448. disableOnlineControllerRepository?: boolean;
  49449. /**
  49450. * A custom URL for the controllers repository
  49451. */
  49452. customControllersRepositoryURL?: string;
  49453. /**
  49454. * Should the controller model's components not move according to the user input
  49455. */
  49456. disableControllerAnimation?: boolean;
  49457. /**
  49458. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49459. */
  49460. controllerOptions?: IWebXRControllerOptions;
  49461. }
  49462. /**
  49463. * XR input used to track XR inputs such as controllers/rays
  49464. */
  49465. export class WebXRInput implements IDisposable {
  49466. /**
  49467. * the xr session manager for this session
  49468. */
  49469. xrSessionManager: WebXRSessionManager;
  49470. /**
  49471. * the WebXR camera for this session. Mainly used for teleportation
  49472. */
  49473. xrCamera: WebXRCamera;
  49474. private readonly options;
  49475. /**
  49476. * XR controllers being tracked
  49477. */
  49478. controllers: Array<WebXRInputSource>;
  49479. private _frameObserver;
  49480. private _sessionEndedObserver;
  49481. private _sessionInitObserver;
  49482. /**
  49483. * Event when a controller has been connected/added
  49484. */
  49485. onControllerAddedObservable: Observable<WebXRInputSource>;
  49486. /**
  49487. * Event when a controller has been removed/disconnected
  49488. */
  49489. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49490. /**
  49491. * Initializes the WebXRInput
  49492. * @param xrSessionManager the xr session manager for this session
  49493. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49494. * @param options = initialization options for this xr input
  49495. */
  49496. constructor(
  49497. /**
  49498. * the xr session manager for this session
  49499. */
  49500. xrSessionManager: WebXRSessionManager,
  49501. /**
  49502. * the WebXR camera for this session. Mainly used for teleportation
  49503. */
  49504. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49505. private _onInputSourcesChange;
  49506. private _addAndRemoveControllers;
  49507. /**
  49508. * Disposes of the object
  49509. */
  49510. dispose(): void;
  49511. }
  49512. }
  49513. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49514. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49515. import { Observable, EventState } from "babylonjs/Misc/observable";
  49516. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49517. /**
  49518. * This is the base class for all WebXR features.
  49519. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49520. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49521. */
  49522. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49523. protected _xrSessionManager: WebXRSessionManager;
  49524. private _attached;
  49525. private _removeOnDetach;
  49526. /**
  49527. * Should auto-attach be disabled?
  49528. */
  49529. disableAutoAttach: boolean;
  49530. /**
  49531. * Construct a new (abstract) WebXR feature
  49532. * @param _xrSessionManager the xr session manager for this feature
  49533. */
  49534. constructor(_xrSessionManager: WebXRSessionManager);
  49535. /**
  49536. * Is this feature attached
  49537. */
  49538. get attached(): boolean;
  49539. /**
  49540. * attach this feature
  49541. *
  49542. * @param force should attachment be forced (even when already attached)
  49543. * @returns true if successful, false is failed or already attached
  49544. */
  49545. attach(force?: boolean): boolean;
  49546. /**
  49547. * detach this feature.
  49548. *
  49549. * @returns true if successful, false if failed or already detached
  49550. */
  49551. detach(): boolean;
  49552. /**
  49553. * Dispose this feature and all of the resources attached
  49554. */
  49555. dispose(): void;
  49556. /**
  49557. * This is used to register callbacks that will automatically be removed when detach is called.
  49558. * @param observable the observable to which the observer will be attached
  49559. * @param callback the callback to register
  49560. */
  49561. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49562. /**
  49563. * Code in this function will be executed on each xrFrame received from the browser.
  49564. * This function will not execute after the feature is detached.
  49565. * @param _xrFrame the current frame
  49566. */
  49567. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49568. }
  49569. }
  49570. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49571. import { IDisposable, Scene } from "babylonjs/scene";
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Observable } from "babylonjs/Misc/observable";
  49574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49575. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49576. import { Camera } from "babylonjs/Cameras/camera";
  49577. /**
  49578. * Renders a layer on top of an existing scene
  49579. */
  49580. export class UtilityLayerRenderer implements IDisposable {
  49581. /** the original scene that will be rendered on top of */
  49582. originalScene: Scene;
  49583. private _pointerCaptures;
  49584. private _lastPointerEvents;
  49585. private static _DefaultUtilityLayer;
  49586. private static _DefaultKeepDepthUtilityLayer;
  49587. private _sharedGizmoLight;
  49588. private _renderCamera;
  49589. /**
  49590. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49591. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49592. * @returns the camera that is used when rendering the utility layer
  49593. */
  49594. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49595. /**
  49596. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49597. * @param cam the camera that should be used when rendering the utility layer
  49598. */
  49599. setRenderCamera(cam: Nullable<Camera>): void;
  49600. /**
  49601. * @hidden
  49602. * Light which used by gizmos to get light shading
  49603. */
  49604. _getSharedGizmoLight(): HemisphericLight;
  49605. /**
  49606. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49607. */
  49608. pickUtilitySceneFirst: boolean;
  49609. /**
  49610. * 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)
  49611. */
  49612. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49613. /**
  49614. * 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)
  49615. */
  49616. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49617. /**
  49618. * The scene that is rendered on top of the original scene
  49619. */
  49620. utilityLayerScene: Scene;
  49621. /**
  49622. * If the utility layer should automatically be rendered on top of existing scene
  49623. */
  49624. shouldRender: boolean;
  49625. /**
  49626. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49627. */
  49628. onlyCheckPointerDownEvents: boolean;
  49629. /**
  49630. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49631. */
  49632. processAllEvents: boolean;
  49633. /**
  49634. * Observable raised when the pointer move from the utility layer scene to the main scene
  49635. */
  49636. onPointerOutObservable: Observable<number>;
  49637. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49638. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49639. private _afterRenderObserver;
  49640. private _sceneDisposeObserver;
  49641. private _originalPointerObserver;
  49642. /**
  49643. * Instantiates a UtilityLayerRenderer
  49644. * @param originalScene the original scene that will be rendered on top of
  49645. * @param handleEvents boolean indicating if the utility layer should handle events
  49646. */
  49647. constructor(
  49648. /** the original scene that will be rendered on top of */
  49649. originalScene: Scene, handleEvents?: boolean);
  49650. private _notifyObservers;
  49651. /**
  49652. * Renders the utility layers scene on top of the original scene
  49653. */
  49654. render(): void;
  49655. /**
  49656. * Disposes of the renderer
  49657. */
  49658. dispose(): void;
  49659. private _updateCamera;
  49660. }
  49661. }
  49662. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49663. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49665. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49666. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49667. import { Scene } from "babylonjs/scene";
  49668. import { Nullable } from "babylonjs/types";
  49669. import { Color3 } from "babylonjs/Maths/math.color";
  49670. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49671. /**
  49672. * Options interface for the pointer selection module
  49673. */
  49674. export interface IWebXRControllerPointerSelectionOptions {
  49675. /**
  49676. * if provided, this scene will be used to render meshes.
  49677. */
  49678. customUtilityLayerScene?: Scene;
  49679. /**
  49680. * 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)
  49681. * If not disabled, the last picked point will be used to execute a pointer up event
  49682. * If disabled, pointer up event will be triggered right after the pointer down event.
  49683. * Used in screen and gaze target ray mode only
  49684. */
  49685. disablePointerUpOnTouchOut: boolean;
  49686. /**
  49687. * For gaze mode (time to select instead of press)
  49688. */
  49689. forceGazeMode: boolean;
  49690. /**
  49691. * 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
  49692. * to start a new countdown to the pointer down event.
  49693. * Defaults to 1.
  49694. */
  49695. gazeModePointerMovedFactor?: number;
  49696. /**
  49697. * Different button type to use instead of the main component
  49698. */
  49699. overrideButtonId?: string;
  49700. /**
  49701. * use this rendering group id for the meshes (optional)
  49702. */
  49703. renderingGroupId?: number;
  49704. /**
  49705. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49706. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49707. * 3000 means 3 seconds between pointing at something and selecting it
  49708. */
  49709. timeToSelect?: number;
  49710. /**
  49711. * Should meshes created here be added to a utility layer or the main scene
  49712. */
  49713. useUtilityLayer?: boolean;
  49714. /**
  49715. * the xr input to use with this pointer selection
  49716. */
  49717. xrInput: WebXRInput;
  49718. }
  49719. /**
  49720. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49721. */
  49722. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49723. private readonly _options;
  49724. private static _idCounter;
  49725. private _attachController;
  49726. private _controllers;
  49727. private _scene;
  49728. private _tmpVectorForPickCompare;
  49729. /**
  49730. * The module's name
  49731. */
  49732. static readonly Name: string;
  49733. /**
  49734. * The (Babylon) version of this module.
  49735. * This is an integer representing the implementation version.
  49736. * This number does not correspond to the WebXR specs version
  49737. */
  49738. static readonly Version: number;
  49739. /**
  49740. * Disable lighting on the laser pointer (so it will always be visible)
  49741. */
  49742. disablePointerLighting: boolean;
  49743. /**
  49744. * Disable lighting on the selection mesh (so it will always be visible)
  49745. */
  49746. disableSelectionMeshLighting: boolean;
  49747. /**
  49748. * Should the laser pointer be displayed
  49749. */
  49750. displayLaserPointer: boolean;
  49751. /**
  49752. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49753. */
  49754. displaySelectionMesh: boolean;
  49755. /**
  49756. * This color will be set to the laser pointer when selection is triggered
  49757. */
  49758. laserPointerPickedColor: Color3;
  49759. /**
  49760. * Default color of the laser pointer
  49761. */
  49762. laserPointerDefaultColor: Color3;
  49763. /**
  49764. * default color of the selection ring
  49765. */
  49766. selectionMeshDefaultColor: Color3;
  49767. /**
  49768. * This color will be applied to the selection ring when selection is triggered
  49769. */
  49770. selectionMeshPickedColor: Color3;
  49771. /**
  49772. * Optional filter to be used for ray selection. This predicate shares behavior with
  49773. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49774. */
  49775. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49776. /**
  49777. * constructs a new background remover module
  49778. * @param _xrSessionManager the session manager for this module
  49779. * @param _options read-only options to be used in this module
  49780. */
  49781. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49782. /**
  49783. * attach this feature
  49784. * Will usually be called by the features manager
  49785. *
  49786. * @returns true if successful.
  49787. */
  49788. attach(): boolean;
  49789. /**
  49790. * detach this feature.
  49791. * Will usually be called by the features manager
  49792. *
  49793. * @returns true if successful.
  49794. */
  49795. detach(): boolean;
  49796. /**
  49797. * Will get the mesh under a specific pointer.
  49798. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49799. * @param controllerId the controllerId to check
  49800. * @returns The mesh under pointer or null if no mesh is under the pointer
  49801. */
  49802. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49803. /**
  49804. * Get the xr controller that correlates to the pointer id in the pointer event
  49805. *
  49806. * @param id the pointer id to search for
  49807. * @returns the controller that correlates to this id or null if not found
  49808. */
  49809. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49810. protected _onXRFrame(_xrFrame: XRFrame): void;
  49811. private _attachGazeMode;
  49812. private _attachScreenRayMode;
  49813. private _attachTrackedPointerRayMode;
  49814. private _convertNormalToDirectionOfRay;
  49815. private _detachController;
  49816. private _generateNewMeshPair;
  49817. private _pickingMoved;
  49818. private _updatePointerDistance;
  49819. /** @hidden */
  49820. get lasterPointerDefaultColor(): Color3;
  49821. }
  49822. }
  49823. declare module "babylonjs/XR/webXREnterExitUI" {
  49824. import { Nullable } from "babylonjs/types";
  49825. import { Observable } from "babylonjs/Misc/observable";
  49826. import { IDisposable, Scene } from "babylonjs/scene";
  49827. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49828. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49829. /**
  49830. * Button which can be used to enter a different mode of XR
  49831. */
  49832. export class WebXREnterExitUIButton {
  49833. /** button element */
  49834. element: HTMLElement;
  49835. /** XR initialization options for the button */
  49836. sessionMode: XRSessionMode;
  49837. /** Reference space type */
  49838. referenceSpaceType: XRReferenceSpaceType;
  49839. /**
  49840. * Creates a WebXREnterExitUIButton
  49841. * @param element button element
  49842. * @param sessionMode XR initialization session mode
  49843. * @param referenceSpaceType the type of reference space to be used
  49844. */
  49845. constructor(
  49846. /** button element */
  49847. element: HTMLElement,
  49848. /** XR initialization options for the button */
  49849. sessionMode: XRSessionMode,
  49850. /** Reference space type */
  49851. referenceSpaceType: XRReferenceSpaceType);
  49852. /**
  49853. * Extendable function which can be used to update the button's visuals when the state changes
  49854. * @param activeButton the current active button in the UI
  49855. */
  49856. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49857. }
  49858. /**
  49859. * Options to create the webXR UI
  49860. */
  49861. export class WebXREnterExitUIOptions {
  49862. /**
  49863. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49864. */
  49865. customButtons?: Array<WebXREnterExitUIButton>;
  49866. /**
  49867. * A reference space type to use when creating the default button.
  49868. * Default is local-floor
  49869. */
  49870. referenceSpaceType?: XRReferenceSpaceType;
  49871. /**
  49872. * Context to enter xr with
  49873. */
  49874. renderTarget?: Nullable<WebXRRenderTarget>;
  49875. /**
  49876. * A session mode to use when creating the default button.
  49877. * Default is immersive-vr
  49878. */
  49879. sessionMode?: XRSessionMode;
  49880. /**
  49881. * A list of optional features to init the session with
  49882. */
  49883. optionalFeatures?: string[];
  49884. }
  49885. /**
  49886. * UI to allow the user to enter/exit XR mode
  49887. */
  49888. export class WebXREnterExitUI implements IDisposable {
  49889. private scene;
  49890. /** version of the options passed to this UI */
  49891. options: WebXREnterExitUIOptions;
  49892. private _activeButton;
  49893. private _buttons;
  49894. private _overlay;
  49895. /**
  49896. * Fired every time the active button is changed.
  49897. *
  49898. * When xr is entered via a button that launches xr that button will be the callback parameter
  49899. *
  49900. * When exiting xr the callback parameter will be null)
  49901. */
  49902. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49903. /**
  49904. *
  49905. * @param scene babylon scene object to use
  49906. * @param options (read-only) version of the options passed to this UI
  49907. */
  49908. private constructor();
  49909. /**
  49910. * Creates UI to allow the user to enter/exit XR mode
  49911. * @param scene the scene to add the ui to
  49912. * @param helper the xr experience helper to enter/exit xr with
  49913. * @param options options to configure the UI
  49914. * @returns the created ui
  49915. */
  49916. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49917. /**
  49918. * Disposes of the XR UI component
  49919. */
  49920. dispose(): void;
  49921. private _updateButtons;
  49922. }
  49923. }
  49924. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49925. import { Vector3 } from "babylonjs/Maths/math.vector";
  49926. import { Color4 } from "babylonjs/Maths/math.color";
  49927. import { Nullable } from "babylonjs/types";
  49928. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49929. import { Scene } from "babylonjs/scene";
  49930. /**
  49931. * Class containing static functions to help procedurally build meshes
  49932. */
  49933. export class LinesBuilder {
  49934. /**
  49935. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49936. * * 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
  49937. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49938. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49939. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49940. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49941. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49942. * * 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
  49943. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49946. * @param name defines the name of the new line system
  49947. * @param options defines the options used to create the line system
  49948. * @param scene defines the hosting scene
  49949. * @returns a new line system mesh
  49950. */
  49951. static CreateLineSystem(name: string, options: {
  49952. lines: Vector3[][];
  49953. updatable?: boolean;
  49954. instance?: Nullable<LinesMesh>;
  49955. colors?: Nullable<Color4[][]>;
  49956. useVertexAlpha?: boolean;
  49957. }, scene: Nullable<Scene>): LinesMesh;
  49958. /**
  49959. * Creates a line mesh
  49960. * 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
  49961. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49962. * * The parameter `points` is an array successive Vector3
  49963. * * 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
  49964. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49965. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49966. * * When updating an instance, remember that only point positions can change, not the number of points
  49967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49969. * @param name defines the name of the new line system
  49970. * @param options defines the options used to create the line system
  49971. * @param scene defines the hosting scene
  49972. * @returns a new line mesh
  49973. */
  49974. static CreateLines(name: string, options: {
  49975. points: Vector3[];
  49976. updatable?: boolean;
  49977. instance?: Nullable<LinesMesh>;
  49978. colors?: Color4[];
  49979. useVertexAlpha?: boolean;
  49980. }, scene?: Nullable<Scene>): LinesMesh;
  49981. /**
  49982. * Creates a dashed line mesh
  49983. * * 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
  49984. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49985. * * The parameter `points` is an array successive Vector3
  49986. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49987. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49988. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49989. * * 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
  49990. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49991. * * When updating an instance, remember that only point positions can change, not the number of points
  49992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49993. * @param name defines the name of the mesh
  49994. * @param options defines the options used to create the mesh
  49995. * @param scene defines the hosting scene
  49996. * @returns the dashed line mesh
  49997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49998. */
  49999. static CreateDashedLines(name: string, options: {
  50000. points: Vector3[];
  50001. dashSize?: number;
  50002. gapSize?: number;
  50003. dashNb?: number;
  50004. updatable?: boolean;
  50005. instance?: LinesMesh;
  50006. useVertexAlpha?: boolean;
  50007. }, scene?: Nullable<Scene>): LinesMesh;
  50008. }
  50009. }
  50010. declare module "babylonjs/Misc/timer" {
  50011. import { Observable, Observer } from "babylonjs/Misc/observable";
  50012. import { Nullable } from "babylonjs/types";
  50013. import { IDisposable } from "babylonjs/scene";
  50014. /**
  50015. * Construction options for a timer
  50016. */
  50017. export interface ITimerOptions<T> {
  50018. /**
  50019. * Time-to-end
  50020. */
  50021. timeout: number;
  50022. /**
  50023. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50024. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50025. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50026. */
  50027. contextObservable: Observable<T>;
  50028. /**
  50029. * Optional parameters when adding an observer to the observable
  50030. */
  50031. observableParameters?: {
  50032. mask?: number;
  50033. insertFirst?: boolean;
  50034. scope?: any;
  50035. };
  50036. /**
  50037. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50038. */
  50039. breakCondition?: (data?: ITimerData<T>) => boolean;
  50040. /**
  50041. * Will be triggered when the time condition has met
  50042. */
  50043. onEnded?: (data: ITimerData<any>) => void;
  50044. /**
  50045. * Will be triggered when the break condition has met (prematurely ended)
  50046. */
  50047. onAborted?: (data: ITimerData<any>) => void;
  50048. /**
  50049. * Optional function to execute on each tick (or count)
  50050. */
  50051. onTick?: (data: ITimerData<any>) => void;
  50052. }
  50053. /**
  50054. * An interface defining the data sent by the timer
  50055. */
  50056. export interface ITimerData<T> {
  50057. /**
  50058. * When did it start
  50059. */
  50060. startTime: number;
  50061. /**
  50062. * Time now
  50063. */
  50064. currentTime: number;
  50065. /**
  50066. * Time passed since started
  50067. */
  50068. deltaTime: number;
  50069. /**
  50070. * How much is completed, in [0.0...1.0].
  50071. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50072. */
  50073. completeRate: number;
  50074. /**
  50075. * What the registered observable sent in the last count
  50076. */
  50077. payload: T;
  50078. }
  50079. /**
  50080. * The current state of the timer
  50081. */
  50082. export enum TimerState {
  50083. /**
  50084. * Timer initialized, not yet started
  50085. */
  50086. INIT = 0,
  50087. /**
  50088. * Timer started and counting
  50089. */
  50090. STARTED = 1,
  50091. /**
  50092. * Timer ended (whether aborted or time reached)
  50093. */
  50094. ENDED = 2
  50095. }
  50096. /**
  50097. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50098. *
  50099. * @param options options with which to initialize this timer
  50100. */
  50101. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50102. /**
  50103. * An advanced implementation of a timer class
  50104. */
  50105. export class AdvancedTimer<T = any> implements IDisposable {
  50106. /**
  50107. * Will notify each time the timer calculates the remaining time
  50108. */
  50109. onEachCountObservable: Observable<ITimerData<T>>;
  50110. /**
  50111. * Will trigger when the timer was aborted due to the break condition
  50112. */
  50113. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50114. /**
  50115. * Will trigger when the timer ended successfully
  50116. */
  50117. onTimerEndedObservable: Observable<ITimerData<T>>;
  50118. /**
  50119. * Will trigger when the timer state has changed
  50120. */
  50121. onStateChangedObservable: Observable<TimerState>;
  50122. private _observer;
  50123. private _contextObservable;
  50124. private _observableParameters;
  50125. private _startTime;
  50126. private _timer;
  50127. private _state;
  50128. private _breakCondition;
  50129. private _timeToEnd;
  50130. private _breakOnNextTick;
  50131. /**
  50132. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50133. * @param options construction options for this advanced timer
  50134. */
  50135. constructor(options: ITimerOptions<T>);
  50136. /**
  50137. * set a breaking condition for this timer. Default is to never break during count
  50138. * @param predicate the new break condition. Returns true to break, false otherwise
  50139. */
  50140. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50141. /**
  50142. * Reset ALL associated observables in this advanced timer
  50143. */
  50144. clearObservables(): void;
  50145. /**
  50146. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50147. *
  50148. * @param timeToEnd how much time to measure until timer ended
  50149. */
  50150. start(timeToEnd?: number): void;
  50151. /**
  50152. * Will force a stop on the next tick.
  50153. */
  50154. stop(): void;
  50155. /**
  50156. * Dispose this timer, clearing all resources
  50157. */
  50158. dispose(): void;
  50159. private _setState;
  50160. private _tick;
  50161. private _stop;
  50162. }
  50163. }
  50164. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50165. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50166. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50167. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50169. import { Vector3 } from "babylonjs/Maths/math.vector";
  50170. import { Material } from "babylonjs/Materials/material";
  50171. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50172. import { Scene } from "babylonjs/scene";
  50173. /**
  50174. * The options container for the teleportation module
  50175. */
  50176. export interface IWebXRTeleportationOptions {
  50177. /**
  50178. * if provided, this scene will be used to render meshes.
  50179. */
  50180. customUtilityLayerScene?: Scene;
  50181. /**
  50182. * Values to configure the default target mesh
  50183. */
  50184. defaultTargetMeshOptions?: {
  50185. /**
  50186. * Fill color of the teleportation area
  50187. */
  50188. teleportationFillColor?: string;
  50189. /**
  50190. * Border color for the teleportation area
  50191. */
  50192. teleportationBorderColor?: string;
  50193. /**
  50194. * Disable the mesh's animation sequence
  50195. */
  50196. disableAnimation?: boolean;
  50197. /**
  50198. * Disable lighting on the material or the ring and arrow
  50199. */
  50200. disableLighting?: boolean;
  50201. /**
  50202. * Override the default material of the torus and arrow
  50203. */
  50204. torusArrowMaterial?: Material;
  50205. };
  50206. /**
  50207. * A list of meshes to use as floor meshes.
  50208. * Meshes can be added and removed after initializing the feature using the
  50209. * addFloorMesh and removeFloorMesh functions
  50210. * If empty, rotation will still work
  50211. */
  50212. floorMeshes?: AbstractMesh[];
  50213. /**
  50214. * use this rendering group id for the meshes (optional)
  50215. */
  50216. renderingGroupId?: number;
  50217. /**
  50218. * Should teleportation move only to snap points
  50219. */
  50220. snapPointsOnly?: boolean;
  50221. /**
  50222. * An array of points to which the teleportation will snap to.
  50223. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50224. */
  50225. snapPositions?: Vector3[];
  50226. /**
  50227. * How close should the teleportation ray be in order to snap to position.
  50228. * Default to 0.8 units (meters)
  50229. */
  50230. snapToPositionRadius?: number;
  50231. /**
  50232. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50233. * If you want to support rotation, make sure your mesh has a direction indicator.
  50234. *
  50235. * When left untouched, the default mesh will be initialized.
  50236. */
  50237. teleportationTargetMesh?: AbstractMesh;
  50238. /**
  50239. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50240. */
  50241. timeToTeleport?: number;
  50242. /**
  50243. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50244. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50245. */
  50246. useMainComponentOnly?: boolean;
  50247. /**
  50248. * Should meshes created here be added to a utility layer or the main scene
  50249. */
  50250. useUtilityLayer?: boolean;
  50251. /**
  50252. * Babylon XR Input class for controller
  50253. */
  50254. xrInput: WebXRInput;
  50255. }
  50256. /**
  50257. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50258. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50259. * the input of the attached controllers.
  50260. */
  50261. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50262. private _options;
  50263. private _controllers;
  50264. private _currentTeleportationControllerId;
  50265. private _floorMeshes;
  50266. private _quadraticBezierCurve;
  50267. private _selectionFeature;
  50268. private _snapToPositions;
  50269. private _snappedToPoint;
  50270. private _teleportationRingMaterial?;
  50271. private _tmpRay;
  50272. private _tmpVector;
  50273. /**
  50274. * The module's name
  50275. */
  50276. static readonly Name: string;
  50277. /**
  50278. * The (Babylon) version of this module.
  50279. * This is an integer representing the implementation version.
  50280. * This number does not correspond to the webxr specs version
  50281. */
  50282. static readonly Version: number;
  50283. /**
  50284. * Is movement backwards enabled
  50285. */
  50286. backwardsMovementEnabled: boolean;
  50287. /**
  50288. * Distance to travel when moving backwards
  50289. */
  50290. backwardsTeleportationDistance: number;
  50291. /**
  50292. * The distance from the user to the inspection point in the direction of the controller
  50293. * A higher number will allow the user to move further
  50294. * defaults to 5 (meters, in xr units)
  50295. */
  50296. parabolicCheckRadius: number;
  50297. /**
  50298. * Should the module support parabolic ray on top of direct ray
  50299. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50300. * Very helpful when moving between floors / different heights
  50301. */
  50302. parabolicRayEnabled: boolean;
  50303. /**
  50304. * How much rotation should be applied when rotating right and left
  50305. */
  50306. rotationAngle: number;
  50307. /**
  50308. * Is rotation enabled when moving forward?
  50309. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50310. */
  50311. rotationEnabled: boolean;
  50312. /**
  50313. * constructs a new anchor system
  50314. * @param _xrSessionManager an instance of WebXRSessionManager
  50315. * @param _options configuration object for this feature
  50316. */
  50317. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50318. /**
  50319. * Get the snapPointsOnly flag
  50320. */
  50321. get snapPointsOnly(): boolean;
  50322. /**
  50323. * Sets the snapPointsOnly flag
  50324. * @param snapToPoints should teleportation be exclusively to snap points
  50325. */
  50326. set snapPointsOnly(snapToPoints: boolean);
  50327. /**
  50328. * Add a new mesh to the floor meshes array
  50329. * @param mesh the mesh to use as floor mesh
  50330. */
  50331. addFloorMesh(mesh: AbstractMesh): void;
  50332. /**
  50333. * Add a new snap-to point to fix teleportation to this position
  50334. * @param newSnapPoint The new Snap-To point
  50335. */
  50336. addSnapPoint(newSnapPoint: Vector3): void;
  50337. attach(): boolean;
  50338. detach(): boolean;
  50339. dispose(): void;
  50340. /**
  50341. * Remove a mesh from the floor meshes array
  50342. * @param mesh the mesh to remove
  50343. */
  50344. removeFloorMesh(mesh: AbstractMesh): void;
  50345. /**
  50346. * Remove a mesh from the floor meshes array using its name
  50347. * @param name the mesh name to remove
  50348. */
  50349. removeFloorMeshByName(name: string): void;
  50350. /**
  50351. * 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
  50352. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50353. * @returns was the point found and removed or not
  50354. */
  50355. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50356. /**
  50357. * This function sets a selection feature that will be disabled when
  50358. * the forward ray is shown and will be reattached when hidden.
  50359. * This is used to remove the selection rays when moving.
  50360. * @param selectionFeature the feature to disable when forward movement is enabled
  50361. */
  50362. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50363. protected _onXRFrame(_xrFrame: XRFrame): void;
  50364. private _attachController;
  50365. private _createDefaultTargetMesh;
  50366. private _detachController;
  50367. private _findClosestSnapPointWithRadius;
  50368. private _setTargetMeshPosition;
  50369. private _setTargetMeshVisibility;
  50370. private _showParabolicPath;
  50371. private _teleportForward;
  50372. }
  50373. }
  50374. declare module "babylonjs/XR/webXRDefaultExperience" {
  50375. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50376. import { Scene } from "babylonjs/scene";
  50377. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50378. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50379. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50380. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50382. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50383. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50384. /**
  50385. * Options for the default xr helper
  50386. */
  50387. export class WebXRDefaultExperienceOptions {
  50388. /**
  50389. * Enable or disable default UI to enter XR
  50390. */
  50391. disableDefaultUI?: boolean;
  50392. /**
  50393. * Should teleportation not initialize. defaults to false.
  50394. */
  50395. disableTeleportation?: boolean;
  50396. /**
  50397. * Floor meshes that will be used for teleport
  50398. */
  50399. floorMeshes?: Array<AbstractMesh>;
  50400. /**
  50401. * If set to true, the first frame will not be used to reset position
  50402. * The first frame is mainly used when copying transformation from the old camera
  50403. * Mainly used in AR
  50404. */
  50405. ignoreNativeCameraTransformation?: boolean;
  50406. /**
  50407. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50408. */
  50409. inputOptions?: IWebXRInputOptions;
  50410. /**
  50411. * optional configuration for the output canvas
  50412. */
  50413. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50414. /**
  50415. * optional UI options. This can be used among other to change session mode and reference space type
  50416. */
  50417. uiOptions?: WebXREnterExitUIOptions;
  50418. /**
  50419. * When loading teleportation and pointer select, use stable versions instead of latest.
  50420. */
  50421. useStablePlugins?: boolean;
  50422. /**
  50423. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50424. */
  50425. renderingGroupId?: number;
  50426. /**
  50427. * A list of optional features to init the session with
  50428. * If set to true, all features we support will be added
  50429. */
  50430. optionalFeatures?: boolean | string[];
  50431. }
  50432. /**
  50433. * Default experience which provides a similar setup to the previous webVRExperience
  50434. */
  50435. export class WebXRDefaultExperience {
  50436. /**
  50437. * Base experience
  50438. */
  50439. baseExperience: WebXRExperienceHelper;
  50440. /**
  50441. * Enables ui for entering/exiting xr
  50442. */
  50443. enterExitUI: WebXREnterExitUI;
  50444. /**
  50445. * Input experience extension
  50446. */
  50447. input: WebXRInput;
  50448. /**
  50449. * Enables laser pointer and selection
  50450. */
  50451. pointerSelection: WebXRControllerPointerSelection;
  50452. /**
  50453. * Default target xr should render to
  50454. */
  50455. renderTarget: WebXRRenderTarget;
  50456. /**
  50457. * Enables teleportation
  50458. */
  50459. teleportation: WebXRMotionControllerTeleportation;
  50460. private constructor();
  50461. /**
  50462. * Creates the default xr experience
  50463. * @param scene scene
  50464. * @param options options for basic configuration
  50465. * @returns resulting WebXRDefaultExperience
  50466. */
  50467. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50468. /**
  50469. * DIsposes of the experience helper
  50470. */
  50471. dispose(): void;
  50472. }
  50473. }
  50474. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50475. import { Observable } from "babylonjs/Misc/observable";
  50476. import { Nullable } from "babylonjs/types";
  50477. import { Camera } from "babylonjs/Cameras/camera";
  50478. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50479. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50480. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50481. import { Scene } from "babylonjs/scene";
  50482. import { Vector3 } from "babylonjs/Maths/math.vector";
  50483. import { Color3 } from "babylonjs/Maths/math.color";
  50484. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50486. import { Mesh } from "babylonjs/Meshes/mesh";
  50487. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50488. import { EasingFunction } from "babylonjs/Animations/easing";
  50489. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50490. import "babylonjs/Meshes/Builders/groundBuilder";
  50491. import "babylonjs/Meshes/Builders/torusBuilder";
  50492. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50493. import "babylonjs/Gamepads/gamepadSceneComponent";
  50494. import "babylonjs/Animations/animatable";
  50495. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50496. /**
  50497. * Options to modify the vr teleportation behavior.
  50498. */
  50499. export interface VRTeleportationOptions {
  50500. /**
  50501. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50502. */
  50503. floorMeshName?: string;
  50504. /**
  50505. * A list of meshes to be used as the teleportation floor. (default: empty)
  50506. */
  50507. floorMeshes?: Mesh[];
  50508. /**
  50509. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50510. */
  50511. teleportationMode?: number;
  50512. /**
  50513. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50514. */
  50515. teleportationTime?: number;
  50516. /**
  50517. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50518. */
  50519. teleportationSpeed?: number;
  50520. /**
  50521. * The easing function used in the animation or null for Linear. (default CircleEase)
  50522. */
  50523. easingFunction?: EasingFunction;
  50524. }
  50525. /**
  50526. * Options to modify the vr experience helper's behavior.
  50527. */
  50528. export interface VRExperienceHelperOptions extends WebVROptions {
  50529. /**
  50530. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50531. */
  50532. createDeviceOrientationCamera?: boolean;
  50533. /**
  50534. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50535. */
  50536. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50537. /**
  50538. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50539. */
  50540. laserToggle?: boolean;
  50541. /**
  50542. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50543. */
  50544. floorMeshes?: Mesh[];
  50545. /**
  50546. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50547. */
  50548. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50549. /**
  50550. * Defines if WebXR should be used instead of WebVR (if available)
  50551. */
  50552. useXR?: boolean;
  50553. }
  50554. /**
  50555. * Event containing information after VR has been entered
  50556. */
  50557. export class OnAfterEnteringVRObservableEvent {
  50558. /**
  50559. * If entering vr was successful
  50560. */
  50561. success: boolean;
  50562. }
  50563. /**
  50564. * Helps to quickly add VR support to an existing scene.
  50565. * See http://doc.babylonjs.com/how_to/webvr_helper
  50566. */
  50567. export class VRExperienceHelper {
  50568. /** Options to modify the vr experience helper's behavior. */
  50569. webVROptions: VRExperienceHelperOptions;
  50570. private _scene;
  50571. private _position;
  50572. private _btnVR;
  50573. private _btnVRDisplayed;
  50574. private _webVRsupported;
  50575. private _webVRready;
  50576. private _webVRrequesting;
  50577. private _webVRpresenting;
  50578. private _hasEnteredVR;
  50579. private _fullscreenVRpresenting;
  50580. private _inputElement;
  50581. private _webVRCamera;
  50582. private _vrDeviceOrientationCamera;
  50583. private _deviceOrientationCamera;
  50584. private _existingCamera;
  50585. private _onKeyDown;
  50586. private _onVrDisplayPresentChange;
  50587. private _onVRDisplayChanged;
  50588. private _onVRRequestPresentStart;
  50589. private _onVRRequestPresentComplete;
  50590. /**
  50591. * 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)
  50592. */
  50593. enableGazeEvenWhenNoPointerLock: boolean;
  50594. /**
  50595. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50596. */
  50597. exitVROnDoubleTap: boolean;
  50598. /**
  50599. * Observable raised right before entering VR.
  50600. */
  50601. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50602. /**
  50603. * Observable raised when entering VR has completed.
  50604. */
  50605. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50606. /**
  50607. * Observable raised when exiting VR.
  50608. */
  50609. onExitingVRObservable: Observable<VRExperienceHelper>;
  50610. /**
  50611. * Observable raised when controller mesh is loaded.
  50612. */
  50613. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50614. /** Return this.onEnteringVRObservable
  50615. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50616. */
  50617. get onEnteringVR(): Observable<VRExperienceHelper>;
  50618. /** Return this.onExitingVRObservable
  50619. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50620. */
  50621. get onExitingVR(): Observable<VRExperienceHelper>;
  50622. /** Return this.onControllerMeshLoadedObservable
  50623. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50624. */
  50625. get onControllerMeshLoaded(): Observable<WebVRController>;
  50626. private _rayLength;
  50627. private _useCustomVRButton;
  50628. private _teleportationRequested;
  50629. private _teleportActive;
  50630. private _floorMeshName;
  50631. private _floorMeshesCollection;
  50632. private _teleportationMode;
  50633. private _teleportationTime;
  50634. private _teleportationSpeed;
  50635. private _teleportationEasing;
  50636. private _rotationAllowed;
  50637. private _teleportBackwardsVector;
  50638. private _teleportationTarget;
  50639. private _isDefaultTeleportationTarget;
  50640. private _postProcessMove;
  50641. private _teleportationFillColor;
  50642. private _teleportationBorderColor;
  50643. private _rotationAngle;
  50644. private _haloCenter;
  50645. private _cameraGazer;
  50646. private _padSensibilityUp;
  50647. private _padSensibilityDown;
  50648. private _leftController;
  50649. private _rightController;
  50650. private _gazeColor;
  50651. private _laserColor;
  50652. private _pickedLaserColor;
  50653. private _pickedGazeColor;
  50654. /**
  50655. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50656. */
  50657. onNewMeshSelected: Observable<AbstractMesh>;
  50658. /**
  50659. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50660. * This observable will provide the mesh and the controller used to select the mesh
  50661. */
  50662. onMeshSelectedWithController: Observable<{
  50663. mesh: AbstractMesh;
  50664. controller: WebVRController;
  50665. }>;
  50666. /**
  50667. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50668. */
  50669. onNewMeshPicked: Observable<PickingInfo>;
  50670. private _circleEase;
  50671. /**
  50672. * Observable raised before camera teleportation
  50673. */
  50674. onBeforeCameraTeleport: Observable<Vector3>;
  50675. /**
  50676. * Observable raised after camera teleportation
  50677. */
  50678. onAfterCameraTeleport: Observable<Vector3>;
  50679. /**
  50680. * Observable raised when current selected mesh gets unselected
  50681. */
  50682. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50683. private _raySelectionPredicate;
  50684. /**
  50685. * To be optionaly changed by user to define custom ray selection
  50686. */
  50687. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50688. /**
  50689. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50690. */
  50691. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50692. /**
  50693. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50694. */
  50695. teleportationEnabled: boolean;
  50696. private _defaultHeight;
  50697. private _teleportationInitialized;
  50698. private _interactionsEnabled;
  50699. private _interactionsRequested;
  50700. private _displayGaze;
  50701. private _displayLaserPointer;
  50702. /**
  50703. * The mesh used to display where the user is going to teleport.
  50704. */
  50705. get teleportationTarget(): Mesh;
  50706. /**
  50707. * Sets the mesh to be used to display where the user is going to teleport.
  50708. */
  50709. set teleportationTarget(value: Mesh);
  50710. /**
  50711. * 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
  50712. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50713. * See http://doc.babylonjs.com/resources/baking_transformations
  50714. */
  50715. get gazeTrackerMesh(): Mesh;
  50716. set gazeTrackerMesh(value: Mesh);
  50717. /**
  50718. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50719. */
  50720. updateGazeTrackerScale: boolean;
  50721. /**
  50722. * If the gaze trackers color should be updated when selecting meshes
  50723. */
  50724. updateGazeTrackerColor: boolean;
  50725. /**
  50726. * If the controller laser color should be updated when selecting meshes
  50727. */
  50728. updateControllerLaserColor: boolean;
  50729. /**
  50730. * The gaze tracking mesh corresponding to the left controller
  50731. */
  50732. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50733. /**
  50734. * The gaze tracking mesh corresponding to the right controller
  50735. */
  50736. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50737. /**
  50738. * If the ray of the gaze should be displayed.
  50739. */
  50740. get displayGaze(): boolean;
  50741. /**
  50742. * Sets if the ray of the gaze should be displayed.
  50743. */
  50744. set displayGaze(value: boolean);
  50745. /**
  50746. * If the ray of the LaserPointer should be displayed.
  50747. */
  50748. get displayLaserPointer(): boolean;
  50749. /**
  50750. * Sets if the ray of the LaserPointer should be displayed.
  50751. */
  50752. set displayLaserPointer(value: boolean);
  50753. /**
  50754. * The deviceOrientationCamera used as the camera when not in VR.
  50755. */
  50756. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50757. /**
  50758. * Based on the current WebVR support, returns the current VR camera used.
  50759. */
  50760. get currentVRCamera(): Nullable<Camera>;
  50761. /**
  50762. * The webVRCamera which is used when in VR.
  50763. */
  50764. get webVRCamera(): WebVRFreeCamera;
  50765. /**
  50766. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50767. */
  50768. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50769. /**
  50770. * The html button that is used to trigger entering into VR.
  50771. */
  50772. get vrButton(): Nullable<HTMLButtonElement>;
  50773. private get _teleportationRequestInitiated();
  50774. /**
  50775. * Defines whether or not Pointer lock should be requested when switching to
  50776. * full screen.
  50777. */
  50778. requestPointerLockOnFullScreen: boolean;
  50779. /**
  50780. * If asking to force XR, this will be populated with the default xr experience
  50781. */
  50782. xr: WebXRDefaultExperience;
  50783. /**
  50784. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50785. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50786. */
  50787. xrTestDone: boolean;
  50788. /**
  50789. * Instantiates a VRExperienceHelper.
  50790. * Helps to quickly add VR support to an existing scene.
  50791. * @param scene The scene the VRExperienceHelper belongs to.
  50792. * @param webVROptions Options to modify the vr experience helper's behavior.
  50793. */
  50794. constructor(scene: Scene,
  50795. /** Options to modify the vr experience helper's behavior. */
  50796. webVROptions?: VRExperienceHelperOptions);
  50797. private completeVRInit;
  50798. private _onDefaultMeshLoaded;
  50799. private _onResize;
  50800. private _onFullscreenChange;
  50801. /**
  50802. * Gets a value indicating if we are currently in VR mode.
  50803. */
  50804. get isInVRMode(): boolean;
  50805. private onVrDisplayPresentChange;
  50806. private onVRDisplayChanged;
  50807. private moveButtonToBottomRight;
  50808. private displayVRButton;
  50809. private updateButtonVisibility;
  50810. private _cachedAngularSensibility;
  50811. /**
  50812. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50813. * Otherwise, will use the fullscreen API.
  50814. */
  50815. enterVR(): void;
  50816. /**
  50817. * Attempt to exit VR, or fullscreen.
  50818. */
  50819. exitVR(): void;
  50820. /**
  50821. * The position of the vr experience helper.
  50822. */
  50823. get position(): Vector3;
  50824. /**
  50825. * Sets the position of the vr experience helper.
  50826. */
  50827. set position(value: Vector3);
  50828. /**
  50829. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50830. */
  50831. enableInteractions(): void;
  50832. private get _noControllerIsActive();
  50833. private beforeRender;
  50834. private _isTeleportationFloor;
  50835. /**
  50836. * Adds a floor mesh to be used for teleportation.
  50837. * @param floorMesh the mesh to be used for teleportation.
  50838. */
  50839. addFloorMesh(floorMesh: Mesh): void;
  50840. /**
  50841. * Removes a floor mesh from being used for teleportation.
  50842. * @param floorMesh the mesh to be removed.
  50843. */
  50844. removeFloorMesh(floorMesh: Mesh): void;
  50845. /**
  50846. * Enables interactions and teleportation using the VR controllers and gaze.
  50847. * @param vrTeleportationOptions options to modify teleportation behavior.
  50848. */
  50849. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50850. private _onNewGamepadConnected;
  50851. private _tryEnableInteractionOnController;
  50852. private _onNewGamepadDisconnected;
  50853. private _enableInteractionOnController;
  50854. private _checkTeleportWithRay;
  50855. private _checkRotate;
  50856. private _checkTeleportBackwards;
  50857. private _enableTeleportationOnController;
  50858. private _createTeleportationCircles;
  50859. private _displayTeleportationTarget;
  50860. private _hideTeleportationTarget;
  50861. private _rotateCamera;
  50862. private _moveTeleportationSelectorTo;
  50863. private _workingVector;
  50864. private _workingQuaternion;
  50865. private _workingMatrix;
  50866. /**
  50867. * Time Constant Teleportation Mode
  50868. */
  50869. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50870. /**
  50871. * Speed Constant Teleportation Mode
  50872. */
  50873. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50874. /**
  50875. * Teleports the users feet to the desired location
  50876. * @param location The location where the user's feet should be placed
  50877. */
  50878. teleportCamera(location: Vector3): void;
  50879. private _convertNormalToDirectionOfRay;
  50880. private _castRayAndSelectObject;
  50881. private _notifySelectedMeshUnselected;
  50882. /**
  50883. * Permanently set new colors for the laser pointer
  50884. * @param color the new laser color
  50885. * @param pickedColor the new laser color when picked mesh detected
  50886. */
  50887. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50888. /**
  50889. * Set lighting enabled / disabled on the laser pointer of both controllers
  50890. * @param enabled should the lighting be enabled on the laser pointer
  50891. */
  50892. setLaserLightingState(enabled?: boolean): void;
  50893. /**
  50894. * Permanently set new colors for the gaze pointer
  50895. * @param color the new gaze color
  50896. * @param pickedColor the new gaze color when picked mesh detected
  50897. */
  50898. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50899. /**
  50900. * Sets the color of the laser ray from the vr controllers.
  50901. * @param color new color for the ray.
  50902. */
  50903. changeLaserColor(color: Color3): void;
  50904. /**
  50905. * Sets the color of the ray from the vr headsets gaze.
  50906. * @param color new color for the ray.
  50907. */
  50908. changeGazeColor(color: Color3): void;
  50909. /**
  50910. * Exits VR and disposes of the vr experience helper
  50911. */
  50912. dispose(): void;
  50913. /**
  50914. * Gets the name of the VRExperienceHelper class
  50915. * @returns "VRExperienceHelper"
  50916. */
  50917. getClassName(): string;
  50918. }
  50919. }
  50920. declare module "babylonjs/Cameras/VR/index" {
  50921. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50922. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50923. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50924. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50925. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50926. export * from "babylonjs/Cameras/VR/webVRCamera";
  50927. }
  50928. declare module "babylonjs/Cameras/RigModes/index" {
  50929. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50930. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50931. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50932. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50933. }
  50934. declare module "babylonjs/Cameras/index" {
  50935. export * from "babylonjs/Cameras/Inputs/index";
  50936. export * from "babylonjs/Cameras/cameraInputsManager";
  50937. export * from "babylonjs/Cameras/camera";
  50938. export * from "babylonjs/Cameras/targetCamera";
  50939. export * from "babylonjs/Cameras/freeCamera";
  50940. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50941. export * from "babylonjs/Cameras/touchCamera";
  50942. export * from "babylonjs/Cameras/arcRotateCamera";
  50943. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50944. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50945. export * from "babylonjs/Cameras/flyCamera";
  50946. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50947. export * from "babylonjs/Cameras/followCamera";
  50948. export * from "babylonjs/Cameras/followCameraInputsManager";
  50949. export * from "babylonjs/Cameras/gamepadCamera";
  50950. export * from "babylonjs/Cameras/Stereoscopic/index";
  50951. export * from "babylonjs/Cameras/universalCamera";
  50952. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50953. export * from "babylonjs/Cameras/VR/index";
  50954. export * from "babylonjs/Cameras/RigModes/index";
  50955. }
  50956. declare module "babylonjs/Collisions/index" {
  50957. export * from "babylonjs/Collisions/collider";
  50958. export * from "babylonjs/Collisions/collisionCoordinator";
  50959. export * from "babylonjs/Collisions/pickingInfo";
  50960. export * from "babylonjs/Collisions/intersectionInfo";
  50961. export * from "babylonjs/Collisions/meshCollisionData";
  50962. }
  50963. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50964. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50965. import { Vector3 } from "babylonjs/Maths/math.vector";
  50966. import { Ray } from "babylonjs/Culling/ray";
  50967. import { Plane } from "babylonjs/Maths/math.plane";
  50968. /**
  50969. * Contains an array of blocks representing the octree
  50970. */
  50971. export interface IOctreeContainer<T> {
  50972. /**
  50973. * Blocks within the octree
  50974. */
  50975. blocks: Array<OctreeBlock<T>>;
  50976. }
  50977. /**
  50978. * Class used to store a cell in an octree
  50979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50980. */
  50981. export class OctreeBlock<T> {
  50982. /**
  50983. * Gets the content of the current block
  50984. */
  50985. entries: T[];
  50986. /**
  50987. * Gets the list of block children
  50988. */
  50989. blocks: Array<OctreeBlock<T>>;
  50990. private _depth;
  50991. private _maxDepth;
  50992. private _capacity;
  50993. private _minPoint;
  50994. private _maxPoint;
  50995. private _boundingVectors;
  50996. private _creationFunc;
  50997. /**
  50998. * Creates a new block
  50999. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51000. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51001. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51002. * @param depth defines the current depth of this block in the octree
  51003. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51004. * @param creationFunc defines a callback to call when an element is added to the block
  51005. */
  51006. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51007. /**
  51008. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51009. */
  51010. get capacity(): number;
  51011. /**
  51012. * Gets the minimum vector (in world space) of the block's bounding box
  51013. */
  51014. get minPoint(): Vector3;
  51015. /**
  51016. * Gets the maximum vector (in world space) of the block's bounding box
  51017. */
  51018. get maxPoint(): Vector3;
  51019. /**
  51020. * Add a new element to this block
  51021. * @param entry defines the element to add
  51022. */
  51023. addEntry(entry: T): void;
  51024. /**
  51025. * Remove an element from this block
  51026. * @param entry defines the element to remove
  51027. */
  51028. removeEntry(entry: T): void;
  51029. /**
  51030. * Add an array of elements to this block
  51031. * @param entries defines the array of elements to add
  51032. */
  51033. addEntries(entries: T[]): void;
  51034. /**
  51035. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51036. * @param frustumPlanes defines the frustum planes to test
  51037. * @param selection defines the array to store current content if selection is positive
  51038. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51039. */
  51040. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51041. /**
  51042. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51043. * @param sphereCenter defines the bounding sphere center
  51044. * @param sphereRadius defines the bounding sphere radius
  51045. * @param selection defines the array to store current content if selection is positive
  51046. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51047. */
  51048. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51049. /**
  51050. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51051. * @param ray defines the ray to test with
  51052. * @param selection defines the array to store current content if selection is positive
  51053. */
  51054. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51055. /**
  51056. * Subdivide the content into child blocks (this block will then be empty)
  51057. */
  51058. createInnerBlocks(): void;
  51059. /**
  51060. * @hidden
  51061. */
  51062. 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;
  51063. }
  51064. }
  51065. declare module "babylonjs/Culling/Octrees/octree" {
  51066. import { SmartArray } from "babylonjs/Misc/smartArray";
  51067. import { Vector3 } from "babylonjs/Maths/math.vector";
  51068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51070. import { Ray } from "babylonjs/Culling/ray";
  51071. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51072. import { Plane } from "babylonjs/Maths/math.plane";
  51073. /**
  51074. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51075. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51076. */
  51077. export class Octree<T> {
  51078. /** 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.) */
  51079. maxDepth: number;
  51080. /**
  51081. * Blocks within the octree containing objects
  51082. */
  51083. blocks: Array<OctreeBlock<T>>;
  51084. /**
  51085. * Content stored in the octree
  51086. */
  51087. dynamicContent: T[];
  51088. private _maxBlockCapacity;
  51089. private _selectionContent;
  51090. private _creationFunc;
  51091. /**
  51092. * Creates a octree
  51093. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51094. * @param creationFunc function to be used to instatiate the octree
  51095. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51096. * @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.)
  51097. */
  51098. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51099. /** 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.) */
  51100. maxDepth?: number);
  51101. /**
  51102. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51103. * @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);
  51104. * @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);
  51105. * @param entries meshes to be added to the octree blocks
  51106. */
  51107. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51108. /**
  51109. * Adds a mesh to the octree
  51110. * @param entry Mesh to add to the octree
  51111. */
  51112. addMesh(entry: T): void;
  51113. /**
  51114. * Remove an element from the octree
  51115. * @param entry defines the element to remove
  51116. */
  51117. removeMesh(entry: T): void;
  51118. /**
  51119. * Selects an array of meshes within the frustum
  51120. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51121. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51122. * @returns array of meshes within the frustum
  51123. */
  51124. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51125. /**
  51126. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51127. * @param sphereCenter defines the bounding sphere center
  51128. * @param sphereRadius defines the bounding sphere radius
  51129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51130. * @returns an array of objects that intersect the sphere
  51131. */
  51132. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51133. /**
  51134. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51135. * @param ray defines the ray to test with
  51136. * @returns array of intersected objects
  51137. */
  51138. intersectsRay(ray: Ray): SmartArray<T>;
  51139. /**
  51140. * Adds a mesh into the octree block if it intersects the block
  51141. */
  51142. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51143. /**
  51144. * Adds a submesh into the octree block if it intersects the block
  51145. */
  51146. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51147. }
  51148. }
  51149. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51150. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51151. import { Scene } from "babylonjs/scene";
  51152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51154. import { Ray } from "babylonjs/Culling/ray";
  51155. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51156. import { Collider } from "babylonjs/Collisions/collider";
  51157. module "babylonjs/scene" {
  51158. interface Scene {
  51159. /**
  51160. * @hidden
  51161. * Backing Filed
  51162. */
  51163. _selectionOctree: Octree<AbstractMesh>;
  51164. /**
  51165. * Gets the octree used to boost mesh selection (picking)
  51166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51167. */
  51168. selectionOctree: Octree<AbstractMesh>;
  51169. /**
  51170. * Creates or updates the octree used to boost selection (picking)
  51171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51172. * @param maxCapacity defines the maximum capacity per leaf
  51173. * @param maxDepth defines the maximum depth of the octree
  51174. * @returns an octree of AbstractMesh
  51175. */
  51176. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51177. }
  51178. }
  51179. module "babylonjs/Meshes/abstractMesh" {
  51180. interface AbstractMesh {
  51181. /**
  51182. * @hidden
  51183. * Backing Field
  51184. */
  51185. _submeshesOctree: Octree<SubMesh>;
  51186. /**
  51187. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51188. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51189. * @param maxCapacity defines the maximum size of each block (64 by default)
  51190. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51191. * @returns the new octree
  51192. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51194. */
  51195. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51196. }
  51197. }
  51198. /**
  51199. * Defines the octree scene component responsible to manage any octrees
  51200. * in a given scene.
  51201. */
  51202. export class OctreeSceneComponent {
  51203. /**
  51204. * The component name help to identify the component in the list of scene components.
  51205. */
  51206. readonly name: string;
  51207. /**
  51208. * The scene the component belongs to.
  51209. */
  51210. scene: Scene;
  51211. /**
  51212. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51213. */
  51214. readonly checksIsEnabled: boolean;
  51215. /**
  51216. * Creates a new instance of the component for the given scene
  51217. * @param scene Defines the scene to register the component in
  51218. */
  51219. constructor(scene: Scene);
  51220. /**
  51221. * Registers the component in a given scene
  51222. */
  51223. register(): void;
  51224. /**
  51225. * Return the list of active meshes
  51226. * @returns the list of active meshes
  51227. */
  51228. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51229. /**
  51230. * Return the list of active sub meshes
  51231. * @param mesh The mesh to get the candidates sub meshes from
  51232. * @returns the list of active sub meshes
  51233. */
  51234. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51235. private _tempRay;
  51236. /**
  51237. * Return the list of sub meshes intersecting with a given local ray
  51238. * @param mesh defines the mesh to find the submesh for
  51239. * @param localRay defines the ray in local space
  51240. * @returns the list of intersecting sub meshes
  51241. */
  51242. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51243. /**
  51244. * Return the list of sub meshes colliding with a collider
  51245. * @param mesh defines the mesh to find the submesh for
  51246. * @param collider defines the collider to evaluate the collision against
  51247. * @returns the list of colliding sub meshes
  51248. */
  51249. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51250. /**
  51251. * Rebuilds the elements related to this component in case of
  51252. * context lost for instance.
  51253. */
  51254. rebuild(): void;
  51255. /**
  51256. * Disposes the component and the associated ressources.
  51257. */
  51258. dispose(): void;
  51259. }
  51260. }
  51261. declare module "babylonjs/Culling/Octrees/index" {
  51262. export * from "babylonjs/Culling/Octrees/octree";
  51263. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51264. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51265. }
  51266. declare module "babylonjs/Culling/index" {
  51267. export * from "babylonjs/Culling/boundingBox";
  51268. export * from "babylonjs/Culling/boundingInfo";
  51269. export * from "babylonjs/Culling/boundingSphere";
  51270. export * from "babylonjs/Culling/Octrees/index";
  51271. export * from "babylonjs/Culling/ray";
  51272. }
  51273. declare module "babylonjs/Gizmos/gizmo" {
  51274. import { Nullable } from "babylonjs/types";
  51275. import { IDisposable } from "babylonjs/scene";
  51276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51277. import { Mesh } from "babylonjs/Meshes/mesh";
  51278. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51279. /**
  51280. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51281. */
  51282. export class Gizmo implements IDisposable {
  51283. /** The utility layer the gizmo will be added to */
  51284. gizmoLayer: UtilityLayerRenderer;
  51285. /**
  51286. * The root mesh of the gizmo
  51287. */
  51288. _rootMesh: Mesh;
  51289. private _attachedMesh;
  51290. /**
  51291. * Ratio for the scale of the gizmo (Default: 1)
  51292. */
  51293. scaleRatio: number;
  51294. /**
  51295. * If a custom mesh has been set (Default: false)
  51296. */
  51297. protected _customMeshSet: boolean;
  51298. /**
  51299. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51300. * * When set, interactions will be enabled
  51301. */
  51302. get attachedMesh(): Nullable<AbstractMesh>;
  51303. set attachedMesh(value: Nullable<AbstractMesh>);
  51304. /**
  51305. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51306. * @param mesh The mesh to replace the default mesh of the gizmo
  51307. */
  51308. setCustomMesh(mesh: Mesh): void;
  51309. /**
  51310. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51311. */
  51312. updateGizmoRotationToMatchAttachedMesh: boolean;
  51313. /**
  51314. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51315. */
  51316. updateGizmoPositionToMatchAttachedMesh: boolean;
  51317. /**
  51318. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51319. */
  51320. updateScale: boolean;
  51321. protected _interactionsEnabled: boolean;
  51322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51323. private _beforeRenderObserver;
  51324. private _tempVector;
  51325. /**
  51326. * Creates a gizmo
  51327. * @param gizmoLayer The utility layer the gizmo will be added to
  51328. */
  51329. constructor(
  51330. /** The utility layer the gizmo will be added to */
  51331. gizmoLayer?: UtilityLayerRenderer);
  51332. /**
  51333. * Updates the gizmo to match the attached mesh's position/rotation
  51334. */
  51335. protected _update(): void;
  51336. /**
  51337. * Disposes of the gizmo
  51338. */
  51339. dispose(): void;
  51340. }
  51341. }
  51342. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51343. import { Observable } from "babylonjs/Misc/observable";
  51344. import { Nullable } from "babylonjs/types";
  51345. import { Vector3 } from "babylonjs/Maths/math.vector";
  51346. import { Color3 } from "babylonjs/Maths/math.color";
  51347. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51349. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51350. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51351. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51352. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51353. import { Scene } from "babylonjs/scene";
  51354. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51355. /**
  51356. * Single plane drag gizmo
  51357. */
  51358. export class PlaneDragGizmo extends Gizmo {
  51359. /**
  51360. * Drag behavior responsible for the gizmos dragging interactions
  51361. */
  51362. dragBehavior: PointerDragBehavior;
  51363. private _pointerObserver;
  51364. /**
  51365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51366. */
  51367. snapDistance: number;
  51368. /**
  51369. * Event that fires each time the gizmo snaps to a new location.
  51370. * * snapDistance is the the change in distance
  51371. */
  51372. onSnapObservable: Observable<{
  51373. snapDistance: number;
  51374. }>;
  51375. private _plane;
  51376. private _coloredMaterial;
  51377. private _hoverMaterial;
  51378. private _isEnabled;
  51379. private _parent;
  51380. /** @hidden */
  51381. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51382. /** @hidden */
  51383. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51384. /**
  51385. * Creates a PlaneDragGizmo
  51386. * @param gizmoLayer The utility layer the gizmo will be added to
  51387. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51388. * @param color The color of the gizmo
  51389. */
  51390. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51391. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51392. /**
  51393. * If the gizmo is enabled
  51394. */
  51395. set isEnabled(value: boolean);
  51396. get isEnabled(): boolean;
  51397. /**
  51398. * Disposes of the gizmo
  51399. */
  51400. dispose(): void;
  51401. }
  51402. }
  51403. declare module "babylonjs/Gizmos/positionGizmo" {
  51404. import { Observable } from "babylonjs/Misc/observable";
  51405. import { Nullable } from "babylonjs/types";
  51406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51407. import { Mesh } from "babylonjs/Meshes/mesh";
  51408. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51409. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51410. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51412. /**
  51413. * Gizmo that enables dragging a mesh along 3 axis
  51414. */
  51415. export class PositionGizmo extends Gizmo {
  51416. /**
  51417. * Internal gizmo used for interactions on the x axis
  51418. */
  51419. xGizmo: AxisDragGizmo;
  51420. /**
  51421. * Internal gizmo used for interactions on the y axis
  51422. */
  51423. yGizmo: AxisDragGizmo;
  51424. /**
  51425. * Internal gizmo used for interactions on the z axis
  51426. */
  51427. zGizmo: AxisDragGizmo;
  51428. /**
  51429. * Internal gizmo used for interactions on the yz plane
  51430. */
  51431. xPlaneGizmo: PlaneDragGizmo;
  51432. /**
  51433. * Internal gizmo used for interactions on the xz plane
  51434. */
  51435. yPlaneGizmo: PlaneDragGizmo;
  51436. /**
  51437. * Internal gizmo used for interactions on the xy plane
  51438. */
  51439. zPlaneGizmo: PlaneDragGizmo;
  51440. /**
  51441. * private variables
  51442. */
  51443. private _meshAttached;
  51444. private _updateGizmoRotationToMatchAttachedMesh;
  51445. private _snapDistance;
  51446. private _scaleRatio;
  51447. /** Fires an event when any of it's sub gizmos are dragged */
  51448. onDragStartObservable: Observable<unknown>;
  51449. /** Fires an event when any of it's sub gizmos are released from dragging */
  51450. onDragEndObservable: Observable<unknown>;
  51451. /**
  51452. * If set to true, planar drag is enabled
  51453. */
  51454. private _planarGizmoEnabled;
  51455. get attachedMesh(): Nullable<AbstractMesh>;
  51456. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51457. /**
  51458. * Creates a PositionGizmo
  51459. * @param gizmoLayer The utility layer the gizmo will be added to
  51460. */
  51461. constructor(gizmoLayer?: UtilityLayerRenderer);
  51462. /**
  51463. * If the planar drag gizmo is enabled
  51464. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51465. */
  51466. set planarGizmoEnabled(value: boolean);
  51467. get planarGizmoEnabled(): boolean;
  51468. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51469. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51470. /**
  51471. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51472. */
  51473. set snapDistance(value: number);
  51474. get snapDistance(): number;
  51475. /**
  51476. * Ratio for the scale of the gizmo (Default: 1)
  51477. */
  51478. set scaleRatio(value: number);
  51479. get scaleRatio(): number;
  51480. /**
  51481. * Disposes of the gizmo
  51482. */
  51483. dispose(): void;
  51484. /**
  51485. * CustomMeshes are not supported by this gizmo
  51486. * @param mesh The mesh to replace the default mesh of the gizmo
  51487. */
  51488. setCustomMesh(mesh: Mesh): void;
  51489. }
  51490. }
  51491. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51492. import { Observable } from "babylonjs/Misc/observable";
  51493. import { Nullable } from "babylonjs/types";
  51494. import { Vector3 } from "babylonjs/Maths/math.vector";
  51495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51497. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51498. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51499. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51500. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51501. import { Scene } from "babylonjs/scene";
  51502. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51503. import { Color3 } from "babylonjs/Maths/math.color";
  51504. /**
  51505. * Single axis drag gizmo
  51506. */
  51507. export class AxisDragGizmo extends Gizmo {
  51508. /**
  51509. * Drag behavior responsible for the gizmos dragging interactions
  51510. */
  51511. dragBehavior: PointerDragBehavior;
  51512. private _pointerObserver;
  51513. /**
  51514. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51515. */
  51516. snapDistance: number;
  51517. /**
  51518. * Event that fires each time the gizmo snaps to a new location.
  51519. * * snapDistance is the the change in distance
  51520. */
  51521. onSnapObservable: Observable<{
  51522. snapDistance: number;
  51523. }>;
  51524. private _isEnabled;
  51525. private _parent;
  51526. private _arrow;
  51527. private _coloredMaterial;
  51528. private _hoverMaterial;
  51529. /** @hidden */
  51530. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51531. /** @hidden */
  51532. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51533. /**
  51534. * Creates an AxisDragGizmo
  51535. * @param gizmoLayer The utility layer the gizmo will be added to
  51536. * @param dragAxis The axis which the gizmo will be able to drag on
  51537. * @param color The color of the gizmo
  51538. */
  51539. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51541. /**
  51542. * If the gizmo is enabled
  51543. */
  51544. set isEnabled(value: boolean);
  51545. get isEnabled(): boolean;
  51546. /**
  51547. * Disposes of the gizmo
  51548. */
  51549. dispose(): void;
  51550. }
  51551. }
  51552. declare module "babylonjs/Debug/axesViewer" {
  51553. import { Vector3 } from "babylonjs/Maths/math.vector";
  51554. import { Nullable } from "babylonjs/types";
  51555. import { Scene } from "babylonjs/scene";
  51556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51557. /**
  51558. * The Axes viewer will show 3 axes in a specific point in space
  51559. */
  51560. export class AxesViewer {
  51561. private _xAxis;
  51562. private _yAxis;
  51563. private _zAxis;
  51564. private _scaleLinesFactor;
  51565. private _instanced;
  51566. /**
  51567. * Gets the hosting scene
  51568. */
  51569. scene: Scene;
  51570. /**
  51571. * Gets or sets a number used to scale line length
  51572. */
  51573. scaleLines: number;
  51574. /** Gets the node hierarchy used to render x-axis */
  51575. get xAxis(): TransformNode;
  51576. /** Gets the node hierarchy used to render y-axis */
  51577. get yAxis(): TransformNode;
  51578. /** Gets the node hierarchy used to render z-axis */
  51579. get zAxis(): TransformNode;
  51580. /**
  51581. * Creates a new AxesViewer
  51582. * @param scene defines the hosting scene
  51583. * @param scaleLines defines a number used to scale line length (1 by default)
  51584. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51585. * @param xAxis defines the node hierarchy used to render the x-axis
  51586. * @param yAxis defines the node hierarchy used to render the y-axis
  51587. * @param zAxis defines the node hierarchy used to render the z-axis
  51588. */
  51589. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51590. /**
  51591. * Force the viewer to update
  51592. * @param position defines the position of the viewer
  51593. * @param xaxis defines the x axis of the viewer
  51594. * @param yaxis defines the y axis of the viewer
  51595. * @param zaxis defines the z axis of the viewer
  51596. */
  51597. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51598. /**
  51599. * Creates an instance of this axes viewer.
  51600. * @returns a new axes viewer with instanced meshes
  51601. */
  51602. createInstance(): AxesViewer;
  51603. /** Releases resources */
  51604. dispose(): void;
  51605. private static _SetRenderingGroupId;
  51606. }
  51607. }
  51608. declare module "babylonjs/Debug/boneAxesViewer" {
  51609. import { Nullable } from "babylonjs/types";
  51610. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51611. import { Vector3 } from "babylonjs/Maths/math.vector";
  51612. import { Mesh } from "babylonjs/Meshes/mesh";
  51613. import { Bone } from "babylonjs/Bones/bone";
  51614. import { Scene } from "babylonjs/scene";
  51615. /**
  51616. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51617. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51618. */
  51619. export class BoneAxesViewer extends AxesViewer {
  51620. /**
  51621. * Gets or sets the target mesh where to display the axes viewer
  51622. */
  51623. mesh: Nullable<Mesh>;
  51624. /**
  51625. * Gets or sets the target bone where to display the axes viewer
  51626. */
  51627. bone: Nullable<Bone>;
  51628. /** Gets current position */
  51629. pos: Vector3;
  51630. /** Gets direction of X axis */
  51631. xaxis: Vector3;
  51632. /** Gets direction of Y axis */
  51633. yaxis: Vector3;
  51634. /** Gets direction of Z axis */
  51635. zaxis: Vector3;
  51636. /**
  51637. * Creates a new BoneAxesViewer
  51638. * @param scene defines the hosting scene
  51639. * @param bone defines the target bone
  51640. * @param mesh defines the target mesh
  51641. * @param scaleLines defines a scaling factor for line length (1 by default)
  51642. */
  51643. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51644. /**
  51645. * Force the viewer to update
  51646. */
  51647. update(): void;
  51648. /** Releases resources */
  51649. dispose(): void;
  51650. }
  51651. }
  51652. declare module "babylonjs/Debug/debugLayer" {
  51653. import { Scene } from "babylonjs/scene";
  51654. /**
  51655. * Interface used to define scene explorer extensibility option
  51656. */
  51657. export interface IExplorerExtensibilityOption {
  51658. /**
  51659. * Define the option label
  51660. */
  51661. label: string;
  51662. /**
  51663. * Defines the action to execute on click
  51664. */
  51665. action: (entity: any) => void;
  51666. }
  51667. /**
  51668. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51669. */
  51670. export interface IExplorerExtensibilityGroup {
  51671. /**
  51672. * Defines a predicate to test if a given type mut be extended
  51673. */
  51674. predicate: (entity: any) => boolean;
  51675. /**
  51676. * Gets the list of options added to a type
  51677. */
  51678. entries: IExplorerExtensibilityOption[];
  51679. }
  51680. /**
  51681. * Interface used to define the options to use to create the Inspector
  51682. */
  51683. export interface IInspectorOptions {
  51684. /**
  51685. * Display in overlay mode (default: false)
  51686. */
  51687. overlay?: boolean;
  51688. /**
  51689. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51690. */
  51691. globalRoot?: HTMLElement;
  51692. /**
  51693. * Display the Scene explorer
  51694. */
  51695. showExplorer?: boolean;
  51696. /**
  51697. * Display the property inspector
  51698. */
  51699. showInspector?: boolean;
  51700. /**
  51701. * Display in embed mode (both panes on the right)
  51702. */
  51703. embedMode?: boolean;
  51704. /**
  51705. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51706. */
  51707. handleResize?: boolean;
  51708. /**
  51709. * Allow the panes to popup (default: true)
  51710. */
  51711. enablePopup?: boolean;
  51712. /**
  51713. * Allow the panes to be closed by users (default: true)
  51714. */
  51715. enableClose?: boolean;
  51716. /**
  51717. * Optional list of extensibility entries
  51718. */
  51719. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51720. /**
  51721. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51722. */
  51723. inspectorURL?: string;
  51724. /**
  51725. * Optional initial tab (default to DebugLayerTab.Properties)
  51726. */
  51727. initialTab?: DebugLayerTab;
  51728. }
  51729. module "babylonjs/scene" {
  51730. interface Scene {
  51731. /**
  51732. * @hidden
  51733. * Backing field
  51734. */
  51735. _debugLayer: DebugLayer;
  51736. /**
  51737. * Gets the debug layer (aka Inspector) associated with the scene
  51738. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51739. */
  51740. debugLayer: DebugLayer;
  51741. }
  51742. }
  51743. /**
  51744. * Enum of inspector action tab
  51745. */
  51746. export enum DebugLayerTab {
  51747. /**
  51748. * Properties tag (default)
  51749. */
  51750. Properties = 0,
  51751. /**
  51752. * Debug tab
  51753. */
  51754. Debug = 1,
  51755. /**
  51756. * Statistics tab
  51757. */
  51758. Statistics = 2,
  51759. /**
  51760. * Tools tab
  51761. */
  51762. Tools = 3,
  51763. /**
  51764. * Settings tab
  51765. */
  51766. Settings = 4
  51767. }
  51768. /**
  51769. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51770. * what is happening in your scene
  51771. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51772. */
  51773. export class DebugLayer {
  51774. /**
  51775. * Define the url to get the inspector script from.
  51776. * By default it uses the babylonjs CDN.
  51777. * @ignoreNaming
  51778. */
  51779. static InspectorURL: string;
  51780. private _scene;
  51781. private BJSINSPECTOR;
  51782. private _onPropertyChangedObservable?;
  51783. /**
  51784. * Observable triggered when a property is changed through the inspector.
  51785. */
  51786. get onPropertyChangedObservable(): any;
  51787. /**
  51788. * Instantiates a new debug layer.
  51789. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51790. * what is happening in your scene
  51791. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51792. * @param scene Defines the scene to inspect
  51793. */
  51794. constructor(scene: Scene);
  51795. /** Creates the inspector window. */
  51796. private _createInspector;
  51797. /**
  51798. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51799. * @param entity defines the entity to select
  51800. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51801. */
  51802. select(entity: any, lineContainerTitles?: string | string[]): void;
  51803. /** Get the inspector from bundle or global */
  51804. private _getGlobalInspector;
  51805. /**
  51806. * Get if the inspector is visible or not.
  51807. * @returns true if visible otherwise, false
  51808. */
  51809. isVisible(): boolean;
  51810. /**
  51811. * Hide the inspector and close its window.
  51812. */
  51813. hide(): void;
  51814. /**
  51815. * Update the scene in the inspector
  51816. */
  51817. setAsActiveScene(): void;
  51818. /**
  51819. * Launch the debugLayer.
  51820. * @param config Define the configuration of the inspector
  51821. * @return a promise fulfilled when the debug layer is visible
  51822. */
  51823. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51824. }
  51825. }
  51826. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51827. import { Nullable } from "babylonjs/types";
  51828. import { Scene } from "babylonjs/scene";
  51829. import { Vector4 } from "babylonjs/Maths/math.vector";
  51830. import { Color4 } from "babylonjs/Maths/math.color";
  51831. import { Mesh } from "babylonjs/Meshes/mesh";
  51832. /**
  51833. * Class containing static functions to help procedurally build meshes
  51834. */
  51835. export class BoxBuilder {
  51836. /**
  51837. * Creates a box mesh
  51838. * * The parameter `size` sets the size (float) of each box side (default 1)
  51839. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51840. * * 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)
  51841. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51845. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51846. * @param name defines the name of the mesh
  51847. * @param options defines the options used to create the mesh
  51848. * @param scene defines the hosting scene
  51849. * @returns the box mesh
  51850. */
  51851. static CreateBox(name: string, options: {
  51852. size?: number;
  51853. width?: number;
  51854. height?: number;
  51855. depth?: number;
  51856. faceUV?: Vector4[];
  51857. faceColors?: Color4[];
  51858. sideOrientation?: number;
  51859. frontUVs?: Vector4;
  51860. backUVs?: Vector4;
  51861. wrap?: boolean;
  51862. topBaseAt?: number;
  51863. bottomBaseAt?: number;
  51864. updatable?: boolean;
  51865. }, scene?: Nullable<Scene>): Mesh;
  51866. }
  51867. }
  51868. declare module "babylonjs/Debug/physicsViewer" {
  51869. import { Nullable } from "babylonjs/types";
  51870. import { Scene } from "babylonjs/scene";
  51871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51872. import { Mesh } from "babylonjs/Meshes/mesh";
  51873. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51874. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51875. /**
  51876. * Used to show the physics impostor around the specific mesh
  51877. */
  51878. export class PhysicsViewer {
  51879. /** @hidden */
  51880. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51881. /** @hidden */
  51882. protected _meshes: Array<Nullable<AbstractMesh>>;
  51883. /** @hidden */
  51884. protected _scene: Nullable<Scene>;
  51885. /** @hidden */
  51886. protected _numMeshes: number;
  51887. /** @hidden */
  51888. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51889. private _renderFunction;
  51890. private _utilityLayer;
  51891. private _debugBoxMesh;
  51892. private _debugSphereMesh;
  51893. private _debugCylinderMesh;
  51894. private _debugMaterial;
  51895. private _debugMeshMeshes;
  51896. /**
  51897. * Creates a new PhysicsViewer
  51898. * @param scene defines the hosting scene
  51899. */
  51900. constructor(scene: Scene);
  51901. /** @hidden */
  51902. protected _updateDebugMeshes(): void;
  51903. /**
  51904. * Renders a specified physic impostor
  51905. * @param impostor defines the impostor to render
  51906. * @param targetMesh defines the mesh represented by the impostor
  51907. * @returns the new debug mesh used to render the impostor
  51908. */
  51909. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51910. /**
  51911. * Hides a specified physic impostor
  51912. * @param impostor defines the impostor to hide
  51913. */
  51914. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51915. private _getDebugMaterial;
  51916. private _getDebugBoxMesh;
  51917. private _getDebugSphereMesh;
  51918. private _getDebugCylinderMesh;
  51919. private _getDebugMeshMesh;
  51920. private _getDebugMesh;
  51921. /** Releases all resources */
  51922. dispose(): void;
  51923. }
  51924. }
  51925. declare module "babylonjs/Debug/rayHelper" {
  51926. import { Nullable } from "babylonjs/types";
  51927. import { Ray } from "babylonjs/Culling/ray";
  51928. import { Vector3 } from "babylonjs/Maths/math.vector";
  51929. import { Color3 } from "babylonjs/Maths/math.color";
  51930. import { Scene } from "babylonjs/scene";
  51931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51932. import "babylonjs/Meshes/Builders/linesBuilder";
  51933. /**
  51934. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51935. * in order to better appreciate the issue one might have.
  51936. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51937. */
  51938. export class RayHelper {
  51939. /**
  51940. * Defines the ray we are currently tryin to visualize.
  51941. */
  51942. ray: Nullable<Ray>;
  51943. private _renderPoints;
  51944. private _renderLine;
  51945. private _renderFunction;
  51946. private _scene;
  51947. private _updateToMeshFunction;
  51948. private _attachedToMesh;
  51949. private _meshSpaceDirection;
  51950. private _meshSpaceOrigin;
  51951. /**
  51952. * Helper function to create a colored helper in a scene in one line.
  51953. * @param ray Defines the ray we are currently tryin to visualize
  51954. * @param scene Defines the scene the ray is used in
  51955. * @param color Defines the color we want to see the ray in
  51956. * @returns The newly created ray helper.
  51957. */
  51958. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51959. /**
  51960. * Instantiate a new ray helper.
  51961. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51962. * in order to better appreciate the issue one might have.
  51963. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51964. * @param ray Defines the ray we are currently tryin to visualize
  51965. */
  51966. constructor(ray: Ray);
  51967. /**
  51968. * Shows the ray we are willing to debug.
  51969. * @param scene Defines the scene the ray needs to be rendered in
  51970. * @param color Defines the color the ray needs to be rendered in
  51971. */
  51972. show(scene: Scene, color?: Color3): void;
  51973. /**
  51974. * Hides the ray we are debugging.
  51975. */
  51976. hide(): void;
  51977. private _render;
  51978. /**
  51979. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51980. * @param mesh Defines the mesh we want the helper attached to
  51981. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51982. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51983. * @param length Defines the length of the ray
  51984. */
  51985. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51986. /**
  51987. * Detach the ray helper from the mesh it has previously been attached to.
  51988. */
  51989. detachFromMesh(): void;
  51990. private _updateToMesh;
  51991. /**
  51992. * Dispose the helper and release its associated resources.
  51993. */
  51994. dispose(): void;
  51995. }
  51996. }
  51997. declare module "babylonjs/Debug/skeletonViewer" {
  51998. import { Color3 } from "babylonjs/Maths/math.color";
  51999. import { Scene } from "babylonjs/scene";
  52000. import { Nullable } from "babylonjs/types";
  52001. import { Skeleton } from "babylonjs/Bones/skeleton";
  52002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52003. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52004. /**
  52005. * Class used to render a debug view of a given skeleton
  52006. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52007. */
  52008. export class SkeletonViewer {
  52009. /** defines the skeleton to render */
  52010. skeleton: Skeleton;
  52011. /** defines the mesh attached to the skeleton */
  52012. mesh: AbstractMesh;
  52013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52014. autoUpdateBonesMatrices: boolean;
  52015. /** defines the rendering group id to use with the viewer */
  52016. renderingGroupId: number;
  52017. /** Gets or sets the color used to render the skeleton */
  52018. color: Color3;
  52019. private _scene;
  52020. private _debugLines;
  52021. private _debugMesh;
  52022. private _isEnabled;
  52023. private _renderFunction;
  52024. private _utilityLayer;
  52025. /**
  52026. * Returns the mesh used to render the bones
  52027. */
  52028. get debugMesh(): Nullable<LinesMesh>;
  52029. /**
  52030. * Creates a new SkeletonViewer
  52031. * @param skeleton defines the skeleton to render
  52032. * @param mesh defines the mesh attached to the skeleton
  52033. * @param scene defines the hosting scene
  52034. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52035. * @param renderingGroupId defines the rendering group id to use with the viewer
  52036. */
  52037. constructor(
  52038. /** defines the skeleton to render */
  52039. skeleton: Skeleton,
  52040. /** defines the mesh attached to the skeleton */
  52041. mesh: AbstractMesh, scene: Scene,
  52042. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52043. autoUpdateBonesMatrices?: boolean,
  52044. /** defines the rendering group id to use with the viewer */
  52045. renderingGroupId?: number);
  52046. /** Gets or sets a boolean indicating if the viewer is enabled */
  52047. set isEnabled(value: boolean);
  52048. get isEnabled(): boolean;
  52049. private _getBonePosition;
  52050. private _getLinesForBonesWithLength;
  52051. private _getLinesForBonesNoLength;
  52052. /** Update the viewer to sync with current skeleton state */
  52053. update(): void;
  52054. /** Release associated resources */
  52055. dispose(): void;
  52056. }
  52057. }
  52058. declare module "babylonjs/Debug/index" {
  52059. export * from "babylonjs/Debug/axesViewer";
  52060. export * from "babylonjs/Debug/boneAxesViewer";
  52061. export * from "babylonjs/Debug/debugLayer";
  52062. export * from "babylonjs/Debug/physicsViewer";
  52063. export * from "babylonjs/Debug/rayHelper";
  52064. export * from "babylonjs/Debug/skeletonViewer";
  52065. }
  52066. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52067. /**
  52068. * Enum for Device Types
  52069. */
  52070. export enum DeviceType {
  52071. /** Generic */
  52072. Generic = 0,
  52073. /** Keyboard */
  52074. Keyboard = 1,
  52075. /** Mouse */
  52076. Mouse = 2,
  52077. /** Touch Pointers */
  52078. Touch = 3,
  52079. /** PS4 Dual Shock */
  52080. DualShock = 4,
  52081. /** Xbox */
  52082. Xbox = 5,
  52083. /** Switch Controller */
  52084. Switch = 6
  52085. }
  52086. /**
  52087. * Enum for All Pointers (Touch/Mouse)
  52088. */
  52089. export enum PointerInput {
  52090. /** Horizontal Axis */
  52091. Horizontal = 0,
  52092. /** Vertical Axis */
  52093. Vertical = 1,
  52094. /** Left Click or Touch */
  52095. LeftClick = 2,
  52096. /** Middle Click */
  52097. MiddleClick = 3,
  52098. /** Right Click */
  52099. RightClick = 4,
  52100. /** Browser Back */
  52101. BrowserBack = 5,
  52102. /** Browser Forward */
  52103. BrowserForward = 6
  52104. }
  52105. /**
  52106. * Enum for Dual Shock Gamepad
  52107. */
  52108. export enum DualShockInput {
  52109. /** Cross */
  52110. Cross = 0,
  52111. /** Circle */
  52112. Circle = 1,
  52113. /** Square */
  52114. Square = 2,
  52115. /** Triangle */
  52116. Triangle = 3,
  52117. /** L1 */
  52118. L1 = 4,
  52119. /** R1 */
  52120. R1 = 5,
  52121. /** L2 */
  52122. L2 = 6,
  52123. /** R2 */
  52124. R2 = 7,
  52125. /** Share */
  52126. Share = 8,
  52127. /** Options */
  52128. Options = 9,
  52129. /** L3 */
  52130. L3 = 10,
  52131. /** R3 */
  52132. R3 = 11,
  52133. /** DPadUp */
  52134. DPadUp = 12,
  52135. /** DPadDown */
  52136. DPadDown = 13,
  52137. /** DPadLeft */
  52138. DPadLeft = 14,
  52139. /** DRight */
  52140. DPadRight = 15,
  52141. /** Home */
  52142. Home = 16,
  52143. /** TouchPad */
  52144. TouchPad = 17,
  52145. /** LStickXAxis */
  52146. LStickXAxis = 18,
  52147. /** LStickYAxis */
  52148. LStickYAxis = 19,
  52149. /** RStickXAxis */
  52150. RStickXAxis = 20,
  52151. /** RStickYAxis */
  52152. RStickYAxis = 21
  52153. }
  52154. /**
  52155. * Enum for Xbox Gamepad
  52156. */
  52157. export enum XboxInput {
  52158. /** A */
  52159. A = 0,
  52160. /** B */
  52161. B = 1,
  52162. /** X */
  52163. X = 2,
  52164. /** Y */
  52165. Y = 3,
  52166. /** LB */
  52167. LB = 4,
  52168. /** RB */
  52169. RB = 5,
  52170. /** LT */
  52171. LT = 6,
  52172. /** RT */
  52173. RT = 7,
  52174. /** Back */
  52175. Back = 8,
  52176. /** Start */
  52177. Start = 9,
  52178. /** LS */
  52179. LS = 10,
  52180. /** RS */
  52181. RS = 11,
  52182. /** DPadUp */
  52183. DPadUp = 12,
  52184. /** DPadDown */
  52185. DPadDown = 13,
  52186. /** DPadLeft */
  52187. DPadLeft = 14,
  52188. /** DRight */
  52189. DPadRight = 15,
  52190. /** Home */
  52191. Home = 16,
  52192. /** LStickXAxis */
  52193. LStickXAxis = 17,
  52194. /** LStickYAxis */
  52195. LStickYAxis = 18,
  52196. /** RStickXAxis */
  52197. RStickXAxis = 19,
  52198. /** RStickYAxis */
  52199. RStickYAxis = 20
  52200. }
  52201. /**
  52202. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52203. */
  52204. export enum SwitchInput {
  52205. /** B */
  52206. B = 0,
  52207. /** A */
  52208. A = 1,
  52209. /** Y */
  52210. Y = 2,
  52211. /** X */
  52212. X = 3,
  52213. /** L */
  52214. L = 4,
  52215. /** R */
  52216. R = 5,
  52217. /** ZL */
  52218. ZL = 6,
  52219. /** ZR */
  52220. ZR = 7,
  52221. /** Minus */
  52222. Minus = 8,
  52223. /** Plus */
  52224. Plus = 9,
  52225. /** LS */
  52226. LS = 10,
  52227. /** RS */
  52228. RS = 11,
  52229. /** DPadUp */
  52230. DPadUp = 12,
  52231. /** DPadDown */
  52232. DPadDown = 13,
  52233. /** DPadLeft */
  52234. DPadLeft = 14,
  52235. /** DRight */
  52236. DPadRight = 15,
  52237. /** Home */
  52238. Home = 16,
  52239. /** Capture */
  52240. Capture = 17,
  52241. /** LStickXAxis */
  52242. LStickXAxis = 18,
  52243. /** LStickYAxis */
  52244. LStickYAxis = 19,
  52245. /** RStickXAxis */
  52246. RStickXAxis = 20,
  52247. /** RStickYAxis */
  52248. RStickYAxis = 21
  52249. }
  52250. }
  52251. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52252. import { Engine } from "babylonjs/Engines/engine";
  52253. import { IDisposable } from "babylonjs/scene";
  52254. import { Nullable } from "babylonjs/types";
  52255. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52256. /**
  52257. * This class will take all inputs from Keyboard, Pointer, and
  52258. * any Gamepads and provide a polling system that all devices
  52259. * will use. This class assumes that there will only be one
  52260. * pointer device and one keyboard.
  52261. */
  52262. export class DeviceInputSystem implements IDisposable {
  52263. /**
  52264. * Callback to be triggered when a device is connected
  52265. */
  52266. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52267. /**
  52268. * Callback to be triggered when a device is disconnected
  52269. */
  52270. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52271. /**
  52272. * Callback to be triggered when event driven input is updated
  52273. */
  52274. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52275. private _inputs;
  52276. private _gamepads;
  52277. private _keyboardActive;
  52278. private _pointerActive;
  52279. private _elementToAttachTo;
  52280. private _keyboardDownEvent;
  52281. private _keyboardUpEvent;
  52282. private _pointerMoveEvent;
  52283. private _pointerDownEvent;
  52284. private _pointerUpEvent;
  52285. private _gamepadConnectedEvent;
  52286. private _gamepadDisconnectedEvent;
  52287. private static _MAX_KEYCODES;
  52288. private static _MAX_POINTER_INPUTS;
  52289. private constructor();
  52290. /**
  52291. * Creates a new DeviceInputSystem instance
  52292. * @param engine Engine to pull input element from
  52293. * @returns The new instance
  52294. */
  52295. static Create(engine: Engine): DeviceInputSystem;
  52296. /**
  52297. * Checks for current device input value, given an id and input index
  52298. * @param deviceName Id of connected device
  52299. * @param inputIndex Index of device input
  52300. * @returns Current value of input
  52301. */
  52302. /**
  52303. * Checks for current device input value, given an id and input index
  52304. * @param deviceType Enum specifiying device type
  52305. * @param deviceSlot "Slot" or index that device is referenced in
  52306. * @param inputIndex Id of input to be checked
  52307. * @returns Current value of input
  52308. */
  52309. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52310. /**
  52311. * Dispose of all the eventlisteners
  52312. */
  52313. dispose(): void;
  52314. /**
  52315. * Add device and inputs to device array
  52316. * @param deviceType Enum specifiying device type
  52317. * @param deviceSlot "Slot" or index that device is referenced in
  52318. * @param numberOfInputs Number of input entries to create for given device
  52319. */
  52320. private _registerDevice;
  52321. /**
  52322. * Given a specific device name, remove that device from the device map
  52323. * @param deviceType Enum specifiying device type
  52324. * @param deviceSlot "Slot" or index that device is referenced in
  52325. */
  52326. private _unregisterDevice;
  52327. /**
  52328. * Handle all actions that come from keyboard interaction
  52329. */
  52330. private _handleKeyActions;
  52331. /**
  52332. * Handle all actions that come from pointer interaction
  52333. */
  52334. private _handlePointerActions;
  52335. /**
  52336. * Handle all actions that come from gamepad interaction
  52337. */
  52338. private _handleGamepadActions;
  52339. /**
  52340. * Update all non-event based devices with each frame
  52341. * @param deviceType Enum specifiying device type
  52342. * @param deviceSlot "Slot" or index that device is referenced in
  52343. * @param inputIndex Id of input to be checked
  52344. */
  52345. private _updateDevice;
  52346. /**
  52347. * Gets DeviceType from the device name
  52348. * @param deviceName Name of Device from DeviceInputSystem
  52349. * @returns DeviceType enum value
  52350. */
  52351. private _getGamepadDeviceType;
  52352. }
  52353. }
  52354. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52355. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52356. /**
  52357. * Type to handle enforcement of inputs
  52358. */
  52359. 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;
  52360. }
  52361. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52362. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52363. import { Engine } from "babylonjs/Engines/engine";
  52364. import { IDisposable } from "babylonjs/scene";
  52365. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52366. import { Nullable } from "babylonjs/types";
  52367. import { Observable } from "babylonjs/Misc/observable";
  52368. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52369. /**
  52370. * Class that handles all input for a specific device
  52371. */
  52372. export class DeviceSource<T extends DeviceType> {
  52373. /** Type of device */
  52374. readonly deviceType: DeviceType;
  52375. /** "Slot" or index that device is referenced in */
  52376. readonly deviceSlot: number;
  52377. /**
  52378. * Observable to handle device input changes per device
  52379. */
  52380. readonly onInputChangedObservable: Observable<{
  52381. inputIndex: DeviceInput<T>;
  52382. previousState: Nullable<number>;
  52383. currentState: Nullable<number>;
  52384. }>;
  52385. private readonly _deviceInputSystem;
  52386. /**
  52387. * Default Constructor
  52388. * @param deviceInputSystem Reference to DeviceInputSystem
  52389. * @param deviceType Type of device
  52390. * @param deviceSlot "Slot" or index that device is referenced in
  52391. */
  52392. constructor(deviceInputSystem: DeviceInputSystem,
  52393. /** Type of device */
  52394. deviceType: DeviceType,
  52395. /** "Slot" or index that device is referenced in */
  52396. deviceSlot?: number);
  52397. /**
  52398. * Get input for specific input
  52399. * @param inputIndex index of specific input on device
  52400. * @returns Input value from DeviceInputSystem
  52401. */
  52402. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52403. }
  52404. /**
  52405. * Class to keep track of devices
  52406. */
  52407. export class DeviceSourceManager implements IDisposable {
  52408. /**
  52409. * Observable to be triggered when before a device is connected
  52410. */
  52411. readonly onBeforeDeviceConnectedObservable: Observable<{
  52412. deviceType: DeviceType;
  52413. deviceSlot: number;
  52414. }>;
  52415. /**
  52416. * Observable to be triggered when before a device is disconnected
  52417. */
  52418. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52419. deviceType: DeviceType;
  52420. deviceSlot: number;
  52421. }>;
  52422. /**
  52423. * Observable to be triggered when after a device is connected
  52424. */
  52425. readonly onAfterDeviceConnectedObservable: Observable<{
  52426. deviceType: DeviceType;
  52427. deviceSlot: number;
  52428. }>;
  52429. /**
  52430. * Observable to be triggered when after a device is disconnected
  52431. */
  52432. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52433. deviceType: DeviceType;
  52434. deviceSlot: number;
  52435. }>;
  52436. private readonly _devices;
  52437. private readonly _firstDevice;
  52438. private readonly _deviceInputSystem;
  52439. /**
  52440. * Default Constructor
  52441. * @param engine engine to pull input element from
  52442. */
  52443. constructor(engine: Engine);
  52444. /**
  52445. * Gets a DeviceSource, given a type and slot
  52446. * @param deviceType Enum specifying device type
  52447. * @param deviceSlot "Slot" or index that device is referenced in
  52448. * @returns DeviceSource object
  52449. */
  52450. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52451. /**
  52452. * Gets an array of DeviceSource objects for a given device type
  52453. * @param deviceType Enum specifying device type
  52454. * @returns Array of DeviceSource objects
  52455. */
  52456. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52457. /**
  52458. * Dispose of DeviceInputSystem and other parts
  52459. */
  52460. dispose(): void;
  52461. /**
  52462. * Function to add device name to device list
  52463. * @param deviceType Enum specifying device type
  52464. * @param deviceSlot "Slot" or index that device is referenced in
  52465. */
  52466. private _addDevice;
  52467. /**
  52468. * Function to remove device name to device list
  52469. * @param deviceType Enum specifying device type
  52470. * @param deviceSlot "Slot" or index that device is referenced in
  52471. */
  52472. private _removeDevice;
  52473. /**
  52474. * Updates array storing first connected device of each type
  52475. * @param type Type of Device
  52476. */
  52477. private _updateFirstDevices;
  52478. }
  52479. }
  52480. declare module "babylonjs/DeviceInput/index" {
  52481. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52482. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52483. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52484. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52485. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52486. }
  52487. declare module "babylonjs/Engines/nullEngine" {
  52488. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52489. import { Engine } from "babylonjs/Engines/engine";
  52490. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52492. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52493. import { Effect } from "babylonjs/Materials/effect";
  52494. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52495. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52496. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52497. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52498. /**
  52499. * Options to create the null engine
  52500. */
  52501. export class NullEngineOptions {
  52502. /**
  52503. * Render width (Default: 512)
  52504. */
  52505. renderWidth: number;
  52506. /**
  52507. * Render height (Default: 256)
  52508. */
  52509. renderHeight: number;
  52510. /**
  52511. * Texture size (Default: 512)
  52512. */
  52513. textureSize: number;
  52514. /**
  52515. * If delta time between frames should be constant
  52516. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52517. */
  52518. deterministicLockstep: boolean;
  52519. /**
  52520. * Maximum about of steps between frames (Default: 4)
  52521. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52522. */
  52523. lockstepMaxSteps: number;
  52524. }
  52525. /**
  52526. * The null engine class provides support for headless version of babylon.js.
  52527. * This can be used in server side scenario or for testing purposes
  52528. */
  52529. export class NullEngine extends Engine {
  52530. private _options;
  52531. /**
  52532. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52534. * @returns true if engine is in deterministic lock step mode
  52535. */
  52536. isDeterministicLockStep(): boolean;
  52537. /**
  52538. * Gets the max steps when engine is running in deterministic lock step
  52539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52540. * @returns the max steps
  52541. */
  52542. getLockstepMaxSteps(): number;
  52543. /**
  52544. * Gets the current hardware scaling level.
  52545. * By default the hardware scaling level is computed from the window device ratio.
  52546. * 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.
  52547. * @returns a number indicating the current hardware scaling level
  52548. */
  52549. getHardwareScalingLevel(): number;
  52550. constructor(options?: NullEngineOptions);
  52551. /**
  52552. * Creates a vertex buffer
  52553. * @param vertices the data for the vertex buffer
  52554. * @returns the new WebGL static buffer
  52555. */
  52556. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52557. /**
  52558. * Creates a new index buffer
  52559. * @param indices defines the content of the index buffer
  52560. * @param updatable defines if the index buffer must be updatable
  52561. * @returns a new webGL buffer
  52562. */
  52563. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52564. /**
  52565. * Clear the current render buffer or the current render target (if any is set up)
  52566. * @param color defines the color to use
  52567. * @param backBuffer defines if the back buffer must be cleared
  52568. * @param depth defines if the depth buffer must be cleared
  52569. * @param stencil defines if the stencil buffer must be cleared
  52570. */
  52571. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52572. /**
  52573. * Gets the current render width
  52574. * @param useScreen defines if screen size must be used (or the current render target if any)
  52575. * @returns a number defining the current render width
  52576. */
  52577. getRenderWidth(useScreen?: boolean): number;
  52578. /**
  52579. * Gets the current render height
  52580. * @param useScreen defines if screen size must be used (or the current render target if any)
  52581. * @returns a number defining the current render height
  52582. */
  52583. getRenderHeight(useScreen?: boolean): number;
  52584. /**
  52585. * Set the WebGL's viewport
  52586. * @param viewport defines the viewport element to be used
  52587. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52588. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52589. */
  52590. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52591. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52592. /**
  52593. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52594. * @param pipelineContext defines the pipeline context to use
  52595. * @param uniformsNames defines the list of uniform names
  52596. * @returns an array of webGL uniform locations
  52597. */
  52598. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52599. /**
  52600. * Gets the lsit of active attributes for a given webGL program
  52601. * @param pipelineContext defines the pipeline context to use
  52602. * @param attributesNames defines the list of attribute names to get
  52603. * @returns an array of indices indicating the offset of each attribute
  52604. */
  52605. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52606. /**
  52607. * Binds an effect to the webGL context
  52608. * @param effect defines the effect to bind
  52609. */
  52610. bindSamplers(effect: Effect): void;
  52611. /**
  52612. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52613. * @param effect defines the effect to activate
  52614. */
  52615. enableEffect(effect: Effect): void;
  52616. /**
  52617. * Set various states to the webGL context
  52618. * @param culling defines backface culling state
  52619. * @param zOffset defines the value to apply to zOffset (0 by default)
  52620. * @param force defines if states must be applied even if cache is up to date
  52621. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52622. */
  52623. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52624. /**
  52625. * Set the value of an uniform to an array of int32
  52626. * @param uniform defines the webGL uniform location where to store the value
  52627. * @param array defines the array of int32 to store
  52628. */
  52629. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52630. /**
  52631. * Set the value of an uniform to an array of int32 (stored as vec2)
  52632. * @param uniform defines the webGL uniform location where to store the value
  52633. * @param array defines the array of int32 to store
  52634. */
  52635. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52636. /**
  52637. * Set the value of an uniform to an array of int32 (stored as vec3)
  52638. * @param uniform defines the webGL uniform location where to store the value
  52639. * @param array defines the array of int32 to store
  52640. */
  52641. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52642. /**
  52643. * Set the value of an uniform to an array of int32 (stored as vec4)
  52644. * @param uniform defines the webGL uniform location where to store the value
  52645. * @param array defines the array of int32 to store
  52646. */
  52647. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52648. /**
  52649. * Set the value of an uniform to an array of float32
  52650. * @param uniform defines the webGL uniform location where to store the value
  52651. * @param array defines the array of float32 to store
  52652. */
  52653. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52654. /**
  52655. * Set the value of an uniform to an array of float32 (stored as vec2)
  52656. * @param uniform defines the webGL uniform location where to store the value
  52657. * @param array defines the array of float32 to store
  52658. */
  52659. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52660. /**
  52661. * Set the value of an uniform to an array of float32 (stored as vec3)
  52662. * @param uniform defines the webGL uniform location where to store the value
  52663. * @param array defines the array of float32 to store
  52664. */
  52665. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52666. /**
  52667. * Set the value of an uniform to an array of float32 (stored as vec4)
  52668. * @param uniform defines the webGL uniform location where to store the value
  52669. * @param array defines the array of float32 to store
  52670. */
  52671. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52672. /**
  52673. * Set the value of an uniform to an array of number
  52674. * @param uniform defines the webGL uniform location where to store the value
  52675. * @param array defines the array of number to store
  52676. */
  52677. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52678. /**
  52679. * Set the value of an uniform to an array of number (stored as vec2)
  52680. * @param uniform defines the webGL uniform location where to store the value
  52681. * @param array defines the array of number to store
  52682. */
  52683. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52684. /**
  52685. * Set the value of an uniform to an array of number (stored as vec3)
  52686. * @param uniform defines the webGL uniform location where to store the value
  52687. * @param array defines the array of number to store
  52688. */
  52689. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52690. /**
  52691. * Set the value of an uniform to an array of number (stored as vec4)
  52692. * @param uniform defines the webGL uniform location where to store the value
  52693. * @param array defines the array of number to store
  52694. */
  52695. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52696. /**
  52697. * Set the value of an uniform to an array of float32 (stored as matrices)
  52698. * @param uniform defines the webGL uniform location where to store the value
  52699. * @param matrices defines the array of float32 to store
  52700. */
  52701. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52702. /**
  52703. * Set the value of an uniform to a matrix (3x3)
  52704. * @param uniform defines the webGL uniform location where to store the value
  52705. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52706. */
  52707. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52708. /**
  52709. * Set the value of an uniform to a matrix (2x2)
  52710. * @param uniform defines the webGL uniform location where to store the value
  52711. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52712. */
  52713. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52714. /**
  52715. * Set the value of an uniform to a number (float)
  52716. * @param uniform defines the webGL uniform location where to store the value
  52717. * @param value defines the float number to store
  52718. */
  52719. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52720. /**
  52721. * Set the value of an uniform to a vec2
  52722. * @param uniform defines the webGL uniform location where to store the value
  52723. * @param x defines the 1st component of the value
  52724. * @param y defines the 2nd component of the value
  52725. */
  52726. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52727. /**
  52728. * Set the value of an uniform to a vec3
  52729. * @param uniform defines the webGL uniform location where to store the value
  52730. * @param x defines the 1st component of the value
  52731. * @param y defines the 2nd component of the value
  52732. * @param z defines the 3rd component of the value
  52733. */
  52734. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52735. /**
  52736. * Set the value of an uniform to a boolean
  52737. * @param uniform defines the webGL uniform location where to store the value
  52738. * @param bool defines the boolean to store
  52739. */
  52740. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52741. /**
  52742. * Set the value of an uniform to a vec4
  52743. * @param uniform defines the webGL uniform location where to store the value
  52744. * @param x defines the 1st component of the value
  52745. * @param y defines the 2nd component of the value
  52746. * @param z defines the 3rd component of the value
  52747. * @param w defines the 4th component of the value
  52748. */
  52749. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52750. /**
  52751. * Sets the current alpha mode
  52752. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52753. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52754. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52755. */
  52756. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52757. /**
  52758. * Bind webGl buffers directly to the webGL context
  52759. * @param vertexBuffers defines the vertex buffer to bind
  52760. * @param indexBuffer defines the index buffer to bind
  52761. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52762. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52763. * @param effect defines the effect associated with the vertex buffer
  52764. */
  52765. bindBuffers(vertexBuffers: {
  52766. [key: string]: VertexBuffer;
  52767. }, indexBuffer: DataBuffer, effect: Effect): void;
  52768. /**
  52769. * Force the entire cache to be cleared
  52770. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52771. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52772. */
  52773. wipeCaches(bruteForce?: boolean): void;
  52774. /**
  52775. * Send a draw order
  52776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52777. * @param indexStart defines the starting index
  52778. * @param indexCount defines the number of index to draw
  52779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52780. */
  52781. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52782. /**
  52783. * Draw a list of indexed primitives
  52784. * @param fillMode defines the primitive to use
  52785. * @param indexStart defines the starting index
  52786. * @param indexCount defines the number of index to draw
  52787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52788. */
  52789. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52790. /**
  52791. * Draw a list of unindexed primitives
  52792. * @param fillMode defines the primitive to use
  52793. * @param verticesStart defines the index of first vertex to draw
  52794. * @param verticesCount defines the count of vertices to draw
  52795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52796. */
  52797. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52798. /** @hidden */
  52799. _createTexture(): WebGLTexture;
  52800. /** @hidden */
  52801. _releaseTexture(texture: InternalTexture): void;
  52802. /**
  52803. * Usually called from Texture.ts.
  52804. * Passed information to create a WebGLTexture
  52805. * @param urlArg defines a value which contains one of the following:
  52806. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52807. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52808. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52810. * @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)
  52811. * @param scene needed for loading to the correct scene
  52812. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52813. * @param onLoad optional callback to be called upon successful completion
  52814. * @param onError optional callback to be called upon failure
  52815. * @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
  52816. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52817. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52818. * @param forcedExtension defines the extension to use to pick the right loader
  52819. * @param mimeType defines an optional mime type
  52820. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52821. */
  52822. 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;
  52823. /**
  52824. * Creates a new render target texture
  52825. * @param size defines the size of the texture
  52826. * @param options defines the options used to create the texture
  52827. * @returns a new render target texture stored in an InternalTexture
  52828. */
  52829. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52830. /**
  52831. * Update the sampling mode of a given texture
  52832. * @param samplingMode defines the required sampling mode
  52833. * @param texture defines the texture to update
  52834. */
  52835. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52836. /**
  52837. * Binds the frame buffer to the specified texture.
  52838. * @param texture The texture to render to or null for the default canvas
  52839. * @param faceIndex The face of the texture to render to in case of cube texture
  52840. * @param requiredWidth The width of the target to render to
  52841. * @param requiredHeight The height of the target to render to
  52842. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52843. * @param lodLevel defines le lod level to bind to the frame buffer
  52844. */
  52845. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52846. /**
  52847. * Unbind the current render target texture from the webGL context
  52848. * @param texture defines the render target texture to unbind
  52849. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52850. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52851. */
  52852. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52853. /**
  52854. * Creates a dynamic vertex buffer
  52855. * @param vertices the data for the dynamic vertex buffer
  52856. * @returns the new WebGL dynamic buffer
  52857. */
  52858. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52859. /**
  52860. * Update the content of a dynamic texture
  52861. * @param texture defines the texture to update
  52862. * @param canvas defines the canvas containing the source
  52863. * @param invertY defines if data must be stored with Y axis inverted
  52864. * @param premulAlpha defines if alpha is stored as premultiplied
  52865. * @param format defines the format of the data
  52866. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52867. */
  52868. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52869. /**
  52870. * Gets a boolean indicating if all created effects are ready
  52871. * @returns true if all effects are ready
  52872. */
  52873. areAllEffectsReady(): boolean;
  52874. /**
  52875. * @hidden
  52876. * Get the current error code of the webGL context
  52877. * @returns the error code
  52878. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52879. */
  52880. getError(): number;
  52881. /** @hidden */
  52882. _getUnpackAlignement(): number;
  52883. /** @hidden */
  52884. _unpackFlipY(value: boolean): void;
  52885. /**
  52886. * Update a dynamic index buffer
  52887. * @param indexBuffer defines the target index buffer
  52888. * @param indices defines the data to update
  52889. * @param offset defines the offset in the target index buffer where update should start
  52890. */
  52891. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52892. /**
  52893. * Updates a dynamic vertex buffer.
  52894. * @param vertexBuffer the vertex buffer to update
  52895. * @param vertices the data used to update the vertex buffer
  52896. * @param byteOffset the byte offset of the data (optional)
  52897. * @param byteLength the byte length of the data (optional)
  52898. */
  52899. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52900. /** @hidden */
  52901. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52902. /** @hidden */
  52903. _bindTexture(channel: number, texture: InternalTexture): void;
  52904. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52905. /**
  52906. * 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
  52907. */
  52908. releaseEffects(): void;
  52909. displayLoadingUI(): void;
  52910. hideLoadingUI(): void;
  52911. /** @hidden */
  52912. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52913. /** @hidden */
  52914. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52915. /** @hidden */
  52916. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52917. /** @hidden */
  52918. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52919. }
  52920. }
  52921. declare module "babylonjs/Instrumentation/timeToken" {
  52922. import { Nullable } from "babylonjs/types";
  52923. /**
  52924. * @hidden
  52925. **/
  52926. export class _TimeToken {
  52927. _startTimeQuery: Nullable<WebGLQuery>;
  52928. _endTimeQuery: Nullable<WebGLQuery>;
  52929. _timeElapsedQuery: Nullable<WebGLQuery>;
  52930. _timeElapsedQueryEnded: boolean;
  52931. }
  52932. }
  52933. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52934. import { Nullable, int } from "babylonjs/types";
  52935. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52936. /** @hidden */
  52937. export class _OcclusionDataStorage {
  52938. /** @hidden */
  52939. occlusionInternalRetryCounter: number;
  52940. /** @hidden */
  52941. isOcclusionQueryInProgress: boolean;
  52942. /** @hidden */
  52943. isOccluded: boolean;
  52944. /** @hidden */
  52945. occlusionRetryCount: number;
  52946. /** @hidden */
  52947. occlusionType: number;
  52948. /** @hidden */
  52949. occlusionQueryAlgorithmType: number;
  52950. }
  52951. module "babylonjs/Engines/engine" {
  52952. interface Engine {
  52953. /**
  52954. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52955. * @return the new query
  52956. */
  52957. createQuery(): WebGLQuery;
  52958. /**
  52959. * Delete and release a webGL query
  52960. * @param query defines the query to delete
  52961. * @return the current engine
  52962. */
  52963. deleteQuery(query: WebGLQuery): Engine;
  52964. /**
  52965. * Check if a given query has resolved and got its value
  52966. * @param query defines the query to check
  52967. * @returns true if the query got its value
  52968. */
  52969. isQueryResultAvailable(query: WebGLQuery): boolean;
  52970. /**
  52971. * Gets the value of a given query
  52972. * @param query defines the query to check
  52973. * @returns the value of the query
  52974. */
  52975. getQueryResult(query: WebGLQuery): number;
  52976. /**
  52977. * Initiates an occlusion query
  52978. * @param algorithmType defines the algorithm to use
  52979. * @param query defines the query to use
  52980. * @returns the current engine
  52981. * @see http://doc.babylonjs.com/features/occlusionquery
  52982. */
  52983. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52984. /**
  52985. * Ends an occlusion query
  52986. * @see http://doc.babylonjs.com/features/occlusionquery
  52987. * @param algorithmType defines the algorithm to use
  52988. * @returns the current engine
  52989. */
  52990. endOcclusionQuery(algorithmType: number): Engine;
  52991. /**
  52992. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52993. * Please note that only one query can be issued at a time
  52994. * @returns a time token used to track the time span
  52995. */
  52996. startTimeQuery(): Nullable<_TimeToken>;
  52997. /**
  52998. * Ends a time query
  52999. * @param token defines the token used to measure the time span
  53000. * @returns the time spent (in ns)
  53001. */
  53002. endTimeQuery(token: _TimeToken): int;
  53003. /** @hidden */
  53004. _currentNonTimestampToken: Nullable<_TimeToken>;
  53005. /** @hidden */
  53006. _createTimeQuery(): WebGLQuery;
  53007. /** @hidden */
  53008. _deleteTimeQuery(query: WebGLQuery): void;
  53009. /** @hidden */
  53010. _getGlAlgorithmType(algorithmType: number): number;
  53011. /** @hidden */
  53012. _getTimeQueryResult(query: WebGLQuery): any;
  53013. /** @hidden */
  53014. _getTimeQueryAvailability(query: WebGLQuery): any;
  53015. }
  53016. }
  53017. module "babylonjs/Meshes/abstractMesh" {
  53018. interface AbstractMesh {
  53019. /**
  53020. * Backing filed
  53021. * @hidden
  53022. */
  53023. __occlusionDataStorage: _OcclusionDataStorage;
  53024. /**
  53025. * Access property
  53026. * @hidden
  53027. */
  53028. _occlusionDataStorage: _OcclusionDataStorage;
  53029. /**
  53030. * 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.
  53031. * The default value is -1 which means don't break the query and wait till the result
  53032. * @see http://doc.babylonjs.com/features/occlusionquery
  53033. */
  53034. occlusionRetryCount: number;
  53035. /**
  53036. * 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:
  53037. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53038. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53039. * * 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.
  53040. * @see http://doc.babylonjs.com/features/occlusionquery
  53041. */
  53042. occlusionType: number;
  53043. /**
  53044. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53045. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53046. * * 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.
  53047. * @see http://doc.babylonjs.com/features/occlusionquery
  53048. */
  53049. occlusionQueryAlgorithmType: number;
  53050. /**
  53051. * 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
  53052. * @see http://doc.babylonjs.com/features/occlusionquery
  53053. */
  53054. isOccluded: boolean;
  53055. /**
  53056. * Flag to check the progress status of the query
  53057. * @see http://doc.babylonjs.com/features/occlusionquery
  53058. */
  53059. isOcclusionQueryInProgress: boolean;
  53060. }
  53061. }
  53062. }
  53063. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53064. import { Nullable } from "babylonjs/types";
  53065. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53066. /** @hidden */
  53067. export var _forceTransformFeedbackToBundle: boolean;
  53068. module "babylonjs/Engines/engine" {
  53069. interface Engine {
  53070. /**
  53071. * Creates a webGL transform feedback object
  53072. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53073. * @returns the webGL transform feedback object
  53074. */
  53075. createTransformFeedback(): WebGLTransformFeedback;
  53076. /**
  53077. * Delete a webGL transform feedback object
  53078. * @param value defines the webGL transform feedback object to delete
  53079. */
  53080. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53081. /**
  53082. * Bind a webGL transform feedback object to the webgl context
  53083. * @param value defines the webGL transform feedback object to bind
  53084. */
  53085. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53086. /**
  53087. * Begins a transform feedback operation
  53088. * @param usePoints defines if points or triangles must be used
  53089. */
  53090. beginTransformFeedback(usePoints: boolean): void;
  53091. /**
  53092. * Ends a transform feedback operation
  53093. */
  53094. endTransformFeedback(): void;
  53095. /**
  53096. * Specify the varyings to use with transform feedback
  53097. * @param program defines the associated webGL program
  53098. * @param value defines the list of strings representing the varying names
  53099. */
  53100. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53101. /**
  53102. * Bind a webGL buffer for a transform feedback operation
  53103. * @param value defines the webGL buffer to bind
  53104. */
  53105. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53106. }
  53107. }
  53108. }
  53109. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53110. import { Scene } from "babylonjs/scene";
  53111. import { Engine } from "babylonjs/Engines/engine";
  53112. import { Texture } from "babylonjs/Materials/Textures/texture";
  53113. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53114. import "babylonjs/Engines/Extensions/engine.multiRender";
  53115. /**
  53116. * Creation options of the multi render target texture.
  53117. */
  53118. export interface IMultiRenderTargetOptions {
  53119. /**
  53120. * Define if the texture needs to create mip maps after render.
  53121. */
  53122. generateMipMaps?: boolean;
  53123. /**
  53124. * Define the types of all the draw buffers we want to create
  53125. */
  53126. types?: number[];
  53127. /**
  53128. * Define the sampling modes of all the draw buffers we want to create
  53129. */
  53130. samplingModes?: number[];
  53131. /**
  53132. * Define if a depth buffer is required
  53133. */
  53134. generateDepthBuffer?: boolean;
  53135. /**
  53136. * Define if a stencil buffer is required
  53137. */
  53138. generateStencilBuffer?: boolean;
  53139. /**
  53140. * Define if a depth texture is required instead of a depth buffer
  53141. */
  53142. generateDepthTexture?: boolean;
  53143. /**
  53144. * Define the number of desired draw buffers
  53145. */
  53146. textureCount?: number;
  53147. /**
  53148. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53149. */
  53150. doNotChangeAspectRatio?: boolean;
  53151. /**
  53152. * Define the default type of the buffers we are creating
  53153. */
  53154. defaultType?: number;
  53155. }
  53156. /**
  53157. * A multi render target, like a render target provides the ability to render to a texture.
  53158. * Unlike the render target, it can render to several draw buffers in one draw.
  53159. * This is specially interesting in deferred rendering or for any effects requiring more than
  53160. * just one color from a single pass.
  53161. */
  53162. export class MultiRenderTarget extends RenderTargetTexture {
  53163. private _internalTextures;
  53164. private _textures;
  53165. private _multiRenderTargetOptions;
  53166. /**
  53167. * Get if draw buffers are currently supported by the used hardware and browser.
  53168. */
  53169. get isSupported(): boolean;
  53170. /**
  53171. * Get the list of textures generated by the multi render target.
  53172. */
  53173. get textures(): Texture[];
  53174. /**
  53175. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53176. */
  53177. get depthTexture(): Texture;
  53178. /**
  53179. * Set the wrapping mode on U of all the textures we are rendering to.
  53180. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53181. */
  53182. set wrapU(wrap: number);
  53183. /**
  53184. * Set the wrapping mode on V of all the textures we are rendering to.
  53185. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53186. */
  53187. set wrapV(wrap: number);
  53188. /**
  53189. * Instantiate a new multi render target texture.
  53190. * A multi render target, like a render target provides the ability to render to a texture.
  53191. * Unlike the render target, it can render to several draw buffers in one draw.
  53192. * This is specially interesting in deferred rendering or for any effects requiring more than
  53193. * just one color from a single pass.
  53194. * @param name Define the name of the texture
  53195. * @param size Define the size of the buffers to render to
  53196. * @param count Define the number of target we are rendering into
  53197. * @param scene Define the scene the texture belongs to
  53198. * @param options Define the options used to create the multi render target
  53199. */
  53200. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53201. /** @hidden */
  53202. _rebuild(): void;
  53203. private _createInternalTextures;
  53204. private _createTextures;
  53205. /**
  53206. * Define the number of samples used if MSAA is enabled.
  53207. */
  53208. get samples(): number;
  53209. set samples(value: number);
  53210. /**
  53211. * Resize all the textures in the multi render target.
  53212. * Be carrefull as it will recreate all the data in the new texture.
  53213. * @param size Define the new size
  53214. */
  53215. resize(size: any): void;
  53216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53217. /**
  53218. * Dispose the render targets and their associated resources
  53219. */
  53220. dispose(): void;
  53221. /**
  53222. * Release all the underlying texture used as draw buffers.
  53223. */
  53224. releaseInternalTextures(): void;
  53225. }
  53226. }
  53227. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53229. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53230. import { Nullable } from "babylonjs/types";
  53231. module "babylonjs/Engines/thinEngine" {
  53232. interface ThinEngine {
  53233. /**
  53234. * Unbind a list of render target textures from the webGL context
  53235. * This is used only when drawBuffer extension or webGL2 are active
  53236. * @param textures defines the render target textures to unbind
  53237. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53238. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53239. */
  53240. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53241. /**
  53242. * Create a multi render target texture
  53243. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  53244. * @param size defines the size of the texture
  53245. * @param options defines the creation options
  53246. * @returns the cube texture as an InternalTexture
  53247. */
  53248. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53249. /**
  53250. * Update the sample count for a given multiple render target texture
  53251. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53252. * @param textures defines the textures to update
  53253. * @param samples defines the sample count to set
  53254. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53255. */
  53256. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53257. }
  53258. }
  53259. }
  53260. declare module "babylonjs/Engines/Extensions/engine.views" {
  53261. import { Camera } from "babylonjs/Cameras/camera";
  53262. import { Nullable } from "babylonjs/types";
  53263. /**
  53264. * Class used to define an additional view for the engine
  53265. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53266. */
  53267. export class EngineView {
  53268. /** Defines the canvas where to render the view */
  53269. target: HTMLCanvasElement;
  53270. /** Defines an optional camera used to render the view (will use active camera else) */
  53271. camera?: Camera;
  53272. }
  53273. module "babylonjs/Engines/engine" {
  53274. interface Engine {
  53275. /**
  53276. * Gets or sets the HTML element to use for attaching events
  53277. */
  53278. inputElement: Nullable<HTMLElement>;
  53279. /**
  53280. * Gets the current engine view
  53281. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53282. */
  53283. activeView: Nullable<EngineView>;
  53284. /** Gets or sets the list of views */
  53285. views: EngineView[];
  53286. /**
  53287. * Register a new child canvas
  53288. * @param canvas defines the canvas to register
  53289. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53290. * @returns the associated view
  53291. */
  53292. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53293. /**
  53294. * Remove a registered child canvas
  53295. * @param canvas defines the canvas to remove
  53296. * @returns the current engine
  53297. */
  53298. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53299. }
  53300. }
  53301. }
  53302. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53303. import { Nullable } from "babylonjs/types";
  53304. module "babylonjs/Engines/engine" {
  53305. interface Engine {
  53306. /** @hidden */
  53307. _excludedCompressedTextures: string[];
  53308. /** @hidden */
  53309. _textureFormatInUse: string;
  53310. /**
  53311. * Gets the list of texture formats supported
  53312. */
  53313. readonly texturesSupported: Array<string>;
  53314. /**
  53315. * Gets the texture format in use
  53316. */
  53317. readonly textureFormatInUse: Nullable<string>;
  53318. /**
  53319. * Set the compressed texture extensions or file names to skip.
  53320. *
  53321. * @param skippedFiles defines the list of those texture files you want to skip
  53322. * Example: [".dds", ".env", "myfile.png"]
  53323. */
  53324. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53325. /**
  53326. * Set the compressed texture format to use, based on the formats you have, and the formats
  53327. * supported by the hardware / browser.
  53328. *
  53329. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53330. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53331. * to API arguments needed to compressed textures. This puts the burden on the container
  53332. * generator to house the arcane code for determining these for current & future formats.
  53333. *
  53334. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53335. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53336. *
  53337. * Note: The result of this call is not taken into account when a texture is base64.
  53338. *
  53339. * @param formatsAvailable defines the list of those format families you have created
  53340. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53341. *
  53342. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53343. * @returns The extension selected.
  53344. */
  53345. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53346. }
  53347. }
  53348. }
  53349. declare module "babylonjs/Engines/Extensions/index" {
  53350. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53351. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53352. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53353. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53354. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53355. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53356. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53357. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53358. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53359. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53360. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53361. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53362. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53363. export * from "babylonjs/Engines/Extensions/engine.views";
  53364. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53365. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53366. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53367. }
  53368. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53369. import { Nullable } from "babylonjs/types";
  53370. /**
  53371. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53372. */
  53373. export interface CubeMapInfo {
  53374. /**
  53375. * The pixel array for the front face.
  53376. * This is stored in format, left to right, up to down format.
  53377. */
  53378. front: Nullable<ArrayBufferView>;
  53379. /**
  53380. * The pixel array for the back face.
  53381. * This is stored in format, left to right, up to down format.
  53382. */
  53383. back: Nullable<ArrayBufferView>;
  53384. /**
  53385. * The pixel array for the left face.
  53386. * This is stored in format, left to right, up to down format.
  53387. */
  53388. left: Nullable<ArrayBufferView>;
  53389. /**
  53390. * The pixel array for the right face.
  53391. * This is stored in format, left to right, up to down format.
  53392. */
  53393. right: Nullable<ArrayBufferView>;
  53394. /**
  53395. * The pixel array for the up face.
  53396. * This is stored in format, left to right, up to down format.
  53397. */
  53398. up: Nullable<ArrayBufferView>;
  53399. /**
  53400. * The pixel array for the down face.
  53401. * This is stored in format, left to right, up to down format.
  53402. */
  53403. down: Nullable<ArrayBufferView>;
  53404. /**
  53405. * The size of the cubemap stored.
  53406. *
  53407. * Each faces will be size * size pixels.
  53408. */
  53409. size: number;
  53410. /**
  53411. * The format of the texture.
  53412. *
  53413. * RGBA, RGB.
  53414. */
  53415. format: number;
  53416. /**
  53417. * The type of the texture data.
  53418. *
  53419. * UNSIGNED_INT, FLOAT.
  53420. */
  53421. type: number;
  53422. /**
  53423. * Specifies whether the texture is in gamma space.
  53424. */
  53425. gammaSpace: boolean;
  53426. }
  53427. /**
  53428. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53429. */
  53430. export class PanoramaToCubeMapTools {
  53431. private static FACE_LEFT;
  53432. private static FACE_RIGHT;
  53433. private static FACE_FRONT;
  53434. private static FACE_BACK;
  53435. private static FACE_DOWN;
  53436. private static FACE_UP;
  53437. /**
  53438. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53439. *
  53440. * @param float32Array The source data.
  53441. * @param inputWidth The width of the input panorama.
  53442. * @param inputHeight The height of the input panorama.
  53443. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53444. * @return The cubemap data
  53445. */
  53446. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53447. private static CreateCubemapTexture;
  53448. private static CalcProjectionSpherical;
  53449. }
  53450. }
  53451. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53452. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53454. import { Nullable } from "babylonjs/types";
  53455. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53456. /**
  53457. * Helper class dealing with the extraction of spherical polynomial dataArray
  53458. * from a cube map.
  53459. */
  53460. export class CubeMapToSphericalPolynomialTools {
  53461. private static FileFaces;
  53462. /**
  53463. * Converts a texture to the according Spherical Polynomial data.
  53464. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53465. *
  53466. * @param texture The texture to extract the information from.
  53467. * @return The Spherical Polynomial data.
  53468. */
  53469. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53470. /**
  53471. * Converts a cubemap to the according Spherical Polynomial data.
  53472. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53473. *
  53474. * @param cubeInfo The Cube map to extract the information from.
  53475. * @return The Spherical Polynomial data.
  53476. */
  53477. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53478. }
  53479. }
  53480. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53481. import { Nullable } from "babylonjs/types";
  53482. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53483. module "babylonjs/Materials/Textures/baseTexture" {
  53484. interface BaseTexture {
  53485. /**
  53486. * Get the polynomial representation of the texture data.
  53487. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53488. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53489. */
  53490. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53491. }
  53492. }
  53493. }
  53494. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53496. /** @hidden */
  53497. export var rgbdEncodePixelShader: {
  53498. name: string;
  53499. shader: string;
  53500. };
  53501. }
  53502. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53504. /** @hidden */
  53505. export var rgbdDecodePixelShader: {
  53506. name: string;
  53507. shader: string;
  53508. };
  53509. }
  53510. declare module "babylonjs/Misc/environmentTextureTools" {
  53511. import { Nullable } from "babylonjs/types";
  53512. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53515. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53516. import "babylonjs/Engines/Extensions/engine.readTexture";
  53517. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53518. import "babylonjs/Shaders/rgbdEncode.fragment";
  53519. import "babylonjs/Shaders/rgbdDecode.fragment";
  53520. /**
  53521. * Raw texture data and descriptor sufficient for WebGL texture upload
  53522. */
  53523. export interface EnvironmentTextureInfo {
  53524. /**
  53525. * Version of the environment map
  53526. */
  53527. version: number;
  53528. /**
  53529. * Width of image
  53530. */
  53531. width: number;
  53532. /**
  53533. * Irradiance information stored in the file.
  53534. */
  53535. irradiance: any;
  53536. /**
  53537. * Specular information stored in the file.
  53538. */
  53539. specular: any;
  53540. }
  53541. /**
  53542. * Defines One Image in the file. It requires only the position in the file
  53543. * as well as the length.
  53544. */
  53545. interface BufferImageData {
  53546. /**
  53547. * Length of the image data.
  53548. */
  53549. length: number;
  53550. /**
  53551. * Position of the data from the null terminator delimiting the end of the JSON.
  53552. */
  53553. position: number;
  53554. }
  53555. /**
  53556. * Defines the specular data enclosed in the file.
  53557. * This corresponds to the version 1 of the data.
  53558. */
  53559. export interface EnvironmentTextureSpecularInfoV1 {
  53560. /**
  53561. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53562. */
  53563. specularDataPosition?: number;
  53564. /**
  53565. * This contains all the images data needed to reconstruct the cubemap.
  53566. */
  53567. mipmaps: Array<BufferImageData>;
  53568. /**
  53569. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53570. */
  53571. lodGenerationScale: number;
  53572. }
  53573. /**
  53574. * Sets of helpers addressing the serialization and deserialization of environment texture
  53575. * stored in a BabylonJS env file.
  53576. * Those files are usually stored as .env files.
  53577. */
  53578. export class EnvironmentTextureTools {
  53579. /**
  53580. * Magic number identifying the env file.
  53581. */
  53582. private static _MagicBytes;
  53583. /**
  53584. * Gets the environment info from an env file.
  53585. * @param data The array buffer containing the .env bytes.
  53586. * @returns the environment file info (the json header) if successfully parsed.
  53587. */
  53588. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53589. /**
  53590. * Creates an environment texture from a loaded cube texture.
  53591. * @param texture defines the cube texture to convert in env file
  53592. * @return a promise containing the environment data if succesfull.
  53593. */
  53594. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53595. /**
  53596. * Creates a JSON representation of the spherical data.
  53597. * @param texture defines the texture containing the polynomials
  53598. * @return the JSON representation of the spherical info
  53599. */
  53600. private static _CreateEnvTextureIrradiance;
  53601. /**
  53602. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53603. * @param data the image data
  53604. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53605. * @return the views described by info providing access to the underlying buffer
  53606. */
  53607. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53608. /**
  53609. * Uploads the texture info contained in the env file to the GPU.
  53610. * @param texture defines the internal texture to upload to
  53611. * @param data defines the data to load
  53612. * @param info defines the texture info retrieved through the GetEnvInfo method
  53613. * @returns a promise
  53614. */
  53615. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53616. private static _OnImageReadyAsync;
  53617. /**
  53618. * Uploads the levels of image data to the GPU.
  53619. * @param texture defines the internal texture to upload to
  53620. * @param imageData defines the array buffer views of image data [mipmap][face]
  53621. * @returns a promise
  53622. */
  53623. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53624. /**
  53625. * Uploads spherical polynomials information to the texture.
  53626. * @param texture defines the texture we are trying to upload the information to
  53627. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53628. */
  53629. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53630. /** @hidden */
  53631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53632. }
  53633. }
  53634. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53635. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53636. /** @hidden */
  53637. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53638. private _genericAttributeLocation;
  53639. private _varyingLocationCount;
  53640. private _varyingLocationMap;
  53641. private _replacements;
  53642. private _textureCount;
  53643. private _uniforms;
  53644. lineProcessor(line: string): string;
  53645. attributeProcessor(attribute: string): string;
  53646. varyingProcessor(varying: string, isFragment: boolean): string;
  53647. uniformProcessor(uniform: string): string;
  53648. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53649. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53650. }
  53651. }
  53652. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53653. /**
  53654. * Class used to inline functions in shader code
  53655. */
  53656. export class ShaderCodeInliner {
  53657. private static readonly _RegexpFindFunctionNameAndType;
  53658. private _sourceCode;
  53659. private _functionDescr;
  53660. private _numMaxIterations;
  53661. /** Gets or sets the token used to mark the functions to inline */
  53662. inlineToken: string;
  53663. /** Gets or sets the debug mode */
  53664. debug: boolean;
  53665. /** Gets the code after the inlining process */
  53666. get code(): string;
  53667. /**
  53668. * Initializes the inliner
  53669. * @param sourceCode shader code source to inline
  53670. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53671. */
  53672. constructor(sourceCode: string, numMaxIterations?: number);
  53673. /**
  53674. * Start the processing of the shader code
  53675. */
  53676. processCode(): void;
  53677. private _collectFunctions;
  53678. private _processInlining;
  53679. private _extractBetweenMarkers;
  53680. private _skipWhitespaces;
  53681. private _removeComments;
  53682. private _replaceFunctionCallsByCode;
  53683. private _findBackward;
  53684. private _escapeRegExp;
  53685. private _replaceNames;
  53686. }
  53687. }
  53688. declare module "babylonjs/Engines/nativeEngine" {
  53689. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53690. import { Engine } from "babylonjs/Engines/engine";
  53691. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53693. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53694. import { Effect } from "babylonjs/Materials/effect";
  53695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53696. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53697. import { IColor4Like } from "babylonjs/Maths/math.like";
  53698. import { Scene } from "babylonjs/scene";
  53699. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53700. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53701. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53702. /**
  53703. * Container for accessors for natively-stored mesh data buffers.
  53704. */
  53705. class NativeDataBuffer extends DataBuffer {
  53706. /**
  53707. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53708. */
  53709. nativeIndexBuffer?: any;
  53710. /**
  53711. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53712. */
  53713. nativeVertexBuffer?: any;
  53714. }
  53715. /** @hidden */
  53716. class NativeTexture extends InternalTexture {
  53717. getInternalTexture(): InternalTexture;
  53718. getViewCount(): number;
  53719. }
  53720. /** @hidden */
  53721. export class NativeEngine extends Engine {
  53722. private readonly _native;
  53723. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53724. private readonly INVALID_HANDLE;
  53725. getHardwareScalingLevel(): number;
  53726. constructor();
  53727. dispose(): void;
  53728. /**
  53729. * Can be used to override the current requestAnimationFrame requester.
  53730. * @hidden
  53731. */
  53732. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53733. /**
  53734. * Override default engine behavior.
  53735. * @param color
  53736. * @param backBuffer
  53737. * @param depth
  53738. * @param stencil
  53739. */
  53740. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53741. /**
  53742. * Gets host document
  53743. * @returns the host document object
  53744. */
  53745. getHostDocument(): Nullable<Document>;
  53746. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53747. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53748. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53749. recordVertexArrayObject(vertexBuffers: {
  53750. [key: string]: VertexBuffer;
  53751. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53752. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53753. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53754. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53755. /**
  53756. * Draw a list of indexed primitives
  53757. * @param fillMode defines the primitive to use
  53758. * @param indexStart defines the starting index
  53759. * @param indexCount defines the number of index to draw
  53760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53761. */
  53762. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53763. /**
  53764. * Draw a list of unindexed primitives
  53765. * @param fillMode defines the primitive to use
  53766. * @param verticesStart defines the index of first vertex to draw
  53767. * @param verticesCount defines the count of vertices to draw
  53768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53769. */
  53770. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53771. createPipelineContext(): IPipelineContext;
  53772. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53773. /** @hidden */
  53774. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53775. /** @hidden */
  53776. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53777. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53778. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53779. protected _setProgram(program: WebGLProgram): void;
  53780. _releaseEffect(effect: Effect): void;
  53781. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53782. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53783. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53784. bindSamplers(effect: Effect): void;
  53785. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53786. getRenderWidth(useScreen?: boolean): number;
  53787. getRenderHeight(useScreen?: boolean): number;
  53788. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53789. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53790. /**
  53791. * Set the z offset to apply to current rendering
  53792. * @param value defines the offset to apply
  53793. */
  53794. setZOffset(value: number): void;
  53795. /**
  53796. * Gets the current value of the zOffset
  53797. * @returns the current zOffset state
  53798. */
  53799. getZOffset(): number;
  53800. /**
  53801. * Enable or disable depth buffering
  53802. * @param enable defines the state to set
  53803. */
  53804. setDepthBuffer(enable: boolean): void;
  53805. /**
  53806. * Gets a boolean indicating if depth writing is enabled
  53807. * @returns the current depth writing state
  53808. */
  53809. getDepthWrite(): boolean;
  53810. /**
  53811. * Enable or disable depth writing
  53812. * @param enable defines the state to set
  53813. */
  53814. setDepthWrite(enable: boolean): void;
  53815. /**
  53816. * Enable or disable color writing
  53817. * @param enable defines the state to set
  53818. */
  53819. setColorWrite(enable: boolean): void;
  53820. /**
  53821. * Gets a boolean indicating if color writing is enabled
  53822. * @returns the current color writing state
  53823. */
  53824. getColorWrite(): boolean;
  53825. /**
  53826. * Sets alpha constants used by some alpha blending modes
  53827. * @param r defines the red component
  53828. * @param g defines the green component
  53829. * @param b defines the blue component
  53830. * @param a defines the alpha component
  53831. */
  53832. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53833. /**
  53834. * Sets the current alpha mode
  53835. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53836. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53837. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53838. */
  53839. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53840. /**
  53841. * Gets the current alpha mode
  53842. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53843. * @returns the current alpha mode
  53844. */
  53845. getAlphaMode(): number;
  53846. setInt(uniform: WebGLUniformLocation, int: number): void;
  53847. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53848. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53849. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53850. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53851. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53852. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53853. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53854. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53855. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53856. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53857. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53858. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53859. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53860. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53861. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53862. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53863. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53864. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53865. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53866. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53867. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53868. wipeCaches(bruteForce?: boolean): void;
  53869. _createTexture(): WebGLTexture;
  53870. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53871. /**
  53872. * Usually called from Texture.ts.
  53873. * Passed information to create a WebGLTexture
  53874. * @param url defines a value which contains one of the following:
  53875. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53876. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53877. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53879. * @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)
  53880. * @param scene needed for loading to the correct scene
  53881. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53882. * @param onLoad optional callback to be called upon successful completion
  53883. * @param onError optional callback to be called upon failure
  53884. * @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
  53885. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53886. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53887. * @param forcedExtension defines the extension to use to pick the right loader
  53888. * @param mimeType defines an optional mime type
  53889. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53890. */
  53891. 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;
  53892. /**
  53893. * Creates a cube texture
  53894. * @param rootUrl defines the url where the files to load is located
  53895. * @param scene defines the current scene
  53896. * @param files defines the list of files to load (1 per face)
  53897. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53898. * @param onLoad defines an optional callback raised when the texture is loaded
  53899. * @param onError defines an optional callback raised if there is an issue to load the texture
  53900. * @param format defines the format of the data
  53901. * @param forcedExtension defines the extension to use to pick the right loader
  53902. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53903. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53904. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53905. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53906. * @returns the cube texture as an InternalTexture
  53907. */
  53908. 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;
  53909. private _getSamplingFilter;
  53910. private static _GetNativeTextureFormat;
  53911. createRenderTargetTexture(size: number | {
  53912. width: number;
  53913. height: number;
  53914. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53915. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53916. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53917. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53918. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53919. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53920. /**
  53921. * Updates a dynamic vertex buffer.
  53922. * @param vertexBuffer the vertex buffer to update
  53923. * @param data the data used to update the vertex buffer
  53924. * @param byteOffset the byte offset of the data (optional)
  53925. * @param byteLength the byte length of the data (optional)
  53926. */
  53927. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53928. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53929. private _updateAnisotropicLevel;
  53930. private _getAddressMode;
  53931. /** @hidden */
  53932. _bindTexture(channel: number, texture: InternalTexture): void;
  53933. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53934. releaseEffects(): void;
  53935. /** @hidden */
  53936. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53937. /** @hidden */
  53938. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53939. /** @hidden */
  53940. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53941. /** @hidden */
  53942. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53943. }
  53944. }
  53945. declare module "babylonjs/Engines/index" {
  53946. export * from "babylonjs/Engines/constants";
  53947. export * from "babylonjs/Engines/engineCapabilities";
  53948. export * from "babylonjs/Engines/instancingAttributeInfo";
  53949. export * from "babylonjs/Engines/thinEngine";
  53950. export * from "babylonjs/Engines/engine";
  53951. export * from "babylonjs/Engines/engineStore";
  53952. export * from "babylonjs/Engines/nullEngine";
  53953. export * from "babylonjs/Engines/Extensions/index";
  53954. export * from "babylonjs/Engines/IPipelineContext";
  53955. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53956. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53957. export * from "babylonjs/Engines/nativeEngine";
  53958. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53959. }
  53960. declare module "babylonjs/Events/clipboardEvents" {
  53961. /**
  53962. * Gather the list of clipboard event types as constants.
  53963. */
  53964. export class ClipboardEventTypes {
  53965. /**
  53966. * The clipboard event is fired when a copy command is active (pressed).
  53967. */
  53968. static readonly COPY: number;
  53969. /**
  53970. * The clipboard event is fired when a cut command is active (pressed).
  53971. */
  53972. static readonly CUT: number;
  53973. /**
  53974. * The clipboard event is fired when a paste command is active (pressed).
  53975. */
  53976. static readonly PASTE: number;
  53977. }
  53978. /**
  53979. * This class is used to store clipboard related info for the onClipboardObservable event.
  53980. */
  53981. export class ClipboardInfo {
  53982. /**
  53983. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53984. */
  53985. type: number;
  53986. /**
  53987. * Defines the related dom event
  53988. */
  53989. event: ClipboardEvent;
  53990. /**
  53991. *Creates an instance of ClipboardInfo.
  53992. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53993. * @param event Defines the related dom event
  53994. */
  53995. constructor(
  53996. /**
  53997. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53998. */
  53999. type: number,
  54000. /**
  54001. * Defines the related dom event
  54002. */
  54003. event: ClipboardEvent);
  54004. /**
  54005. * Get the clipboard event's type from the keycode.
  54006. * @param keyCode Defines the keyCode for the current keyboard event.
  54007. * @return {number}
  54008. */
  54009. static GetTypeFromCharacter(keyCode: number): number;
  54010. }
  54011. }
  54012. declare module "babylonjs/Events/index" {
  54013. export * from "babylonjs/Events/keyboardEvents";
  54014. export * from "babylonjs/Events/pointerEvents";
  54015. export * from "babylonjs/Events/clipboardEvents";
  54016. }
  54017. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54018. import { Scene } from "babylonjs/scene";
  54019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54020. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54021. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54022. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54023. /**
  54024. * Google Daydream controller
  54025. */
  54026. export class DaydreamController extends WebVRController {
  54027. /**
  54028. * Base Url for the controller model.
  54029. */
  54030. static MODEL_BASE_URL: string;
  54031. /**
  54032. * File name for the controller model.
  54033. */
  54034. static MODEL_FILENAME: string;
  54035. /**
  54036. * Gamepad Id prefix used to identify Daydream Controller.
  54037. */
  54038. static readonly GAMEPAD_ID_PREFIX: string;
  54039. /**
  54040. * Creates a new DaydreamController from a gamepad
  54041. * @param vrGamepad the gamepad that the controller should be created from
  54042. */
  54043. constructor(vrGamepad: any);
  54044. /**
  54045. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54046. * @param scene scene in which to add meshes
  54047. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54048. */
  54049. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54050. /**
  54051. * Called once for each button that changed state since the last frame
  54052. * @param buttonIdx Which button index changed
  54053. * @param state New state of the button
  54054. * @param changes Which properties on the state changed since last frame
  54055. */
  54056. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54057. }
  54058. }
  54059. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54060. import { Scene } from "babylonjs/scene";
  54061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54062. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54063. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54064. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54065. /**
  54066. * Gear VR Controller
  54067. */
  54068. export class GearVRController extends WebVRController {
  54069. /**
  54070. * Base Url for the controller model.
  54071. */
  54072. static MODEL_BASE_URL: string;
  54073. /**
  54074. * File name for the controller model.
  54075. */
  54076. static MODEL_FILENAME: string;
  54077. /**
  54078. * Gamepad Id prefix used to identify this controller.
  54079. */
  54080. static readonly GAMEPAD_ID_PREFIX: string;
  54081. private readonly _buttonIndexToObservableNameMap;
  54082. /**
  54083. * Creates a new GearVRController from a gamepad
  54084. * @param vrGamepad the gamepad that the controller should be created from
  54085. */
  54086. constructor(vrGamepad: any);
  54087. /**
  54088. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54089. * @param scene scene in which to add meshes
  54090. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54091. */
  54092. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54093. /**
  54094. * Called once for each button that changed state since the last frame
  54095. * @param buttonIdx Which button index changed
  54096. * @param state New state of the button
  54097. * @param changes Which properties on the state changed since last frame
  54098. */
  54099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54100. }
  54101. }
  54102. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54103. import { Scene } from "babylonjs/scene";
  54104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54105. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54106. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54107. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54108. /**
  54109. * Generic Controller
  54110. */
  54111. export class GenericController extends WebVRController {
  54112. /**
  54113. * Base Url for the controller model.
  54114. */
  54115. static readonly MODEL_BASE_URL: string;
  54116. /**
  54117. * File name for the controller model.
  54118. */
  54119. static readonly MODEL_FILENAME: string;
  54120. /**
  54121. * Creates a new GenericController from a gamepad
  54122. * @param vrGamepad the gamepad that the controller should be created from
  54123. */
  54124. constructor(vrGamepad: any);
  54125. /**
  54126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54127. * @param scene scene in which to add meshes
  54128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54129. */
  54130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54131. /**
  54132. * Called once for each button that changed state since the last frame
  54133. * @param buttonIdx Which button index changed
  54134. * @param state New state of the button
  54135. * @param changes Which properties on the state changed since last frame
  54136. */
  54137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54138. }
  54139. }
  54140. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54141. import { Observable } from "babylonjs/Misc/observable";
  54142. import { Scene } from "babylonjs/scene";
  54143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54144. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54145. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54146. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54147. /**
  54148. * Oculus Touch Controller
  54149. */
  54150. export class OculusTouchController extends WebVRController {
  54151. /**
  54152. * Base Url for the controller model.
  54153. */
  54154. static MODEL_BASE_URL: string;
  54155. /**
  54156. * File name for the left controller model.
  54157. */
  54158. static MODEL_LEFT_FILENAME: string;
  54159. /**
  54160. * File name for the right controller model.
  54161. */
  54162. static MODEL_RIGHT_FILENAME: string;
  54163. /**
  54164. * Base Url for the Quest controller model.
  54165. */
  54166. static QUEST_MODEL_BASE_URL: string;
  54167. /**
  54168. * @hidden
  54169. * If the controllers are running on a device that needs the updated Quest controller models
  54170. */
  54171. static _IsQuest: boolean;
  54172. /**
  54173. * Fired when the secondary trigger on this controller is modified
  54174. */
  54175. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54176. /**
  54177. * Fired when the thumb rest on this controller is modified
  54178. */
  54179. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54180. /**
  54181. * Creates a new OculusTouchController from a gamepad
  54182. * @param vrGamepad the gamepad that the controller should be created from
  54183. */
  54184. constructor(vrGamepad: any);
  54185. /**
  54186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54187. * @param scene scene in which to add meshes
  54188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54189. */
  54190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54191. /**
  54192. * Fired when the A button on this controller is modified
  54193. */
  54194. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54195. /**
  54196. * Fired when the B button on this controller is modified
  54197. */
  54198. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54199. /**
  54200. * Fired when the X button on this controller is modified
  54201. */
  54202. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54203. /**
  54204. * Fired when the Y button on this controller is modified
  54205. */
  54206. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54207. /**
  54208. * Called once for each button that changed state since the last frame
  54209. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54210. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54211. * 2) secondary trigger (same)
  54212. * 3) A (right) X (left), touch, pressed = value
  54213. * 4) B / Y
  54214. * 5) thumb rest
  54215. * @param buttonIdx Which button index changed
  54216. * @param state New state of the button
  54217. * @param changes Which properties on the state changed since last frame
  54218. */
  54219. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54220. }
  54221. }
  54222. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54223. import { Scene } from "babylonjs/scene";
  54224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54225. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54226. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54227. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54228. import { Observable } from "babylonjs/Misc/observable";
  54229. /**
  54230. * Vive Controller
  54231. */
  54232. export class ViveController extends WebVRController {
  54233. /**
  54234. * Base Url for the controller model.
  54235. */
  54236. static MODEL_BASE_URL: string;
  54237. /**
  54238. * File name for the controller model.
  54239. */
  54240. static MODEL_FILENAME: string;
  54241. /**
  54242. * Creates a new ViveController from a gamepad
  54243. * @param vrGamepad the gamepad that the controller should be created from
  54244. */
  54245. constructor(vrGamepad: any);
  54246. /**
  54247. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54248. * @param scene scene in which to add meshes
  54249. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54250. */
  54251. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54252. /**
  54253. * Fired when the left button on this controller is modified
  54254. */
  54255. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54256. /**
  54257. * Fired when the right button on this controller is modified
  54258. */
  54259. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54260. /**
  54261. * Fired when the menu button on this controller is modified
  54262. */
  54263. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54264. /**
  54265. * Called once for each button that changed state since the last frame
  54266. * Vive mapping:
  54267. * 0: touchpad
  54268. * 1: trigger
  54269. * 2: left AND right buttons
  54270. * 3: menu button
  54271. * @param buttonIdx Which button index changed
  54272. * @param state New state of the button
  54273. * @param changes Which properties on the state changed since last frame
  54274. */
  54275. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54276. }
  54277. }
  54278. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54279. import { Observable } from "babylonjs/Misc/observable";
  54280. import { Scene } from "babylonjs/scene";
  54281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54282. import { Ray } from "babylonjs/Culling/ray";
  54283. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54284. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54285. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54286. /**
  54287. * Defines the WindowsMotionController object that the state of the windows motion controller
  54288. */
  54289. export class WindowsMotionController extends WebVRController {
  54290. /**
  54291. * The base url used to load the left and right controller models
  54292. */
  54293. static MODEL_BASE_URL: string;
  54294. /**
  54295. * The name of the left controller model file
  54296. */
  54297. static MODEL_LEFT_FILENAME: string;
  54298. /**
  54299. * The name of the right controller model file
  54300. */
  54301. static MODEL_RIGHT_FILENAME: string;
  54302. /**
  54303. * The controller name prefix for this controller type
  54304. */
  54305. static readonly GAMEPAD_ID_PREFIX: string;
  54306. /**
  54307. * The controller id pattern for this controller type
  54308. */
  54309. private static readonly GAMEPAD_ID_PATTERN;
  54310. private _loadedMeshInfo;
  54311. protected readonly _mapping: {
  54312. buttons: string[];
  54313. buttonMeshNames: {
  54314. trigger: string;
  54315. menu: string;
  54316. grip: string;
  54317. thumbstick: string;
  54318. trackpad: string;
  54319. };
  54320. buttonObservableNames: {
  54321. trigger: string;
  54322. menu: string;
  54323. grip: string;
  54324. thumbstick: string;
  54325. trackpad: string;
  54326. };
  54327. axisMeshNames: string[];
  54328. pointingPoseMeshName: string;
  54329. };
  54330. /**
  54331. * Fired when the trackpad on this controller is clicked
  54332. */
  54333. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54334. /**
  54335. * Fired when the trackpad on this controller is modified
  54336. */
  54337. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54338. /**
  54339. * The current x and y values of this controller's trackpad
  54340. */
  54341. trackpad: StickValues;
  54342. /**
  54343. * Creates a new WindowsMotionController from a gamepad
  54344. * @param vrGamepad the gamepad that the controller should be created from
  54345. */
  54346. constructor(vrGamepad: any);
  54347. /**
  54348. * Fired when the trigger on this controller is modified
  54349. */
  54350. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54351. /**
  54352. * Fired when the menu button on this controller is modified
  54353. */
  54354. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54355. /**
  54356. * Fired when the grip button on this controller is modified
  54357. */
  54358. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54359. /**
  54360. * Fired when the thumbstick button on this controller is modified
  54361. */
  54362. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54363. /**
  54364. * Fired when the touchpad button on this controller is modified
  54365. */
  54366. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54367. /**
  54368. * Fired when the touchpad values on this controller are modified
  54369. */
  54370. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54371. protected _updateTrackpad(): void;
  54372. /**
  54373. * Called once per frame by the engine.
  54374. */
  54375. update(): void;
  54376. /**
  54377. * Called once for each button that changed state since the last frame
  54378. * @param buttonIdx Which button index changed
  54379. * @param state New state of the button
  54380. * @param changes Which properties on the state changed since last frame
  54381. */
  54382. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54383. /**
  54384. * Moves the buttons on the controller mesh based on their current state
  54385. * @param buttonName the name of the button to move
  54386. * @param buttonValue the value of the button which determines the buttons new position
  54387. */
  54388. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54389. /**
  54390. * Moves the axis on the controller mesh based on its current state
  54391. * @param axis the index of the axis
  54392. * @param axisValue the value of the axis which determines the meshes new position
  54393. * @hidden
  54394. */
  54395. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54396. /**
  54397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54398. * @param scene scene in which to add meshes
  54399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54400. */
  54401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54402. /**
  54403. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54404. * can be transformed by button presses and axes values, based on this._mapping.
  54405. *
  54406. * @param scene scene in which the meshes exist
  54407. * @param meshes list of meshes that make up the controller model to process
  54408. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54409. */
  54410. private processModel;
  54411. private createMeshInfo;
  54412. /**
  54413. * Gets the ray of the controller in the direction the controller is pointing
  54414. * @param length the length the resulting ray should be
  54415. * @returns a ray in the direction the controller is pointing
  54416. */
  54417. getForwardRay(length?: number): Ray;
  54418. /**
  54419. * Disposes of the controller
  54420. */
  54421. dispose(): void;
  54422. }
  54423. /**
  54424. * This class represents a new windows motion controller in XR.
  54425. */
  54426. export class XRWindowsMotionController extends WindowsMotionController {
  54427. /**
  54428. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54429. */
  54430. protected readonly _mapping: {
  54431. buttons: string[];
  54432. buttonMeshNames: {
  54433. trigger: string;
  54434. menu: string;
  54435. grip: string;
  54436. thumbstick: string;
  54437. trackpad: string;
  54438. };
  54439. buttonObservableNames: {
  54440. trigger: string;
  54441. menu: string;
  54442. grip: string;
  54443. thumbstick: string;
  54444. trackpad: string;
  54445. };
  54446. axisMeshNames: string[];
  54447. pointingPoseMeshName: string;
  54448. };
  54449. /**
  54450. * Construct a new XR-Based windows motion controller
  54451. *
  54452. * @param gamepadInfo the gamepad object from the browser
  54453. */
  54454. constructor(gamepadInfo: any);
  54455. /**
  54456. * holds the thumbstick values (X,Y)
  54457. */
  54458. thumbstickValues: StickValues;
  54459. /**
  54460. * Fired when the thumbstick on this controller is clicked
  54461. */
  54462. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54463. /**
  54464. * Fired when the thumbstick on this controller is modified
  54465. */
  54466. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54467. /**
  54468. * Fired when the touchpad button on this controller is modified
  54469. */
  54470. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54471. /**
  54472. * Fired when the touchpad values on this controller are modified
  54473. */
  54474. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54475. /**
  54476. * Fired when the thumbstick button on this controller is modified
  54477. * here to prevent breaking changes
  54478. */
  54479. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54480. /**
  54481. * updating the thumbstick(!) and not the trackpad.
  54482. * This is named this way due to the difference between WebVR and XR and to avoid
  54483. * changing the parent class.
  54484. */
  54485. protected _updateTrackpad(): void;
  54486. /**
  54487. * Disposes the class with joy
  54488. */
  54489. dispose(): void;
  54490. }
  54491. }
  54492. declare module "babylonjs/Gamepads/Controllers/index" {
  54493. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54494. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54495. export * from "babylonjs/Gamepads/Controllers/genericController";
  54496. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54497. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54498. export * from "babylonjs/Gamepads/Controllers/viveController";
  54499. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54500. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54501. }
  54502. declare module "babylonjs/Gamepads/index" {
  54503. export * from "babylonjs/Gamepads/Controllers/index";
  54504. export * from "babylonjs/Gamepads/gamepad";
  54505. export * from "babylonjs/Gamepads/gamepadManager";
  54506. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54507. export * from "babylonjs/Gamepads/xboxGamepad";
  54508. export * from "babylonjs/Gamepads/dualShockGamepad";
  54509. }
  54510. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54511. import { Scene } from "babylonjs/scene";
  54512. import { Vector4 } from "babylonjs/Maths/math.vector";
  54513. import { Color4 } from "babylonjs/Maths/math.color";
  54514. import { Mesh } from "babylonjs/Meshes/mesh";
  54515. import { Nullable } from "babylonjs/types";
  54516. /**
  54517. * Class containing static functions to help procedurally build meshes
  54518. */
  54519. export class PolyhedronBuilder {
  54520. /**
  54521. * Creates a polyhedron mesh
  54522. * * 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
  54523. * * The parameter `size` (positive float, default 1) sets the polygon size
  54524. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54525. * * 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`
  54526. * * 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
  54527. * * 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)`)
  54528. * * 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
  54529. * * 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
  54530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54533. * @param name defines the name of the mesh
  54534. * @param options defines the options used to create the mesh
  54535. * @param scene defines the hosting scene
  54536. * @returns the polyhedron mesh
  54537. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54538. */
  54539. static CreatePolyhedron(name: string, options: {
  54540. type?: number;
  54541. size?: number;
  54542. sizeX?: number;
  54543. sizeY?: number;
  54544. sizeZ?: number;
  54545. custom?: any;
  54546. faceUV?: Vector4[];
  54547. faceColors?: Color4[];
  54548. flat?: boolean;
  54549. updatable?: boolean;
  54550. sideOrientation?: number;
  54551. frontUVs?: Vector4;
  54552. backUVs?: Vector4;
  54553. }, scene?: Nullable<Scene>): Mesh;
  54554. }
  54555. }
  54556. declare module "babylonjs/Gizmos/scaleGizmo" {
  54557. import { Observable } from "babylonjs/Misc/observable";
  54558. import { Nullable } from "babylonjs/types";
  54559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54560. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54561. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54562. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54563. /**
  54564. * Gizmo that enables scaling a mesh along 3 axis
  54565. */
  54566. export class ScaleGizmo extends Gizmo {
  54567. /**
  54568. * Internal gizmo used for interactions on the x axis
  54569. */
  54570. xGizmo: AxisScaleGizmo;
  54571. /**
  54572. * Internal gizmo used for interactions on the y axis
  54573. */
  54574. yGizmo: AxisScaleGizmo;
  54575. /**
  54576. * Internal gizmo used for interactions on the z axis
  54577. */
  54578. zGizmo: AxisScaleGizmo;
  54579. /**
  54580. * Internal gizmo used to scale all axis equally
  54581. */
  54582. uniformScaleGizmo: AxisScaleGizmo;
  54583. private _meshAttached;
  54584. private _updateGizmoRotationToMatchAttachedMesh;
  54585. private _snapDistance;
  54586. private _scaleRatio;
  54587. private _uniformScalingMesh;
  54588. private _octahedron;
  54589. private _sensitivity;
  54590. /** Fires an event when any of it's sub gizmos are dragged */
  54591. onDragStartObservable: Observable<unknown>;
  54592. /** Fires an event when any of it's sub gizmos are released from dragging */
  54593. onDragEndObservable: Observable<unknown>;
  54594. get attachedMesh(): Nullable<AbstractMesh>;
  54595. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54596. /**
  54597. * Creates a ScaleGizmo
  54598. * @param gizmoLayer The utility layer the gizmo will be added to
  54599. */
  54600. constructor(gizmoLayer?: UtilityLayerRenderer);
  54601. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54602. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54603. /**
  54604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54605. */
  54606. set snapDistance(value: number);
  54607. get snapDistance(): number;
  54608. /**
  54609. * Ratio for the scale of the gizmo (Default: 1)
  54610. */
  54611. set scaleRatio(value: number);
  54612. get scaleRatio(): number;
  54613. /**
  54614. * Sensitivity factor for dragging (Default: 1)
  54615. */
  54616. set sensitivity(value: number);
  54617. get sensitivity(): number;
  54618. /**
  54619. * Disposes of the gizmo
  54620. */
  54621. dispose(): void;
  54622. }
  54623. }
  54624. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54625. import { Observable } from "babylonjs/Misc/observable";
  54626. import { Nullable } from "babylonjs/types";
  54627. import { Vector3 } from "babylonjs/Maths/math.vector";
  54628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54629. import { Mesh } from "babylonjs/Meshes/mesh";
  54630. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54631. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54632. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54633. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54634. import { Color3 } from "babylonjs/Maths/math.color";
  54635. /**
  54636. * Single axis scale gizmo
  54637. */
  54638. export class AxisScaleGizmo extends Gizmo {
  54639. /**
  54640. * Drag behavior responsible for the gizmos dragging interactions
  54641. */
  54642. dragBehavior: PointerDragBehavior;
  54643. private _pointerObserver;
  54644. /**
  54645. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54646. */
  54647. snapDistance: number;
  54648. /**
  54649. * Event that fires each time the gizmo snaps to a new location.
  54650. * * snapDistance is the the change in distance
  54651. */
  54652. onSnapObservable: Observable<{
  54653. snapDistance: number;
  54654. }>;
  54655. /**
  54656. * If the scaling operation should be done on all axis (default: false)
  54657. */
  54658. uniformScaling: boolean;
  54659. /**
  54660. * Custom sensitivity value for the drag strength
  54661. */
  54662. sensitivity: number;
  54663. private _isEnabled;
  54664. private _parent;
  54665. private _arrow;
  54666. private _coloredMaterial;
  54667. private _hoverMaterial;
  54668. /**
  54669. * Creates an AxisScaleGizmo
  54670. * @param gizmoLayer The utility layer the gizmo will be added to
  54671. * @param dragAxis The axis which the gizmo will be able to scale on
  54672. * @param color The color of the gizmo
  54673. */
  54674. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54675. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54676. /**
  54677. * If the gizmo is enabled
  54678. */
  54679. set isEnabled(value: boolean);
  54680. get isEnabled(): boolean;
  54681. /**
  54682. * Disposes of the gizmo
  54683. */
  54684. dispose(): void;
  54685. /**
  54686. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54687. * @param mesh The mesh to replace the default mesh of the gizmo
  54688. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54689. */
  54690. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54691. }
  54692. }
  54693. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54694. import { Observable } from "babylonjs/Misc/observable";
  54695. import { Nullable } from "babylonjs/types";
  54696. import { Vector3 } from "babylonjs/Maths/math.vector";
  54697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54698. import { Mesh } from "babylonjs/Meshes/mesh";
  54699. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54700. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54701. import { Color3 } from "babylonjs/Maths/math.color";
  54702. import "babylonjs/Meshes/Builders/boxBuilder";
  54703. /**
  54704. * Bounding box gizmo
  54705. */
  54706. export class BoundingBoxGizmo extends Gizmo {
  54707. private _lineBoundingBox;
  54708. private _rotateSpheresParent;
  54709. private _scaleBoxesParent;
  54710. private _boundingDimensions;
  54711. private _renderObserver;
  54712. private _pointerObserver;
  54713. private _scaleDragSpeed;
  54714. private _tmpQuaternion;
  54715. private _tmpVector;
  54716. private _tmpRotationMatrix;
  54717. /**
  54718. * 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)
  54719. */
  54720. ignoreChildren: boolean;
  54721. /**
  54722. * 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)
  54723. */
  54724. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54725. /**
  54726. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54727. */
  54728. rotationSphereSize: number;
  54729. /**
  54730. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54731. */
  54732. scaleBoxSize: number;
  54733. /**
  54734. * 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)
  54735. */
  54736. fixedDragMeshScreenSize: boolean;
  54737. /**
  54738. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54739. */
  54740. fixedDragMeshScreenSizeDistanceFactor: number;
  54741. /**
  54742. * Fired when a rotation sphere or scale box is dragged
  54743. */
  54744. onDragStartObservable: Observable<{}>;
  54745. /**
  54746. * Fired when a scale box is dragged
  54747. */
  54748. onScaleBoxDragObservable: Observable<{}>;
  54749. /**
  54750. * Fired when a scale box drag is ended
  54751. */
  54752. onScaleBoxDragEndObservable: Observable<{}>;
  54753. /**
  54754. * Fired when a rotation sphere is dragged
  54755. */
  54756. onRotationSphereDragObservable: Observable<{}>;
  54757. /**
  54758. * Fired when a rotation sphere drag is ended
  54759. */
  54760. onRotationSphereDragEndObservable: Observable<{}>;
  54761. /**
  54762. * 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)
  54763. */
  54764. scalePivot: Nullable<Vector3>;
  54765. /**
  54766. * Mesh used as a pivot to rotate the attached mesh
  54767. */
  54768. private _anchorMesh;
  54769. private _existingMeshScale;
  54770. private _dragMesh;
  54771. private pointerDragBehavior;
  54772. private coloredMaterial;
  54773. private hoverColoredMaterial;
  54774. /**
  54775. * Sets the color of the bounding box gizmo
  54776. * @param color the color to set
  54777. */
  54778. setColor(color: Color3): void;
  54779. /**
  54780. * Creates an BoundingBoxGizmo
  54781. * @param gizmoLayer The utility layer the gizmo will be added to
  54782. * @param color The color of the gizmo
  54783. */
  54784. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54785. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54786. private _selectNode;
  54787. /**
  54788. * Updates the bounding box information for the Gizmo
  54789. */
  54790. updateBoundingBox(): void;
  54791. private _updateRotationSpheres;
  54792. private _updateScaleBoxes;
  54793. /**
  54794. * Enables rotation on the specified axis and disables rotation on the others
  54795. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54796. */
  54797. setEnabledRotationAxis(axis: string): void;
  54798. /**
  54799. * Enables/disables scaling
  54800. * @param enable if scaling should be enabled
  54801. * @param homogeneousScaling defines if scaling should only be homogeneous
  54802. */
  54803. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54804. private _updateDummy;
  54805. /**
  54806. * Enables a pointer drag behavior on the bounding box of the gizmo
  54807. */
  54808. enableDragBehavior(): void;
  54809. /**
  54810. * Disposes of the gizmo
  54811. */
  54812. dispose(): void;
  54813. /**
  54814. * 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)
  54815. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54816. * @returns the bounding box mesh with the passed in mesh as a child
  54817. */
  54818. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54819. /**
  54820. * CustomMeshes are not supported by this gizmo
  54821. * @param mesh The mesh to replace the default mesh of the gizmo
  54822. */
  54823. setCustomMesh(mesh: Mesh): void;
  54824. }
  54825. }
  54826. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54827. import { Observable } from "babylonjs/Misc/observable";
  54828. import { Nullable } from "babylonjs/types";
  54829. import { Vector3 } from "babylonjs/Maths/math.vector";
  54830. import { Color3 } from "babylonjs/Maths/math.color";
  54831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54832. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54833. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54834. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54835. import "babylonjs/Meshes/Builders/linesBuilder";
  54836. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54837. /**
  54838. * Single plane rotation gizmo
  54839. */
  54840. export class PlaneRotationGizmo extends Gizmo {
  54841. /**
  54842. * Drag behavior responsible for the gizmos dragging interactions
  54843. */
  54844. dragBehavior: PointerDragBehavior;
  54845. private _pointerObserver;
  54846. /**
  54847. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54848. */
  54849. snapDistance: number;
  54850. /**
  54851. * Event that fires each time the gizmo snaps to a new location.
  54852. * * snapDistance is the the change in distance
  54853. */
  54854. onSnapObservable: Observable<{
  54855. snapDistance: number;
  54856. }>;
  54857. private _isEnabled;
  54858. private _parent;
  54859. /**
  54860. * Creates a PlaneRotationGizmo
  54861. * @param gizmoLayer The utility layer the gizmo will be added to
  54862. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54863. * @param color The color of the gizmo
  54864. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54865. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54866. */
  54867. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54868. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54869. /**
  54870. * If the gizmo is enabled
  54871. */
  54872. set isEnabled(value: boolean);
  54873. get isEnabled(): boolean;
  54874. /**
  54875. * Disposes of the gizmo
  54876. */
  54877. dispose(): void;
  54878. }
  54879. }
  54880. declare module "babylonjs/Gizmos/rotationGizmo" {
  54881. import { Observable } from "babylonjs/Misc/observable";
  54882. import { Nullable } from "babylonjs/types";
  54883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54884. import { Mesh } from "babylonjs/Meshes/mesh";
  54885. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54886. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54887. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54888. /**
  54889. * Gizmo that enables rotating a mesh along 3 axis
  54890. */
  54891. export class RotationGizmo extends Gizmo {
  54892. /**
  54893. * Internal gizmo used for interactions on the x axis
  54894. */
  54895. xGizmo: PlaneRotationGizmo;
  54896. /**
  54897. * Internal gizmo used for interactions on the y axis
  54898. */
  54899. yGizmo: PlaneRotationGizmo;
  54900. /**
  54901. * Internal gizmo used for interactions on the z axis
  54902. */
  54903. zGizmo: PlaneRotationGizmo;
  54904. /** Fires an event when any of it's sub gizmos are dragged */
  54905. onDragStartObservable: Observable<unknown>;
  54906. /** Fires an event when any of it's sub gizmos are released from dragging */
  54907. onDragEndObservable: Observable<unknown>;
  54908. private _meshAttached;
  54909. get attachedMesh(): Nullable<AbstractMesh>;
  54910. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54911. /**
  54912. * Creates a RotationGizmo
  54913. * @param gizmoLayer The utility layer the gizmo will be added to
  54914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54915. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54916. */
  54917. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54918. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54919. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54920. /**
  54921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54922. */
  54923. set snapDistance(value: number);
  54924. get snapDistance(): number;
  54925. /**
  54926. * Ratio for the scale of the gizmo (Default: 1)
  54927. */
  54928. set scaleRatio(value: number);
  54929. get scaleRatio(): number;
  54930. /**
  54931. * Disposes of the gizmo
  54932. */
  54933. dispose(): void;
  54934. /**
  54935. * CustomMeshes are not supported by this gizmo
  54936. * @param mesh The mesh to replace the default mesh of the gizmo
  54937. */
  54938. setCustomMesh(mesh: Mesh): void;
  54939. }
  54940. }
  54941. declare module "babylonjs/Gizmos/gizmoManager" {
  54942. import { Observable } from "babylonjs/Misc/observable";
  54943. import { Nullable } from "babylonjs/types";
  54944. import { Scene, IDisposable } from "babylonjs/scene";
  54945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54946. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54947. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54948. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54949. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54950. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54951. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54952. /**
  54953. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54954. */
  54955. export class GizmoManager implements IDisposable {
  54956. private scene;
  54957. /**
  54958. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54959. */
  54960. gizmos: {
  54961. positionGizmo: Nullable<PositionGizmo>;
  54962. rotationGizmo: Nullable<RotationGizmo>;
  54963. scaleGizmo: Nullable<ScaleGizmo>;
  54964. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54965. };
  54966. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54967. clearGizmoOnEmptyPointerEvent: boolean;
  54968. /** Fires an event when the manager is attached to a mesh */
  54969. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54970. private _gizmosEnabled;
  54971. private _pointerObserver;
  54972. private _attachedMesh;
  54973. private _boundingBoxColor;
  54974. private _defaultUtilityLayer;
  54975. private _defaultKeepDepthUtilityLayer;
  54976. /**
  54977. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54978. */
  54979. boundingBoxDragBehavior: SixDofDragBehavior;
  54980. /**
  54981. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54982. */
  54983. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54984. /**
  54985. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54986. */
  54987. usePointerToAttachGizmos: boolean;
  54988. /**
  54989. * Utility layer that the bounding box gizmo belongs to
  54990. */
  54991. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54992. /**
  54993. * Utility layer that all gizmos besides bounding box belong to
  54994. */
  54995. get utilityLayer(): UtilityLayerRenderer;
  54996. /**
  54997. * Instatiates a gizmo manager
  54998. * @param scene the scene to overlay the gizmos on top of
  54999. */
  55000. constructor(scene: Scene);
  55001. /**
  55002. * Attaches a set of gizmos to the specified mesh
  55003. * @param mesh The mesh the gizmo's should be attached to
  55004. */
  55005. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55006. /**
  55007. * If the position gizmo is enabled
  55008. */
  55009. set positionGizmoEnabled(value: boolean);
  55010. get positionGizmoEnabled(): boolean;
  55011. /**
  55012. * If the rotation gizmo is enabled
  55013. */
  55014. set rotationGizmoEnabled(value: boolean);
  55015. get rotationGizmoEnabled(): boolean;
  55016. /**
  55017. * If the scale gizmo is enabled
  55018. */
  55019. set scaleGizmoEnabled(value: boolean);
  55020. get scaleGizmoEnabled(): boolean;
  55021. /**
  55022. * If the boundingBox gizmo is enabled
  55023. */
  55024. set boundingBoxGizmoEnabled(value: boolean);
  55025. get boundingBoxGizmoEnabled(): boolean;
  55026. /**
  55027. * Disposes of the gizmo manager
  55028. */
  55029. dispose(): void;
  55030. }
  55031. }
  55032. declare module "babylonjs/Lights/directionalLight" {
  55033. import { Camera } from "babylonjs/Cameras/camera";
  55034. import { Scene } from "babylonjs/scene";
  55035. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55037. import { Light } from "babylonjs/Lights/light";
  55038. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55039. import { Effect } from "babylonjs/Materials/effect";
  55040. /**
  55041. * A directional light is defined by a direction (what a surprise!).
  55042. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55043. * 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.
  55044. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55045. */
  55046. export class DirectionalLight extends ShadowLight {
  55047. private _shadowFrustumSize;
  55048. /**
  55049. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55050. */
  55051. get shadowFrustumSize(): number;
  55052. /**
  55053. * Specifies a fix frustum size for the shadow generation.
  55054. */
  55055. set shadowFrustumSize(value: number);
  55056. private _shadowOrthoScale;
  55057. /**
  55058. * Gets the shadow projection scale against the optimal computed one.
  55059. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55060. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55061. */
  55062. get shadowOrthoScale(): number;
  55063. /**
  55064. * Sets the shadow projection scale against the optimal computed one.
  55065. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55066. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55067. */
  55068. set shadowOrthoScale(value: number);
  55069. /**
  55070. * Automatically compute the projection matrix to best fit (including all the casters)
  55071. * on each frame.
  55072. */
  55073. autoUpdateExtends: boolean;
  55074. /**
  55075. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55076. * on each frame. autoUpdateExtends must be set to true for this to work
  55077. */
  55078. autoCalcShadowZBounds: boolean;
  55079. private _orthoLeft;
  55080. private _orthoRight;
  55081. private _orthoTop;
  55082. private _orthoBottom;
  55083. /**
  55084. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55085. * The directional light is emitted from everywhere in the given direction.
  55086. * It can cast shadows.
  55087. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55088. * @param name The friendly name of the light
  55089. * @param direction The direction of the light
  55090. * @param scene The scene the light belongs to
  55091. */
  55092. constructor(name: string, direction: Vector3, scene: Scene);
  55093. /**
  55094. * Returns the string "DirectionalLight".
  55095. * @return The class name
  55096. */
  55097. getClassName(): string;
  55098. /**
  55099. * Returns the integer 1.
  55100. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55101. */
  55102. getTypeID(): number;
  55103. /**
  55104. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55105. * Returns the DirectionalLight Shadow projection matrix.
  55106. */
  55107. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55108. /**
  55109. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55110. * Returns the DirectionalLight Shadow projection matrix.
  55111. */
  55112. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55113. /**
  55114. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55115. * Returns the DirectionalLight Shadow projection matrix.
  55116. */
  55117. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55118. protected _buildUniformLayout(): void;
  55119. /**
  55120. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55121. * @param effect The effect to update
  55122. * @param lightIndex The index of the light in the effect to update
  55123. * @returns The directional light
  55124. */
  55125. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55126. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55127. /**
  55128. * Gets the minZ used for shadow according to both the scene and the light.
  55129. *
  55130. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55131. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55132. * @param activeCamera The camera we are returning the min for
  55133. * @returns the depth min z
  55134. */
  55135. getDepthMinZ(activeCamera: Camera): number;
  55136. /**
  55137. * Gets the maxZ used for shadow according to both the scene and the light.
  55138. *
  55139. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55140. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55141. * @param activeCamera The camera we are returning the max for
  55142. * @returns the depth max z
  55143. */
  55144. getDepthMaxZ(activeCamera: Camera): number;
  55145. /**
  55146. * Prepares the list of defines specific to the light type.
  55147. * @param defines the list of defines
  55148. * @param lightIndex defines the index of the light for the effect
  55149. */
  55150. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55151. }
  55152. }
  55153. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55154. import { Mesh } from "babylonjs/Meshes/mesh";
  55155. /**
  55156. * Class containing static functions to help procedurally build meshes
  55157. */
  55158. export class HemisphereBuilder {
  55159. /**
  55160. * Creates a hemisphere mesh
  55161. * @param name defines the name of the mesh
  55162. * @param options defines the options used to create the mesh
  55163. * @param scene defines the hosting scene
  55164. * @returns the hemisphere mesh
  55165. */
  55166. static CreateHemisphere(name: string, options: {
  55167. segments?: number;
  55168. diameter?: number;
  55169. sideOrientation?: number;
  55170. }, scene: any): Mesh;
  55171. }
  55172. }
  55173. declare module "babylonjs/Lights/spotLight" {
  55174. import { Nullable } from "babylonjs/types";
  55175. import { Scene } from "babylonjs/scene";
  55176. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55178. import { Effect } from "babylonjs/Materials/effect";
  55179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55180. import { Light } from "babylonjs/Lights/light";
  55181. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55182. /**
  55183. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55184. * These values define a cone of light starting from the position, emitting toward the direction.
  55185. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55186. * and the exponent defines the speed of the decay of the light with distance (reach).
  55187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55188. */
  55189. export class SpotLight extends ShadowLight {
  55190. private _angle;
  55191. private _innerAngle;
  55192. private _cosHalfAngle;
  55193. private _lightAngleScale;
  55194. private _lightAngleOffset;
  55195. /**
  55196. * Gets the cone angle of the spot light in Radians.
  55197. */
  55198. get angle(): number;
  55199. /**
  55200. * Sets the cone angle of the spot light in Radians.
  55201. */
  55202. set angle(value: number);
  55203. /**
  55204. * Only used in gltf falloff mode, this defines the angle where
  55205. * the directional falloff will start before cutting at angle which could be seen
  55206. * as outer angle.
  55207. */
  55208. get innerAngle(): number;
  55209. /**
  55210. * Only used in gltf falloff mode, this defines the angle where
  55211. * the directional falloff will start before cutting at angle which could be seen
  55212. * as outer angle.
  55213. */
  55214. set innerAngle(value: number);
  55215. private _shadowAngleScale;
  55216. /**
  55217. * Allows scaling the angle of the light for shadow generation only.
  55218. */
  55219. get shadowAngleScale(): number;
  55220. /**
  55221. * Allows scaling the angle of the light for shadow generation only.
  55222. */
  55223. set shadowAngleScale(value: number);
  55224. /**
  55225. * The light decay speed with the distance from the emission spot.
  55226. */
  55227. exponent: number;
  55228. private _projectionTextureMatrix;
  55229. /**
  55230. * Allows reading the projecton texture
  55231. */
  55232. get projectionTextureMatrix(): Matrix;
  55233. protected _projectionTextureLightNear: number;
  55234. /**
  55235. * Gets the near clip of the Spotlight for texture projection.
  55236. */
  55237. get projectionTextureLightNear(): number;
  55238. /**
  55239. * Sets the near clip of the Spotlight for texture projection.
  55240. */
  55241. set projectionTextureLightNear(value: number);
  55242. protected _projectionTextureLightFar: number;
  55243. /**
  55244. * Gets the far clip of the Spotlight for texture projection.
  55245. */
  55246. get projectionTextureLightFar(): number;
  55247. /**
  55248. * Sets the far clip of the Spotlight for texture projection.
  55249. */
  55250. set projectionTextureLightFar(value: number);
  55251. protected _projectionTextureUpDirection: Vector3;
  55252. /**
  55253. * Gets the Up vector of the Spotlight for texture projection.
  55254. */
  55255. get projectionTextureUpDirection(): Vector3;
  55256. /**
  55257. * Sets the Up vector of the Spotlight for texture projection.
  55258. */
  55259. set projectionTextureUpDirection(value: Vector3);
  55260. private _projectionTexture;
  55261. /**
  55262. * Gets the projection texture of the light.
  55263. */
  55264. get projectionTexture(): Nullable<BaseTexture>;
  55265. /**
  55266. * Sets the projection texture of the light.
  55267. */
  55268. set projectionTexture(value: Nullable<BaseTexture>);
  55269. private _projectionTextureViewLightDirty;
  55270. private _projectionTextureProjectionLightDirty;
  55271. private _projectionTextureDirty;
  55272. private _projectionTextureViewTargetVector;
  55273. private _projectionTextureViewLightMatrix;
  55274. private _projectionTextureProjectionLightMatrix;
  55275. private _projectionTextureScalingMatrix;
  55276. /**
  55277. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55278. * It can cast shadows.
  55279. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55280. * @param name The light friendly name
  55281. * @param position The position of the spot light in the scene
  55282. * @param direction The direction of the light in the scene
  55283. * @param angle The cone angle of the light in Radians
  55284. * @param exponent The light decay speed with the distance from the emission spot
  55285. * @param scene The scene the lights belongs to
  55286. */
  55287. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55288. /**
  55289. * Returns the string "SpotLight".
  55290. * @returns the class name
  55291. */
  55292. getClassName(): string;
  55293. /**
  55294. * Returns the integer 2.
  55295. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55296. */
  55297. getTypeID(): number;
  55298. /**
  55299. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55300. */
  55301. protected _setDirection(value: Vector3): void;
  55302. /**
  55303. * Overrides the position setter to recompute the projection texture view light Matrix.
  55304. */
  55305. protected _setPosition(value: Vector3): void;
  55306. /**
  55307. * 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.
  55308. * Returns the SpotLight.
  55309. */
  55310. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55311. protected _computeProjectionTextureViewLightMatrix(): void;
  55312. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55313. /**
  55314. * Main function for light texture projection matrix computing.
  55315. */
  55316. protected _computeProjectionTextureMatrix(): void;
  55317. protected _buildUniformLayout(): void;
  55318. private _computeAngleValues;
  55319. /**
  55320. * Sets the passed Effect "effect" with the Light textures.
  55321. * @param effect The effect to update
  55322. * @param lightIndex The index of the light in the effect to update
  55323. * @returns The light
  55324. */
  55325. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55326. /**
  55327. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55328. * @param effect The effect to update
  55329. * @param lightIndex The index of the light in the effect to update
  55330. * @returns The spot light
  55331. */
  55332. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55333. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55334. /**
  55335. * Disposes the light and the associated resources.
  55336. */
  55337. dispose(): void;
  55338. /**
  55339. * Prepares the list of defines specific to the light type.
  55340. * @param defines the list of defines
  55341. * @param lightIndex defines the index of the light for the effect
  55342. */
  55343. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55344. }
  55345. }
  55346. declare module "babylonjs/Gizmos/lightGizmo" {
  55347. import { Nullable } from "babylonjs/types";
  55348. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55349. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55350. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55351. import { Light } from "babylonjs/Lights/light";
  55352. /**
  55353. * Gizmo that enables viewing a light
  55354. */
  55355. export class LightGizmo extends Gizmo {
  55356. private _lightMesh;
  55357. private _material;
  55358. private _cachedPosition;
  55359. private _cachedForward;
  55360. private _attachedMeshParent;
  55361. /**
  55362. * Creates a LightGizmo
  55363. * @param gizmoLayer The utility layer the gizmo will be added to
  55364. */
  55365. constructor(gizmoLayer?: UtilityLayerRenderer);
  55366. private _light;
  55367. /**
  55368. * The light that the gizmo is attached to
  55369. */
  55370. set light(light: Nullable<Light>);
  55371. get light(): Nullable<Light>;
  55372. /**
  55373. * Gets the material used to render the light gizmo
  55374. */
  55375. get material(): StandardMaterial;
  55376. /**
  55377. * @hidden
  55378. * Updates the gizmo to match the attached mesh's position/rotation
  55379. */
  55380. protected _update(): void;
  55381. private static _Scale;
  55382. /**
  55383. * Creates the lines for a light mesh
  55384. */
  55385. private static _CreateLightLines;
  55386. /**
  55387. * Disposes of the light gizmo
  55388. */
  55389. dispose(): void;
  55390. private static _CreateHemisphericLightMesh;
  55391. private static _CreatePointLightMesh;
  55392. private static _CreateSpotLightMesh;
  55393. private static _CreateDirectionalLightMesh;
  55394. }
  55395. }
  55396. declare module "babylonjs/Gizmos/index" {
  55397. export * from "babylonjs/Gizmos/axisDragGizmo";
  55398. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55399. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55400. export * from "babylonjs/Gizmos/gizmo";
  55401. export * from "babylonjs/Gizmos/gizmoManager";
  55402. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55403. export * from "babylonjs/Gizmos/positionGizmo";
  55404. export * from "babylonjs/Gizmos/rotationGizmo";
  55405. export * from "babylonjs/Gizmos/scaleGizmo";
  55406. export * from "babylonjs/Gizmos/lightGizmo";
  55407. export * from "babylonjs/Gizmos/planeDragGizmo";
  55408. }
  55409. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55410. /** @hidden */
  55411. export var backgroundFragmentDeclaration: {
  55412. name: string;
  55413. shader: string;
  55414. };
  55415. }
  55416. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55417. /** @hidden */
  55418. export var backgroundUboDeclaration: {
  55419. name: string;
  55420. shader: string;
  55421. };
  55422. }
  55423. declare module "babylonjs/Shaders/background.fragment" {
  55424. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55425. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55426. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55427. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55428. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55429. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55430. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55431. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55432. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55433. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55434. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55435. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55436. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55437. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55438. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55439. /** @hidden */
  55440. export var backgroundPixelShader: {
  55441. name: string;
  55442. shader: string;
  55443. };
  55444. }
  55445. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55446. /** @hidden */
  55447. export var backgroundVertexDeclaration: {
  55448. name: string;
  55449. shader: string;
  55450. };
  55451. }
  55452. declare module "babylonjs/Shaders/background.vertex" {
  55453. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55454. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55457. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55458. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55459. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55460. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55461. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55462. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55463. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55465. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55466. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55467. /** @hidden */
  55468. export var backgroundVertexShader: {
  55469. name: string;
  55470. shader: string;
  55471. };
  55472. }
  55473. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55474. import { Nullable, int, float } from "babylonjs/types";
  55475. import { Scene } from "babylonjs/scene";
  55476. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55479. import { Mesh } from "babylonjs/Meshes/mesh";
  55480. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55481. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55482. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55484. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55485. import { Color3 } from "babylonjs/Maths/math.color";
  55486. import "babylonjs/Shaders/background.fragment";
  55487. import "babylonjs/Shaders/background.vertex";
  55488. /**
  55489. * Background material used to create an efficient environement around your scene.
  55490. */
  55491. export class BackgroundMaterial extends PushMaterial {
  55492. /**
  55493. * Standard reflectance value at parallel view angle.
  55494. */
  55495. static StandardReflectance0: number;
  55496. /**
  55497. * Standard reflectance value at grazing angle.
  55498. */
  55499. static StandardReflectance90: number;
  55500. protected _primaryColor: Color3;
  55501. /**
  55502. * Key light Color (multiply against the environement texture)
  55503. */
  55504. primaryColor: Color3;
  55505. protected __perceptualColor: Nullable<Color3>;
  55506. /**
  55507. * Experimental Internal Use Only.
  55508. *
  55509. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55510. * This acts as a helper to set the primary color to a more "human friendly" value.
  55511. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55512. * output color as close as possible from the chosen value.
  55513. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55514. * part of lighting setup.)
  55515. */
  55516. get _perceptualColor(): Nullable<Color3>;
  55517. set _perceptualColor(value: Nullable<Color3>);
  55518. protected _primaryColorShadowLevel: float;
  55519. /**
  55520. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55521. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55522. */
  55523. get primaryColorShadowLevel(): float;
  55524. set primaryColorShadowLevel(value: float);
  55525. protected _primaryColorHighlightLevel: float;
  55526. /**
  55527. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55528. * The primary color is used at the level chosen to define what the white area would look.
  55529. */
  55530. get primaryColorHighlightLevel(): float;
  55531. set primaryColorHighlightLevel(value: float);
  55532. protected _reflectionTexture: Nullable<BaseTexture>;
  55533. /**
  55534. * Reflection Texture used in the material.
  55535. * Should be author in a specific way for the best result (refer to the documentation).
  55536. */
  55537. reflectionTexture: Nullable<BaseTexture>;
  55538. protected _reflectionBlur: float;
  55539. /**
  55540. * Reflection Texture level of blur.
  55541. *
  55542. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55543. * texture twice.
  55544. */
  55545. reflectionBlur: float;
  55546. protected _diffuseTexture: Nullable<BaseTexture>;
  55547. /**
  55548. * Diffuse Texture used in the material.
  55549. * Should be author in a specific way for the best result (refer to the documentation).
  55550. */
  55551. diffuseTexture: Nullable<BaseTexture>;
  55552. protected _shadowLights: Nullable<IShadowLight[]>;
  55553. /**
  55554. * Specify the list of lights casting shadow on the material.
  55555. * All scene shadow lights will be included if null.
  55556. */
  55557. shadowLights: Nullable<IShadowLight[]>;
  55558. protected _shadowLevel: float;
  55559. /**
  55560. * Helps adjusting the shadow to a softer level if required.
  55561. * 0 means black shadows and 1 means no shadows.
  55562. */
  55563. shadowLevel: float;
  55564. protected _sceneCenter: Vector3;
  55565. /**
  55566. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55567. * It is usually zero but might be interesting to modify according to your setup.
  55568. */
  55569. sceneCenter: Vector3;
  55570. protected _opacityFresnel: boolean;
  55571. /**
  55572. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55573. * This helps ensuring a nice transition when the camera goes under the ground.
  55574. */
  55575. opacityFresnel: boolean;
  55576. protected _reflectionFresnel: boolean;
  55577. /**
  55578. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55579. * This helps adding a mirror texture on the ground.
  55580. */
  55581. reflectionFresnel: boolean;
  55582. protected _reflectionFalloffDistance: number;
  55583. /**
  55584. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55585. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55586. */
  55587. reflectionFalloffDistance: number;
  55588. protected _reflectionAmount: number;
  55589. /**
  55590. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55591. */
  55592. reflectionAmount: number;
  55593. protected _reflectionReflectance0: number;
  55594. /**
  55595. * This specifies the weight of the reflection at grazing angle.
  55596. */
  55597. reflectionReflectance0: number;
  55598. protected _reflectionReflectance90: number;
  55599. /**
  55600. * This specifies the weight of the reflection at a perpendicular point of view.
  55601. */
  55602. reflectionReflectance90: number;
  55603. /**
  55604. * Sets the reflection reflectance fresnel values according to the default standard
  55605. * empirically know to work well :-)
  55606. */
  55607. set reflectionStandardFresnelWeight(value: number);
  55608. protected _useRGBColor: boolean;
  55609. /**
  55610. * Helps to directly use the maps channels instead of their level.
  55611. */
  55612. useRGBColor: boolean;
  55613. protected _enableNoise: boolean;
  55614. /**
  55615. * This helps reducing the banding effect that could occur on the background.
  55616. */
  55617. enableNoise: boolean;
  55618. /**
  55619. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55620. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55621. * Recommended to be keep at 1.0 except for special cases.
  55622. */
  55623. get fovMultiplier(): number;
  55624. set fovMultiplier(value: number);
  55625. private _fovMultiplier;
  55626. /**
  55627. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55628. */
  55629. useEquirectangularFOV: boolean;
  55630. private _maxSimultaneousLights;
  55631. /**
  55632. * Number of Simultaneous lights allowed on the material.
  55633. */
  55634. maxSimultaneousLights: int;
  55635. private _shadowOnly;
  55636. /**
  55637. * Make the material only render shadows
  55638. */
  55639. shadowOnly: boolean;
  55640. /**
  55641. * Default configuration related to image processing available in the Background Material.
  55642. */
  55643. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55644. /**
  55645. * Keep track of the image processing observer to allow dispose and replace.
  55646. */
  55647. private _imageProcessingObserver;
  55648. /**
  55649. * Attaches a new image processing configuration to the PBR Material.
  55650. * @param configuration (if null the scene configuration will be use)
  55651. */
  55652. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55653. /**
  55654. * Gets the image processing configuration used either in this material.
  55655. */
  55656. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55657. /**
  55658. * Sets the Default image processing configuration used either in the this material.
  55659. *
  55660. * If sets to null, the scene one is in use.
  55661. */
  55662. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55663. /**
  55664. * Gets wether the color curves effect is enabled.
  55665. */
  55666. get cameraColorCurvesEnabled(): boolean;
  55667. /**
  55668. * Sets wether the color curves effect is enabled.
  55669. */
  55670. set cameraColorCurvesEnabled(value: boolean);
  55671. /**
  55672. * Gets wether the color grading effect is enabled.
  55673. */
  55674. get cameraColorGradingEnabled(): boolean;
  55675. /**
  55676. * Gets wether the color grading effect is enabled.
  55677. */
  55678. set cameraColorGradingEnabled(value: boolean);
  55679. /**
  55680. * Gets wether tonemapping is enabled or not.
  55681. */
  55682. get cameraToneMappingEnabled(): boolean;
  55683. /**
  55684. * Sets wether tonemapping is enabled or not
  55685. */
  55686. set cameraToneMappingEnabled(value: boolean);
  55687. /**
  55688. * The camera exposure used on this material.
  55689. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55690. * This corresponds to a photographic exposure.
  55691. */
  55692. get cameraExposure(): float;
  55693. /**
  55694. * The camera exposure used on this material.
  55695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55696. * This corresponds to a photographic exposure.
  55697. */
  55698. set cameraExposure(value: float);
  55699. /**
  55700. * Gets The camera contrast used on this material.
  55701. */
  55702. get cameraContrast(): float;
  55703. /**
  55704. * Sets The camera contrast used on this material.
  55705. */
  55706. set cameraContrast(value: float);
  55707. /**
  55708. * Gets the Color Grading 2D Lookup Texture.
  55709. */
  55710. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55711. /**
  55712. * Sets the Color Grading 2D Lookup Texture.
  55713. */
  55714. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55715. /**
  55716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55718. * 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;
  55719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55720. */
  55721. get cameraColorCurves(): Nullable<ColorCurves>;
  55722. /**
  55723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55725. * 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;
  55726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55727. */
  55728. set cameraColorCurves(value: Nullable<ColorCurves>);
  55729. /**
  55730. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55731. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55732. */
  55733. switchToBGR: boolean;
  55734. private _renderTargets;
  55735. private _reflectionControls;
  55736. private _white;
  55737. private _primaryShadowColor;
  55738. private _primaryHighlightColor;
  55739. /**
  55740. * Instantiates a Background Material in the given scene
  55741. * @param name The friendly name of the material
  55742. * @param scene The scene to add the material to
  55743. */
  55744. constructor(name: string, scene: Scene);
  55745. /**
  55746. * Gets a boolean indicating that current material needs to register RTT
  55747. */
  55748. get hasRenderTargetTextures(): boolean;
  55749. /**
  55750. * The entire material has been created in order to prevent overdraw.
  55751. * @returns false
  55752. */
  55753. needAlphaTesting(): boolean;
  55754. /**
  55755. * The entire material has been created in order to prevent overdraw.
  55756. * @returns true if blending is enable
  55757. */
  55758. needAlphaBlending(): boolean;
  55759. /**
  55760. * Checks wether the material is ready to be rendered for a given mesh.
  55761. * @param mesh The mesh to render
  55762. * @param subMesh The submesh to check against
  55763. * @param useInstances Specify wether or not the material is used with instances
  55764. * @returns true if all the dependencies are ready (Textures, Effects...)
  55765. */
  55766. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55767. /**
  55768. * Compute the primary color according to the chosen perceptual color.
  55769. */
  55770. private _computePrimaryColorFromPerceptualColor;
  55771. /**
  55772. * Compute the highlights and shadow colors according to their chosen levels.
  55773. */
  55774. private _computePrimaryColors;
  55775. /**
  55776. * Build the uniform buffer used in the material.
  55777. */
  55778. buildUniformLayout(): void;
  55779. /**
  55780. * Unbind the material.
  55781. */
  55782. unbind(): void;
  55783. /**
  55784. * Bind only the world matrix to the material.
  55785. * @param world The world matrix to bind.
  55786. */
  55787. bindOnlyWorldMatrix(world: Matrix): void;
  55788. /**
  55789. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55790. * @param world The world matrix to bind.
  55791. * @param subMesh The submesh to bind for.
  55792. */
  55793. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55794. /**
  55795. * Checks to see if a texture is used in the material.
  55796. * @param texture - Base texture to use.
  55797. * @returns - Boolean specifying if a texture is used in the material.
  55798. */
  55799. hasTexture(texture: BaseTexture): boolean;
  55800. /**
  55801. * Dispose the material.
  55802. * @param forceDisposeEffect Force disposal of the associated effect.
  55803. * @param forceDisposeTextures Force disposal of the associated textures.
  55804. */
  55805. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55806. /**
  55807. * Clones the material.
  55808. * @param name The cloned name.
  55809. * @returns The cloned material.
  55810. */
  55811. clone(name: string): BackgroundMaterial;
  55812. /**
  55813. * Serializes the current material to its JSON representation.
  55814. * @returns The JSON representation.
  55815. */
  55816. serialize(): any;
  55817. /**
  55818. * Gets the class name of the material
  55819. * @returns "BackgroundMaterial"
  55820. */
  55821. getClassName(): string;
  55822. /**
  55823. * Parse a JSON input to create back a background material.
  55824. * @param source The JSON data to parse
  55825. * @param scene The scene to create the parsed material in
  55826. * @param rootUrl The root url of the assets the material depends upon
  55827. * @returns the instantiated BackgroundMaterial.
  55828. */
  55829. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55830. }
  55831. }
  55832. declare module "babylonjs/Helpers/environmentHelper" {
  55833. import { Observable } from "babylonjs/Misc/observable";
  55834. import { Nullable } from "babylonjs/types";
  55835. import { Scene } from "babylonjs/scene";
  55836. import { Vector3 } from "babylonjs/Maths/math.vector";
  55837. import { Color3 } from "babylonjs/Maths/math.color";
  55838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55839. import { Mesh } from "babylonjs/Meshes/mesh";
  55840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55841. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55842. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55843. import "babylonjs/Meshes/Builders/planeBuilder";
  55844. import "babylonjs/Meshes/Builders/boxBuilder";
  55845. /**
  55846. * Represents the different options available during the creation of
  55847. * a Environment helper.
  55848. *
  55849. * This can control the default ground, skybox and image processing setup of your scene.
  55850. */
  55851. export interface IEnvironmentHelperOptions {
  55852. /**
  55853. * Specifies whether or not to create a ground.
  55854. * True by default.
  55855. */
  55856. createGround: boolean;
  55857. /**
  55858. * Specifies the ground size.
  55859. * 15 by default.
  55860. */
  55861. groundSize: number;
  55862. /**
  55863. * The texture used on the ground for the main color.
  55864. * Comes from the BabylonJS CDN by default.
  55865. *
  55866. * Remarks: Can be either a texture or a url.
  55867. */
  55868. groundTexture: string | BaseTexture;
  55869. /**
  55870. * The color mixed in the ground texture by default.
  55871. * BabylonJS clearColor by default.
  55872. */
  55873. groundColor: Color3;
  55874. /**
  55875. * Specifies the ground opacity.
  55876. * 1 by default.
  55877. */
  55878. groundOpacity: number;
  55879. /**
  55880. * Enables the ground to receive shadows.
  55881. * True by default.
  55882. */
  55883. enableGroundShadow: boolean;
  55884. /**
  55885. * Helps preventing the shadow to be fully black on the ground.
  55886. * 0.5 by default.
  55887. */
  55888. groundShadowLevel: number;
  55889. /**
  55890. * Creates a mirror texture attach to the ground.
  55891. * false by default.
  55892. */
  55893. enableGroundMirror: boolean;
  55894. /**
  55895. * Specifies the ground mirror size ratio.
  55896. * 0.3 by default as the default kernel is 64.
  55897. */
  55898. groundMirrorSizeRatio: number;
  55899. /**
  55900. * Specifies the ground mirror blur kernel size.
  55901. * 64 by default.
  55902. */
  55903. groundMirrorBlurKernel: number;
  55904. /**
  55905. * Specifies the ground mirror visibility amount.
  55906. * 1 by default
  55907. */
  55908. groundMirrorAmount: number;
  55909. /**
  55910. * Specifies the ground mirror reflectance weight.
  55911. * This uses the standard weight of the background material to setup the fresnel effect
  55912. * of the mirror.
  55913. * 1 by default.
  55914. */
  55915. groundMirrorFresnelWeight: number;
  55916. /**
  55917. * Specifies the ground mirror Falloff distance.
  55918. * This can helps reducing the size of the reflection.
  55919. * 0 by Default.
  55920. */
  55921. groundMirrorFallOffDistance: number;
  55922. /**
  55923. * Specifies the ground mirror texture type.
  55924. * Unsigned Int by Default.
  55925. */
  55926. groundMirrorTextureType: number;
  55927. /**
  55928. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55929. * the shown objects.
  55930. */
  55931. groundYBias: number;
  55932. /**
  55933. * Specifies whether or not to create a skybox.
  55934. * True by default.
  55935. */
  55936. createSkybox: boolean;
  55937. /**
  55938. * Specifies the skybox size.
  55939. * 20 by default.
  55940. */
  55941. skyboxSize: number;
  55942. /**
  55943. * The texture used on the skybox for the main color.
  55944. * Comes from the BabylonJS CDN by default.
  55945. *
  55946. * Remarks: Can be either a texture or a url.
  55947. */
  55948. skyboxTexture: string | BaseTexture;
  55949. /**
  55950. * The color mixed in the skybox texture by default.
  55951. * BabylonJS clearColor by default.
  55952. */
  55953. skyboxColor: Color3;
  55954. /**
  55955. * The background rotation around the Y axis of the scene.
  55956. * This helps aligning the key lights of your scene with the background.
  55957. * 0 by default.
  55958. */
  55959. backgroundYRotation: number;
  55960. /**
  55961. * Compute automatically the size of the elements to best fit with the scene.
  55962. */
  55963. sizeAuto: boolean;
  55964. /**
  55965. * Default position of the rootMesh if autoSize is not true.
  55966. */
  55967. rootPosition: Vector3;
  55968. /**
  55969. * Sets up the image processing in the scene.
  55970. * true by default.
  55971. */
  55972. setupImageProcessing: boolean;
  55973. /**
  55974. * The texture used as your environment texture in the scene.
  55975. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55976. *
  55977. * Remarks: Can be either a texture or a url.
  55978. */
  55979. environmentTexture: string | BaseTexture;
  55980. /**
  55981. * The value of the exposure to apply to the scene.
  55982. * 0.6 by default if setupImageProcessing is true.
  55983. */
  55984. cameraExposure: number;
  55985. /**
  55986. * The value of the contrast to apply to the scene.
  55987. * 1.6 by default if setupImageProcessing is true.
  55988. */
  55989. cameraContrast: number;
  55990. /**
  55991. * Specifies whether or not tonemapping should be enabled in the scene.
  55992. * true by default if setupImageProcessing is true.
  55993. */
  55994. toneMappingEnabled: boolean;
  55995. }
  55996. /**
  55997. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55998. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55999. * It also helps with the default setup of your imageProcessing configuration.
  56000. */
  56001. export class EnvironmentHelper {
  56002. /**
  56003. * Default ground texture URL.
  56004. */
  56005. private static _groundTextureCDNUrl;
  56006. /**
  56007. * Default skybox texture URL.
  56008. */
  56009. private static _skyboxTextureCDNUrl;
  56010. /**
  56011. * Default environment texture URL.
  56012. */
  56013. private static _environmentTextureCDNUrl;
  56014. /**
  56015. * Creates the default options for the helper.
  56016. */
  56017. private static _getDefaultOptions;
  56018. private _rootMesh;
  56019. /**
  56020. * Gets the root mesh created by the helper.
  56021. */
  56022. get rootMesh(): Mesh;
  56023. private _skybox;
  56024. /**
  56025. * Gets the skybox created by the helper.
  56026. */
  56027. get skybox(): Nullable<Mesh>;
  56028. private _skyboxTexture;
  56029. /**
  56030. * Gets the skybox texture created by the helper.
  56031. */
  56032. get skyboxTexture(): Nullable<BaseTexture>;
  56033. private _skyboxMaterial;
  56034. /**
  56035. * Gets the skybox material created by the helper.
  56036. */
  56037. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56038. private _ground;
  56039. /**
  56040. * Gets the ground mesh created by the helper.
  56041. */
  56042. get ground(): Nullable<Mesh>;
  56043. private _groundTexture;
  56044. /**
  56045. * Gets the ground texture created by the helper.
  56046. */
  56047. get groundTexture(): Nullable<BaseTexture>;
  56048. private _groundMirror;
  56049. /**
  56050. * Gets the ground mirror created by the helper.
  56051. */
  56052. get groundMirror(): Nullable<MirrorTexture>;
  56053. /**
  56054. * Gets the ground mirror render list to helps pushing the meshes
  56055. * you wish in the ground reflection.
  56056. */
  56057. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56058. private _groundMaterial;
  56059. /**
  56060. * Gets the ground material created by the helper.
  56061. */
  56062. get groundMaterial(): Nullable<BackgroundMaterial>;
  56063. /**
  56064. * Stores the creation options.
  56065. */
  56066. private readonly _scene;
  56067. private _options;
  56068. /**
  56069. * This observable will be notified with any error during the creation of the environment,
  56070. * mainly texture creation errors.
  56071. */
  56072. onErrorObservable: Observable<{
  56073. message?: string;
  56074. exception?: any;
  56075. }>;
  56076. /**
  56077. * constructor
  56078. * @param options Defines the options we want to customize the helper
  56079. * @param scene The scene to add the material to
  56080. */
  56081. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56082. /**
  56083. * Updates the background according to the new options
  56084. * @param options
  56085. */
  56086. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56087. /**
  56088. * Sets the primary color of all the available elements.
  56089. * @param color the main color to affect to the ground and the background
  56090. */
  56091. setMainColor(color: Color3): void;
  56092. /**
  56093. * Setup the image processing according to the specified options.
  56094. */
  56095. private _setupImageProcessing;
  56096. /**
  56097. * Setup the environment texture according to the specified options.
  56098. */
  56099. private _setupEnvironmentTexture;
  56100. /**
  56101. * Setup the background according to the specified options.
  56102. */
  56103. private _setupBackground;
  56104. /**
  56105. * Get the scene sizes according to the setup.
  56106. */
  56107. private _getSceneSize;
  56108. /**
  56109. * Setup the ground according to the specified options.
  56110. */
  56111. private _setupGround;
  56112. /**
  56113. * Setup the ground material according to the specified options.
  56114. */
  56115. private _setupGroundMaterial;
  56116. /**
  56117. * Setup the ground diffuse texture according to the specified options.
  56118. */
  56119. private _setupGroundDiffuseTexture;
  56120. /**
  56121. * Setup the ground mirror texture according to the specified options.
  56122. */
  56123. private _setupGroundMirrorTexture;
  56124. /**
  56125. * Setup the ground to receive the mirror texture.
  56126. */
  56127. private _setupMirrorInGroundMaterial;
  56128. /**
  56129. * Setup the skybox according to the specified options.
  56130. */
  56131. private _setupSkybox;
  56132. /**
  56133. * Setup the skybox material according to the specified options.
  56134. */
  56135. private _setupSkyboxMaterial;
  56136. /**
  56137. * Setup the skybox reflection texture according to the specified options.
  56138. */
  56139. private _setupSkyboxReflectionTexture;
  56140. private _errorHandler;
  56141. /**
  56142. * Dispose all the elements created by the Helper.
  56143. */
  56144. dispose(): void;
  56145. }
  56146. }
  56147. declare module "babylonjs/Helpers/photoDome" {
  56148. import { Observable } from "babylonjs/Misc/observable";
  56149. import { Nullable } from "babylonjs/types";
  56150. import { Scene } from "babylonjs/scene";
  56151. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56152. import { Mesh } from "babylonjs/Meshes/mesh";
  56153. import { Texture } from "babylonjs/Materials/Textures/texture";
  56154. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56155. import "babylonjs/Meshes/Builders/sphereBuilder";
  56156. /**
  56157. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56158. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56159. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56160. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56161. */
  56162. export class PhotoDome extends TransformNode {
  56163. /**
  56164. * Define the image as a Monoscopic panoramic 360 image.
  56165. */
  56166. static readonly MODE_MONOSCOPIC: number;
  56167. /**
  56168. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56169. */
  56170. static readonly MODE_TOPBOTTOM: number;
  56171. /**
  56172. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56173. */
  56174. static readonly MODE_SIDEBYSIDE: number;
  56175. private _useDirectMapping;
  56176. /**
  56177. * The texture being displayed on the sphere
  56178. */
  56179. protected _photoTexture: Texture;
  56180. /**
  56181. * Gets or sets the texture being displayed on the sphere
  56182. */
  56183. get photoTexture(): Texture;
  56184. set photoTexture(value: Texture);
  56185. /**
  56186. * Observable raised when an error occured while loading the 360 image
  56187. */
  56188. onLoadErrorObservable: Observable<string>;
  56189. /**
  56190. * The skybox material
  56191. */
  56192. protected _material: BackgroundMaterial;
  56193. /**
  56194. * The surface used for the skybox
  56195. */
  56196. protected _mesh: Mesh;
  56197. /**
  56198. * Gets the mesh used for the skybox.
  56199. */
  56200. get mesh(): Mesh;
  56201. /**
  56202. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56203. * Also see the options.resolution property.
  56204. */
  56205. get fovMultiplier(): number;
  56206. set fovMultiplier(value: number);
  56207. private _imageMode;
  56208. /**
  56209. * Gets or set the current video mode for the video. It can be:
  56210. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56211. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56212. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56213. */
  56214. get imageMode(): number;
  56215. set imageMode(value: number);
  56216. /**
  56217. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56218. * @param name Element's name, child elements will append suffixes for their own names.
  56219. * @param urlsOfPhoto defines the url of the photo to display
  56220. * @param options defines an object containing optional or exposed sub element properties
  56221. * @param onError defines a callback called when an error occured while loading the texture
  56222. */
  56223. constructor(name: string, urlOfPhoto: string, options: {
  56224. resolution?: number;
  56225. size?: number;
  56226. useDirectMapping?: boolean;
  56227. faceForward?: boolean;
  56228. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56229. private _onBeforeCameraRenderObserver;
  56230. private _changeImageMode;
  56231. /**
  56232. * Releases resources associated with this node.
  56233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56235. */
  56236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56237. }
  56238. }
  56239. declare module "babylonjs/Misc/rgbdTextureTools" {
  56240. import "babylonjs/Shaders/rgbdDecode.fragment";
  56241. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56242. import { Texture } from "babylonjs/Materials/Textures/texture";
  56243. /**
  56244. * Class used to host RGBD texture specific utilities
  56245. */
  56246. export class RGBDTextureTools {
  56247. /**
  56248. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56249. * @param texture the texture to expand.
  56250. */
  56251. static ExpandRGBDTexture(texture: Texture): void;
  56252. }
  56253. }
  56254. declare module "babylonjs/Misc/brdfTextureTools" {
  56255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56256. import { Scene } from "babylonjs/scene";
  56257. /**
  56258. * Class used to host texture specific utilities
  56259. */
  56260. export class BRDFTextureTools {
  56261. /**
  56262. * Prevents texture cache collision
  56263. */
  56264. private static _instanceNumber;
  56265. /**
  56266. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56267. * @param scene defines the hosting scene
  56268. * @returns the environment BRDF texture
  56269. */
  56270. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56271. private static _environmentBRDFBase64Texture;
  56272. }
  56273. }
  56274. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56275. import { Nullable } from "babylonjs/types";
  56276. import { Color3 } from "babylonjs/Maths/math.color";
  56277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56278. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56280. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56281. import { Engine } from "babylonjs/Engines/engine";
  56282. import { Scene } from "babylonjs/scene";
  56283. /**
  56284. * @hidden
  56285. */
  56286. export interface IMaterialClearCoatDefines {
  56287. CLEARCOAT: boolean;
  56288. CLEARCOAT_DEFAULTIOR: boolean;
  56289. CLEARCOAT_TEXTURE: boolean;
  56290. CLEARCOAT_TEXTUREDIRECTUV: number;
  56291. CLEARCOAT_BUMP: boolean;
  56292. CLEARCOAT_BUMPDIRECTUV: number;
  56293. CLEARCOAT_TINT: boolean;
  56294. CLEARCOAT_TINT_TEXTURE: boolean;
  56295. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56296. /** @hidden */
  56297. _areTexturesDirty: boolean;
  56298. }
  56299. /**
  56300. * Define the code related to the clear coat parameters of the pbr material.
  56301. */
  56302. export class PBRClearCoatConfiguration {
  56303. /**
  56304. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56305. * The default fits with a polyurethane material.
  56306. */
  56307. private static readonly _DefaultIndexOfRefraction;
  56308. private _isEnabled;
  56309. /**
  56310. * Defines if the clear coat is enabled in the material.
  56311. */
  56312. isEnabled: boolean;
  56313. /**
  56314. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56315. */
  56316. intensity: number;
  56317. /**
  56318. * Defines the clear coat layer roughness.
  56319. */
  56320. roughness: number;
  56321. private _indexOfRefraction;
  56322. /**
  56323. * Defines the index of refraction of the clear coat.
  56324. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56325. * The default fits with a polyurethane material.
  56326. * Changing the default value is more performance intensive.
  56327. */
  56328. indexOfRefraction: number;
  56329. private _texture;
  56330. /**
  56331. * Stores the clear coat values in a texture.
  56332. */
  56333. texture: Nullable<BaseTexture>;
  56334. private _bumpTexture;
  56335. /**
  56336. * Define the clear coat specific bump texture.
  56337. */
  56338. bumpTexture: Nullable<BaseTexture>;
  56339. private _isTintEnabled;
  56340. /**
  56341. * Defines if the clear coat tint is enabled in the material.
  56342. */
  56343. isTintEnabled: boolean;
  56344. /**
  56345. * Defines the clear coat tint of the material.
  56346. * This is only use if tint is enabled
  56347. */
  56348. tintColor: Color3;
  56349. /**
  56350. * Defines the distance at which the tint color should be found in the
  56351. * clear coat media.
  56352. * This is only use if tint is enabled
  56353. */
  56354. tintColorAtDistance: number;
  56355. /**
  56356. * Defines the clear coat layer thickness.
  56357. * This is only use if tint is enabled
  56358. */
  56359. tintThickness: number;
  56360. private _tintTexture;
  56361. /**
  56362. * Stores the clear tint values in a texture.
  56363. * rgb is tint
  56364. * a is a thickness factor
  56365. */
  56366. tintTexture: Nullable<BaseTexture>;
  56367. /** @hidden */
  56368. private _internalMarkAllSubMeshesAsTexturesDirty;
  56369. /** @hidden */
  56370. _markAllSubMeshesAsTexturesDirty(): void;
  56371. /**
  56372. * Instantiate a new istance of clear coat configuration.
  56373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56374. */
  56375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56376. /**
  56377. * Gets wehter the submesh is ready to be used or not.
  56378. * @param defines the list of "defines" to update.
  56379. * @param scene defines the scene the material belongs to.
  56380. * @param engine defines the engine the material belongs to.
  56381. * @param disableBumpMap defines wether the material disables bump or not.
  56382. * @returns - boolean indicating that the submesh is ready or not.
  56383. */
  56384. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56385. /**
  56386. * Checks to see if a texture is used in the material.
  56387. * @param defines the list of "defines" to update.
  56388. * @param scene defines the scene to the material belongs to.
  56389. */
  56390. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56391. /**
  56392. * Binds the material data.
  56393. * @param uniformBuffer defines the Uniform buffer to fill in.
  56394. * @param scene defines the scene the material belongs to.
  56395. * @param engine defines the engine the material belongs to.
  56396. * @param disableBumpMap defines wether the material disables bump or not.
  56397. * @param isFrozen defines wether the material is frozen or not.
  56398. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56399. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56400. */
  56401. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56402. /**
  56403. * Checks to see if a texture is used in the material.
  56404. * @param texture - Base texture to use.
  56405. * @returns - Boolean specifying if a texture is used in the material.
  56406. */
  56407. hasTexture(texture: BaseTexture): boolean;
  56408. /**
  56409. * Returns an array of the actively used textures.
  56410. * @param activeTextures Array of BaseTextures
  56411. */
  56412. getActiveTextures(activeTextures: BaseTexture[]): void;
  56413. /**
  56414. * Returns the animatable textures.
  56415. * @param animatables Array of animatable textures.
  56416. */
  56417. getAnimatables(animatables: IAnimatable[]): void;
  56418. /**
  56419. * Disposes the resources of the material.
  56420. * @param forceDisposeTextures - Forces the disposal of all textures.
  56421. */
  56422. dispose(forceDisposeTextures?: boolean): void;
  56423. /**
  56424. * Get the current class name of the texture useful for serialization or dynamic coding.
  56425. * @returns "PBRClearCoatConfiguration"
  56426. */
  56427. getClassName(): string;
  56428. /**
  56429. * Add fallbacks to the effect fallbacks list.
  56430. * @param defines defines the Base texture to use.
  56431. * @param fallbacks defines the current fallback list.
  56432. * @param currentRank defines the current fallback rank.
  56433. * @returns the new fallback rank.
  56434. */
  56435. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56436. /**
  56437. * Add the required uniforms to the current list.
  56438. * @param uniforms defines the current uniform list.
  56439. */
  56440. static AddUniforms(uniforms: string[]): void;
  56441. /**
  56442. * Add the required samplers to the current list.
  56443. * @param samplers defines the current sampler list.
  56444. */
  56445. static AddSamplers(samplers: string[]): void;
  56446. /**
  56447. * Add the required uniforms to the current buffer.
  56448. * @param uniformBuffer defines the current uniform buffer.
  56449. */
  56450. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56451. /**
  56452. * Makes a duplicate of the current configuration into another one.
  56453. * @param clearCoatConfiguration define the config where to copy the info
  56454. */
  56455. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56456. /**
  56457. * Serializes this clear coat configuration.
  56458. * @returns - An object with the serialized config.
  56459. */
  56460. serialize(): any;
  56461. /**
  56462. * Parses a anisotropy Configuration from a serialized object.
  56463. * @param source - Serialized object.
  56464. * @param scene Defines the scene we are parsing for
  56465. * @param rootUrl Defines the rootUrl to load from
  56466. */
  56467. parse(source: any, scene: Scene, rootUrl: string): void;
  56468. }
  56469. }
  56470. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56471. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56473. import { Vector2 } from "babylonjs/Maths/math.vector";
  56474. import { Scene } from "babylonjs/scene";
  56475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56476. import { Nullable } from "babylonjs/types";
  56477. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56478. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56479. /**
  56480. * @hidden
  56481. */
  56482. export interface IMaterialAnisotropicDefines {
  56483. ANISOTROPIC: boolean;
  56484. ANISOTROPIC_TEXTURE: boolean;
  56485. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56486. MAINUV1: boolean;
  56487. _areTexturesDirty: boolean;
  56488. _needUVs: boolean;
  56489. }
  56490. /**
  56491. * Define the code related to the anisotropic parameters of the pbr material.
  56492. */
  56493. export class PBRAnisotropicConfiguration {
  56494. private _isEnabled;
  56495. /**
  56496. * Defines if the anisotropy is enabled in the material.
  56497. */
  56498. isEnabled: boolean;
  56499. /**
  56500. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56501. */
  56502. intensity: number;
  56503. /**
  56504. * Defines if the effect is along the tangents, bitangents or in between.
  56505. * By default, the effect is "strectching" the highlights along the tangents.
  56506. */
  56507. direction: Vector2;
  56508. private _texture;
  56509. /**
  56510. * Stores the anisotropy values in a texture.
  56511. * rg is direction (like normal from -1 to 1)
  56512. * b is a intensity
  56513. */
  56514. texture: Nullable<BaseTexture>;
  56515. /** @hidden */
  56516. private _internalMarkAllSubMeshesAsTexturesDirty;
  56517. /** @hidden */
  56518. _markAllSubMeshesAsTexturesDirty(): void;
  56519. /**
  56520. * Instantiate a new istance of anisotropy configuration.
  56521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56522. */
  56523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56524. /**
  56525. * Specifies that the submesh is ready to be used.
  56526. * @param defines the list of "defines" to update.
  56527. * @param scene defines the scene the material belongs to.
  56528. * @returns - boolean indicating that the submesh is ready or not.
  56529. */
  56530. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56531. /**
  56532. * Checks to see if a texture is used in the material.
  56533. * @param defines the list of "defines" to update.
  56534. * @param mesh the mesh we are preparing the defines for.
  56535. * @param scene defines the scene the material belongs to.
  56536. */
  56537. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56538. /**
  56539. * Binds the material data.
  56540. * @param uniformBuffer defines the Uniform buffer to fill in.
  56541. * @param scene defines the scene the material belongs to.
  56542. * @param isFrozen defines wether the material is frozen or not.
  56543. */
  56544. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56545. /**
  56546. * Checks to see if a texture is used in the material.
  56547. * @param texture - Base texture to use.
  56548. * @returns - Boolean specifying if a texture is used in the material.
  56549. */
  56550. hasTexture(texture: BaseTexture): boolean;
  56551. /**
  56552. * Returns an array of the actively used textures.
  56553. * @param activeTextures Array of BaseTextures
  56554. */
  56555. getActiveTextures(activeTextures: BaseTexture[]): void;
  56556. /**
  56557. * Returns the animatable textures.
  56558. * @param animatables Array of animatable textures.
  56559. */
  56560. getAnimatables(animatables: IAnimatable[]): void;
  56561. /**
  56562. * Disposes the resources of the material.
  56563. * @param forceDisposeTextures - Forces the disposal of all textures.
  56564. */
  56565. dispose(forceDisposeTextures?: boolean): void;
  56566. /**
  56567. * Get the current class name of the texture useful for serialization or dynamic coding.
  56568. * @returns "PBRAnisotropicConfiguration"
  56569. */
  56570. getClassName(): string;
  56571. /**
  56572. * Add fallbacks to the effect fallbacks list.
  56573. * @param defines defines the Base texture to use.
  56574. * @param fallbacks defines the current fallback list.
  56575. * @param currentRank defines the current fallback rank.
  56576. * @returns the new fallback rank.
  56577. */
  56578. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56579. /**
  56580. * Add the required uniforms to the current list.
  56581. * @param uniforms defines the current uniform list.
  56582. */
  56583. static AddUniforms(uniforms: string[]): void;
  56584. /**
  56585. * Add the required uniforms to the current buffer.
  56586. * @param uniformBuffer defines the current uniform buffer.
  56587. */
  56588. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56589. /**
  56590. * Add the required samplers to the current list.
  56591. * @param samplers defines the current sampler list.
  56592. */
  56593. static AddSamplers(samplers: string[]): void;
  56594. /**
  56595. * Makes a duplicate of the current configuration into another one.
  56596. * @param anisotropicConfiguration define the config where to copy the info
  56597. */
  56598. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56599. /**
  56600. * Serializes this anisotropy configuration.
  56601. * @returns - An object with the serialized config.
  56602. */
  56603. serialize(): any;
  56604. /**
  56605. * Parses a anisotropy Configuration from a serialized object.
  56606. * @param source - Serialized object.
  56607. * @param scene Defines the scene we are parsing for
  56608. * @param rootUrl Defines the rootUrl to load from
  56609. */
  56610. parse(source: any, scene: Scene, rootUrl: string): void;
  56611. }
  56612. }
  56613. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56614. import { Scene } from "babylonjs/scene";
  56615. /**
  56616. * @hidden
  56617. */
  56618. export interface IMaterialBRDFDefines {
  56619. BRDF_V_HEIGHT_CORRELATED: boolean;
  56620. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56621. SPHERICAL_HARMONICS: boolean;
  56622. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56623. /** @hidden */
  56624. _areMiscDirty: boolean;
  56625. }
  56626. /**
  56627. * Define the code related to the BRDF parameters of the pbr material.
  56628. */
  56629. export class PBRBRDFConfiguration {
  56630. /**
  56631. * Default value used for the energy conservation.
  56632. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56633. */
  56634. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56635. /**
  56636. * Default value used for the Smith Visibility Height Correlated mode.
  56637. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56638. */
  56639. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56640. /**
  56641. * Default value used for the IBL diffuse part.
  56642. * This can help switching back to the polynomials mode globally which is a tiny bit
  56643. * less GPU intensive at the drawback of a lower quality.
  56644. */
  56645. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56646. /**
  56647. * Default value used for activating energy conservation for the specular workflow.
  56648. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56649. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56650. */
  56651. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56652. private _useEnergyConservation;
  56653. /**
  56654. * Defines if the material uses energy conservation.
  56655. */
  56656. useEnergyConservation: boolean;
  56657. private _useSmithVisibilityHeightCorrelated;
  56658. /**
  56659. * LEGACY Mode set to false
  56660. * Defines if the material uses height smith correlated visibility term.
  56661. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56662. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56663. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56664. * Not relying on height correlated will also disable energy conservation.
  56665. */
  56666. useSmithVisibilityHeightCorrelated: boolean;
  56667. private _useSphericalHarmonics;
  56668. /**
  56669. * LEGACY Mode set to false
  56670. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56671. * diffuse part of the IBL.
  56672. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56673. * to the ground truth.
  56674. */
  56675. useSphericalHarmonics: boolean;
  56676. private _useSpecularGlossinessInputEnergyConservation;
  56677. /**
  56678. * Defines if the material uses energy conservation, when the specular workflow is active.
  56679. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56680. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56681. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56682. */
  56683. useSpecularGlossinessInputEnergyConservation: boolean;
  56684. /** @hidden */
  56685. private _internalMarkAllSubMeshesAsMiscDirty;
  56686. /** @hidden */
  56687. _markAllSubMeshesAsMiscDirty(): void;
  56688. /**
  56689. * Instantiate a new istance of clear coat configuration.
  56690. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56691. */
  56692. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56693. /**
  56694. * Checks to see if a texture is used in the material.
  56695. * @param defines the list of "defines" to update.
  56696. */
  56697. prepareDefines(defines: IMaterialBRDFDefines): void;
  56698. /**
  56699. * Get the current class name of the texture useful for serialization or dynamic coding.
  56700. * @returns "PBRClearCoatConfiguration"
  56701. */
  56702. getClassName(): string;
  56703. /**
  56704. * Makes a duplicate of the current configuration into another one.
  56705. * @param brdfConfiguration define the config where to copy the info
  56706. */
  56707. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56708. /**
  56709. * Serializes this BRDF configuration.
  56710. * @returns - An object with the serialized config.
  56711. */
  56712. serialize(): any;
  56713. /**
  56714. * Parses a anisotropy Configuration from a serialized object.
  56715. * @param source - Serialized object.
  56716. * @param scene Defines the scene we are parsing for
  56717. * @param rootUrl Defines the rootUrl to load from
  56718. */
  56719. parse(source: any, scene: Scene, rootUrl: string): void;
  56720. }
  56721. }
  56722. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56723. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56724. import { Color3 } from "babylonjs/Maths/math.color";
  56725. import { Scene } from "babylonjs/scene";
  56726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56727. import { Nullable } from "babylonjs/types";
  56728. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56729. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56730. /**
  56731. * @hidden
  56732. */
  56733. export interface IMaterialSheenDefines {
  56734. SHEEN: boolean;
  56735. SHEEN_TEXTURE: boolean;
  56736. SHEEN_TEXTUREDIRECTUV: number;
  56737. SHEEN_LINKWITHALBEDO: boolean;
  56738. SHEEN_ROUGHNESS: boolean;
  56739. SHEEN_ALBEDOSCALING: boolean;
  56740. /** @hidden */
  56741. _areTexturesDirty: boolean;
  56742. }
  56743. /**
  56744. * Define the code related to the Sheen parameters of the pbr material.
  56745. */
  56746. export class PBRSheenConfiguration {
  56747. private _isEnabled;
  56748. /**
  56749. * Defines if the material uses sheen.
  56750. */
  56751. isEnabled: boolean;
  56752. private _linkSheenWithAlbedo;
  56753. /**
  56754. * Defines if the sheen is linked to the sheen color.
  56755. */
  56756. linkSheenWithAlbedo: boolean;
  56757. /**
  56758. * Defines the sheen intensity.
  56759. */
  56760. intensity: number;
  56761. /**
  56762. * Defines the sheen color.
  56763. */
  56764. color: Color3;
  56765. private _texture;
  56766. /**
  56767. * Stores the sheen tint values in a texture.
  56768. * rgb is tint
  56769. * a is a intensity or roughness if roughness has been defined
  56770. */
  56771. texture: Nullable<BaseTexture>;
  56772. private _roughness;
  56773. /**
  56774. * Defines the sheen roughness.
  56775. * It is not taken into account if linkSheenWithAlbedo is true.
  56776. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56777. */
  56778. roughness: Nullable<number>;
  56779. private _albedoScaling;
  56780. /**
  56781. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56782. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56783. * making it easier to setup and tweak the effect
  56784. */
  56785. albedoScaling: boolean;
  56786. /** @hidden */
  56787. private _internalMarkAllSubMeshesAsTexturesDirty;
  56788. /** @hidden */
  56789. _markAllSubMeshesAsTexturesDirty(): void;
  56790. /**
  56791. * Instantiate a new istance of clear coat configuration.
  56792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56793. */
  56794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56795. /**
  56796. * Specifies that the submesh is ready to be used.
  56797. * @param defines the list of "defines" to update.
  56798. * @param scene defines the scene the material belongs to.
  56799. * @returns - boolean indicating that the submesh is ready or not.
  56800. */
  56801. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56802. /**
  56803. * Checks to see if a texture is used in the material.
  56804. * @param defines the list of "defines" to update.
  56805. * @param scene defines the scene the material belongs to.
  56806. */
  56807. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56808. /**
  56809. * Binds the material data.
  56810. * @param uniformBuffer defines the Uniform buffer to fill in.
  56811. * @param scene defines the scene the material belongs to.
  56812. * @param isFrozen defines wether the material is frozen or not.
  56813. */
  56814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56815. /**
  56816. * Checks to see if a texture is used in the material.
  56817. * @param texture - Base texture to use.
  56818. * @returns - Boolean specifying if a texture is used in the material.
  56819. */
  56820. hasTexture(texture: BaseTexture): boolean;
  56821. /**
  56822. * Returns an array of the actively used textures.
  56823. * @param activeTextures Array of BaseTextures
  56824. */
  56825. getActiveTextures(activeTextures: BaseTexture[]): void;
  56826. /**
  56827. * Returns the animatable textures.
  56828. * @param animatables Array of animatable textures.
  56829. */
  56830. getAnimatables(animatables: IAnimatable[]): void;
  56831. /**
  56832. * Disposes the resources of the material.
  56833. * @param forceDisposeTextures - Forces the disposal of all textures.
  56834. */
  56835. dispose(forceDisposeTextures?: boolean): void;
  56836. /**
  56837. * Get the current class name of the texture useful for serialization or dynamic coding.
  56838. * @returns "PBRSheenConfiguration"
  56839. */
  56840. getClassName(): string;
  56841. /**
  56842. * Add fallbacks to the effect fallbacks list.
  56843. * @param defines defines the Base texture to use.
  56844. * @param fallbacks defines the current fallback list.
  56845. * @param currentRank defines the current fallback rank.
  56846. * @returns the new fallback rank.
  56847. */
  56848. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56849. /**
  56850. * Add the required uniforms to the current list.
  56851. * @param uniforms defines the current uniform list.
  56852. */
  56853. static AddUniforms(uniforms: string[]): void;
  56854. /**
  56855. * Add the required uniforms to the current buffer.
  56856. * @param uniformBuffer defines the current uniform buffer.
  56857. */
  56858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56859. /**
  56860. * Add the required samplers to the current list.
  56861. * @param samplers defines the current sampler list.
  56862. */
  56863. static AddSamplers(samplers: string[]): void;
  56864. /**
  56865. * Makes a duplicate of the current configuration into another one.
  56866. * @param sheenConfiguration define the config where to copy the info
  56867. */
  56868. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56869. /**
  56870. * Serializes this BRDF configuration.
  56871. * @returns - An object with the serialized config.
  56872. */
  56873. serialize(): any;
  56874. /**
  56875. * Parses a anisotropy Configuration from a serialized object.
  56876. * @param source - Serialized object.
  56877. * @param scene Defines the scene we are parsing for
  56878. * @param rootUrl Defines the rootUrl to load from
  56879. */
  56880. parse(source: any, scene: Scene, rootUrl: string): void;
  56881. }
  56882. }
  56883. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56884. import { Nullable } from "babylonjs/types";
  56885. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56886. import { Color3 } from "babylonjs/Maths/math.color";
  56887. import { SmartArray } from "babylonjs/Misc/smartArray";
  56888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56890. import { Effect } from "babylonjs/Materials/effect";
  56891. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56892. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56893. import { Engine } from "babylonjs/Engines/engine";
  56894. import { Scene } from "babylonjs/scene";
  56895. /**
  56896. * @hidden
  56897. */
  56898. export interface IMaterialSubSurfaceDefines {
  56899. SUBSURFACE: boolean;
  56900. SS_REFRACTION: boolean;
  56901. SS_TRANSLUCENCY: boolean;
  56902. SS_SCATTERING: boolean;
  56903. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56904. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56905. SS_REFRACTIONMAP_3D: boolean;
  56906. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56907. SS_LODINREFRACTIONALPHA: boolean;
  56908. SS_GAMMAREFRACTION: boolean;
  56909. SS_RGBDREFRACTION: boolean;
  56910. SS_LINEARSPECULARREFRACTION: boolean;
  56911. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56912. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56913. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56914. /** @hidden */
  56915. _areTexturesDirty: boolean;
  56916. }
  56917. /**
  56918. * Define the code related to the sub surface parameters of the pbr material.
  56919. */
  56920. export class PBRSubSurfaceConfiguration {
  56921. private _isRefractionEnabled;
  56922. /**
  56923. * Defines if the refraction is enabled in the material.
  56924. */
  56925. isRefractionEnabled: boolean;
  56926. private _isTranslucencyEnabled;
  56927. /**
  56928. * Defines if the translucency is enabled in the material.
  56929. */
  56930. isTranslucencyEnabled: boolean;
  56931. private _isScatteringEnabled;
  56932. /**
  56933. * Defines the refraction intensity of the material.
  56934. * The refraction when enabled replaces the Diffuse part of the material.
  56935. * The intensity helps transitionning between diffuse and refraction.
  56936. */
  56937. refractionIntensity: number;
  56938. /**
  56939. * Defines the translucency intensity of the material.
  56940. * When translucency has been enabled, this defines how much of the "translucency"
  56941. * is addded to the diffuse part of the material.
  56942. */
  56943. translucencyIntensity: number;
  56944. /**
  56945. * Defines the scattering intensity of the material.
  56946. * When scattering has been enabled, this defines how much of the "scattered light"
  56947. * is addded to the diffuse part of the material.
  56948. */
  56949. scatteringIntensity: number;
  56950. /**
  56951. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56952. */
  56953. useAlbedoToTintRefraction: boolean;
  56954. private _thicknessTexture;
  56955. /**
  56956. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56957. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56958. * 0 would mean minimumThickness
  56959. * 1 would mean maximumThickness
  56960. * The other channels might be use as a mask to vary the different effects intensity.
  56961. */
  56962. thicknessTexture: Nullable<BaseTexture>;
  56963. private _refractionTexture;
  56964. /**
  56965. * Defines the texture to use for refraction.
  56966. */
  56967. refractionTexture: Nullable<BaseTexture>;
  56968. private _indexOfRefraction;
  56969. /**
  56970. * Index of refraction of the material base layer.
  56971. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56972. *
  56973. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56974. *
  56975. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56976. */
  56977. indexOfRefraction: number;
  56978. private _volumeIndexOfRefraction;
  56979. /**
  56980. * Index of refraction of the material's volume.
  56981. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56982. *
  56983. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56984. * the volume will use the same IOR as the surface.
  56985. */
  56986. get volumeIndexOfRefraction(): number;
  56987. set volumeIndexOfRefraction(value: number);
  56988. private _invertRefractionY;
  56989. /**
  56990. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56991. */
  56992. invertRefractionY: boolean;
  56993. private _linkRefractionWithTransparency;
  56994. /**
  56995. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56996. * Materials half opaque for instance using refraction could benefit from this control.
  56997. */
  56998. linkRefractionWithTransparency: boolean;
  56999. /**
  57000. * Defines the minimum thickness stored in the thickness map.
  57001. * If no thickness map is defined, this value will be used to simulate thickness.
  57002. */
  57003. minimumThickness: number;
  57004. /**
  57005. * Defines the maximum thickness stored in the thickness map.
  57006. */
  57007. maximumThickness: number;
  57008. /**
  57009. * Defines the volume tint of the material.
  57010. * This is used for both translucency and scattering.
  57011. */
  57012. tintColor: Color3;
  57013. /**
  57014. * Defines the distance at which the tint color should be found in the media.
  57015. * This is used for refraction only.
  57016. */
  57017. tintColorAtDistance: number;
  57018. /**
  57019. * Defines how far each channel transmit through the media.
  57020. * It is defined as a color to simplify it selection.
  57021. */
  57022. diffusionDistance: Color3;
  57023. private _useMaskFromThicknessTexture;
  57024. /**
  57025. * Stores the intensity of the different subsurface effects in the thickness texture.
  57026. * * the green channel is the translucency intensity.
  57027. * * the blue channel is the scattering intensity.
  57028. * * the alpha channel is the refraction intensity.
  57029. */
  57030. useMaskFromThicknessTexture: boolean;
  57031. /** @hidden */
  57032. private _internalMarkAllSubMeshesAsTexturesDirty;
  57033. /** @hidden */
  57034. _markAllSubMeshesAsTexturesDirty(): void;
  57035. /**
  57036. * Instantiate a new istance of sub surface configuration.
  57037. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57038. */
  57039. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57040. /**
  57041. * Gets wehter the submesh is ready to be used or not.
  57042. * @param defines the list of "defines" to update.
  57043. * @param scene defines the scene the material belongs to.
  57044. * @returns - boolean indicating that the submesh is ready or not.
  57045. */
  57046. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57047. /**
  57048. * Checks to see if a texture is used in the material.
  57049. * @param defines the list of "defines" to update.
  57050. * @param scene defines the scene to the material belongs to.
  57051. */
  57052. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57053. /**
  57054. * Binds the material data.
  57055. * @param uniformBuffer defines the Uniform buffer to fill in.
  57056. * @param scene defines the scene the material belongs to.
  57057. * @param engine defines the engine the material belongs to.
  57058. * @param isFrozen defines whether the material is frozen or not.
  57059. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57060. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57061. */
  57062. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57063. /**
  57064. * Unbinds the material from the mesh.
  57065. * @param activeEffect defines the effect that should be unbound from.
  57066. * @returns true if unbound, otherwise false
  57067. */
  57068. unbind(activeEffect: Effect): boolean;
  57069. /**
  57070. * Returns the texture used for refraction or null if none is used.
  57071. * @param scene defines the scene the material belongs to.
  57072. * @returns - Refraction texture if present. If no refraction texture and refraction
  57073. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57074. */
  57075. private _getRefractionTexture;
  57076. /**
  57077. * Returns true if alpha blending should be disabled.
  57078. */
  57079. get disableAlphaBlending(): boolean;
  57080. /**
  57081. * Fills the list of render target textures.
  57082. * @param renderTargets the list of render targets to update
  57083. */
  57084. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57085. /**
  57086. * Checks to see if a texture is used in the material.
  57087. * @param texture - Base texture to use.
  57088. * @returns - Boolean specifying if a texture is used in the material.
  57089. */
  57090. hasTexture(texture: BaseTexture): boolean;
  57091. /**
  57092. * Gets a boolean indicating that current material needs to register RTT
  57093. * @returns true if this uses a render target otherwise false.
  57094. */
  57095. hasRenderTargetTextures(): boolean;
  57096. /**
  57097. * Returns an array of the actively used textures.
  57098. * @param activeTextures Array of BaseTextures
  57099. */
  57100. getActiveTextures(activeTextures: BaseTexture[]): void;
  57101. /**
  57102. * Returns the animatable textures.
  57103. * @param animatables Array of animatable textures.
  57104. */
  57105. getAnimatables(animatables: IAnimatable[]): void;
  57106. /**
  57107. * Disposes the resources of the material.
  57108. * @param forceDisposeTextures - Forces the disposal of all textures.
  57109. */
  57110. dispose(forceDisposeTextures?: boolean): void;
  57111. /**
  57112. * Get the current class name of the texture useful for serialization or dynamic coding.
  57113. * @returns "PBRSubSurfaceConfiguration"
  57114. */
  57115. getClassName(): string;
  57116. /**
  57117. * Add fallbacks to the effect fallbacks list.
  57118. * @param defines defines the Base texture to use.
  57119. * @param fallbacks defines the current fallback list.
  57120. * @param currentRank defines the current fallback rank.
  57121. * @returns the new fallback rank.
  57122. */
  57123. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57124. /**
  57125. * Add the required uniforms to the current list.
  57126. * @param uniforms defines the current uniform list.
  57127. */
  57128. static AddUniforms(uniforms: string[]): void;
  57129. /**
  57130. * Add the required samplers to the current list.
  57131. * @param samplers defines the current sampler list.
  57132. */
  57133. static AddSamplers(samplers: string[]): void;
  57134. /**
  57135. * Add the required uniforms to the current buffer.
  57136. * @param uniformBuffer defines the current uniform buffer.
  57137. */
  57138. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57139. /**
  57140. * Makes a duplicate of the current configuration into another one.
  57141. * @param configuration define the config where to copy the info
  57142. */
  57143. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57144. /**
  57145. * Serializes this Sub Surface configuration.
  57146. * @returns - An object with the serialized config.
  57147. */
  57148. serialize(): any;
  57149. /**
  57150. * Parses a anisotropy Configuration from a serialized object.
  57151. * @param source - Serialized object.
  57152. * @param scene Defines the scene we are parsing for
  57153. * @param rootUrl Defines the rootUrl to load from
  57154. */
  57155. parse(source: any, scene: Scene, rootUrl: string): void;
  57156. }
  57157. }
  57158. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57159. /** @hidden */
  57160. export var pbrFragmentDeclaration: {
  57161. name: string;
  57162. shader: string;
  57163. };
  57164. }
  57165. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57166. /** @hidden */
  57167. export var pbrUboDeclaration: {
  57168. name: string;
  57169. shader: string;
  57170. };
  57171. }
  57172. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57173. /** @hidden */
  57174. export var pbrFragmentExtraDeclaration: {
  57175. name: string;
  57176. shader: string;
  57177. };
  57178. }
  57179. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57180. /** @hidden */
  57181. export var pbrFragmentSamplersDeclaration: {
  57182. name: string;
  57183. shader: string;
  57184. };
  57185. }
  57186. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57187. /** @hidden */
  57188. export var importanceSampling: {
  57189. name: string;
  57190. shader: string;
  57191. };
  57192. }
  57193. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57194. /** @hidden */
  57195. export var pbrHelperFunctions: {
  57196. name: string;
  57197. shader: string;
  57198. };
  57199. }
  57200. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57201. /** @hidden */
  57202. export var harmonicsFunctions: {
  57203. name: string;
  57204. shader: string;
  57205. };
  57206. }
  57207. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57208. /** @hidden */
  57209. export var pbrDirectLightingSetupFunctions: {
  57210. name: string;
  57211. shader: string;
  57212. };
  57213. }
  57214. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57215. /** @hidden */
  57216. export var pbrDirectLightingFalloffFunctions: {
  57217. name: string;
  57218. shader: string;
  57219. };
  57220. }
  57221. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57222. /** @hidden */
  57223. export var pbrBRDFFunctions: {
  57224. name: string;
  57225. shader: string;
  57226. };
  57227. }
  57228. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57229. /** @hidden */
  57230. export var hdrFilteringFunctions: {
  57231. name: string;
  57232. shader: string;
  57233. };
  57234. }
  57235. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57236. /** @hidden */
  57237. export var pbrDirectLightingFunctions: {
  57238. name: string;
  57239. shader: string;
  57240. };
  57241. }
  57242. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57243. /** @hidden */
  57244. export var pbrIBLFunctions: {
  57245. name: string;
  57246. shader: string;
  57247. };
  57248. }
  57249. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57250. /** @hidden */
  57251. export var pbrBlockAlbedoOpacity: {
  57252. name: string;
  57253. shader: string;
  57254. };
  57255. }
  57256. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57257. /** @hidden */
  57258. export var pbrBlockReflectivity: {
  57259. name: string;
  57260. shader: string;
  57261. };
  57262. }
  57263. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57264. /** @hidden */
  57265. export var pbrBlockAmbientOcclusion: {
  57266. name: string;
  57267. shader: string;
  57268. };
  57269. }
  57270. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57271. /** @hidden */
  57272. export var pbrBlockAlphaFresnel: {
  57273. name: string;
  57274. shader: string;
  57275. };
  57276. }
  57277. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57278. /** @hidden */
  57279. export var pbrBlockAnisotropic: {
  57280. name: string;
  57281. shader: string;
  57282. };
  57283. }
  57284. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57285. /** @hidden */
  57286. export var pbrBlockReflection: {
  57287. name: string;
  57288. shader: string;
  57289. };
  57290. }
  57291. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57292. /** @hidden */
  57293. export var pbrBlockSheen: {
  57294. name: string;
  57295. shader: string;
  57296. };
  57297. }
  57298. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57299. /** @hidden */
  57300. export var pbrBlockClearcoat: {
  57301. name: string;
  57302. shader: string;
  57303. };
  57304. }
  57305. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57306. /** @hidden */
  57307. export var pbrBlockSubSurface: {
  57308. name: string;
  57309. shader: string;
  57310. };
  57311. }
  57312. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57313. /** @hidden */
  57314. export var pbrBlockNormalGeometric: {
  57315. name: string;
  57316. shader: string;
  57317. };
  57318. }
  57319. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57320. /** @hidden */
  57321. export var pbrBlockNormalFinal: {
  57322. name: string;
  57323. shader: string;
  57324. };
  57325. }
  57326. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57327. /** @hidden */
  57328. export var pbrBlockGeometryInfo: {
  57329. name: string;
  57330. shader: string;
  57331. };
  57332. }
  57333. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57334. /** @hidden */
  57335. export var pbrBlockReflectance0: {
  57336. name: string;
  57337. shader: string;
  57338. };
  57339. }
  57340. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57341. /** @hidden */
  57342. export var pbrBlockReflectance: {
  57343. name: string;
  57344. shader: string;
  57345. };
  57346. }
  57347. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57348. /** @hidden */
  57349. export var pbrBlockDirectLighting: {
  57350. name: string;
  57351. shader: string;
  57352. };
  57353. }
  57354. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57355. /** @hidden */
  57356. export var pbrBlockFinalLitComponents: {
  57357. name: string;
  57358. shader: string;
  57359. };
  57360. }
  57361. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57362. /** @hidden */
  57363. export var pbrBlockFinalUnlitComponents: {
  57364. name: string;
  57365. shader: string;
  57366. };
  57367. }
  57368. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57369. /** @hidden */
  57370. export var pbrBlockFinalColorComposition: {
  57371. name: string;
  57372. shader: string;
  57373. };
  57374. }
  57375. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57376. /** @hidden */
  57377. export var pbrBlockImageProcessing: {
  57378. name: string;
  57379. shader: string;
  57380. };
  57381. }
  57382. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57383. /** @hidden */
  57384. export var pbrDebug: {
  57385. name: string;
  57386. shader: string;
  57387. };
  57388. }
  57389. declare module "babylonjs/Shaders/pbr.fragment" {
  57390. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57391. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57392. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57393. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57394. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57395. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57396. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57397. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57398. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57399. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57401. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57402. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57403. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57404. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57405. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57406. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57407. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57408. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57409. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57410. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57411. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57412. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57413. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57414. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57415. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57416. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57417. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57418. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57419. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57420. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57421. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57422. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57423. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57425. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57426. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57427. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57428. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57429. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57430. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57431. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57432. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57433. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57434. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57435. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57436. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57437. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57438. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57439. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57440. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57441. /** @hidden */
  57442. export var pbrPixelShader: {
  57443. name: string;
  57444. shader: string;
  57445. };
  57446. }
  57447. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57448. /** @hidden */
  57449. export var pbrVertexDeclaration: {
  57450. name: string;
  57451. shader: string;
  57452. };
  57453. }
  57454. declare module "babylonjs/Shaders/pbr.vertex" {
  57455. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57456. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57457. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57459. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57460. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57461. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57462. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57463. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57464. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57465. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57468. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57472. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57473. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57474. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57475. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57476. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57477. /** @hidden */
  57478. export var pbrVertexShader: {
  57479. name: string;
  57480. shader: string;
  57481. };
  57482. }
  57483. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57484. import { Nullable } from "babylonjs/types";
  57485. import { Scene } from "babylonjs/scene";
  57486. import { Matrix } from "babylonjs/Maths/math.vector";
  57487. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57489. import { Mesh } from "babylonjs/Meshes/mesh";
  57490. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57491. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57492. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57493. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57494. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57495. import { Color3 } from "babylonjs/Maths/math.color";
  57496. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57497. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57498. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57499. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57501. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57502. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57503. import "babylonjs/Shaders/pbr.fragment";
  57504. import "babylonjs/Shaders/pbr.vertex";
  57505. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57506. /**
  57507. * Manages the defines for the PBR Material.
  57508. * @hidden
  57509. */
  57510. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57511. PBR: boolean;
  57512. NUM_SAMPLES: string;
  57513. REALTIME_FILTERING: boolean;
  57514. MAINUV1: boolean;
  57515. MAINUV2: boolean;
  57516. UV1: boolean;
  57517. UV2: boolean;
  57518. ALBEDO: boolean;
  57519. GAMMAALBEDO: boolean;
  57520. ALBEDODIRECTUV: number;
  57521. VERTEXCOLOR: boolean;
  57522. DETAIL: boolean;
  57523. DETAILDIRECTUV: number;
  57524. DETAIL_NORMALBLENDMETHOD: number;
  57525. AMBIENT: boolean;
  57526. AMBIENTDIRECTUV: number;
  57527. AMBIENTINGRAYSCALE: boolean;
  57528. OPACITY: boolean;
  57529. VERTEXALPHA: boolean;
  57530. OPACITYDIRECTUV: number;
  57531. OPACITYRGB: boolean;
  57532. ALPHATEST: boolean;
  57533. DEPTHPREPASS: boolean;
  57534. ALPHABLEND: boolean;
  57535. ALPHAFROMALBEDO: boolean;
  57536. ALPHATESTVALUE: string;
  57537. SPECULAROVERALPHA: boolean;
  57538. RADIANCEOVERALPHA: boolean;
  57539. ALPHAFRESNEL: boolean;
  57540. LINEARALPHAFRESNEL: boolean;
  57541. PREMULTIPLYALPHA: boolean;
  57542. EMISSIVE: boolean;
  57543. EMISSIVEDIRECTUV: number;
  57544. REFLECTIVITY: boolean;
  57545. REFLECTIVITYDIRECTUV: number;
  57546. SPECULARTERM: boolean;
  57547. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57548. MICROSURFACEAUTOMATIC: boolean;
  57549. LODBASEDMICROSFURACE: boolean;
  57550. MICROSURFACEMAP: boolean;
  57551. MICROSURFACEMAPDIRECTUV: number;
  57552. METALLICWORKFLOW: boolean;
  57553. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57554. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57555. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57556. AOSTOREINMETALMAPRED: boolean;
  57557. METALLIC_REFLECTANCE: boolean;
  57558. METALLIC_REFLECTANCEDIRECTUV: number;
  57559. ENVIRONMENTBRDF: boolean;
  57560. ENVIRONMENTBRDF_RGBD: boolean;
  57561. NORMAL: boolean;
  57562. TANGENT: boolean;
  57563. BUMP: boolean;
  57564. BUMPDIRECTUV: number;
  57565. OBJECTSPACE_NORMALMAP: boolean;
  57566. PARALLAX: boolean;
  57567. PARALLAXOCCLUSION: boolean;
  57568. NORMALXYSCALE: boolean;
  57569. LIGHTMAP: boolean;
  57570. LIGHTMAPDIRECTUV: number;
  57571. USELIGHTMAPASSHADOWMAP: boolean;
  57572. GAMMALIGHTMAP: boolean;
  57573. RGBDLIGHTMAP: boolean;
  57574. REFLECTION: boolean;
  57575. REFLECTIONMAP_3D: boolean;
  57576. REFLECTIONMAP_SPHERICAL: boolean;
  57577. REFLECTIONMAP_PLANAR: boolean;
  57578. REFLECTIONMAP_CUBIC: boolean;
  57579. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57580. REFLECTIONMAP_PROJECTION: boolean;
  57581. REFLECTIONMAP_SKYBOX: boolean;
  57582. REFLECTIONMAP_EXPLICIT: boolean;
  57583. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57584. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57585. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57586. INVERTCUBICMAP: boolean;
  57587. USESPHERICALFROMREFLECTIONMAP: boolean;
  57588. USEIRRADIANCEMAP: boolean;
  57589. SPHERICAL_HARMONICS: boolean;
  57590. USESPHERICALINVERTEX: boolean;
  57591. REFLECTIONMAP_OPPOSITEZ: boolean;
  57592. LODINREFLECTIONALPHA: boolean;
  57593. GAMMAREFLECTION: boolean;
  57594. RGBDREFLECTION: boolean;
  57595. LINEARSPECULARREFLECTION: boolean;
  57596. RADIANCEOCCLUSION: boolean;
  57597. HORIZONOCCLUSION: boolean;
  57598. INSTANCES: boolean;
  57599. THIN_INSTANCES: boolean;
  57600. NUM_BONE_INFLUENCERS: number;
  57601. BonesPerMesh: number;
  57602. BONETEXTURE: boolean;
  57603. NONUNIFORMSCALING: boolean;
  57604. MORPHTARGETS: boolean;
  57605. MORPHTARGETS_NORMAL: boolean;
  57606. MORPHTARGETS_TANGENT: boolean;
  57607. MORPHTARGETS_UV: boolean;
  57608. NUM_MORPH_INFLUENCERS: number;
  57609. IMAGEPROCESSING: boolean;
  57610. VIGNETTE: boolean;
  57611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57612. VIGNETTEBLENDMODEOPAQUE: boolean;
  57613. TONEMAPPING: boolean;
  57614. TONEMAPPING_ACES: boolean;
  57615. CONTRAST: boolean;
  57616. COLORCURVES: boolean;
  57617. COLORGRADING: boolean;
  57618. COLORGRADING3D: boolean;
  57619. SAMPLER3DGREENDEPTH: boolean;
  57620. SAMPLER3DBGRMAP: boolean;
  57621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57622. EXPOSURE: boolean;
  57623. MULTIVIEW: boolean;
  57624. USEPHYSICALLIGHTFALLOFF: boolean;
  57625. USEGLTFLIGHTFALLOFF: boolean;
  57626. TWOSIDEDLIGHTING: boolean;
  57627. SHADOWFLOAT: boolean;
  57628. CLIPPLANE: boolean;
  57629. CLIPPLANE2: boolean;
  57630. CLIPPLANE3: boolean;
  57631. CLIPPLANE4: boolean;
  57632. CLIPPLANE5: boolean;
  57633. CLIPPLANE6: boolean;
  57634. POINTSIZE: boolean;
  57635. FOG: boolean;
  57636. LOGARITHMICDEPTH: boolean;
  57637. FORCENORMALFORWARD: boolean;
  57638. SPECULARAA: boolean;
  57639. CLEARCOAT: boolean;
  57640. CLEARCOAT_DEFAULTIOR: boolean;
  57641. CLEARCOAT_TEXTURE: boolean;
  57642. CLEARCOAT_TEXTUREDIRECTUV: number;
  57643. CLEARCOAT_BUMP: boolean;
  57644. CLEARCOAT_BUMPDIRECTUV: number;
  57645. CLEARCOAT_TINT: boolean;
  57646. CLEARCOAT_TINT_TEXTURE: boolean;
  57647. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57648. ANISOTROPIC: boolean;
  57649. ANISOTROPIC_TEXTURE: boolean;
  57650. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57651. BRDF_V_HEIGHT_CORRELATED: boolean;
  57652. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57653. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57654. SHEEN: boolean;
  57655. SHEEN_TEXTURE: boolean;
  57656. SHEEN_TEXTUREDIRECTUV: number;
  57657. SHEEN_LINKWITHALBEDO: boolean;
  57658. SHEEN_ROUGHNESS: boolean;
  57659. SHEEN_ALBEDOSCALING: boolean;
  57660. SUBSURFACE: boolean;
  57661. SS_REFRACTION: boolean;
  57662. SS_TRANSLUCENCY: boolean;
  57663. SS_SCATTERING: boolean;
  57664. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57665. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57666. SS_REFRACTIONMAP_3D: boolean;
  57667. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57668. SS_LODINREFRACTIONALPHA: boolean;
  57669. SS_GAMMAREFRACTION: boolean;
  57670. SS_RGBDREFRACTION: boolean;
  57671. SS_LINEARSPECULARREFRACTION: boolean;
  57672. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57673. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57674. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57675. UNLIT: boolean;
  57676. DEBUGMODE: number;
  57677. /**
  57678. * Initializes the PBR Material defines.
  57679. */
  57680. constructor();
  57681. /**
  57682. * Resets the PBR Material defines.
  57683. */
  57684. reset(): void;
  57685. }
  57686. /**
  57687. * The Physically based material base class of BJS.
  57688. *
  57689. * This offers the main features of a standard PBR material.
  57690. * For more information, please refer to the documentation :
  57691. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57692. */
  57693. export abstract class PBRBaseMaterial extends PushMaterial {
  57694. /**
  57695. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57696. */
  57697. static readonly PBRMATERIAL_OPAQUE: number;
  57698. /**
  57699. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57700. */
  57701. static readonly PBRMATERIAL_ALPHATEST: number;
  57702. /**
  57703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57704. */
  57705. static readonly PBRMATERIAL_ALPHABLEND: number;
  57706. /**
  57707. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57708. * They are also discarded below the alpha cutoff threshold to improve performances.
  57709. */
  57710. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57711. /**
  57712. * Defines the default value of how much AO map is occluding the analytical lights
  57713. * (point spot...).
  57714. */
  57715. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57716. /**
  57717. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57718. */
  57719. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57720. /**
  57721. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57722. * to enhance interoperability with other engines.
  57723. */
  57724. static readonly LIGHTFALLOFF_GLTF: number;
  57725. /**
  57726. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57727. * to enhance interoperability with other materials.
  57728. */
  57729. static readonly LIGHTFALLOFF_STANDARD: number;
  57730. /**
  57731. * Intensity of the direct lights e.g. the four lights available in your scene.
  57732. * This impacts both the direct diffuse and specular highlights.
  57733. */
  57734. protected _directIntensity: number;
  57735. /**
  57736. * Intensity of the emissive part of the material.
  57737. * This helps controlling the emissive effect without modifying the emissive color.
  57738. */
  57739. protected _emissiveIntensity: number;
  57740. /**
  57741. * Intensity of the environment e.g. how much the environment will light the object
  57742. * either through harmonics for rough material or through the refelction for shiny ones.
  57743. */
  57744. protected _environmentIntensity: number;
  57745. /**
  57746. * This is a special control allowing the reduction of the specular highlights coming from the
  57747. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57748. */
  57749. protected _specularIntensity: number;
  57750. /**
  57751. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57752. */
  57753. private _lightingInfos;
  57754. /**
  57755. * Debug Control allowing disabling the bump map on this material.
  57756. */
  57757. protected _disableBumpMap: boolean;
  57758. /**
  57759. * AKA Diffuse Texture in standard nomenclature.
  57760. */
  57761. protected _albedoTexture: Nullable<BaseTexture>;
  57762. /**
  57763. * AKA Occlusion Texture in other nomenclature.
  57764. */
  57765. protected _ambientTexture: Nullable<BaseTexture>;
  57766. /**
  57767. * AKA Occlusion Texture Intensity in other nomenclature.
  57768. */
  57769. protected _ambientTextureStrength: number;
  57770. /**
  57771. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57772. * 1 means it completely occludes it
  57773. * 0 mean it has no impact
  57774. */
  57775. protected _ambientTextureImpactOnAnalyticalLights: number;
  57776. /**
  57777. * Stores the alpha values in a texture.
  57778. */
  57779. protected _opacityTexture: Nullable<BaseTexture>;
  57780. /**
  57781. * Stores the reflection values in a texture.
  57782. */
  57783. protected _reflectionTexture: Nullable<BaseTexture>;
  57784. /**
  57785. * Stores the emissive values in a texture.
  57786. */
  57787. protected _emissiveTexture: Nullable<BaseTexture>;
  57788. /**
  57789. * AKA Specular texture in other nomenclature.
  57790. */
  57791. protected _reflectivityTexture: Nullable<BaseTexture>;
  57792. /**
  57793. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57794. */
  57795. protected _metallicTexture: Nullable<BaseTexture>;
  57796. /**
  57797. * Specifies the metallic scalar of the metallic/roughness workflow.
  57798. * Can also be used to scale the metalness values of the metallic texture.
  57799. */
  57800. protected _metallic: Nullable<number>;
  57801. /**
  57802. * Specifies the roughness scalar of the metallic/roughness workflow.
  57803. * Can also be used to scale the roughness values of the metallic texture.
  57804. */
  57805. protected _roughness: Nullable<number>;
  57806. /**
  57807. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57808. * By default the indexOfrefraction is used to compute F0;
  57809. *
  57810. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57811. *
  57812. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57813. * F90 = metallicReflectanceColor;
  57814. */
  57815. protected _metallicF0Factor: number;
  57816. /**
  57817. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57818. * By default the F90 is always 1;
  57819. *
  57820. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57821. *
  57822. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57823. * F90 = metallicReflectanceColor;
  57824. */
  57825. protected _metallicReflectanceColor: Color3;
  57826. /**
  57827. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57828. * This is multiply against the scalar values defined in the material.
  57829. */
  57830. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57831. /**
  57832. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57833. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57834. */
  57835. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57836. /**
  57837. * Stores surface normal data used to displace a mesh in a texture.
  57838. */
  57839. protected _bumpTexture: Nullable<BaseTexture>;
  57840. /**
  57841. * Stores the pre-calculated light information of a mesh in a texture.
  57842. */
  57843. protected _lightmapTexture: Nullable<BaseTexture>;
  57844. /**
  57845. * The color of a material in ambient lighting.
  57846. */
  57847. protected _ambientColor: Color3;
  57848. /**
  57849. * AKA Diffuse Color in other nomenclature.
  57850. */
  57851. protected _albedoColor: Color3;
  57852. /**
  57853. * AKA Specular Color in other nomenclature.
  57854. */
  57855. protected _reflectivityColor: Color3;
  57856. /**
  57857. * The color applied when light is reflected from a material.
  57858. */
  57859. protected _reflectionColor: Color3;
  57860. /**
  57861. * The color applied when light is emitted from a material.
  57862. */
  57863. protected _emissiveColor: Color3;
  57864. /**
  57865. * AKA Glossiness in other nomenclature.
  57866. */
  57867. protected _microSurface: number;
  57868. /**
  57869. * Specifies that the material will use the light map as a show map.
  57870. */
  57871. protected _useLightmapAsShadowmap: boolean;
  57872. /**
  57873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57874. * makes the reflect vector face the model (under horizon).
  57875. */
  57876. protected _useHorizonOcclusion: boolean;
  57877. /**
  57878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57879. * too much the area relying on ambient texture to define their ambient occlusion.
  57880. */
  57881. protected _useRadianceOcclusion: boolean;
  57882. /**
  57883. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57884. */
  57885. protected _useAlphaFromAlbedoTexture: boolean;
  57886. /**
  57887. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57888. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57889. */
  57890. protected _useSpecularOverAlpha: boolean;
  57891. /**
  57892. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57893. */
  57894. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57895. /**
  57896. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57897. */
  57898. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57899. /**
  57900. * Specifies if the metallic texture contains the roughness information in its green channel.
  57901. */
  57902. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57903. /**
  57904. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57905. */
  57906. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57907. /**
  57908. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57909. */
  57910. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57911. /**
  57912. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57913. */
  57914. protected _useAmbientInGrayScale: boolean;
  57915. /**
  57916. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57917. * The material will try to infer what glossiness each pixel should be.
  57918. */
  57919. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57920. /**
  57921. * Defines the falloff type used in this material.
  57922. * It by default is Physical.
  57923. */
  57924. protected _lightFalloff: number;
  57925. /**
  57926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57928. */
  57929. protected _useRadianceOverAlpha: boolean;
  57930. /**
  57931. * Allows using an object space normal map (instead of tangent space).
  57932. */
  57933. protected _useObjectSpaceNormalMap: boolean;
  57934. /**
  57935. * Allows using the bump map in parallax mode.
  57936. */
  57937. protected _useParallax: boolean;
  57938. /**
  57939. * Allows using the bump map in parallax occlusion mode.
  57940. */
  57941. protected _useParallaxOcclusion: boolean;
  57942. /**
  57943. * Controls the scale bias of the parallax mode.
  57944. */
  57945. protected _parallaxScaleBias: number;
  57946. /**
  57947. * If sets to true, disables all the lights affecting the material.
  57948. */
  57949. protected _disableLighting: boolean;
  57950. /**
  57951. * Number of Simultaneous lights allowed on the material.
  57952. */
  57953. protected _maxSimultaneousLights: number;
  57954. /**
  57955. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57956. */
  57957. protected _invertNormalMapX: boolean;
  57958. /**
  57959. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57960. */
  57961. protected _invertNormalMapY: boolean;
  57962. /**
  57963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57964. */
  57965. protected _twoSidedLighting: boolean;
  57966. /**
  57967. * Defines the alpha limits in alpha test mode.
  57968. */
  57969. protected _alphaCutOff: number;
  57970. /**
  57971. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57972. */
  57973. protected _forceAlphaTest: boolean;
  57974. /**
  57975. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57976. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57977. */
  57978. protected _useAlphaFresnel: boolean;
  57979. /**
  57980. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57981. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57982. */
  57983. protected _useLinearAlphaFresnel: boolean;
  57984. /**
  57985. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57986. * from cos thetav and roughness:
  57987. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57988. */
  57989. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57990. /**
  57991. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57992. */
  57993. protected _forceIrradianceInFragment: boolean;
  57994. private _realTimeFiltering;
  57995. /**
  57996. * Enables realtime filtering on the texture.
  57997. */
  57998. get realTimeFiltering(): boolean;
  57999. set realTimeFiltering(b: boolean);
  58000. private _realTimeFilteringQuality;
  58001. /**
  58002. * Quality switch for realtime filtering
  58003. */
  58004. get realTimeFilteringQuality(): number;
  58005. set realTimeFilteringQuality(n: number);
  58006. /**
  58007. * Force normal to face away from face.
  58008. */
  58009. protected _forceNormalForward: boolean;
  58010. /**
  58011. * Enables specular anti aliasing in the PBR shader.
  58012. * It will both interacts on the Geometry for analytical and IBL lighting.
  58013. * It also prefilter the roughness map based on the bump values.
  58014. */
  58015. protected _enableSpecularAntiAliasing: boolean;
  58016. /**
  58017. * Default configuration related to image processing available in the PBR Material.
  58018. */
  58019. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58020. /**
  58021. * Keep track of the image processing observer to allow dispose and replace.
  58022. */
  58023. private _imageProcessingObserver;
  58024. /**
  58025. * Attaches a new image processing configuration to the PBR Material.
  58026. * @param configuration
  58027. */
  58028. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58029. /**
  58030. * Stores the available render targets.
  58031. */
  58032. private _renderTargets;
  58033. /**
  58034. * Sets the global ambient color for the material used in lighting calculations.
  58035. */
  58036. private _globalAmbientColor;
  58037. /**
  58038. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58039. */
  58040. private _useLogarithmicDepth;
  58041. /**
  58042. * If set to true, no lighting calculations will be applied.
  58043. */
  58044. private _unlit;
  58045. private _debugMode;
  58046. /**
  58047. * @hidden
  58048. * This is reserved for the inspector.
  58049. * Defines the material debug mode.
  58050. * It helps seeing only some components of the material while troubleshooting.
  58051. */
  58052. debugMode: number;
  58053. /**
  58054. * @hidden
  58055. * This is reserved for the inspector.
  58056. * Specify from where on screen the debug mode should start.
  58057. * The value goes from -1 (full screen) to 1 (not visible)
  58058. * It helps with side by side comparison against the final render
  58059. * This defaults to -1
  58060. */
  58061. private debugLimit;
  58062. /**
  58063. * @hidden
  58064. * This is reserved for the inspector.
  58065. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58066. * You can use the factor to better multiply the final value.
  58067. */
  58068. private debugFactor;
  58069. /**
  58070. * Defines the clear coat layer parameters for the material.
  58071. */
  58072. readonly clearCoat: PBRClearCoatConfiguration;
  58073. /**
  58074. * Defines the anisotropic parameters for the material.
  58075. */
  58076. readonly anisotropy: PBRAnisotropicConfiguration;
  58077. /**
  58078. * Defines the BRDF parameters for the material.
  58079. */
  58080. readonly brdf: PBRBRDFConfiguration;
  58081. /**
  58082. * Defines the Sheen parameters for the material.
  58083. */
  58084. readonly sheen: PBRSheenConfiguration;
  58085. /**
  58086. * Defines the SubSurface parameters for the material.
  58087. */
  58088. readonly subSurface: PBRSubSurfaceConfiguration;
  58089. /**
  58090. * Defines the detail map parameters for the material.
  58091. */
  58092. readonly detailMap: DetailMapConfiguration;
  58093. protected _rebuildInParallel: boolean;
  58094. /**
  58095. * Instantiates a new PBRMaterial instance.
  58096. *
  58097. * @param name The material name
  58098. * @param scene The scene the material will be use in.
  58099. */
  58100. constructor(name: string, scene: Scene);
  58101. /**
  58102. * Gets a boolean indicating that current material needs to register RTT
  58103. */
  58104. get hasRenderTargetTextures(): boolean;
  58105. /**
  58106. * Gets the name of the material class.
  58107. */
  58108. getClassName(): string;
  58109. /**
  58110. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58111. */
  58112. get useLogarithmicDepth(): boolean;
  58113. /**
  58114. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58115. */
  58116. set useLogarithmicDepth(value: boolean);
  58117. /**
  58118. * Returns true if alpha blending should be disabled.
  58119. */
  58120. protected get _disableAlphaBlending(): boolean;
  58121. /**
  58122. * Specifies whether or not this material should be rendered in alpha blend mode.
  58123. */
  58124. needAlphaBlending(): boolean;
  58125. /**
  58126. * Specifies whether or not this material should be rendered in alpha test mode.
  58127. */
  58128. needAlphaTesting(): boolean;
  58129. /**
  58130. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58131. */
  58132. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58133. /**
  58134. * Gets the texture used for the alpha test.
  58135. */
  58136. getAlphaTestTexture(): Nullable<BaseTexture>;
  58137. /**
  58138. * Specifies that the submesh is ready to be used.
  58139. * @param mesh - BJS mesh.
  58140. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58141. * @param useInstances - Specifies that instances should be used.
  58142. * @returns - boolean indicating that the submesh is ready or not.
  58143. */
  58144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58145. /**
  58146. * Specifies if the material uses metallic roughness workflow.
  58147. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58148. */
  58149. isMetallicWorkflow(): boolean;
  58150. private _prepareEffect;
  58151. private _prepareDefines;
  58152. /**
  58153. * Force shader compilation
  58154. */
  58155. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58156. /**
  58157. * Initializes the uniform buffer layout for the shader.
  58158. */
  58159. buildUniformLayout(): void;
  58160. /**
  58161. * Unbinds the material from the mesh
  58162. */
  58163. unbind(): void;
  58164. /**
  58165. * Binds the submesh data.
  58166. * @param world - The world matrix.
  58167. * @param mesh - The BJS mesh.
  58168. * @param subMesh - A submesh of the BJS mesh.
  58169. */
  58170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58171. /**
  58172. * Returns the animatable textures.
  58173. * @returns - Array of animatable textures.
  58174. */
  58175. getAnimatables(): IAnimatable[];
  58176. /**
  58177. * Returns the texture used for reflections.
  58178. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58179. */
  58180. private _getReflectionTexture;
  58181. /**
  58182. * Returns an array of the actively used textures.
  58183. * @returns - Array of BaseTextures
  58184. */
  58185. getActiveTextures(): BaseTexture[];
  58186. /**
  58187. * Checks to see if a texture is used in the material.
  58188. * @param texture - Base texture to use.
  58189. * @returns - Boolean specifying if a texture is used in the material.
  58190. */
  58191. hasTexture(texture: BaseTexture): boolean;
  58192. /**
  58193. * Disposes the resources of the material.
  58194. * @param forceDisposeEffect - Forces the disposal of effects.
  58195. * @param forceDisposeTextures - Forces the disposal of all textures.
  58196. */
  58197. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58198. }
  58199. }
  58200. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58201. import { Nullable } from "babylonjs/types";
  58202. import { Scene } from "babylonjs/scene";
  58203. import { Color3 } from "babylonjs/Maths/math.color";
  58204. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58205. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58207. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58208. /**
  58209. * The Physically based material of BJS.
  58210. *
  58211. * This offers the main features of a standard PBR material.
  58212. * For more information, please refer to the documentation :
  58213. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58214. */
  58215. export class PBRMaterial extends PBRBaseMaterial {
  58216. /**
  58217. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58218. */
  58219. static readonly PBRMATERIAL_OPAQUE: number;
  58220. /**
  58221. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58222. */
  58223. static readonly PBRMATERIAL_ALPHATEST: number;
  58224. /**
  58225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58226. */
  58227. static readonly PBRMATERIAL_ALPHABLEND: number;
  58228. /**
  58229. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58230. * They are also discarded below the alpha cutoff threshold to improve performances.
  58231. */
  58232. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58233. /**
  58234. * Defines the default value of how much AO map is occluding the analytical lights
  58235. * (point spot...).
  58236. */
  58237. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58238. /**
  58239. * Intensity of the direct lights e.g. the four lights available in your scene.
  58240. * This impacts both the direct diffuse and specular highlights.
  58241. */
  58242. directIntensity: number;
  58243. /**
  58244. * Intensity of the emissive part of the material.
  58245. * This helps controlling the emissive effect without modifying the emissive color.
  58246. */
  58247. emissiveIntensity: number;
  58248. /**
  58249. * Intensity of the environment e.g. how much the environment will light the object
  58250. * either through harmonics for rough material or through the refelction for shiny ones.
  58251. */
  58252. environmentIntensity: number;
  58253. /**
  58254. * This is a special control allowing the reduction of the specular highlights coming from the
  58255. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58256. */
  58257. specularIntensity: number;
  58258. /**
  58259. * Debug Control allowing disabling the bump map on this material.
  58260. */
  58261. disableBumpMap: boolean;
  58262. /**
  58263. * AKA Diffuse Texture in standard nomenclature.
  58264. */
  58265. albedoTexture: BaseTexture;
  58266. /**
  58267. * AKA Occlusion Texture in other nomenclature.
  58268. */
  58269. ambientTexture: BaseTexture;
  58270. /**
  58271. * AKA Occlusion Texture Intensity in other nomenclature.
  58272. */
  58273. ambientTextureStrength: number;
  58274. /**
  58275. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58276. * 1 means it completely occludes it
  58277. * 0 mean it has no impact
  58278. */
  58279. ambientTextureImpactOnAnalyticalLights: number;
  58280. /**
  58281. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58282. */
  58283. opacityTexture: BaseTexture;
  58284. /**
  58285. * Stores the reflection values in a texture.
  58286. */
  58287. reflectionTexture: Nullable<BaseTexture>;
  58288. /**
  58289. * Stores the emissive values in a texture.
  58290. */
  58291. emissiveTexture: BaseTexture;
  58292. /**
  58293. * AKA Specular texture in other nomenclature.
  58294. */
  58295. reflectivityTexture: BaseTexture;
  58296. /**
  58297. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58298. */
  58299. metallicTexture: BaseTexture;
  58300. /**
  58301. * Specifies the metallic scalar of the metallic/roughness workflow.
  58302. * Can also be used to scale the metalness values of the metallic texture.
  58303. */
  58304. metallic: Nullable<number>;
  58305. /**
  58306. * Specifies the roughness scalar of the metallic/roughness workflow.
  58307. * Can also be used to scale the roughness values of the metallic texture.
  58308. */
  58309. roughness: Nullable<number>;
  58310. /**
  58311. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58312. * By default the indexOfrefraction is used to compute F0;
  58313. *
  58314. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58315. *
  58316. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58317. * F90 = metallicReflectanceColor;
  58318. */
  58319. metallicF0Factor: number;
  58320. /**
  58321. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58322. * By default the F90 is always 1;
  58323. *
  58324. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58325. *
  58326. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58327. * F90 = metallicReflectanceColor;
  58328. */
  58329. metallicReflectanceColor: Color3;
  58330. /**
  58331. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58332. * This is multiply against the scalar values defined in the material.
  58333. */
  58334. metallicReflectanceTexture: Nullable<BaseTexture>;
  58335. /**
  58336. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58337. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58338. */
  58339. microSurfaceTexture: BaseTexture;
  58340. /**
  58341. * Stores surface normal data used to displace a mesh in a texture.
  58342. */
  58343. bumpTexture: BaseTexture;
  58344. /**
  58345. * Stores the pre-calculated light information of a mesh in a texture.
  58346. */
  58347. lightmapTexture: BaseTexture;
  58348. /**
  58349. * Stores the refracted light information in a texture.
  58350. */
  58351. get refractionTexture(): Nullable<BaseTexture>;
  58352. set refractionTexture(value: Nullable<BaseTexture>);
  58353. /**
  58354. * The color of a material in ambient lighting.
  58355. */
  58356. ambientColor: Color3;
  58357. /**
  58358. * AKA Diffuse Color in other nomenclature.
  58359. */
  58360. albedoColor: Color3;
  58361. /**
  58362. * AKA Specular Color in other nomenclature.
  58363. */
  58364. reflectivityColor: Color3;
  58365. /**
  58366. * The color reflected from the material.
  58367. */
  58368. reflectionColor: Color3;
  58369. /**
  58370. * The color emitted from the material.
  58371. */
  58372. emissiveColor: Color3;
  58373. /**
  58374. * AKA Glossiness in other nomenclature.
  58375. */
  58376. microSurface: number;
  58377. /**
  58378. * Index of refraction of the material base layer.
  58379. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58380. *
  58381. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58382. *
  58383. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58384. */
  58385. get indexOfRefraction(): number;
  58386. set indexOfRefraction(value: number);
  58387. /**
  58388. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58389. */
  58390. get invertRefractionY(): boolean;
  58391. set invertRefractionY(value: boolean);
  58392. /**
  58393. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58394. * Materials half opaque for instance using refraction could benefit from this control.
  58395. */
  58396. get linkRefractionWithTransparency(): boolean;
  58397. set linkRefractionWithTransparency(value: boolean);
  58398. /**
  58399. * If true, the light map contains occlusion information instead of lighting info.
  58400. */
  58401. useLightmapAsShadowmap: boolean;
  58402. /**
  58403. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58404. */
  58405. useAlphaFromAlbedoTexture: boolean;
  58406. /**
  58407. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58408. */
  58409. forceAlphaTest: boolean;
  58410. /**
  58411. * Defines the alpha limits in alpha test mode.
  58412. */
  58413. alphaCutOff: number;
  58414. /**
  58415. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58416. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58417. */
  58418. useSpecularOverAlpha: boolean;
  58419. /**
  58420. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58421. */
  58422. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58423. /**
  58424. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58425. */
  58426. useRoughnessFromMetallicTextureAlpha: boolean;
  58427. /**
  58428. * Specifies if the metallic texture contains the roughness information in its green channel.
  58429. */
  58430. useRoughnessFromMetallicTextureGreen: boolean;
  58431. /**
  58432. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58433. */
  58434. useMetallnessFromMetallicTextureBlue: boolean;
  58435. /**
  58436. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58437. */
  58438. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58439. /**
  58440. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58441. */
  58442. useAmbientInGrayScale: boolean;
  58443. /**
  58444. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58445. * The material will try to infer what glossiness each pixel should be.
  58446. */
  58447. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58448. /**
  58449. * BJS is using an harcoded light falloff based on a manually sets up range.
  58450. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58451. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58452. */
  58453. get usePhysicalLightFalloff(): boolean;
  58454. /**
  58455. * BJS is using an harcoded light falloff based on a manually sets up range.
  58456. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58457. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58458. */
  58459. set usePhysicalLightFalloff(value: boolean);
  58460. /**
  58461. * In order to support the falloff compatibility with gltf, a special mode has been added
  58462. * to reproduce the gltf light falloff.
  58463. */
  58464. get useGLTFLightFalloff(): boolean;
  58465. /**
  58466. * In order to support the falloff compatibility with gltf, a special mode has been added
  58467. * to reproduce the gltf light falloff.
  58468. */
  58469. set useGLTFLightFalloff(value: boolean);
  58470. /**
  58471. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58472. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58473. */
  58474. useRadianceOverAlpha: boolean;
  58475. /**
  58476. * Allows using an object space normal map (instead of tangent space).
  58477. */
  58478. useObjectSpaceNormalMap: boolean;
  58479. /**
  58480. * Allows using the bump map in parallax mode.
  58481. */
  58482. useParallax: boolean;
  58483. /**
  58484. * Allows using the bump map in parallax occlusion mode.
  58485. */
  58486. useParallaxOcclusion: boolean;
  58487. /**
  58488. * Controls the scale bias of the parallax mode.
  58489. */
  58490. parallaxScaleBias: number;
  58491. /**
  58492. * If sets to true, disables all the lights affecting the material.
  58493. */
  58494. disableLighting: boolean;
  58495. /**
  58496. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58497. */
  58498. forceIrradianceInFragment: boolean;
  58499. /**
  58500. * Number of Simultaneous lights allowed on the material.
  58501. */
  58502. maxSimultaneousLights: number;
  58503. /**
  58504. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58505. */
  58506. invertNormalMapX: boolean;
  58507. /**
  58508. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58509. */
  58510. invertNormalMapY: boolean;
  58511. /**
  58512. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58513. */
  58514. twoSidedLighting: boolean;
  58515. /**
  58516. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58517. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58518. */
  58519. useAlphaFresnel: boolean;
  58520. /**
  58521. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58522. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58523. */
  58524. useLinearAlphaFresnel: boolean;
  58525. /**
  58526. * Let user defines the brdf lookup texture used for IBL.
  58527. * A default 8bit version is embedded but you could point at :
  58528. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58529. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58530. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58531. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58532. */
  58533. environmentBRDFTexture: Nullable<BaseTexture>;
  58534. /**
  58535. * Force normal to face away from face.
  58536. */
  58537. forceNormalForward: boolean;
  58538. /**
  58539. * Enables specular anti aliasing in the PBR shader.
  58540. * It will both interacts on the Geometry for analytical and IBL lighting.
  58541. * It also prefilter the roughness map based on the bump values.
  58542. */
  58543. enableSpecularAntiAliasing: boolean;
  58544. /**
  58545. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58546. * makes the reflect vector face the model (under horizon).
  58547. */
  58548. useHorizonOcclusion: boolean;
  58549. /**
  58550. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58551. * too much the area relying on ambient texture to define their ambient occlusion.
  58552. */
  58553. useRadianceOcclusion: boolean;
  58554. /**
  58555. * If set to true, no lighting calculations will be applied.
  58556. */
  58557. unlit: boolean;
  58558. /**
  58559. * Gets the image processing configuration used either in this material.
  58560. */
  58561. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58562. /**
  58563. * Sets the Default image processing configuration used either in the this material.
  58564. *
  58565. * If sets to null, the scene one is in use.
  58566. */
  58567. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58568. /**
  58569. * Gets wether the color curves effect is enabled.
  58570. */
  58571. get cameraColorCurvesEnabled(): boolean;
  58572. /**
  58573. * Sets wether the color curves effect is enabled.
  58574. */
  58575. set cameraColorCurvesEnabled(value: boolean);
  58576. /**
  58577. * Gets wether the color grading effect is enabled.
  58578. */
  58579. get cameraColorGradingEnabled(): boolean;
  58580. /**
  58581. * Gets wether the color grading effect is enabled.
  58582. */
  58583. set cameraColorGradingEnabled(value: boolean);
  58584. /**
  58585. * Gets wether tonemapping is enabled or not.
  58586. */
  58587. get cameraToneMappingEnabled(): boolean;
  58588. /**
  58589. * Sets wether tonemapping is enabled or not
  58590. */
  58591. set cameraToneMappingEnabled(value: boolean);
  58592. /**
  58593. * The camera exposure used on this material.
  58594. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58595. * This corresponds to a photographic exposure.
  58596. */
  58597. get cameraExposure(): number;
  58598. /**
  58599. * The camera exposure used on this material.
  58600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58601. * This corresponds to a photographic exposure.
  58602. */
  58603. set cameraExposure(value: number);
  58604. /**
  58605. * Gets The camera contrast used on this material.
  58606. */
  58607. get cameraContrast(): number;
  58608. /**
  58609. * Sets The camera contrast used on this material.
  58610. */
  58611. set cameraContrast(value: number);
  58612. /**
  58613. * Gets the Color Grading 2D Lookup Texture.
  58614. */
  58615. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58616. /**
  58617. * Sets the Color Grading 2D Lookup Texture.
  58618. */
  58619. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58620. /**
  58621. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58622. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58623. * 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;
  58624. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58625. */
  58626. get cameraColorCurves(): Nullable<ColorCurves>;
  58627. /**
  58628. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58629. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58630. * 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;
  58631. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58632. */
  58633. set cameraColorCurves(value: Nullable<ColorCurves>);
  58634. /**
  58635. * Instantiates a new PBRMaterial instance.
  58636. *
  58637. * @param name The material name
  58638. * @param scene The scene the material will be use in.
  58639. */
  58640. constructor(name: string, scene: Scene);
  58641. /**
  58642. * Returns the name of this material class.
  58643. */
  58644. getClassName(): string;
  58645. /**
  58646. * Makes a duplicate of the current material.
  58647. * @param name - name to use for the new material.
  58648. */
  58649. clone(name: string): PBRMaterial;
  58650. /**
  58651. * Serializes this PBR Material.
  58652. * @returns - An object with the serialized material.
  58653. */
  58654. serialize(): any;
  58655. /**
  58656. * Parses a PBR Material from a serialized object.
  58657. * @param source - Serialized object.
  58658. * @param scene - BJS scene instance.
  58659. * @param rootUrl - url for the scene object
  58660. * @returns - PBRMaterial
  58661. */
  58662. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58663. }
  58664. }
  58665. declare module "babylonjs/Misc/dds" {
  58666. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58667. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58668. import { Nullable } from "babylonjs/types";
  58669. import { Scene } from "babylonjs/scene";
  58670. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58671. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58672. /**
  58673. * Direct draw surface info
  58674. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58675. */
  58676. export interface DDSInfo {
  58677. /**
  58678. * Width of the texture
  58679. */
  58680. width: number;
  58681. /**
  58682. * Width of the texture
  58683. */
  58684. height: number;
  58685. /**
  58686. * Number of Mipmaps for the texture
  58687. * @see https://en.wikipedia.org/wiki/Mipmap
  58688. */
  58689. mipmapCount: number;
  58690. /**
  58691. * If the textures format is a known fourCC format
  58692. * @see https://www.fourcc.org/
  58693. */
  58694. isFourCC: boolean;
  58695. /**
  58696. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58697. */
  58698. isRGB: boolean;
  58699. /**
  58700. * If the texture is a lumincance format
  58701. */
  58702. isLuminance: boolean;
  58703. /**
  58704. * If this is a cube texture
  58705. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58706. */
  58707. isCube: boolean;
  58708. /**
  58709. * If the texture is a compressed format eg. FOURCC_DXT1
  58710. */
  58711. isCompressed: boolean;
  58712. /**
  58713. * The dxgiFormat of the texture
  58714. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58715. */
  58716. dxgiFormat: number;
  58717. /**
  58718. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58719. */
  58720. textureType: number;
  58721. /**
  58722. * Sphericle polynomial created for the dds texture
  58723. */
  58724. sphericalPolynomial?: SphericalPolynomial;
  58725. }
  58726. /**
  58727. * Class used to provide DDS decompression tools
  58728. */
  58729. export class DDSTools {
  58730. /**
  58731. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58732. */
  58733. static StoreLODInAlphaChannel: boolean;
  58734. /**
  58735. * Gets DDS information from an array buffer
  58736. * @param data defines the array buffer view to read data from
  58737. * @returns the DDS information
  58738. */
  58739. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58740. private static _FloatView;
  58741. private static _Int32View;
  58742. private static _ToHalfFloat;
  58743. private static _FromHalfFloat;
  58744. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58745. private static _GetHalfFloatRGBAArrayBuffer;
  58746. private static _GetFloatRGBAArrayBuffer;
  58747. private static _GetFloatAsUIntRGBAArrayBuffer;
  58748. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58749. private static _GetRGBAArrayBuffer;
  58750. private static _ExtractLongWordOrder;
  58751. private static _GetRGBArrayBuffer;
  58752. private static _GetLuminanceArrayBuffer;
  58753. /**
  58754. * Uploads DDS Levels to a Babylon Texture
  58755. * @hidden
  58756. */
  58757. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58758. }
  58759. module "babylonjs/Engines/thinEngine" {
  58760. interface ThinEngine {
  58761. /**
  58762. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58763. * @param rootUrl defines the url where the file to load is located
  58764. * @param scene defines the current scene
  58765. * @param lodScale defines scale to apply to the mip map selection
  58766. * @param lodOffset defines offset to apply to the mip map selection
  58767. * @param onLoad defines an optional callback raised when the texture is loaded
  58768. * @param onError defines an optional callback raised if there is an issue to load the texture
  58769. * @param format defines the format of the data
  58770. * @param forcedExtension defines the extension to use to pick the right loader
  58771. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58772. * @returns the cube texture as an InternalTexture
  58773. */
  58774. 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;
  58775. }
  58776. }
  58777. }
  58778. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58779. import { Nullable } from "babylonjs/types";
  58780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58781. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58782. /**
  58783. * Implementation of the DDS Texture Loader.
  58784. * @hidden
  58785. */
  58786. export class _DDSTextureLoader implements IInternalTextureLoader {
  58787. /**
  58788. * Defines wether the loader supports cascade loading the different faces.
  58789. */
  58790. readonly supportCascades: boolean;
  58791. /**
  58792. * This returns if the loader support the current file information.
  58793. * @param extension defines the file extension of the file being loaded
  58794. * @returns true if the loader can load the specified file
  58795. */
  58796. canLoad(extension: string): boolean;
  58797. /**
  58798. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58799. * @param data contains the texture data
  58800. * @param texture defines the BabylonJS internal texture
  58801. * @param createPolynomials will be true if polynomials have been requested
  58802. * @param onLoad defines the callback to trigger once the texture is ready
  58803. * @param onError defines the callback to trigger in case of error
  58804. */
  58805. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58806. /**
  58807. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58808. * @param data contains the texture data
  58809. * @param texture defines the BabylonJS internal texture
  58810. * @param callback defines the method to call once ready to upload
  58811. */
  58812. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58813. }
  58814. }
  58815. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58816. import { Nullable } from "babylonjs/types";
  58817. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58818. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58819. /**
  58820. * Implementation of the ENV Texture Loader.
  58821. * @hidden
  58822. */
  58823. export class _ENVTextureLoader implements IInternalTextureLoader {
  58824. /**
  58825. * Defines wether the loader supports cascade loading the different faces.
  58826. */
  58827. readonly supportCascades: boolean;
  58828. /**
  58829. * This returns if the loader support the current file information.
  58830. * @param extension defines the file extension of the file being loaded
  58831. * @returns true if the loader can load the specified file
  58832. */
  58833. canLoad(extension: string): boolean;
  58834. /**
  58835. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58836. * @param data contains the texture data
  58837. * @param texture defines the BabylonJS internal texture
  58838. * @param createPolynomials will be true if polynomials have been requested
  58839. * @param onLoad defines the callback to trigger once the texture is ready
  58840. * @param onError defines the callback to trigger in case of error
  58841. */
  58842. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58843. /**
  58844. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58845. * @param data contains the texture data
  58846. * @param texture defines the BabylonJS internal texture
  58847. * @param callback defines the method to call once ready to upload
  58848. */
  58849. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58850. }
  58851. }
  58852. declare module "babylonjs/Misc/khronosTextureContainer" {
  58853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58854. /**
  58855. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58856. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58857. */
  58858. export class KhronosTextureContainer {
  58859. /** contents of the KTX container file */
  58860. data: ArrayBufferView;
  58861. private static HEADER_LEN;
  58862. private static COMPRESSED_2D;
  58863. private static COMPRESSED_3D;
  58864. private static TEX_2D;
  58865. private static TEX_3D;
  58866. /**
  58867. * Gets the openGL type
  58868. */
  58869. glType: number;
  58870. /**
  58871. * Gets the openGL type size
  58872. */
  58873. glTypeSize: number;
  58874. /**
  58875. * Gets the openGL format
  58876. */
  58877. glFormat: number;
  58878. /**
  58879. * Gets the openGL internal format
  58880. */
  58881. glInternalFormat: number;
  58882. /**
  58883. * Gets the base internal format
  58884. */
  58885. glBaseInternalFormat: number;
  58886. /**
  58887. * Gets image width in pixel
  58888. */
  58889. pixelWidth: number;
  58890. /**
  58891. * Gets image height in pixel
  58892. */
  58893. pixelHeight: number;
  58894. /**
  58895. * Gets image depth in pixels
  58896. */
  58897. pixelDepth: number;
  58898. /**
  58899. * Gets the number of array elements
  58900. */
  58901. numberOfArrayElements: number;
  58902. /**
  58903. * Gets the number of faces
  58904. */
  58905. numberOfFaces: number;
  58906. /**
  58907. * Gets the number of mipmap levels
  58908. */
  58909. numberOfMipmapLevels: number;
  58910. /**
  58911. * Gets the bytes of key value data
  58912. */
  58913. bytesOfKeyValueData: number;
  58914. /**
  58915. * Gets the load type
  58916. */
  58917. loadType: number;
  58918. /**
  58919. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58920. */
  58921. isInvalid: boolean;
  58922. /**
  58923. * Creates a new KhronosTextureContainer
  58924. * @param data contents of the KTX container file
  58925. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58926. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58927. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58928. */
  58929. constructor(
  58930. /** contents of the KTX container file */
  58931. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58932. /**
  58933. * Uploads KTX content to a Babylon Texture.
  58934. * It is assumed that the texture has already been created & is currently bound
  58935. * @hidden
  58936. */
  58937. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58938. private _upload2DCompressedLevels;
  58939. /**
  58940. * Checks if the given data starts with a KTX file identifier.
  58941. * @param data the data to check
  58942. * @returns true if the data is a KTX file or false otherwise
  58943. */
  58944. static IsValid(data: ArrayBufferView): boolean;
  58945. }
  58946. }
  58947. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58950. /**
  58951. * Class for loading KTX2 files
  58952. * !!! Experimental Extension Subject to Changes !!!
  58953. * @hidden
  58954. */
  58955. export class KhronosTextureContainer2 {
  58956. private static _ModulePromise;
  58957. private static _TranscodeFormat;
  58958. constructor(engine: ThinEngine);
  58959. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58960. private _determineTranscodeFormat;
  58961. /**
  58962. * Checks if the given data starts with a KTX2 file identifier.
  58963. * @param data the data to check
  58964. * @returns true if the data is a KTX2 file or false otherwise
  58965. */
  58966. static IsValid(data: ArrayBufferView): boolean;
  58967. }
  58968. }
  58969. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58970. import { Nullable } from "babylonjs/types";
  58971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58972. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58973. /**
  58974. * Implementation of the KTX Texture Loader.
  58975. * @hidden
  58976. */
  58977. export class _KTXTextureLoader implements IInternalTextureLoader {
  58978. /**
  58979. * Defines wether the loader supports cascade loading the different faces.
  58980. */
  58981. readonly supportCascades: boolean;
  58982. /**
  58983. * This returns if the loader support the current file information.
  58984. * @param extension defines the file extension of the file being loaded
  58985. * @param mimeType defines the optional mime type of the file being loaded
  58986. * @returns true if the loader can load the specified file
  58987. */
  58988. canLoad(extension: string, mimeType?: string): boolean;
  58989. /**
  58990. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58991. * @param data contains the texture data
  58992. * @param texture defines the BabylonJS internal texture
  58993. * @param createPolynomials will be true if polynomials have been requested
  58994. * @param onLoad defines the callback to trigger once the texture is ready
  58995. * @param onError defines the callback to trigger in case of error
  58996. */
  58997. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58998. /**
  58999. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59000. * @param data contains the texture data
  59001. * @param texture defines the BabylonJS internal texture
  59002. * @param callback defines the method to call once ready to upload
  59003. */
  59004. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59005. }
  59006. }
  59007. declare module "babylonjs/Helpers/sceneHelpers" {
  59008. import { Nullable } from "babylonjs/types";
  59009. import { Mesh } from "babylonjs/Meshes/mesh";
  59010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59011. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59012. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59013. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59014. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59015. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59016. import "babylonjs/Meshes/Builders/boxBuilder";
  59017. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59018. /** @hidden */
  59019. export var _forceSceneHelpersToBundle: boolean;
  59020. module "babylonjs/scene" {
  59021. interface Scene {
  59022. /**
  59023. * Creates a default light for the scene.
  59024. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59025. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59026. */
  59027. createDefaultLight(replace?: boolean): void;
  59028. /**
  59029. * Creates a default camera for the scene.
  59030. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59031. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59032. * @param replace has default false, when true replaces the active camera in the scene
  59033. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59034. */
  59035. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59036. /**
  59037. * Creates a default camera and a default light.
  59038. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59039. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59040. * @param replace has the default false, when true replaces the active camera/light in the scene
  59041. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59042. */
  59043. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59044. /**
  59045. * Creates a new sky box
  59046. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59047. * @param environmentTexture defines the texture to use as environment texture
  59048. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59049. * @param scale defines the overall scale of the skybox
  59050. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59051. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59052. * @returns a new mesh holding the sky box
  59053. */
  59054. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59055. /**
  59056. * Creates a new environment
  59057. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59058. * @param options defines the options you can use to configure the environment
  59059. * @returns the new EnvironmentHelper
  59060. */
  59061. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59062. /**
  59063. * Creates a new VREXperienceHelper
  59064. * @see http://doc.babylonjs.com/how_to/webvr_helper
  59065. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59066. * @returns a new VREXperienceHelper
  59067. */
  59068. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59069. /**
  59070. * Creates a new WebXRDefaultExperience
  59071. * @see http://doc.babylonjs.com/how_to/webxr
  59072. * @param options experience options
  59073. * @returns a promise for a new WebXRDefaultExperience
  59074. */
  59075. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59076. }
  59077. }
  59078. }
  59079. declare module "babylonjs/Helpers/videoDome" {
  59080. import { Scene } from "babylonjs/scene";
  59081. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59082. import { Mesh } from "babylonjs/Meshes/mesh";
  59083. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59084. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59085. import "babylonjs/Meshes/Builders/sphereBuilder";
  59086. /**
  59087. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59088. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59089. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59090. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59091. */
  59092. export class VideoDome extends TransformNode {
  59093. /**
  59094. * Define the video source as a Monoscopic panoramic 360 video.
  59095. */
  59096. static readonly MODE_MONOSCOPIC: number;
  59097. /**
  59098. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59099. */
  59100. static readonly MODE_TOPBOTTOM: number;
  59101. /**
  59102. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59103. */
  59104. static readonly MODE_SIDEBYSIDE: number;
  59105. private _halfDome;
  59106. private _useDirectMapping;
  59107. /**
  59108. * The video texture being displayed on the sphere
  59109. */
  59110. protected _videoTexture: VideoTexture;
  59111. /**
  59112. * Gets the video texture being displayed on the sphere
  59113. */
  59114. get videoTexture(): VideoTexture;
  59115. /**
  59116. * The skybox material
  59117. */
  59118. protected _material: BackgroundMaterial;
  59119. /**
  59120. * The surface used for the skybox
  59121. */
  59122. protected _mesh: Mesh;
  59123. /**
  59124. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59125. */
  59126. private _halfDomeMask;
  59127. /**
  59128. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59129. * Also see the options.resolution property.
  59130. */
  59131. get fovMultiplier(): number;
  59132. set fovMultiplier(value: number);
  59133. private _videoMode;
  59134. /**
  59135. * Gets or set the current video mode for the video. It can be:
  59136. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59137. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59138. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59139. */
  59140. get videoMode(): number;
  59141. set videoMode(value: number);
  59142. /**
  59143. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59144. *
  59145. */
  59146. get halfDome(): boolean;
  59147. /**
  59148. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59149. */
  59150. set halfDome(enabled: boolean);
  59151. /**
  59152. * Oberserver used in Stereoscopic VR Mode.
  59153. */
  59154. private _onBeforeCameraRenderObserver;
  59155. /**
  59156. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59157. * @param name Element's name, child elements will append suffixes for their own names.
  59158. * @param urlsOrVideo defines the url(s) or the video element to use
  59159. * @param options An object containing optional or exposed sub element properties
  59160. */
  59161. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59162. resolution?: number;
  59163. clickToPlay?: boolean;
  59164. autoPlay?: boolean;
  59165. loop?: boolean;
  59166. size?: number;
  59167. poster?: string;
  59168. faceForward?: boolean;
  59169. useDirectMapping?: boolean;
  59170. halfDomeMode?: boolean;
  59171. }, scene: Scene);
  59172. private _changeVideoMode;
  59173. /**
  59174. * Releases resources associated with this node.
  59175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59177. */
  59178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59179. }
  59180. }
  59181. declare module "babylonjs/Helpers/index" {
  59182. export * from "babylonjs/Helpers/environmentHelper";
  59183. export * from "babylonjs/Helpers/photoDome";
  59184. export * from "babylonjs/Helpers/sceneHelpers";
  59185. export * from "babylonjs/Helpers/videoDome";
  59186. }
  59187. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59188. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59189. import { IDisposable } from "babylonjs/scene";
  59190. import { Engine } from "babylonjs/Engines/engine";
  59191. /**
  59192. * This class can be used to get instrumentation data from a Babylon engine
  59193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59194. */
  59195. export class EngineInstrumentation implements IDisposable {
  59196. /**
  59197. * Define the instrumented engine.
  59198. */
  59199. engine: Engine;
  59200. private _captureGPUFrameTime;
  59201. private _gpuFrameTimeToken;
  59202. private _gpuFrameTime;
  59203. private _captureShaderCompilationTime;
  59204. private _shaderCompilationTime;
  59205. private _onBeginFrameObserver;
  59206. private _onEndFrameObserver;
  59207. private _onBeforeShaderCompilationObserver;
  59208. private _onAfterShaderCompilationObserver;
  59209. /**
  59210. * Gets the perf counter used for GPU frame time
  59211. */
  59212. get gpuFrameTimeCounter(): PerfCounter;
  59213. /**
  59214. * Gets the GPU frame time capture status
  59215. */
  59216. get captureGPUFrameTime(): boolean;
  59217. /**
  59218. * Enable or disable the GPU frame time capture
  59219. */
  59220. set captureGPUFrameTime(value: boolean);
  59221. /**
  59222. * Gets the perf counter used for shader compilation time
  59223. */
  59224. get shaderCompilationTimeCounter(): PerfCounter;
  59225. /**
  59226. * Gets the shader compilation time capture status
  59227. */
  59228. get captureShaderCompilationTime(): boolean;
  59229. /**
  59230. * Enable or disable the shader compilation time capture
  59231. */
  59232. set captureShaderCompilationTime(value: boolean);
  59233. /**
  59234. * Instantiates a new engine instrumentation.
  59235. * This class can be used to get instrumentation data from a Babylon engine
  59236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59237. * @param engine Defines the engine to instrument
  59238. */
  59239. constructor(
  59240. /**
  59241. * Define the instrumented engine.
  59242. */
  59243. engine: Engine);
  59244. /**
  59245. * Dispose and release associated resources.
  59246. */
  59247. dispose(): void;
  59248. }
  59249. }
  59250. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59251. import { Scene, IDisposable } from "babylonjs/scene";
  59252. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59253. /**
  59254. * This class can be used to get instrumentation data from a Babylon engine
  59255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59256. */
  59257. export class SceneInstrumentation implements IDisposable {
  59258. /**
  59259. * Defines the scene to instrument
  59260. */
  59261. scene: Scene;
  59262. private _captureActiveMeshesEvaluationTime;
  59263. private _activeMeshesEvaluationTime;
  59264. private _captureRenderTargetsRenderTime;
  59265. private _renderTargetsRenderTime;
  59266. private _captureFrameTime;
  59267. private _frameTime;
  59268. private _captureRenderTime;
  59269. private _renderTime;
  59270. private _captureInterFrameTime;
  59271. private _interFrameTime;
  59272. private _captureParticlesRenderTime;
  59273. private _particlesRenderTime;
  59274. private _captureSpritesRenderTime;
  59275. private _spritesRenderTime;
  59276. private _capturePhysicsTime;
  59277. private _physicsTime;
  59278. private _captureAnimationsTime;
  59279. private _animationsTime;
  59280. private _captureCameraRenderTime;
  59281. private _cameraRenderTime;
  59282. private _onBeforeActiveMeshesEvaluationObserver;
  59283. private _onAfterActiveMeshesEvaluationObserver;
  59284. private _onBeforeRenderTargetsRenderObserver;
  59285. private _onAfterRenderTargetsRenderObserver;
  59286. private _onAfterRenderObserver;
  59287. private _onBeforeDrawPhaseObserver;
  59288. private _onAfterDrawPhaseObserver;
  59289. private _onBeforeAnimationsObserver;
  59290. private _onBeforeParticlesRenderingObserver;
  59291. private _onAfterParticlesRenderingObserver;
  59292. private _onBeforeSpritesRenderingObserver;
  59293. private _onAfterSpritesRenderingObserver;
  59294. private _onBeforePhysicsObserver;
  59295. private _onAfterPhysicsObserver;
  59296. private _onAfterAnimationsObserver;
  59297. private _onBeforeCameraRenderObserver;
  59298. private _onAfterCameraRenderObserver;
  59299. /**
  59300. * Gets the perf counter used for active meshes evaluation time
  59301. */
  59302. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59303. /**
  59304. * Gets the active meshes evaluation time capture status
  59305. */
  59306. get captureActiveMeshesEvaluationTime(): boolean;
  59307. /**
  59308. * Enable or disable the active meshes evaluation time capture
  59309. */
  59310. set captureActiveMeshesEvaluationTime(value: boolean);
  59311. /**
  59312. * Gets the perf counter used for render targets render time
  59313. */
  59314. get renderTargetsRenderTimeCounter(): PerfCounter;
  59315. /**
  59316. * Gets the render targets render time capture status
  59317. */
  59318. get captureRenderTargetsRenderTime(): boolean;
  59319. /**
  59320. * Enable or disable the render targets render time capture
  59321. */
  59322. set captureRenderTargetsRenderTime(value: boolean);
  59323. /**
  59324. * Gets the perf counter used for particles render time
  59325. */
  59326. get particlesRenderTimeCounter(): PerfCounter;
  59327. /**
  59328. * Gets the particles render time capture status
  59329. */
  59330. get captureParticlesRenderTime(): boolean;
  59331. /**
  59332. * Enable or disable the particles render time capture
  59333. */
  59334. set captureParticlesRenderTime(value: boolean);
  59335. /**
  59336. * Gets the perf counter used for sprites render time
  59337. */
  59338. get spritesRenderTimeCounter(): PerfCounter;
  59339. /**
  59340. * Gets the sprites render time capture status
  59341. */
  59342. get captureSpritesRenderTime(): boolean;
  59343. /**
  59344. * Enable or disable the sprites render time capture
  59345. */
  59346. set captureSpritesRenderTime(value: boolean);
  59347. /**
  59348. * Gets the perf counter used for physics time
  59349. */
  59350. get physicsTimeCounter(): PerfCounter;
  59351. /**
  59352. * Gets the physics time capture status
  59353. */
  59354. get capturePhysicsTime(): boolean;
  59355. /**
  59356. * Enable or disable the physics time capture
  59357. */
  59358. set capturePhysicsTime(value: boolean);
  59359. /**
  59360. * Gets the perf counter used for animations time
  59361. */
  59362. get animationsTimeCounter(): PerfCounter;
  59363. /**
  59364. * Gets the animations time capture status
  59365. */
  59366. get captureAnimationsTime(): boolean;
  59367. /**
  59368. * Enable or disable the animations time capture
  59369. */
  59370. set captureAnimationsTime(value: boolean);
  59371. /**
  59372. * Gets the perf counter used for frame time capture
  59373. */
  59374. get frameTimeCounter(): PerfCounter;
  59375. /**
  59376. * Gets the frame time capture status
  59377. */
  59378. get captureFrameTime(): boolean;
  59379. /**
  59380. * Enable or disable the frame time capture
  59381. */
  59382. set captureFrameTime(value: boolean);
  59383. /**
  59384. * Gets the perf counter used for inter-frames time capture
  59385. */
  59386. get interFrameTimeCounter(): PerfCounter;
  59387. /**
  59388. * Gets the inter-frames time capture status
  59389. */
  59390. get captureInterFrameTime(): boolean;
  59391. /**
  59392. * Enable or disable the inter-frames time capture
  59393. */
  59394. set captureInterFrameTime(value: boolean);
  59395. /**
  59396. * Gets the perf counter used for render time capture
  59397. */
  59398. get renderTimeCounter(): PerfCounter;
  59399. /**
  59400. * Gets the render time capture status
  59401. */
  59402. get captureRenderTime(): boolean;
  59403. /**
  59404. * Enable or disable the render time capture
  59405. */
  59406. set captureRenderTime(value: boolean);
  59407. /**
  59408. * Gets the perf counter used for camera render time capture
  59409. */
  59410. get cameraRenderTimeCounter(): PerfCounter;
  59411. /**
  59412. * Gets the camera render time capture status
  59413. */
  59414. get captureCameraRenderTime(): boolean;
  59415. /**
  59416. * Enable or disable the camera render time capture
  59417. */
  59418. set captureCameraRenderTime(value: boolean);
  59419. /**
  59420. * Gets the perf counter used for draw calls
  59421. */
  59422. get drawCallsCounter(): PerfCounter;
  59423. /**
  59424. * Instantiates a new scene instrumentation.
  59425. * This class can be used to get instrumentation data from a Babylon engine
  59426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59427. * @param scene Defines the scene to instrument
  59428. */
  59429. constructor(
  59430. /**
  59431. * Defines the scene to instrument
  59432. */
  59433. scene: Scene);
  59434. /**
  59435. * Dispose and release associated resources.
  59436. */
  59437. dispose(): void;
  59438. }
  59439. }
  59440. declare module "babylonjs/Instrumentation/index" {
  59441. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59442. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59443. export * from "babylonjs/Instrumentation/timeToken";
  59444. }
  59445. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59446. /** @hidden */
  59447. export var glowMapGenerationPixelShader: {
  59448. name: string;
  59449. shader: string;
  59450. };
  59451. }
  59452. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59455. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59458. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59459. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59460. /** @hidden */
  59461. export var glowMapGenerationVertexShader: {
  59462. name: string;
  59463. shader: string;
  59464. };
  59465. }
  59466. declare module "babylonjs/Layers/effectLayer" {
  59467. import { Observable } from "babylonjs/Misc/observable";
  59468. import { Nullable } from "babylonjs/types";
  59469. import { Camera } from "babylonjs/Cameras/camera";
  59470. import { Scene } from "babylonjs/scene";
  59471. import { ISize } from "babylonjs/Maths/math.size";
  59472. import { Color4 } from "babylonjs/Maths/math.color";
  59473. import { Engine } from "babylonjs/Engines/engine";
  59474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59476. import { Mesh } from "babylonjs/Meshes/mesh";
  59477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59480. import { Effect } from "babylonjs/Materials/effect";
  59481. import { Material } from "babylonjs/Materials/material";
  59482. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59483. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59484. /**
  59485. * Effect layer options. This helps customizing the behaviour
  59486. * of the effect layer.
  59487. */
  59488. export interface IEffectLayerOptions {
  59489. /**
  59490. * Multiplication factor apply to the canvas size to compute the render target size
  59491. * used to generated the objects (the smaller the faster).
  59492. */
  59493. mainTextureRatio: number;
  59494. /**
  59495. * Enforces a fixed size texture to ensure effect stability across devices.
  59496. */
  59497. mainTextureFixedSize?: number;
  59498. /**
  59499. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59500. */
  59501. alphaBlendingMode: number;
  59502. /**
  59503. * The camera attached to the layer.
  59504. */
  59505. camera: Nullable<Camera>;
  59506. /**
  59507. * The rendering group to draw the layer in.
  59508. */
  59509. renderingGroupId: number;
  59510. }
  59511. /**
  59512. * The effect layer Helps adding post process effect blended with the main pass.
  59513. *
  59514. * This can be for instance use to generate glow or higlight effects on the scene.
  59515. *
  59516. * The effect layer class can not be used directly and is intented to inherited from to be
  59517. * customized per effects.
  59518. */
  59519. export abstract class EffectLayer {
  59520. private _vertexBuffers;
  59521. private _indexBuffer;
  59522. private _cachedDefines;
  59523. private _effectLayerMapGenerationEffect;
  59524. private _effectLayerOptions;
  59525. private _mergeEffect;
  59526. protected _scene: Scene;
  59527. protected _engine: Engine;
  59528. protected _maxSize: number;
  59529. protected _mainTextureDesiredSize: ISize;
  59530. protected _mainTexture: RenderTargetTexture;
  59531. protected _shouldRender: boolean;
  59532. protected _postProcesses: PostProcess[];
  59533. protected _textures: BaseTexture[];
  59534. protected _emissiveTextureAndColor: {
  59535. texture: Nullable<BaseTexture>;
  59536. color: Color4;
  59537. };
  59538. /**
  59539. * The name of the layer
  59540. */
  59541. name: string;
  59542. /**
  59543. * The clear color of the texture used to generate the glow map.
  59544. */
  59545. neutralColor: Color4;
  59546. /**
  59547. * Specifies whether the highlight layer is enabled or not.
  59548. */
  59549. isEnabled: boolean;
  59550. /**
  59551. * Gets the camera attached to the layer.
  59552. */
  59553. get camera(): Nullable<Camera>;
  59554. /**
  59555. * Gets the rendering group id the layer should render in.
  59556. */
  59557. get renderingGroupId(): number;
  59558. set renderingGroupId(renderingGroupId: number);
  59559. /**
  59560. * An event triggered when the effect layer has been disposed.
  59561. */
  59562. onDisposeObservable: Observable<EffectLayer>;
  59563. /**
  59564. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59565. */
  59566. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59567. /**
  59568. * An event triggered when the generated texture is being merged in the scene.
  59569. */
  59570. onBeforeComposeObservable: Observable<EffectLayer>;
  59571. /**
  59572. * An event triggered when the mesh is rendered into the effect render target.
  59573. */
  59574. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59575. /**
  59576. * An event triggered after the mesh has been rendered into the effect render target.
  59577. */
  59578. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59579. /**
  59580. * An event triggered when the generated texture has been merged in the scene.
  59581. */
  59582. onAfterComposeObservable: Observable<EffectLayer>;
  59583. /**
  59584. * An event triggered when the efffect layer changes its size.
  59585. */
  59586. onSizeChangedObservable: Observable<EffectLayer>;
  59587. /** @hidden */
  59588. static _SceneComponentInitialization: (scene: Scene) => void;
  59589. /**
  59590. * Instantiates a new effect Layer and references it in the scene.
  59591. * @param name The name of the layer
  59592. * @param scene The scene to use the layer in
  59593. */
  59594. constructor(
  59595. /** The Friendly of the effect in the scene */
  59596. name: string, scene: Scene);
  59597. /**
  59598. * Get the effect name of the layer.
  59599. * @return The effect name
  59600. */
  59601. abstract getEffectName(): string;
  59602. /**
  59603. * Checks for the readiness of the element composing the layer.
  59604. * @param subMesh the mesh to check for
  59605. * @param useInstances specify whether or not to use instances to render the mesh
  59606. * @return true if ready otherwise, false
  59607. */
  59608. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59609. /**
  59610. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59611. * @returns true if the effect requires stencil during the main canvas render pass.
  59612. */
  59613. abstract needStencil(): boolean;
  59614. /**
  59615. * Create the merge effect. This is the shader use to blit the information back
  59616. * to the main canvas at the end of the scene rendering.
  59617. * @returns The effect containing the shader used to merge the effect on the main canvas
  59618. */
  59619. protected abstract _createMergeEffect(): Effect;
  59620. /**
  59621. * Creates the render target textures and post processes used in the effect layer.
  59622. */
  59623. protected abstract _createTextureAndPostProcesses(): void;
  59624. /**
  59625. * Implementation specific of rendering the generating effect on the main canvas.
  59626. * @param effect The effect used to render through
  59627. */
  59628. protected abstract _internalRender(effect: Effect): void;
  59629. /**
  59630. * Sets the required values for both the emissive texture and and the main color.
  59631. */
  59632. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59633. /**
  59634. * Free any resources and references associated to a mesh.
  59635. * Internal use
  59636. * @param mesh The mesh to free.
  59637. */
  59638. abstract _disposeMesh(mesh: Mesh): void;
  59639. /**
  59640. * Serializes this layer (Glow or Highlight for example)
  59641. * @returns a serialized layer object
  59642. */
  59643. abstract serialize?(): any;
  59644. /**
  59645. * Initializes the effect layer with the required options.
  59646. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59647. */
  59648. protected _init(options: Partial<IEffectLayerOptions>): void;
  59649. /**
  59650. * Generates the index buffer of the full screen quad blending to the main canvas.
  59651. */
  59652. private _generateIndexBuffer;
  59653. /**
  59654. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59655. */
  59656. private _generateVertexBuffer;
  59657. /**
  59658. * Sets the main texture desired size which is the closest power of two
  59659. * of the engine canvas size.
  59660. */
  59661. private _setMainTextureSize;
  59662. /**
  59663. * Creates the main texture for the effect layer.
  59664. */
  59665. protected _createMainTexture(): void;
  59666. /**
  59667. * Adds specific effects defines.
  59668. * @param defines The defines to add specifics to.
  59669. */
  59670. protected _addCustomEffectDefines(defines: string[]): void;
  59671. /**
  59672. * Checks for the readiness of the element composing the layer.
  59673. * @param subMesh the mesh to check for
  59674. * @param useInstances specify whether or not to use instances to render the mesh
  59675. * @param emissiveTexture the associated emissive texture used to generate the glow
  59676. * @return true if ready otherwise, false
  59677. */
  59678. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59679. /**
  59680. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59681. */
  59682. render(): void;
  59683. /**
  59684. * Determine if a given mesh will be used in the current effect.
  59685. * @param mesh mesh to test
  59686. * @returns true if the mesh will be used
  59687. */
  59688. hasMesh(mesh: AbstractMesh): boolean;
  59689. /**
  59690. * Returns true if the layer contains information to display, otherwise false.
  59691. * @returns true if the glow layer should be rendered
  59692. */
  59693. shouldRender(): boolean;
  59694. /**
  59695. * Returns true if the mesh should render, otherwise false.
  59696. * @param mesh The mesh to render
  59697. * @returns true if it should render otherwise false
  59698. */
  59699. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59700. /**
  59701. * Returns true if the mesh can be rendered, otherwise false.
  59702. * @param mesh The mesh to render
  59703. * @param material The material used on the mesh
  59704. * @returns true if it can be rendered otherwise false
  59705. */
  59706. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59707. /**
  59708. * Returns true if the mesh should render, otherwise false.
  59709. * @param mesh The mesh to render
  59710. * @returns true if it should render otherwise false
  59711. */
  59712. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59713. /**
  59714. * Renders the submesh passed in parameter to the generation map.
  59715. */
  59716. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59717. /**
  59718. * Defines whether the current material of the mesh should be use to render the effect.
  59719. * @param mesh defines the current mesh to render
  59720. */
  59721. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59722. /**
  59723. * Rebuild the required buffers.
  59724. * @hidden Internal use only.
  59725. */
  59726. _rebuild(): void;
  59727. /**
  59728. * Dispose only the render target textures and post process.
  59729. */
  59730. private _disposeTextureAndPostProcesses;
  59731. /**
  59732. * Dispose the highlight layer and free resources.
  59733. */
  59734. dispose(): void;
  59735. /**
  59736. * Gets the class name of the effect layer
  59737. * @returns the string with the class name of the effect layer
  59738. */
  59739. getClassName(): string;
  59740. /**
  59741. * Creates an effect layer from parsed effect layer data
  59742. * @param parsedEffectLayer defines effect layer data
  59743. * @param scene defines the current scene
  59744. * @param rootUrl defines the root URL containing the effect layer information
  59745. * @returns a parsed effect Layer
  59746. */
  59747. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59748. }
  59749. }
  59750. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59751. import { Scene } from "babylonjs/scene";
  59752. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59753. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59754. import { AbstractScene } from "babylonjs/abstractScene";
  59755. module "babylonjs/abstractScene" {
  59756. interface AbstractScene {
  59757. /**
  59758. * The list of effect layers (highlights/glow) added to the scene
  59759. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59760. * @see http://doc.babylonjs.com/how_to/glow_layer
  59761. */
  59762. effectLayers: Array<EffectLayer>;
  59763. /**
  59764. * Removes the given effect layer from this scene.
  59765. * @param toRemove defines the effect layer to remove
  59766. * @returns the index of the removed effect layer
  59767. */
  59768. removeEffectLayer(toRemove: EffectLayer): number;
  59769. /**
  59770. * Adds the given effect layer to this scene
  59771. * @param newEffectLayer defines the effect layer to add
  59772. */
  59773. addEffectLayer(newEffectLayer: EffectLayer): void;
  59774. }
  59775. }
  59776. /**
  59777. * Defines the layer scene component responsible to manage any effect layers
  59778. * in a given scene.
  59779. */
  59780. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59781. /**
  59782. * The component name helpfull to identify the component in the list of scene components.
  59783. */
  59784. readonly name: string;
  59785. /**
  59786. * The scene the component belongs to.
  59787. */
  59788. scene: Scene;
  59789. private _engine;
  59790. private _renderEffects;
  59791. private _needStencil;
  59792. private _previousStencilState;
  59793. /**
  59794. * Creates a new instance of the component for the given scene
  59795. * @param scene Defines the scene to register the component in
  59796. */
  59797. constructor(scene: Scene);
  59798. /**
  59799. * Registers the component in a given scene
  59800. */
  59801. register(): void;
  59802. /**
  59803. * Rebuilds the elements related to this component in case of
  59804. * context lost for instance.
  59805. */
  59806. rebuild(): void;
  59807. /**
  59808. * Serializes the component data to the specified json object
  59809. * @param serializationObject The object to serialize to
  59810. */
  59811. serialize(serializationObject: any): void;
  59812. /**
  59813. * Adds all the elements from the container to the scene
  59814. * @param container the container holding the elements
  59815. */
  59816. addFromContainer(container: AbstractScene): void;
  59817. /**
  59818. * Removes all the elements in the container from the scene
  59819. * @param container contains the elements to remove
  59820. * @param dispose if the removed element should be disposed (default: false)
  59821. */
  59822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59823. /**
  59824. * Disposes the component and the associated ressources.
  59825. */
  59826. dispose(): void;
  59827. private _isReadyForMesh;
  59828. private _renderMainTexture;
  59829. private _setStencil;
  59830. private _setStencilBack;
  59831. private _draw;
  59832. private _drawCamera;
  59833. private _drawRenderingGroup;
  59834. }
  59835. }
  59836. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59837. /** @hidden */
  59838. export var glowMapMergePixelShader: {
  59839. name: string;
  59840. shader: string;
  59841. };
  59842. }
  59843. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59844. /** @hidden */
  59845. export var glowMapMergeVertexShader: {
  59846. name: string;
  59847. shader: string;
  59848. };
  59849. }
  59850. declare module "babylonjs/Layers/glowLayer" {
  59851. import { Nullable } from "babylonjs/types";
  59852. import { Camera } from "babylonjs/Cameras/camera";
  59853. import { Scene } from "babylonjs/scene";
  59854. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59856. import { Mesh } from "babylonjs/Meshes/mesh";
  59857. import { Texture } from "babylonjs/Materials/Textures/texture";
  59858. import { Effect } from "babylonjs/Materials/effect";
  59859. import { Material } from "babylonjs/Materials/material";
  59860. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59861. import { Color4 } from "babylonjs/Maths/math.color";
  59862. import "babylonjs/Shaders/glowMapMerge.fragment";
  59863. import "babylonjs/Shaders/glowMapMerge.vertex";
  59864. import "babylonjs/Layers/effectLayerSceneComponent";
  59865. module "babylonjs/abstractScene" {
  59866. interface AbstractScene {
  59867. /**
  59868. * Return a the first highlight layer of the scene with a given name.
  59869. * @param name The name of the highlight layer to look for.
  59870. * @return The highlight layer if found otherwise null.
  59871. */
  59872. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59873. }
  59874. }
  59875. /**
  59876. * Glow layer options. This helps customizing the behaviour
  59877. * of the glow layer.
  59878. */
  59879. export interface IGlowLayerOptions {
  59880. /**
  59881. * Multiplication factor apply to the canvas size to compute the render target size
  59882. * used to generated the glowing objects (the smaller the faster).
  59883. */
  59884. mainTextureRatio: number;
  59885. /**
  59886. * Enforces a fixed size texture to ensure resize independant blur.
  59887. */
  59888. mainTextureFixedSize?: number;
  59889. /**
  59890. * How big is the kernel of the blur texture.
  59891. */
  59892. blurKernelSize: number;
  59893. /**
  59894. * The camera attached to the layer.
  59895. */
  59896. camera: Nullable<Camera>;
  59897. /**
  59898. * Enable MSAA by chosing the number of samples.
  59899. */
  59900. mainTextureSamples?: number;
  59901. /**
  59902. * The rendering group to draw the layer in.
  59903. */
  59904. renderingGroupId: number;
  59905. }
  59906. /**
  59907. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59908. *
  59909. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59910. *
  59911. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59912. */
  59913. export class GlowLayer extends EffectLayer {
  59914. /**
  59915. * Effect Name of the layer.
  59916. */
  59917. static readonly EffectName: string;
  59918. /**
  59919. * The default blur kernel size used for the glow.
  59920. */
  59921. static DefaultBlurKernelSize: number;
  59922. /**
  59923. * The default texture size ratio used for the glow.
  59924. */
  59925. static DefaultTextureRatio: number;
  59926. /**
  59927. * Sets the kernel size of the blur.
  59928. */
  59929. set blurKernelSize(value: number);
  59930. /**
  59931. * Gets the kernel size of the blur.
  59932. */
  59933. get blurKernelSize(): number;
  59934. /**
  59935. * Sets the glow intensity.
  59936. */
  59937. set intensity(value: number);
  59938. /**
  59939. * Gets the glow intensity.
  59940. */
  59941. get intensity(): number;
  59942. private _options;
  59943. private _intensity;
  59944. private _horizontalBlurPostprocess1;
  59945. private _verticalBlurPostprocess1;
  59946. private _horizontalBlurPostprocess2;
  59947. private _verticalBlurPostprocess2;
  59948. private _blurTexture1;
  59949. private _blurTexture2;
  59950. private _postProcesses1;
  59951. private _postProcesses2;
  59952. private _includedOnlyMeshes;
  59953. private _excludedMeshes;
  59954. private _meshesUsingTheirOwnMaterials;
  59955. /**
  59956. * Callback used to let the user override the color selection on a per mesh basis
  59957. */
  59958. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59959. /**
  59960. * Callback used to let the user override the texture selection on a per mesh basis
  59961. */
  59962. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59963. /**
  59964. * Instantiates a new glow Layer and references it to the scene.
  59965. * @param name The name of the layer
  59966. * @param scene The scene to use the layer in
  59967. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59968. */
  59969. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59970. /**
  59971. * Get the effect name of the layer.
  59972. * @return The effect name
  59973. */
  59974. getEffectName(): string;
  59975. /**
  59976. * Create the merge effect. This is the shader use to blit the information back
  59977. * to the main canvas at the end of the scene rendering.
  59978. */
  59979. protected _createMergeEffect(): Effect;
  59980. /**
  59981. * Creates the render target textures and post processes used in the glow layer.
  59982. */
  59983. protected _createTextureAndPostProcesses(): void;
  59984. /**
  59985. * Checks for the readiness of the element composing the layer.
  59986. * @param subMesh the mesh to check for
  59987. * @param useInstances specify wether or not to use instances to render the mesh
  59988. * @param emissiveTexture the associated emissive texture used to generate the glow
  59989. * @return true if ready otherwise, false
  59990. */
  59991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59992. /**
  59993. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59994. */
  59995. needStencil(): boolean;
  59996. /**
  59997. * Returns true if the mesh can be rendered, otherwise false.
  59998. * @param mesh The mesh to render
  59999. * @param material The material used on the mesh
  60000. * @returns true if it can be rendered otherwise false
  60001. */
  60002. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60003. /**
  60004. * Implementation specific of rendering the generating effect on the main canvas.
  60005. * @param effect The effect used to render through
  60006. */
  60007. protected _internalRender(effect: Effect): void;
  60008. /**
  60009. * Sets the required values for both the emissive texture and and the main color.
  60010. */
  60011. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60012. /**
  60013. * Returns true if the mesh should render, otherwise false.
  60014. * @param mesh The mesh to render
  60015. * @returns true if it should render otherwise false
  60016. */
  60017. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60018. /**
  60019. * Adds specific effects defines.
  60020. * @param defines The defines to add specifics to.
  60021. */
  60022. protected _addCustomEffectDefines(defines: string[]): void;
  60023. /**
  60024. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60025. * @param mesh The mesh to exclude from the glow layer
  60026. */
  60027. addExcludedMesh(mesh: Mesh): void;
  60028. /**
  60029. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60030. * @param mesh The mesh to remove
  60031. */
  60032. removeExcludedMesh(mesh: Mesh): void;
  60033. /**
  60034. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60035. * @param mesh The mesh to include in the glow layer
  60036. */
  60037. addIncludedOnlyMesh(mesh: Mesh): void;
  60038. /**
  60039. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60040. * @param mesh The mesh to remove
  60041. */
  60042. removeIncludedOnlyMesh(mesh: Mesh): void;
  60043. /**
  60044. * Determine if a given mesh will be used in the glow layer
  60045. * @param mesh The mesh to test
  60046. * @returns true if the mesh will be highlighted by the current glow layer
  60047. */
  60048. hasMesh(mesh: AbstractMesh): boolean;
  60049. /**
  60050. * Defines whether the current material of the mesh should be use to render the effect.
  60051. * @param mesh defines the current mesh to render
  60052. */
  60053. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60054. /**
  60055. * Add a mesh to be rendered through its own material and not with emissive only.
  60056. * @param mesh The mesh for which we need to use its material
  60057. */
  60058. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60059. /**
  60060. * Remove a mesh from being rendered through its own material and not with emissive only.
  60061. * @param mesh The mesh for which we need to not use its material
  60062. */
  60063. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60064. /**
  60065. * Free any resources and references associated to a mesh.
  60066. * Internal use
  60067. * @param mesh The mesh to free.
  60068. * @hidden
  60069. */
  60070. _disposeMesh(mesh: Mesh): void;
  60071. /**
  60072. * Gets the class name of the effect layer
  60073. * @returns the string with the class name of the effect layer
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Serializes this glow layer
  60078. * @returns a serialized glow layer object
  60079. */
  60080. serialize(): any;
  60081. /**
  60082. * Creates a Glow Layer from parsed glow layer data
  60083. * @param parsedGlowLayer defines glow layer data
  60084. * @param scene defines the current scene
  60085. * @param rootUrl defines the root URL containing the glow layer information
  60086. * @returns a parsed Glow Layer
  60087. */
  60088. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60089. }
  60090. }
  60091. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60092. /** @hidden */
  60093. export var glowBlurPostProcessPixelShader: {
  60094. name: string;
  60095. shader: string;
  60096. };
  60097. }
  60098. declare module "babylonjs/Layers/highlightLayer" {
  60099. import { Observable } from "babylonjs/Misc/observable";
  60100. import { Nullable } from "babylonjs/types";
  60101. import { Camera } from "babylonjs/Cameras/camera";
  60102. import { Scene } from "babylonjs/scene";
  60103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60105. import { Mesh } from "babylonjs/Meshes/mesh";
  60106. import { Effect } from "babylonjs/Materials/effect";
  60107. import { Material } from "babylonjs/Materials/material";
  60108. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60109. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60110. import "babylonjs/Shaders/glowMapMerge.fragment";
  60111. import "babylonjs/Shaders/glowMapMerge.vertex";
  60112. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60113. module "babylonjs/abstractScene" {
  60114. interface AbstractScene {
  60115. /**
  60116. * Return a the first highlight layer of the scene with a given name.
  60117. * @param name The name of the highlight layer to look for.
  60118. * @return The highlight layer if found otherwise null.
  60119. */
  60120. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60121. }
  60122. }
  60123. /**
  60124. * Highlight layer options. This helps customizing the behaviour
  60125. * of the highlight layer.
  60126. */
  60127. export interface IHighlightLayerOptions {
  60128. /**
  60129. * Multiplication factor apply to the canvas size to compute the render target size
  60130. * used to generated the glowing objects (the smaller the faster).
  60131. */
  60132. mainTextureRatio: number;
  60133. /**
  60134. * Enforces a fixed size texture to ensure resize independant blur.
  60135. */
  60136. mainTextureFixedSize?: number;
  60137. /**
  60138. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60139. * of the picture to blur (the smaller the faster).
  60140. */
  60141. blurTextureSizeRatio: number;
  60142. /**
  60143. * How big in texel of the blur texture is the vertical blur.
  60144. */
  60145. blurVerticalSize: number;
  60146. /**
  60147. * How big in texel of the blur texture is the horizontal blur.
  60148. */
  60149. blurHorizontalSize: number;
  60150. /**
  60151. * Alpha blending mode used to apply the blur. Default is combine.
  60152. */
  60153. alphaBlendingMode: number;
  60154. /**
  60155. * The camera attached to the layer.
  60156. */
  60157. camera: Nullable<Camera>;
  60158. /**
  60159. * Should we display highlight as a solid stroke?
  60160. */
  60161. isStroke?: boolean;
  60162. /**
  60163. * The rendering group to draw the layer in.
  60164. */
  60165. renderingGroupId: number;
  60166. }
  60167. /**
  60168. * The highlight layer Helps adding a glow effect around a mesh.
  60169. *
  60170. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60171. * glowy meshes to your scene.
  60172. *
  60173. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60174. */
  60175. export class HighlightLayer extends EffectLayer {
  60176. name: string;
  60177. /**
  60178. * Effect Name of the highlight layer.
  60179. */
  60180. static readonly EffectName: string;
  60181. /**
  60182. * The neutral color used during the preparation of the glow effect.
  60183. * This is black by default as the blend operation is a blend operation.
  60184. */
  60185. static NeutralColor: Color4;
  60186. /**
  60187. * Stencil value used for glowing meshes.
  60188. */
  60189. static GlowingMeshStencilReference: number;
  60190. /**
  60191. * Stencil value used for the other meshes in the scene.
  60192. */
  60193. static NormalMeshStencilReference: number;
  60194. /**
  60195. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60196. */
  60197. innerGlow: boolean;
  60198. /**
  60199. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60200. */
  60201. outerGlow: boolean;
  60202. /**
  60203. * Specifies the horizontal size of the blur.
  60204. */
  60205. set blurHorizontalSize(value: number);
  60206. /**
  60207. * Specifies the vertical size of the blur.
  60208. */
  60209. set blurVerticalSize(value: number);
  60210. /**
  60211. * Gets the horizontal size of the blur.
  60212. */
  60213. get blurHorizontalSize(): number;
  60214. /**
  60215. * Gets the vertical size of the blur.
  60216. */
  60217. get blurVerticalSize(): number;
  60218. /**
  60219. * An event triggered when the highlight layer is being blurred.
  60220. */
  60221. onBeforeBlurObservable: Observable<HighlightLayer>;
  60222. /**
  60223. * An event triggered when the highlight layer has been blurred.
  60224. */
  60225. onAfterBlurObservable: Observable<HighlightLayer>;
  60226. private _instanceGlowingMeshStencilReference;
  60227. private _options;
  60228. private _downSamplePostprocess;
  60229. private _horizontalBlurPostprocess;
  60230. private _verticalBlurPostprocess;
  60231. private _blurTexture;
  60232. private _meshes;
  60233. private _excludedMeshes;
  60234. /**
  60235. * Instantiates a new highlight Layer and references it to the scene..
  60236. * @param name The name of the layer
  60237. * @param scene The scene to use the layer in
  60238. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60239. */
  60240. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60241. /**
  60242. * Get the effect name of the layer.
  60243. * @return The effect name
  60244. */
  60245. getEffectName(): string;
  60246. /**
  60247. * Create the merge effect. This is the shader use to blit the information back
  60248. * to the main canvas at the end of the scene rendering.
  60249. */
  60250. protected _createMergeEffect(): Effect;
  60251. /**
  60252. * Creates the render target textures and post processes used in the highlight layer.
  60253. */
  60254. protected _createTextureAndPostProcesses(): void;
  60255. /**
  60256. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60257. */
  60258. needStencil(): boolean;
  60259. /**
  60260. * Checks for the readiness of the element composing the layer.
  60261. * @param subMesh the mesh to check for
  60262. * @param useInstances specify wether or not to use instances to render the mesh
  60263. * @param emissiveTexture the associated emissive texture used to generate the glow
  60264. * @return true if ready otherwise, false
  60265. */
  60266. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60267. /**
  60268. * Implementation specific of rendering the generating effect on the main canvas.
  60269. * @param effect The effect used to render through
  60270. */
  60271. protected _internalRender(effect: Effect): void;
  60272. /**
  60273. * Returns true if the layer contains information to display, otherwise false.
  60274. */
  60275. shouldRender(): boolean;
  60276. /**
  60277. * Returns true if the mesh should render, otherwise false.
  60278. * @param mesh The mesh to render
  60279. * @returns true if it should render otherwise false
  60280. */
  60281. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60282. /**
  60283. * Returns true if the mesh can be rendered, otherwise false.
  60284. * @param mesh The mesh to render
  60285. * @param material The material used on the mesh
  60286. * @returns true if it can be rendered otherwise false
  60287. */
  60288. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60289. /**
  60290. * Adds specific effects defines.
  60291. * @param defines The defines to add specifics to.
  60292. */
  60293. protected _addCustomEffectDefines(defines: string[]): void;
  60294. /**
  60295. * Sets the required values for both the emissive texture and and the main color.
  60296. */
  60297. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60298. /**
  60299. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60300. * @param mesh The mesh to exclude from the highlight layer
  60301. */
  60302. addExcludedMesh(mesh: Mesh): void;
  60303. /**
  60304. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60305. * @param mesh The mesh to highlight
  60306. */
  60307. removeExcludedMesh(mesh: Mesh): void;
  60308. /**
  60309. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60310. * @param mesh mesh to test
  60311. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60312. */
  60313. hasMesh(mesh: AbstractMesh): boolean;
  60314. /**
  60315. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60316. * @param mesh The mesh to highlight
  60317. * @param color The color of the highlight
  60318. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60319. */
  60320. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60321. /**
  60322. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60323. * @param mesh The mesh to highlight
  60324. */
  60325. removeMesh(mesh: Mesh): void;
  60326. /**
  60327. * Remove all the meshes currently referenced in the highlight layer
  60328. */
  60329. removeAllMeshes(): void;
  60330. /**
  60331. * Force the stencil to the normal expected value for none glowing parts
  60332. */
  60333. private _defaultStencilReference;
  60334. /**
  60335. * Free any resources and references associated to a mesh.
  60336. * Internal use
  60337. * @param mesh The mesh to free.
  60338. * @hidden
  60339. */
  60340. _disposeMesh(mesh: Mesh): void;
  60341. /**
  60342. * Dispose the highlight layer and free resources.
  60343. */
  60344. dispose(): void;
  60345. /**
  60346. * Gets the class name of the effect layer
  60347. * @returns the string with the class name of the effect layer
  60348. */
  60349. getClassName(): string;
  60350. /**
  60351. * Serializes this Highlight layer
  60352. * @returns a serialized Highlight layer object
  60353. */
  60354. serialize(): any;
  60355. /**
  60356. * Creates a Highlight layer from parsed Highlight layer data
  60357. * @param parsedHightlightLayer defines the Highlight layer data
  60358. * @param scene defines the current scene
  60359. * @param rootUrl defines the root URL containing the Highlight layer information
  60360. * @returns a parsed Highlight layer
  60361. */
  60362. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60363. }
  60364. }
  60365. declare module "babylonjs/Layers/layerSceneComponent" {
  60366. import { Scene } from "babylonjs/scene";
  60367. import { ISceneComponent } from "babylonjs/sceneComponent";
  60368. import { Layer } from "babylonjs/Layers/layer";
  60369. import { AbstractScene } from "babylonjs/abstractScene";
  60370. module "babylonjs/abstractScene" {
  60371. interface AbstractScene {
  60372. /**
  60373. * The list of layers (background and foreground) of the scene
  60374. */
  60375. layers: Array<Layer>;
  60376. }
  60377. }
  60378. /**
  60379. * Defines the layer scene component responsible to manage any layers
  60380. * in a given scene.
  60381. */
  60382. export class LayerSceneComponent implements ISceneComponent {
  60383. /**
  60384. * The component name helpfull to identify the component in the list of scene components.
  60385. */
  60386. readonly name: string;
  60387. /**
  60388. * The scene the component belongs to.
  60389. */
  60390. scene: Scene;
  60391. private _engine;
  60392. /**
  60393. * Creates a new instance of the component for the given scene
  60394. * @param scene Defines the scene to register the component in
  60395. */
  60396. constructor(scene: Scene);
  60397. /**
  60398. * Registers the component in a given scene
  60399. */
  60400. register(): void;
  60401. /**
  60402. * Rebuilds the elements related to this component in case of
  60403. * context lost for instance.
  60404. */
  60405. rebuild(): void;
  60406. /**
  60407. * Disposes the component and the associated ressources.
  60408. */
  60409. dispose(): void;
  60410. private _draw;
  60411. private _drawCameraPredicate;
  60412. private _drawCameraBackground;
  60413. private _drawCameraForeground;
  60414. private _drawRenderTargetPredicate;
  60415. private _drawRenderTargetBackground;
  60416. private _drawRenderTargetForeground;
  60417. /**
  60418. * Adds all the elements from the container to the scene
  60419. * @param container the container holding the elements
  60420. */
  60421. addFromContainer(container: AbstractScene): void;
  60422. /**
  60423. * Removes all the elements in the container from the scene
  60424. * @param container contains the elements to remove
  60425. * @param dispose if the removed element should be disposed (default: false)
  60426. */
  60427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60428. }
  60429. }
  60430. declare module "babylonjs/Shaders/layer.fragment" {
  60431. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60432. /** @hidden */
  60433. export var layerPixelShader: {
  60434. name: string;
  60435. shader: string;
  60436. };
  60437. }
  60438. declare module "babylonjs/Shaders/layer.vertex" {
  60439. /** @hidden */
  60440. export var layerVertexShader: {
  60441. name: string;
  60442. shader: string;
  60443. };
  60444. }
  60445. declare module "babylonjs/Layers/layer" {
  60446. import { Observable } from "babylonjs/Misc/observable";
  60447. import { Nullable } from "babylonjs/types";
  60448. import { Scene } from "babylonjs/scene";
  60449. import { Vector2 } from "babylonjs/Maths/math.vector";
  60450. import { Color4 } from "babylonjs/Maths/math.color";
  60451. import { Texture } from "babylonjs/Materials/Textures/texture";
  60452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60453. import "babylonjs/Shaders/layer.fragment";
  60454. import "babylonjs/Shaders/layer.vertex";
  60455. /**
  60456. * This represents a full screen 2d layer.
  60457. * This can be useful to display a picture in the background of your scene for instance.
  60458. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60459. */
  60460. export class Layer {
  60461. /**
  60462. * Define the name of the layer.
  60463. */
  60464. name: string;
  60465. /**
  60466. * Define the texture the layer should display.
  60467. */
  60468. texture: Nullable<Texture>;
  60469. /**
  60470. * Is the layer in background or foreground.
  60471. */
  60472. isBackground: boolean;
  60473. /**
  60474. * Define the color of the layer (instead of texture).
  60475. */
  60476. color: Color4;
  60477. /**
  60478. * Define the scale of the layer in order to zoom in out of the texture.
  60479. */
  60480. scale: Vector2;
  60481. /**
  60482. * Define an offset for the layer in order to shift the texture.
  60483. */
  60484. offset: Vector2;
  60485. /**
  60486. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60487. */
  60488. alphaBlendingMode: number;
  60489. /**
  60490. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60491. * Alpha test will not mix with the background color in case of transparency.
  60492. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60493. */
  60494. alphaTest: boolean;
  60495. /**
  60496. * Define a mask to restrict the layer to only some of the scene cameras.
  60497. */
  60498. layerMask: number;
  60499. /**
  60500. * Define the list of render target the layer is visible into.
  60501. */
  60502. renderTargetTextures: RenderTargetTexture[];
  60503. /**
  60504. * Define if the layer is only used in renderTarget or if it also
  60505. * renders in the main frame buffer of the canvas.
  60506. */
  60507. renderOnlyInRenderTargetTextures: boolean;
  60508. private _scene;
  60509. private _vertexBuffers;
  60510. private _indexBuffer;
  60511. private _effect;
  60512. private _previousDefines;
  60513. /**
  60514. * An event triggered when the layer is disposed.
  60515. */
  60516. onDisposeObservable: Observable<Layer>;
  60517. private _onDisposeObserver;
  60518. /**
  60519. * Back compatibility with callback before the onDisposeObservable existed.
  60520. * The set callback will be triggered when the layer has been disposed.
  60521. */
  60522. set onDispose(callback: () => void);
  60523. /**
  60524. * An event triggered before rendering the scene
  60525. */
  60526. onBeforeRenderObservable: Observable<Layer>;
  60527. private _onBeforeRenderObserver;
  60528. /**
  60529. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60530. * The set callback will be triggered just before rendering the layer.
  60531. */
  60532. set onBeforeRender(callback: () => void);
  60533. /**
  60534. * An event triggered after rendering the scene
  60535. */
  60536. onAfterRenderObservable: Observable<Layer>;
  60537. private _onAfterRenderObserver;
  60538. /**
  60539. * Back compatibility with callback before the onAfterRenderObservable existed.
  60540. * The set callback will be triggered just after rendering the layer.
  60541. */
  60542. set onAfterRender(callback: () => void);
  60543. /**
  60544. * Instantiates a new layer.
  60545. * This represents a full screen 2d layer.
  60546. * This can be useful to display a picture in the background of your scene for instance.
  60547. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60548. * @param name Define the name of the layer in the scene
  60549. * @param imgUrl Define the url of the texture to display in the layer
  60550. * @param scene Define the scene the layer belongs to
  60551. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60552. * @param color Defines a color for the layer
  60553. */
  60554. constructor(
  60555. /**
  60556. * Define the name of the layer.
  60557. */
  60558. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60559. private _createIndexBuffer;
  60560. /** @hidden */
  60561. _rebuild(): void;
  60562. /**
  60563. * Renders the layer in the scene.
  60564. */
  60565. render(): void;
  60566. /**
  60567. * Disposes and releases the associated ressources.
  60568. */
  60569. dispose(): void;
  60570. }
  60571. }
  60572. declare module "babylonjs/Layers/index" {
  60573. export * from "babylonjs/Layers/effectLayer";
  60574. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60575. export * from "babylonjs/Layers/glowLayer";
  60576. export * from "babylonjs/Layers/highlightLayer";
  60577. export * from "babylonjs/Layers/layer";
  60578. export * from "babylonjs/Layers/layerSceneComponent";
  60579. }
  60580. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60581. /** @hidden */
  60582. export var lensFlarePixelShader: {
  60583. name: string;
  60584. shader: string;
  60585. };
  60586. }
  60587. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60588. /** @hidden */
  60589. export var lensFlareVertexShader: {
  60590. name: string;
  60591. shader: string;
  60592. };
  60593. }
  60594. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60595. import { Scene } from "babylonjs/scene";
  60596. import { Vector3 } from "babylonjs/Maths/math.vector";
  60597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60598. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60599. import "babylonjs/Shaders/lensFlare.fragment";
  60600. import "babylonjs/Shaders/lensFlare.vertex";
  60601. import { Viewport } from "babylonjs/Maths/math.viewport";
  60602. /**
  60603. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60604. * It is usually composed of several `lensFlare`.
  60605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60606. */
  60607. export class LensFlareSystem {
  60608. /**
  60609. * Define the name of the lens flare system
  60610. */
  60611. name: string;
  60612. /**
  60613. * List of lens flares used in this system.
  60614. */
  60615. lensFlares: LensFlare[];
  60616. /**
  60617. * Define a limit from the border the lens flare can be visible.
  60618. */
  60619. borderLimit: number;
  60620. /**
  60621. * Define a viewport border we do not want to see the lens flare in.
  60622. */
  60623. viewportBorder: number;
  60624. /**
  60625. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60626. */
  60627. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60628. /**
  60629. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60630. */
  60631. layerMask: number;
  60632. /**
  60633. * Define the id of the lens flare system in the scene.
  60634. * (equal to name by default)
  60635. */
  60636. id: string;
  60637. private _scene;
  60638. private _emitter;
  60639. private _vertexBuffers;
  60640. private _indexBuffer;
  60641. private _effect;
  60642. private _positionX;
  60643. private _positionY;
  60644. private _isEnabled;
  60645. /** @hidden */
  60646. static _SceneComponentInitialization: (scene: Scene) => void;
  60647. /**
  60648. * Instantiates a lens flare system.
  60649. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60650. * It is usually composed of several `lensFlare`.
  60651. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60652. * @param name Define the name of the lens flare system in the scene
  60653. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60654. * @param scene Define the scene the lens flare system belongs to
  60655. */
  60656. constructor(
  60657. /**
  60658. * Define the name of the lens flare system
  60659. */
  60660. name: string, emitter: any, scene: Scene);
  60661. /**
  60662. * Define if the lens flare system is enabled.
  60663. */
  60664. get isEnabled(): boolean;
  60665. set isEnabled(value: boolean);
  60666. /**
  60667. * Get the scene the effects belongs to.
  60668. * @returns the scene holding the lens flare system
  60669. */
  60670. getScene(): Scene;
  60671. /**
  60672. * Get the emitter of the lens flare system.
  60673. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60674. * @returns the emitter of the lens flare system
  60675. */
  60676. getEmitter(): any;
  60677. /**
  60678. * Set the emitter of the lens flare system.
  60679. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60680. * @param newEmitter Define the new emitter of the system
  60681. */
  60682. setEmitter(newEmitter: any): void;
  60683. /**
  60684. * Get the lens flare system emitter position.
  60685. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60686. * @returns the position
  60687. */
  60688. getEmitterPosition(): Vector3;
  60689. /**
  60690. * @hidden
  60691. */
  60692. computeEffectivePosition(globalViewport: Viewport): boolean;
  60693. /** @hidden */
  60694. _isVisible(): boolean;
  60695. /**
  60696. * @hidden
  60697. */
  60698. render(): boolean;
  60699. /**
  60700. * Dispose and release the lens flare with its associated resources.
  60701. */
  60702. dispose(): void;
  60703. /**
  60704. * Parse a lens flare system from a JSON repressentation
  60705. * @param parsedLensFlareSystem Define the JSON to parse
  60706. * @param scene Define the scene the parsed system should be instantiated in
  60707. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60708. * @returns the parsed system
  60709. */
  60710. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60711. /**
  60712. * Serialize the current Lens Flare System into a JSON representation.
  60713. * @returns the serialized JSON
  60714. */
  60715. serialize(): any;
  60716. }
  60717. }
  60718. declare module "babylonjs/LensFlares/lensFlare" {
  60719. import { Nullable } from "babylonjs/types";
  60720. import { Color3 } from "babylonjs/Maths/math.color";
  60721. import { Texture } from "babylonjs/Materials/Textures/texture";
  60722. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60723. /**
  60724. * This represents one of the lens effect in a `lensFlareSystem`.
  60725. * It controls one of the indiviual texture used in the effect.
  60726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60727. */
  60728. export class LensFlare {
  60729. /**
  60730. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60731. */
  60732. size: number;
  60733. /**
  60734. * 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.
  60735. */
  60736. position: number;
  60737. /**
  60738. * Define the lens color.
  60739. */
  60740. color: Color3;
  60741. /**
  60742. * Define the lens texture.
  60743. */
  60744. texture: Nullable<Texture>;
  60745. /**
  60746. * Define the alpha mode to render this particular lens.
  60747. */
  60748. alphaMode: number;
  60749. private _system;
  60750. /**
  60751. * Creates a new Lens Flare.
  60752. * This represents one of the lens effect in a `lensFlareSystem`.
  60753. * It controls one of the indiviual texture used in the effect.
  60754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60755. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60756. * @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.
  60757. * @param color Define the lens color
  60758. * @param imgUrl Define the lens texture url
  60759. * @param system Define the `lensFlareSystem` this flare is part of
  60760. * @returns The newly created Lens Flare
  60761. */
  60762. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60763. /**
  60764. * Instantiates a new Lens Flare.
  60765. * This represents one of the lens effect in a `lensFlareSystem`.
  60766. * It controls one of the indiviual texture used in the effect.
  60767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60768. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60769. * @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.
  60770. * @param color Define the lens color
  60771. * @param imgUrl Define the lens texture url
  60772. * @param system Define the `lensFlareSystem` this flare is part of
  60773. */
  60774. constructor(
  60775. /**
  60776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60777. */
  60778. size: number,
  60779. /**
  60780. * 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.
  60781. */
  60782. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60783. /**
  60784. * Dispose and release the lens flare with its associated resources.
  60785. */
  60786. dispose(): void;
  60787. }
  60788. }
  60789. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60790. import { Nullable } from "babylonjs/types";
  60791. import { Scene } from "babylonjs/scene";
  60792. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60793. import { AbstractScene } from "babylonjs/abstractScene";
  60794. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60795. module "babylonjs/abstractScene" {
  60796. interface AbstractScene {
  60797. /**
  60798. * The list of lens flare system added to the scene
  60799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60800. */
  60801. lensFlareSystems: Array<LensFlareSystem>;
  60802. /**
  60803. * Removes the given lens flare system from this scene.
  60804. * @param toRemove The lens flare system to remove
  60805. * @returns The index of the removed lens flare system
  60806. */
  60807. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60808. /**
  60809. * Adds the given lens flare system to this scene
  60810. * @param newLensFlareSystem The lens flare system to add
  60811. */
  60812. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60813. /**
  60814. * Gets a lens flare system using its name
  60815. * @param name defines the name to look for
  60816. * @returns the lens flare system or null if not found
  60817. */
  60818. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60819. /**
  60820. * Gets a lens flare system using its id
  60821. * @param id defines the id to look for
  60822. * @returns the lens flare system or null if not found
  60823. */
  60824. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60825. }
  60826. }
  60827. /**
  60828. * Defines the lens flare scene component responsible to manage any lens flares
  60829. * in a given scene.
  60830. */
  60831. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60832. /**
  60833. * The component name helpfull to identify the component in the list of scene components.
  60834. */
  60835. readonly name: string;
  60836. /**
  60837. * The scene the component belongs to.
  60838. */
  60839. scene: Scene;
  60840. /**
  60841. * Creates a new instance of the component for the given scene
  60842. * @param scene Defines the scene to register the component in
  60843. */
  60844. constructor(scene: Scene);
  60845. /**
  60846. * Registers the component in a given scene
  60847. */
  60848. register(): void;
  60849. /**
  60850. * Rebuilds the elements related to this component in case of
  60851. * context lost for instance.
  60852. */
  60853. rebuild(): void;
  60854. /**
  60855. * Adds all the elements from the container to the scene
  60856. * @param container the container holding the elements
  60857. */
  60858. addFromContainer(container: AbstractScene): void;
  60859. /**
  60860. * Removes all the elements in the container from the scene
  60861. * @param container contains the elements to remove
  60862. * @param dispose if the removed element should be disposed (default: false)
  60863. */
  60864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60865. /**
  60866. * Serializes the component data to the specified json object
  60867. * @param serializationObject The object to serialize to
  60868. */
  60869. serialize(serializationObject: any): void;
  60870. /**
  60871. * Disposes the component and the associated ressources.
  60872. */
  60873. dispose(): void;
  60874. private _draw;
  60875. }
  60876. }
  60877. declare module "babylonjs/LensFlares/index" {
  60878. export * from "babylonjs/LensFlares/lensFlare";
  60879. export * from "babylonjs/LensFlares/lensFlareSystem";
  60880. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60881. }
  60882. declare module "babylonjs/Shaders/depth.fragment" {
  60883. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60884. /** @hidden */
  60885. export var depthPixelShader: {
  60886. name: string;
  60887. shader: string;
  60888. };
  60889. }
  60890. declare module "babylonjs/Shaders/depth.vertex" {
  60891. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60892. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60894. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60896. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60897. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60898. /** @hidden */
  60899. export var depthVertexShader: {
  60900. name: string;
  60901. shader: string;
  60902. };
  60903. }
  60904. declare module "babylonjs/Rendering/depthRenderer" {
  60905. import { Nullable } from "babylonjs/types";
  60906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60907. import { Scene } from "babylonjs/scene";
  60908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60909. import { Camera } from "babylonjs/Cameras/camera";
  60910. import "babylonjs/Shaders/depth.fragment";
  60911. import "babylonjs/Shaders/depth.vertex";
  60912. /**
  60913. * This represents a depth renderer in Babylon.
  60914. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60915. */
  60916. export class DepthRenderer {
  60917. private _scene;
  60918. private _depthMap;
  60919. private _effect;
  60920. private readonly _storeNonLinearDepth;
  60921. private readonly _clearColor;
  60922. /** Get if the depth renderer is using packed depth or not */
  60923. readonly isPacked: boolean;
  60924. private _cachedDefines;
  60925. private _camera;
  60926. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60927. enabled: boolean;
  60928. /**
  60929. * Specifiess that the depth renderer will only be used within
  60930. * the camera it is created for.
  60931. * This can help forcing its rendering during the camera processing.
  60932. */
  60933. useOnlyInActiveCamera: boolean;
  60934. /** @hidden */
  60935. static _SceneComponentInitialization: (scene: Scene) => void;
  60936. /**
  60937. * Instantiates a depth renderer
  60938. * @param scene The scene the renderer belongs to
  60939. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60940. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60941. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60942. */
  60943. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60944. /**
  60945. * Creates the depth rendering effect and checks if the effect is ready.
  60946. * @param subMesh The submesh to be used to render the depth map of
  60947. * @param useInstances If multiple world instances should be used
  60948. * @returns if the depth renderer is ready to render the depth map
  60949. */
  60950. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60951. /**
  60952. * Gets the texture which the depth map will be written to.
  60953. * @returns The depth map texture
  60954. */
  60955. getDepthMap(): RenderTargetTexture;
  60956. /**
  60957. * Disposes of the depth renderer.
  60958. */
  60959. dispose(): void;
  60960. }
  60961. }
  60962. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60963. /** @hidden */
  60964. export var minmaxReduxPixelShader: {
  60965. name: string;
  60966. shader: string;
  60967. };
  60968. }
  60969. declare module "babylonjs/Misc/minMaxReducer" {
  60970. import { Nullable } from "babylonjs/types";
  60971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60972. import { Camera } from "babylonjs/Cameras/camera";
  60973. import { Observer } from "babylonjs/Misc/observable";
  60974. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60975. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60976. import { Observable } from "babylonjs/Misc/observable";
  60977. import "babylonjs/Shaders/minmaxRedux.fragment";
  60978. /**
  60979. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60980. * and maximum values from all values of the texture.
  60981. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60982. * The source values are read from the red channel of the texture.
  60983. */
  60984. export class MinMaxReducer {
  60985. /**
  60986. * Observable triggered when the computation has been performed
  60987. */
  60988. onAfterReductionPerformed: Observable<{
  60989. min: number;
  60990. max: number;
  60991. }>;
  60992. protected _camera: Camera;
  60993. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60994. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60995. protected _postProcessManager: PostProcessManager;
  60996. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60997. protected _forceFullscreenViewport: boolean;
  60998. /**
  60999. * Creates a min/max reducer
  61000. * @param camera The camera to use for the post processes
  61001. */
  61002. constructor(camera: Camera);
  61003. /**
  61004. * Gets the texture used to read the values from.
  61005. */
  61006. get sourceTexture(): Nullable<RenderTargetTexture>;
  61007. /**
  61008. * Sets the source texture to read the values from.
  61009. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61010. * because in such textures '1' value must not be taken into account to compute the maximum
  61011. * as this value is used to clear the texture.
  61012. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61013. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61014. * @param depthRedux Indicates if the texture is a depth texture or not
  61015. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61016. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61017. */
  61018. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61019. /**
  61020. * Defines the refresh rate of the computation.
  61021. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61022. */
  61023. get refreshRate(): number;
  61024. set refreshRate(value: number);
  61025. protected _activated: boolean;
  61026. /**
  61027. * Gets the activation status of the reducer
  61028. */
  61029. get activated(): boolean;
  61030. /**
  61031. * Activates the reduction computation.
  61032. * When activated, the observers registered in onAfterReductionPerformed are
  61033. * called after the compuation is performed
  61034. */
  61035. activate(): void;
  61036. /**
  61037. * Deactivates the reduction computation.
  61038. */
  61039. deactivate(): void;
  61040. /**
  61041. * Disposes the min/max reducer
  61042. * @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.
  61043. */
  61044. dispose(disposeAll?: boolean): void;
  61045. }
  61046. }
  61047. declare module "babylonjs/Misc/depthReducer" {
  61048. import { Nullable } from "babylonjs/types";
  61049. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61050. import { Camera } from "babylonjs/Cameras/camera";
  61051. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61052. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61053. /**
  61054. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61055. */
  61056. export class DepthReducer extends MinMaxReducer {
  61057. private _depthRenderer;
  61058. private _depthRendererId;
  61059. /**
  61060. * Gets the depth renderer used for the computation.
  61061. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61062. */
  61063. get depthRenderer(): Nullable<DepthRenderer>;
  61064. /**
  61065. * Creates a depth reducer
  61066. * @param camera The camera used to render the depth texture
  61067. */
  61068. constructor(camera: Camera);
  61069. /**
  61070. * Sets the depth renderer to use to generate the depth map
  61071. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61072. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61073. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61074. */
  61075. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61076. /** @hidden */
  61077. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61078. /**
  61079. * Activates the reduction computation.
  61080. * When activated, the observers registered in onAfterReductionPerformed are
  61081. * called after the compuation is performed
  61082. */
  61083. activate(): void;
  61084. /**
  61085. * Deactivates the reduction computation.
  61086. */
  61087. deactivate(): void;
  61088. /**
  61089. * Disposes the depth reducer
  61090. * @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.
  61091. */
  61092. dispose(disposeAll?: boolean): void;
  61093. }
  61094. }
  61095. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61096. import { Nullable } from "babylonjs/types";
  61097. import { Scene } from "babylonjs/scene";
  61098. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61101. import { Effect } from "babylonjs/Materials/effect";
  61102. import "babylonjs/Shaders/shadowMap.fragment";
  61103. import "babylonjs/Shaders/shadowMap.vertex";
  61104. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61105. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61106. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61107. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61108. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61109. /**
  61110. * A CSM implementation allowing casting shadows on large scenes.
  61111. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61112. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61113. */
  61114. export class CascadedShadowGenerator extends ShadowGenerator {
  61115. private static readonly frustumCornersNDCSpace;
  61116. /**
  61117. * Name of the CSM class
  61118. */
  61119. static CLASSNAME: string;
  61120. /**
  61121. * Defines the default number of cascades used by the CSM.
  61122. */
  61123. static readonly DEFAULT_CASCADES_COUNT: number;
  61124. /**
  61125. * Defines the minimum number of cascades used by the CSM.
  61126. */
  61127. static readonly MIN_CASCADES_COUNT: number;
  61128. /**
  61129. * Defines the maximum number of cascades used by the CSM.
  61130. */
  61131. static readonly MAX_CASCADES_COUNT: number;
  61132. protected _validateFilter(filter: number): number;
  61133. /**
  61134. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61135. */
  61136. penumbraDarkness: number;
  61137. private _numCascades;
  61138. /**
  61139. * Gets or set the number of cascades used by the CSM.
  61140. */
  61141. get numCascades(): number;
  61142. set numCascades(value: number);
  61143. /**
  61144. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61145. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61146. */
  61147. stabilizeCascades: boolean;
  61148. private _freezeShadowCastersBoundingInfo;
  61149. private _freezeShadowCastersBoundingInfoObservable;
  61150. /**
  61151. * Enables or disables the shadow casters bounding info computation.
  61152. * If your shadow casters don't move, you can disable this feature.
  61153. * If it is enabled, the bounding box computation is done every frame.
  61154. */
  61155. get freezeShadowCastersBoundingInfo(): boolean;
  61156. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61157. private _scbiMin;
  61158. private _scbiMax;
  61159. protected _computeShadowCastersBoundingInfo(): void;
  61160. protected _shadowCastersBoundingInfo: BoundingInfo;
  61161. /**
  61162. * Gets or sets the shadow casters bounding info.
  61163. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61164. * so that the system won't overwrite the bounds you provide
  61165. */
  61166. get shadowCastersBoundingInfo(): BoundingInfo;
  61167. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61168. protected _breaksAreDirty: boolean;
  61169. protected _minDistance: number;
  61170. protected _maxDistance: number;
  61171. /**
  61172. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61173. *
  61174. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61175. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61176. * @param min minimal distance for the breaks (default to 0.)
  61177. * @param max maximal distance for the breaks (default to 1.)
  61178. */
  61179. setMinMaxDistance(min: number, max: number): void;
  61180. /** Gets the minimal distance used in the cascade break computation */
  61181. get minDistance(): number;
  61182. /** Gets the maximal distance used in the cascade break computation */
  61183. get maxDistance(): number;
  61184. /**
  61185. * Gets the class name of that object
  61186. * @returns "CascadedShadowGenerator"
  61187. */
  61188. getClassName(): string;
  61189. private _cascadeMinExtents;
  61190. private _cascadeMaxExtents;
  61191. /**
  61192. * Gets a cascade minimum extents
  61193. * @param cascadeIndex index of the cascade
  61194. * @returns the minimum cascade extents
  61195. */
  61196. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61197. /**
  61198. * Gets a cascade maximum extents
  61199. * @param cascadeIndex index of the cascade
  61200. * @returns the maximum cascade extents
  61201. */
  61202. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61203. private _cascades;
  61204. private _currentLayer;
  61205. private _viewSpaceFrustumsZ;
  61206. private _viewMatrices;
  61207. private _projectionMatrices;
  61208. private _transformMatrices;
  61209. private _transformMatricesAsArray;
  61210. private _frustumLengths;
  61211. private _lightSizeUVCorrection;
  61212. private _depthCorrection;
  61213. private _frustumCornersWorldSpace;
  61214. private _frustumCenter;
  61215. private _shadowCameraPos;
  61216. private _shadowMaxZ;
  61217. /**
  61218. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61219. * It defaults to camera.maxZ
  61220. */
  61221. get shadowMaxZ(): number;
  61222. /**
  61223. * Sets the shadow max z distance.
  61224. */
  61225. set shadowMaxZ(value: number);
  61226. protected _debug: boolean;
  61227. /**
  61228. * Gets or sets the debug flag.
  61229. * When enabled, the cascades are materialized by different colors on the screen.
  61230. */
  61231. get debug(): boolean;
  61232. set debug(dbg: boolean);
  61233. private _depthClamp;
  61234. /**
  61235. * Gets or sets the depth clamping value.
  61236. *
  61237. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61238. * to account for the shadow casters far away.
  61239. *
  61240. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61241. */
  61242. get depthClamp(): boolean;
  61243. set depthClamp(value: boolean);
  61244. private _cascadeBlendPercentage;
  61245. /**
  61246. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61247. * It defaults to 0.1 (10% blending).
  61248. */
  61249. get cascadeBlendPercentage(): number;
  61250. set cascadeBlendPercentage(value: number);
  61251. private _lambda;
  61252. /**
  61253. * Gets or set the lambda parameter.
  61254. * This parameter is used to split the camera frustum and create the cascades.
  61255. * 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.
  61256. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61257. */
  61258. get lambda(): number;
  61259. set lambda(value: number);
  61260. /**
  61261. * Gets the view matrix corresponding to a given cascade
  61262. * @param cascadeNum cascade to retrieve the view matrix from
  61263. * @returns the cascade view matrix
  61264. */
  61265. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61266. /**
  61267. * Gets the projection matrix corresponding to a given cascade
  61268. * @param cascadeNum cascade to retrieve the projection matrix from
  61269. * @returns the cascade projection matrix
  61270. */
  61271. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61272. /**
  61273. * Gets the transformation matrix corresponding to a given cascade
  61274. * @param cascadeNum cascade to retrieve the transformation matrix from
  61275. * @returns the cascade transformation matrix
  61276. */
  61277. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61278. private _depthRenderer;
  61279. /**
  61280. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61281. *
  61282. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61283. *
  61284. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61285. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61286. * @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
  61287. */
  61288. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61289. private _depthReducer;
  61290. private _autoCalcDepthBounds;
  61291. /**
  61292. * Gets or sets the autoCalcDepthBounds property.
  61293. *
  61294. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61295. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61296. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61297. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61298. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61299. */
  61300. get autoCalcDepthBounds(): boolean;
  61301. set autoCalcDepthBounds(value: boolean);
  61302. /**
  61303. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61304. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61305. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61306. * for setting the refresh rate on the renderer yourself!
  61307. */
  61308. get autoCalcDepthBoundsRefreshRate(): number;
  61309. set autoCalcDepthBoundsRefreshRate(value: number);
  61310. /**
  61311. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61312. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61313. * you change the camera near/far planes!
  61314. */
  61315. splitFrustum(): void;
  61316. private _splitFrustum;
  61317. private _computeMatrices;
  61318. private _computeFrustumInWorldSpace;
  61319. private _computeCascadeFrustum;
  61320. /**
  61321. * Support test.
  61322. */
  61323. static get IsSupported(): boolean;
  61324. /** @hidden */
  61325. static _SceneComponentInitialization: (scene: Scene) => void;
  61326. /**
  61327. * Creates a Cascaded Shadow Generator object.
  61328. * A ShadowGenerator is the required tool to use the shadows.
  61329. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61330. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61331. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61332. * @param light The directional light object generating the shadows.
  61333. * @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.
  61334. */
  61335. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61336. protected _initializeGenerator(): void;
  61337. protected _createTargetRenderTexture(): void;
  61338. protected _initializeShadowMap(): void;
  61339. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61340. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61341. /**
  61342. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61343. * @param defines Defines of the material we want to update
  61344. * @param lightIndex Index of the light in the enabled light list of the material
  61345. */
  61346. prepareDefines(defines: any, lightIndex: number): void;
  61347. /**
  61348. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61349. * defined in the generator but impacting the effect).
  61350. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61351. * @param effect The effect we are binfing the information for
  61352. */
  61353. bindShadowLight(lightIndex: string, effect: Effect): void;
  61354. /**
  61355. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61356. * (eq to view projection * shadow projection matrices)
  61357. * @returns The transform matrix used to create the shadow map
  61358. */
  61359. getTransformMatrix(): Matrix;
  61360. /**
  61361. * Disposes the ShadowGenerator.
  61362. * Returns nothing.
  61363. */
  61364. dispose(): void;
  61365. /**
  61366. * Serializes the shadow generator setup to a json object.
  61367. * @returns The serialized JSON object
  61368. */
  61369. serialize(): any;
  61370. /**
  61371. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61372. * @param parsedShadowGenerator The JSON object to parse
  61373. * @param scene The scene to create the shadow map for
  61374. * @returns The parsed shadow generator
  61375. */
  61376. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61377. }
  61378. }
  61379. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61380. import { Scene } from "babylonjs/scene";
  61381. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61382. import { AbstractScene } from "babylonjs/abstractScene";
  61383. /**
  61384. * Defines the shadow generator component responsible to manage any shadow generators
  61385. * in a given scene.
  61386. */
  61387. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61388. /**
  61389. * The component name helpfull to identify the component in the list of scene components.
  61390. */
  61391. readonly name: string;
  61392. /**
  61393. * The scene the component belongs to.
  61394. */
  61395. scene: Scene;
  61396. /**
  61397. * Creates a new instance of the component for the given scene
  61398. * @param scene Defines the scene to register the component in
  61399. */
  61400. constructor(scene: Scene);
  61401. /**
  61402. * Registers the component in a given scene
  61403. */
  61404. register(): void;
  61405. /**
  61406. * Rebuilds the elements related to this component in case of
  61407. * context lost for instance.
  61408. */
  61409. rebuild(): void;
  61410. /**
  61411. * Serializes the component data to the specified json object
  61412. * @param serializationObject The object to serialize to
  61413. */
  61414. serialize(serializationObject: any): void;
  61415. /**
  61416. * Adds all the elements from the container to the scene
  61417. * @param container the container holding the elements
  61418. */
  61419. addFromContainer(container: AbstractScene): void;
  61420. /**
  61421. * Removes all the elements in the container from the scene
  61422. * @param container contains the elements to remove
  61423. * @param dispose if the removed element should be disposed (default: false)
  61424. */
  61425. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61426. /**
  61427. * Rebuilds the elements related to this component in case of
  61428. * context lost for instance.
  61429. */
  61430. dispose(): void;
  61431. private _gatherRenderTargets;
  61432. }
  61433. }
  61434. declare module "babylonjs/Lights/Shadows/index" {
  61435. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61436. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61437. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61438. }
  61439. declare module "babylonjs/Lights/pointLight" {
  61440. import { Scene } from "babylonjs/scene";
  61441. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61443. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61444. import { Effect } from "babylonjs/Materials/effect";
  61445. /**
  61446. * A point light is a light defined by an unique point in world space.
  61447. * The light is emitted in every direction from this point.
  61448. * A good example of a point light is a standard light bulb.
  61449. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61450. */
  61451. export class PointLight extends ShadowLight {
  61452. private _shadowAngle;
  61453. /**
  61454. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61455. * This specifies what angle the shadow will use to be created.
  61456. *
  61457. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61458. */
  61459. get shadowAngle(): number;
  61460. /**
  61461. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61462. * This specifies what angle the shadow will use to be created.
  61463. *
  61464. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61465. */
  61466. set shadowAngle(value: number);
  61467. /**
  61468. * Gets the direction if it has been set.
  61469. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61470. */
  61471. get direction(): Vector3;
  61472. /**
  61473. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61474. */
  61475. set direction(value: Vector3);
  61476. /**
  61477. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61478. * A PointLight emits the light in every direction.
  61479. * It can cast shadows.
  61480. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61481. * ```javascript
  61482. * var pointLight = new PointLight("pl", camera.position, scene);
  61483. * ```
  61484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61485. * @param name The light friendly name
  61486. * @param position The position of the point light in the scene
  61487. * @param scene The scene the lights belongs to
  61488. */
  61489. constructor(name: string, position: Vector3, scene: Scene);
  61490. /**
  61491. * Returns the string "PointLight"
  61492. * @returns the class name
  61493. */
  61494. getClassName(): string;
  61495. /**
  61496. * Returns the integer 0.
  61497. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61498. */
  61499. getTypeID(): number;
  61500. /**
  61501. * Specifies wether or not the shadowmap should be a cube texture.
  61502. * @returns true if the shadowmap needs to be a cube texture.
  61503. */
  61504. needCube(): boolean;
  61505. /**
  61506. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61507. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61508. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61509. */
  61510. getShadowDirection(faceIndex?: number): Vector3;
  61511. /**
  61512. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61513. * - fov = PI / 2
  61514. * - aspect ratio : 1.0
  61515. * - z-near and far equal to the active camera minZ and maxZ.
  61516. * Returns the PointLight.
  61517. */
  61518. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61519. protected _buildUniformLayout(): void;
  61520. /**
  61521. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61522. * @param effect The effect to update
  61523. * @param lightIndex The index of the light in the effect to update
  61524. * @returns The point light
  61525. */
  61526. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61527. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61528. /**
  61529. * Prepares the list of defines specific to the light type.
  61530. * @param defines the list of defines
  61531. * @param lightIndex defines the index of the light for the effect
  61532. */
  61533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61534. }
  61535. }
  61536. declare module "babylonjs/Lights/index" {
  61537. export * from "babylonjs/Lights/light";
  61538. export * from "babylonjs/Lights/shadowLight";
  61539. export * from "babylonjs/Lights/Shadows/index";
  61540. export * from "babylonjs/Lights/directionalLight";
  61541. export * from "babylonjs/Lights/hemisphericLight";
  61542. export * from "babylonjs/Lights/pointLight";
  61543. export * from "babylonjs/Lights/spotLight";
  61544. }
  61545. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61546. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61547. /**
  61548. * Header information of HDR texture files.
  61549. */
  61550. export interface HDRInfo {
  61551. /**
  61552. * The height of the texture in pixels.
  61553. */
  61554. height: number;
  61555. /**
  61556. * The width of the texture in pixels.
  61557. */
  61558. width: number;
  61559. /**
  61560. * The index of the beginning of the data in the binary file.
  61561. */
  61562. dataPosition: number;
  61563. }
  61564. /**
  61565. * This groups tools to convert HDR texture to native colors array.
  61566. */
  61567. export class HDRTools {
  61568. private static Ldexp;
  61569. private static Rgbe2float;
  61570. private static readStringLine;
  61571. /**
  61572. * Reads header information from an RGBE texture stored in a native array.
  61573. * More information on this format are available here:
  61574. * https://en.wikipedia.org/wiki/RGBE_image_format
  61575. *
  61576. * @param uint8array The binary file stored in native array.
  61577. * @return The header information.
  61578. */
  61579. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61580. /**
  61581. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61582. * This RGBE texture needs to store the information as a panorama.
  61583. *
  61584. * More information on this format are available here:
  61585. * https://en.wikipedia.org/wiki/RGBE_image_format
  61586. *
  61587. * @param buffer The binary file stored in an array buffer.
  61588. * @param size The expected size of the extracted cubemap.
  61589. * @return The Cube Map information.
  61590. */
  61591. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61592. /**
  61593. * Returns the pixels data extracted from an RGBE texture.
  61594. * This pixels will be stored left to right up to down in the R G B order in one array.
  61595. *
  61596. * More information on this format are available here:
  61597. * https://en.wikipedia.org/wiki/RGBE_image_format
  61598. *
  61599. * @param uint8array The binary file stored in an array buffer.
  61600. * @param hdrInfo The header information of the file.
  61601. * @return The pixels data in RGB right to left up to down order.
  61602. */
  61603. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61604. private static RGBE_ReadPixels_RLE;
  61605. }
  61606. }
  61607. declare module "babylonjs/Materials/effectRenderer" {
  61608. import { Nullable } from "babylonjs/types";
  61609. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61610. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61611. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61612. import { Viewport } from "babylonjs/Maths/math.viewport";
  61613. import { Observable } from "babylonjs/Misc/observable";
  61614. import { Effect } from "babylonjs/Materials/effect";
  61615. import "babylonjs/Shaders/postprocess.vertex";
  61616. /**
  61617. * Effect Render Options
  61618. */
  61619. export interface IEffectRendererOptions {
  61620. /**
  61621. * Defines the vertices positions.
  61622. */
  61623. positions?: number[];
  61624. /**
  61625. * Defines the indices.
  61626. */
  61627. indices?: number[];
  61628. }
  61629. /**
  61630. * Helper class to render one or more effects.
  61631. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61632. */
  61633. export class EffectRenderer {
  61634. private engine;
  61635. private static _DefaultOptions;
  61636. private _vertexBuffers;
  61637. private _indexBuffer;
  61638. private _fullscreenViewport;
  61639. /**
  61640. * Creates an effect renderer
  61641. * @param engine the engine to use for rendering
  61642. * @param options defines the options of the effect renderer
  61643. */
  61644. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61645. /**
  61646. * Sets the current viewport in normalized coordinates 0-1
  61647. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61648. */
  61649. setViewport(viewport?: Viewport): void;
  61650. /**
  61651. * Binds the embedded attributes buffer to the effect.
  61652. * @param effect Defines the effect to bind the attributes for
  61653. */
  61654. bindBuffers(effect: Effect): void;
  61655. /**
  61656. * Sets the current effect wrapper to use during draw.
  61657. * The effect needs to be ready before calling this api.
  61658. * This also sets the default full screen position attribute.
  61659. * @param effectWrapper Defines the effect to draw with
  61660. */
  61661. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61662. /**
  61663. * Restores engine states
  61664. */
  61665. restoreStates(): void;
  61666. /**
  61667. * Draws a full screen quad.
  61668. */
  61669. draw(): void;
  61670. private isRenderTargetTexture;
  61671. /**
  61672. * renders one or more effects to a specified texture
  61673. * @param effectWrapper the effect to renderer
  61674. * @param outputTexture texture to draw to, if null it will render to the screen.
  61675. */
  61676. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61677. /**
  61678. * Disposes of the effect renderer
  61679. */
  61680. dispose(): void;
  61681. }
  61682. /**
  61683. * Options to create an EffectWrapper
  61684. */
  61685. interface EffectWrapperCreationOptions {
  61686. /**
  61687. * Engine to use to create the effect
  61688. */
  61689. engine: ThinEngine;
  61690. /**
  61691. * Fragment shader for the effect
  61692. */
  61693. fragmentShader: string;
  61694. /**
  61695. * Use the shader store instead of direct source code
  61696. */
  61697. useShaderStore?: boolean;
  61698. /**
  61699. * Vertex shader for the effect
  61700. */
  61701. vertexShader?: string;
  61702. /**
  61703. * Attributes to use in the shader
  61704. */
  61705. attributeNames?: Array<string>;
  61706. /**
  61707. * Uniforms to use in the shader
  61708. */
  61709. uniformNames?: Array<string>;
  61710. /**
  61711. * Texture sampler names to use in the shader
  61712. */
  61713. samplerNames?: Array<string>;
  61714. /**
  61715. * Defines to use in the shader
  61716. */
  61717. defines?: Array<string>;
  61718. /**
  61719. * Callback when effect is compiled
  61720. */
  61721. onCompiled?: Nullable<(effect: Effect) => void>;
  61722. /**
  61723. * The friendly name of the effect displayed in Spector.
  61724. */
  61725. name?: string;
  61726. }
  61727. /**
  61728. * Wraps an effect to be used for rendering
  61729. */
  61730. export class EffectWrapper {
  61731. /**
  61732. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61733. */
  61734. onApplyObservable: Observable<{}>;
  61735. /**
  61736. * The underlying effect
  61737. */
  61738. effect: Effect;
  61739. /**
  61740. * Creates an effect to be renderer
  61741. * @param creationOptions options to create the effect
  61742. */
  61743. constructor(creationOptions: EffectWrapperCreationOptions);
  61744. /**
  61745. * Disposes of the effect wrapper
  61746. */
  61747. dispose(): void;
  61748. }
  61749. }
  61750. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61751. /** @hidden */
  61752. export var hdrFilteringVertexShader: {
  61753. name: string;
  61754. shader: string;
  61755. };
  61756. }
  61757. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61759. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61760. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61761. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61762. /** @hidden */
  61763. export var hdrFilteringPixelShader: {
  61764. name: string;
  61765. shader: string;
  61766. };
  61767. }
  61768. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61770. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61771. import { Nullable } from "babylonjs/types";
  61772. import "babylonjs/Shaders/hdrFiltering.vertex";
  61773. import "babylonjs/Shaders/hdrFiltering.fragment";
  61774. /**
  61775. * Options for texture filtering
  61776. */
  61777. interface IHDRFilteringOptions {
  61778. /**
  61779. * Scales pixel intensity for the input HDR map.
  61780. */
  61781. hdrScale?: number;
  61782. /**
  61783. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61784. */
  61785. quality?: number;
  61786. }
  61787. /**
  61788. * Filters HDR maps to get correct renderings of PBR reflections
  61789. */
  61790. export class HDRFiltering {
  61791. private _engine;
  61792. private _effectRenderer;
  61793. private _effectWrapper;
  61794. private _lodGenerationOffset;
  61795. private _lodGenerationScale;
  61796. /**
  61797. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61798. * you care about baking speed.
  61799. */
  61800. quality: number;
  61801. /**
  61802. * Scales pixel intensity for the input HDR map.
  61803. */
  61804. hdrScale: number;
  61805. /**
  61806. * Instantiates HDR filter for reflection maps
  61807. *
  61808. * @param engine Thin engine
  61809. * @param options Options
  61810. */
  61811. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61812. private _createRenderTarget;
  61813. private _prefilterInternal;
  61814. private _createEffect;
  61815. /**
  61816. * Get a value indicating if the filter is ready to be used
  61817. * @param texture Texture to filter
  61818. * @returns true if the filter is ready
  61819. */
  61820. isReady(texture: BaseTexture): boolean;
  61821. /**
  61822. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61823. * Prefiltering will be invoked at the end of next rendering pass.
  61824. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61825. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61826. * @param texture Texture to filter
  61827. * @param onFinished Callback when filtering is done
  61828. * @return Promise called when prefiltering is done
  61829. */
  61830. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61831. }
  61832. }
  61833. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61834. import { Nullable } from "babylonjs/types";
  61835. import { Scene } from "babylonjs/scene";
  61836. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61838. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61839. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61840. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61841. /**
  61842. * This represents a texture coming from an HDR input.
  61843. *
  61844. * The only supported format is currently panorama picture stored in RGBE format.
  61845. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61846. */
  61847. export class HDRCubeTexture extends BaseTexture {
  61848. private static _facesMapping;
  61849. private _generateHarmonics;
  61850. private _noMipmap;
  61851. private _prefilterOnLoad;
  61852. private _textureMatrix;
  61853. private _size;
  61854. private _onLoad;
  61855. private _onError;
  61856. /**
  61857. * The texture URL.
  61858. */
  61859. url: string;
  61860. /**
  61861. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61862. */
  61863. coordinatesMode: number;
  61864. protected _isBlocking: boolean;
  61865. /**
  61866. * Sets wether or not the texture is blocking during loading.
  61867. */
  61868. set isBlocking(value: boolean);
  61869. /**
  61870. * Gets wether or not the texture is blocking during loading.
  61871. */
  61872. get isBlocking(): boolean;
  61873. protected _rotationY: number;
  61874. /**
  61875. * Sets texture matrix rotation angle around Y axis in radians.
  61876. */
  61877. set rotationY(value: number);
  61878. /**
  61879. * Gets texture matrix rotation angle around Y axis radians.
  61880. */
  61881. get rotationY(): number;
  61882. /**
  61883. * Gets or sets the center of the bounding box associated with the cube texture
  61884. * It must define where the camera used to render the texture was set
  61885. */
  61886. boundingBoxPosition: Vector3;
  61887. private _boundingBoxSize;
  61888. /**
  61889. * Gets or sets the size of the bounding box associated with the cube texture
  61890. * When defined, the cubemap will switch to local mode
  61891. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61892. * @example https://www.babylonjs-playground.com/#RNASML
  61893. */
  61894. set boundingBoxSize(value: Vector3);
  61895. get boundingBoxSize(): Vector3;
  61896. /**
  61897. * Instantiates an HDRTexture from the following parameters.
  61898. *
  61899. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61900. * @param sceneOrEngine The scene or engine the texture will be used in
  61901. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61902. * @param noMipmap Forces to not generate the mipmap if true
  61903. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61904. * @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)
  61905. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61906. */
  61907. 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>);
  61908. /**
  61909. * Get the current class name of the texture useful for serialization or dynamic coding.
  61910. * @returns "HDRCubeTexture"
  61911. */
  61912. getClassName(): string;
  61913. /**
  61914. * Occurs when the file is raw .hdr file.
  61915. */
  61916. private loadTexture;
  61917. clone(): HDRCubeTexture;
  61918. delayLoad(): void;
  61919. /**
  61920. * Get the texture reflection matrix used to rotate/transform the reflection.
  61921. * @returns the reflection matrix
  61922. */
  61923. getReflectionTextureMatrix(): Matrix;
  61924. /**
  61925. * Set the texture reflection matrix used to rotate/transform the reflection.
  61926. * @param value Define the reflection matrix to set
  61927. */
  61928. setReflectionTextureMatrix(value: Matrix): void;
  61929. /**
  61930. * Parses a JSON representation of an HDR Texture in order to create the texture
  61931. * @param parsedTexture Define the JSON representation
  61932. * @param scene Define the scene the texture should be created in
  61933. * @param rootUrl Define the root url in case we need to load relative dependencies
  61934. * @returns the newly created texture after parsing
  61935. */
  61936. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61937. serialize(): any;
  61938. }
  61939. }
  61940. declare module "babylonjs/Physics/physicsEngine" {
  61941. import { Nullable } from "babylonjs/types";
  61942. import { Vector3 } from "babylonjs/Maths/math.vector";
  61943. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61944. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61945. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61946. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61947. /**
  61948. * Class used to control physics engine
  61949. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61950. */
  61951. export class PhysicsEngine implements IPhysicsEngine {
  61952. private _physicsPlugin;
  61953. /**
  61954. * Global value used to control the smallest number supported by the simulation
  61955. */
  61956. static Epsilon: number;
  61957. private _impostors;
  61958. private _joints;
  61959. private _subTimeStep;
  61960. /**
  61961. * Gets the gravity vector used by the simulation
  61962. */
  61963. gravity: Vector3;
  61964. /**
  61965. * Factory used to create the default physics plugin.
  61966. * @returns The default physics plugin
  61967. */
  61968. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61969. /**
  61970. * Creates a new Physics Engine
  61971. * @param gravity defines the gravity vector used by the simulation
  61972. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61973. */
  61974. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61975. /**
  61976. * Sets the gravity vector used by the simulation
  61977. * @param gravity defines the gravity vector to use
  61978. */
  61979. setGravity(gravity: Vector3): void;
  61980. /**
  61981. * Set the time step of the physics engine.
  61982. * Default is 1/60.
  61983. * To slow it down, enter 1/600 for example.
  61984. * To speed it up, 1/30
  61985. * @param newTimeStep defines the new timestep to apply to this world.
  61986. */
  61987. setTimeStep(newTimeStep?: number): void;
  61988. /**
  61989. * Get the time step of the physics engine.
  61990. * @returns the current time step
  61991. */
  61992. getTimeStep(): number;
  61993. /**
  61994. * Set the sub time step of the physics engine.
  61995. * Default is 0 meaning there is no sub steps
  61996. * To increase physics resolution precision, set a small value (like 1 ms)
  61997. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61998. */
  61999. setSubTimeStep(subTimeStep?: number): void;
  62000. /**
  62001. * Get the sub time step of the physics engine.
  62002. * @returns the current sub time step
  62003. */
  62004. getSubTimeStep(): number;
  62005. /**
  62006. * Release all resources
  62007. */
  62008. dispose(): void;
  62009. /**
  62010. * Gets the name of the current physics plugin
  62011. * @returns the name of the plugin
  62012. */
  62013. getPhysicsPluginName(): string;
  62014. /**
  62015. * Adding a new impostor for the impostor tracking.
  62016. * This will be done by the impostor itself.
  62017. * @param impostor the impostor to add
  62018. */
  62019. addImpostor(impostor: PhysicsImpostor): void;
  62020. /**
  62021. * Remove an impostor from the engine.
  62022. * This impostor and its mesh will not longer be updated by the physics engine.
  62023. * @param impostor the impostor to remove
  62024. */
  62025. removeImpostor(impostor: PhysicsImpostor): void;
  62026. /**
  62027. * Add a joint to the physics engine
  62028. * @param mainImpostor defines the main impostor to which the joint is added.
  62029. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62030. * @param joint defines the joint that will connect both impostors.
  62031. */
  62032. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62033. /**
  62034. * Removes a joint from the simulation
  62035. * @param mainImpostor defines the impostor used with the joint
  62036. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62037. * @param joint defines the joint to remove
  62038. */
  62039. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62040. /**
  62041. * Called by the scene. No need to call it.
  62042. * @param delta defines the timespam between frames
  62043. */
  62044. _step(delta: number): void;
  62045. /**
  62046. * Gets the current plugin used to run the simulation
  62047. * @returns current plugin
  62048. */
  62049. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62050. /**
  62051. * Gets the list of physic impostors
  62052. * @returns an array of PhysicsImpostor
  62053. */
  62054. getImpostors(): Array<PhysicsImpostor>;
  62055. /**
  62056. * Gets the impostor for a physics enabled object
  62057. * @param object defines the object impersonated by the impostor
  62058. * @returns the PhysicsImpostor or null if not found
  62059. */
  62060. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62061. /**
  62062. * Gets the impostor for a physics body object
  62063. * @param body defines physics body used by the impostor
  62064. * @returns the PhysicsImpostor or null if not found
  62065. */
  62066. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62067. /**
  62068. * Does a raycast in the physics world
  62069. * @param from when should the ray start?
  62070. * @param to when should the ray end?
  62071. * @returns PhysicsRaycastResult
  62072. */
  62073. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62074. }
  62075. }
  62076. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62077. import { Nullable } from "babylonjs/types";
  62078. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62080. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62081. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62082. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62083. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62084. /** @hidden */
  62085. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62086. private _useDeltaForWorldStep;
  62087. world: any;
  62088. name: string;
  62089. private _physicsMaterials;
  62090. private _fixedTimeStep;
  62091. private _cannonRaycastResult;
  62092. private _raycastResult;
  62093. private _physicsBodysToRemoveAfterStep;
  62094. private _firstFrame;
  62095. BJSCANNON: any;
  62096. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62097. setGravity(gravity: Vector3): void;
  62098. setTimeStep(timeStep: number): void;
  62099. getTimeStep(): number;
  62100. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62101. private _removeMarkedPhysicsBodiesFromWorld;
  62102. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62103. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62104. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62105. private _processChildMeshes;
  62106. removePhysicsBody(impostor: PhysicsImpostor): void;
  62107. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62108. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62109. private _addMaterial;
  62110. private _checkWithEpsilon;
  62111. private _createShape;
  62112. private _createHeightmap;
  62113. private _minus90X;
  62114. private _plus90X;
  62115. private _tmpPosition;
  62116. private _tmpDeltaPosition;
  62117. private _tmpUnityRotation;
  62118. private _updatePhysicsBodyTransformation;
  62119. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62120. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62121. isSupported(): boolean;
  62122. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62123. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62124. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62125. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62126. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62127. getBodyMass(impostor: PhysicsImpostor): number;
  62128. getBodyFriction(impostor: PhysicsImpostor): number;
  62129. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62130. getBodyRestitution(impostor: PhysicsImpostor): number;
  62131. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62132. sleepBody(impostor: PhysicsImpostor): void;
  62133. wakeUpBody(impostor: PhysicsImpostor): void;
  62134. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62135. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62136. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62137. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62138. getRadius(impostor: PhysicsImpostor): number;
  62139. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62140. dispose(): void;
  62141. private _extendNamespace;
  62142. /**
  62143. * Does a raycast in the physics world
  62144. * @param from when should the ray start?
  62145. * @param to when should the ray end?
  62146. * @returns PhysicsRaycastResult
  62147. */
  62148. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62149. }
  62150. }
  62151. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62152. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62153. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62154. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62156. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62157. import { Nullable } from "babylonjs/types";
  62158. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62159. /** @hidden */
  62160. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62161. private _useDeltaForWorldStep;
  62162. world: any;
  62163. name: string;
  62164. BJSOIMO: any;
  62165. private _raycastResult;
  62166. private _fixedTimeStep;
  62167. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62168. setGravity(gravity: Vector3): void;
  62169. setTimeStep(timeStep: number): void;
  62170. getTimeStep(): number;
  62171. private _tmpImpostorsArray;
  62172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62176. private _tmpPositionVector;
  62177. removePhysicsBody(impostor: PhysicsImpostor): void;
  62178. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62179. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62180. isSupported(): boolean;
  62181. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62183. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62184. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62185. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62186. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62187. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62188. getBodyMass(impostor: PhysicsImpostor): number;
  62189. getBodyFriction(impostor: PhysicsImpostor): number;
  62190. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62191. getBodyRestitution(impostor: PhysicsImpostor): number;
  62192. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62193. sleepBody(impostor: PhysicsImpostor): void;
  62194. wakeUpBody(impostor: PhysicsImpostor): void;
  62195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62196. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62198. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62199. getRadius(impostor: PhysicsImpostor): number;
  62200. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62201. dispose(): void;
  62202. /**
  62203. * Does a raycast in the physics world
  62204. * @param from when should the ray start?
  62205. * @param to when should the ray end?
  62206. * @returns PhysicsRaycastResult
  62207. */
  62208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62209. }
  62210. }
  62211. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62212. import { Nullable } from "babylonjs/types";
  62213. import { Scene } from "babylonjs/scene";
  62214. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62215. import { Color4 } from "babylonjs/Maths/math.color";
  62216. import { Mesh } from "babylonjs/Meshes/mesh";
  62217. /**
  62218. * Class containing static functions to help procedurally build meshes
  62219. */
  62220. export class RibbonBuilder {
  62221. /**
  62222. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62223. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62224. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62225. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62226. * * 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
  62227. * * 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
  62228. * * 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
  62229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62232. * * 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
  62233. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62234. * * 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
  62235. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62237. * @param name defines the name of the mesh
  62238. * @param options defines the options used to create the mesh
  62239. * @param scene defines the hosting scene
  62240. * @returns the ribbon mesh
  62241. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62243. */
  62244. static CreateRibbon(name: string, options: {
  62245. pathArray: Vector3[][];
  62246. closeArray?: boolean;
  62247. closePath?: boolean;
  62248. offset?: number;
  62249. updatable?: boolean;
  62250. sideOrientation?: number;
  62251. frontUVs?: Vector4;
  62252. backUVs?: Vector4;
  62253. instance?: Mesh;
  62254. invertUV?: boolean;
  62255. uvs?: Vector2[];
  62256. colors?: Color4[];
  62257. }, scene?: Nullable<Scene>): Mesh;
  62258. }
  62259. }
  62260. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62261. import { Nullable } from "babylonjs/types";
  62262. import { Scene } from "babylonjs/scene";
  62263. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62264. import { Mesh } from "babylonjs/Meshes/mesh";
  62265. /**
  62266. * Class containing static functions to help procedurally build meshes
  62267. */
  62268. export class ShapeBuilder {
  62269. /**
  62270. * 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.
  62271. * * 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.
  62272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62273. * * 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.
  62274. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62275. * * 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
  62276. * * 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
  62277. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62282. * @param name defines the name of the mesh
  62283. * @param options defines the options used to create the mesh
  62284. * @param scene defines the hosting scene
  62285. * @returns the extruded shape mesh
  62286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62288. */
  62289. static ExtrudeShape(name: string, options: {
  62290. shape: Vector3[];
  62291. path: Vector3[];
  62292. scale?: number;
  62293. rotation?: number;
  62294. cap?: number;
  62295. updatable?: boolean;
  62296. sideOrientation?: number;
  62297. frontUVs?: Vector4;
  62298. backUVs?: Vector4;
  62299. instance?: Mesh;
  62300. invertUV?: boolean;
  62301. }, scene?: Nullable<Scene>): Mesh;
  62302. /**
  62303. * Creates an custom extruded shape mesh.
  62304. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62305. * * 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.
  62306. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62307. * * 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
  62308. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62309. * * 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
  62310. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62311. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62312. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62313. * * 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
  62314. * * 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
  62315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62320. * @param name defines the name of the mesh
  62321. * @param options defines the options used to create the mesh
  62322. * @param scene defines the hosting scene
  62323. * @returns the custom extruded shape mesh
  62324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62327. */
  62328. static ExtrudeShapeCustom(name: string, options: {
  62329. shape: Vector3[];
  62330. path: Vector3[];
  62331. scaleFunction?: any;
  62332. rotationFunction?: any;
  62333. ribbonCloseArray?: boolean;
  62334. ribbonClosePath?: boolean;
  62335. cap?: number;
  62336. updatable?: boolean;
  62337. sideOrientation?: number;
  62338. frontUVs?: Vector4;
  62339. backUVs?: Vector4;
  62340. instance?: Mesh;
  62341. invertUV?: boolean;
  62342. }, scene?: Nullable<Scene>): Mesh;
  62343. private static _ExtrudeShapeGeneric;
  62344. }
  62345. }
  62346. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62347. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62348. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62349. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62350. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62351. import { Nullable } from "babylonjs/types";
  62352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62353. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62354. /**
  62355. * AmmoJS Physics plugin
  62356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62357. * @see https://github.com/kripken/ammo.js/
  62358. */
  62359. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62360. private _useDeltaForWorldStep;
  62361. /**
  62362. * Reference to the Ammo library
  62363. */
  62364. bjsAMMO: any;
  62365. /**
  62366. * Created ammoJS world which physics bodies are added to
  62367. */
  62368. world: any;
  62369. /**
  62370. * Name of the plugin
  62371. */
  62372. name: string;
  62373. private _timeStep;
  62374. private _fixedTimeStep;
  62375. private _maxSteps;
  62376. private _tmpQuaternion;
  62377. private _tmpAmmoTransform;
  62378. private _tmpAmmoQuaternion;
  62379. private _tmpAmmoConcreteContactResultCallback;
  62380. private _collisionConfiguration;
  62381. private _dispatcher;
  62382. private _overlappingPairCache;
  62383. private _solver;
  62384. private _softBodySolver;
  62385. private _tmpAmmoVectorA;
  62386. private _tmpAmmoVectorB;
  62387. private _tmpAmmoVectorC;
  62388. private _tmpAmmoVectorD;
  62389. private _tmpContactCallbackResult;
  62390. private _tmpAmmoVectorRCA;
  62391. private _tmpAmmoVectorRCB;
  62392. private _raycastResult;
  62393. private static readonly DISABLE_COLLISION_FLAG;
  62394. private static readonly KINEMATIC_FLAG;
  62395. private static readonly DISABLE_DEACTIVATION_FLAG;
  62396. /**
  62397. * Initializes the ammoJS plugin
  62398. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62399. * @param ammoInjection can be used to inject your own ammo reference
  62400. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62401. */
  62402. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62403. /**
  62404. * Sets the gravity of the physics world (m/(s^2))
  62405. * @param gravity Gravity to set
  62406. */
  62407. setGravity(gravity: Vector3): void;
  62408. /**
  62409. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62410. * @param timeStep timestep to use in seconds
  62411. */
  62412. setTimeStep(timeStep: number): void;
  62413. /**
  62414. * 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)
  62415. * @param fixedTimeStep fixedTimeStep to use in seconds
  62416. */
  62417. setFixedTimeStep(fixedTimeStep: number): void;
  62418. /**
  62419. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62420. * @param maxSteps the maximum number of steps by the physics engine per frame
  62421. */
  62422. setMaxSteps(maxSteps: number): void;
  62423. /**
  62424. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62425. * @returns the current timestep in seconds
  62426. */
  62427. getTimeStep(): number;
  62428. /**
  62429. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62430. */
  62431. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62432. private _isImpostorInContact;
  62433. private _isImpostorPairInContact;
  62434. private _stepSimulation;
  62435. /**
  62436. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62437. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62438. * After the step the babylon meshes are set to the position of the physics imposters
  62439. * @param delta amount of time to step forward
  62440. * @param impostors array of imposters to update before/after the step
  62441. */
  62442. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62443. /**
  62444. * Update babylon mesh to match physics world object
  62445. * @param impostor imposter to match
  62446. */
  62447. private _afterSoftStep;
  62448. /**
  62449. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62450. * @param impostor imposter to match
  62451. */
  62452. private _ropeStep;
  62453. /**
  62454. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62455. * @param impostor imposter to match
  62456. */
  62457. private _softbodyOrClothStep;
  62458. private _tmpMatrix;
  62459. /**
  62460. * Applies an impulse on the imposter
  62461. * @param impostor imposter to apply impulse to
  62462. * @param force amount of force to be applied to the imposter
  62463. * @param contactPoint the location to apply the impulse on the imposter
  62464. */
  62465. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62466. /**
  62467. * Applies a force on the imposter
  62468. * @param impostor imposter to apply force
  62469. * @param force amount of force to be applied to the imposter
  62470. * @param contactPoint the location to apply the force on the imposter
  62471. */
  62472. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62473. /**
  62474. * Creates a physics body using the plugin
  62475. * @param impostor the imposter to create the physics body on
  62476. */
  62477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62478. /**
  62479. * Removes the physics body from the imposter and disposes of the body's memory
  62480. * @param impostor imposter to remove the physics body from
  62481. */
  62482. removePhysicsBody(impostor: PhysicsImpostor): void;
  62483. /**
  62484. * Generates a joint
  62485. * @param impostorJoint the imposter joint to create the joint with
  62486. */
  62487. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62488. /**
  62489. * Removes a joint
  62490. * @param impostorJoint the imposter joint to remove the joint from
  62491. */
  62492. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62493. private _addMeshVerts;
  62494. /**
  62495. * Initialise the soft body vertices to match its object's (mesh) vertices
  62496. * Softbody vertices (nodes) are in world space and to match this
  62497. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62498. * @param impostor to create the softbody for
  62499. */
  62500. private _softVertexData;
  62501. /**
  62502. * Create an impostor's soft body
  62503. * @param impostor to create the softbody for
  62504. */
  62505. private _createSoftbody;
  62506. /**
  62507. * Create cloth for an impostor
  62508. * @param impostor to create the softbody for
  62509. */
  62510. private _createCloth;
  62511. /**
  62512. * Create rope for an impostor
  62513. * @param impostor to create the softbody for
  62514. */
  62515. private _createRope;
  62516. /**
  62517. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62518. * @param impostor to create the custom physics shape for
  62519. */
  62520. private _createCustom;
  62521. private _addHullVerts;
  62522. private _createShape;
  62523. /**
  62524. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62525. * @param impostor imposter containing the physics body and babylon object
  62526. */
  62527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62528. /**
  62529. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62530. * @param impostor imposter containing the physics body and babylon object
  62531. * @param newPosition new position
  62532. * @param newRotation new rotation
  62533. */
  62534. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62535. /**
  62536. * If this plugin is supported
  62537. * @returns true if its supported
  62538. */
  62539. isSupported(): boolean;
  62540. /**
  62541. * Sets the linear velocity of the physics body
  62542. * @param impostor imposter to set the velocity on
  62543. * @param velocity velocity to set
  62544. */
  62545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62546. /**
  62547. * Sets the angular velocity of the physics body
  62548. * @param impostor imposter to set the velocity on
  62549. * @param velocity velocity to set
  62550. */
  62551. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62552. /**
  62553. * gets the linear velocity
  62554. * @param impostor imposter to get linear velocity from
  62555. * @returns linear velocity
  62556. */
  62557. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62558. /**
  62559. * gets the angular velocity
  62560. * @param impostor imposter to get angular velocity from
  62561. * @returns angular velocity
  62562. */
  62563. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62564. /**
  62565. * Sets the mass of physics body
  62566. * @param impostor imposter to set the mass on
  62567. * @param mass mass to set
  62568. */
  62569. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62570. /**
  62571. * Gets the mass of the physics body
  62572. * @param impostor imposter to get the mass from
  62573. * @returns mass
  62574. */
  62575. getBodyMass(impostor: PhysicsImpostor): number;
  62576. /**
  62577. * Gets friction of the impostor
  62578. * @param impostor impostor to get friction from
  62579. * @returns friction value
  62580. */
  62581. getBodyFriction(impostor: PhysicsImpostor): number;
  62582. /**
  62583. * Sets friction of the impostor
  62584. * @param impostor impostor to set friction on
  62585. * @param friction friction value
  62586. */
  62587. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62588. /**
  62589. * Gets restitution of the impostor
  62590. * @param impostor impostor to get restitution from
  62591. * @returns restitution value
  62592. */
  62593. getBodyRestitution(impostor: PhysicsImpostor): number;
  62594. /**
  62595. * Sets resitution of the impostor
  62596. * @param impostor impostor to set resitution on
  62597. * @param restitution resitution value
  62598. */
  62599. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62600. /**
  62601. * Gets pressure inside the impostor
  62602. * @param impostor impostor to get pressure from
  62603. * @returns pressure value
  62604. */
  62605. getBodyPressure(impostor: PhysicsImpostor): number;
  62606. /**
  62607. * Sets pressure inside a soft body impostor
  62608. * Cloth and rope must remain 0 pressure
  62609. * @param impostor impostor to set pressure on
  62610. * @param pressure pressure value
  62611. */
  62612. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62613. /**
  62614. * Gets stiffness of the impostor
  62615. * @param impostor impostor to get stiffness from
  62616. * @returns pressure value
  62617. */
  62618. getBodyStiffness(impostor: PhysicsImpostor): number;
  62619. /**
  62620. * Sets stiffness of the impostor
  62621. * @param impostor impostor to set stiffness on
  62622. * @param stiffness stiffness value from 0 to 1
  62623. */
  62624. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62625. /**
  62626. * Gets velocityIterations of the impostor
  62627. * @param impostor impostor to get velocity iterations from
  62628. * @returns velocityIterations value
  62629. */
  62630. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62631. /**
  62632. * Sets velocityIterations of the impostor
  62633. * @param impostor impostor to set velocity iterations on
  62634. * @param velocityIterations velocityIterations value
  62635. */
  62636. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62637. /**
  62638. * Gets positionIterations of the impostor
  62639. * @param impostor impostor to get position iterations from
  62640. * @returns positionIterations value
  62641. */
  62642. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62643. /**
  62644. * Sets positionIterations of the impostor
  62645. * @param impostor impostor to set position on
  62646. * @param positionIterations positionIterations value
  62647. */
  62648. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62649. /**
  62650. * Append an anchor to a cloth object
  62651. * @param impostor is the cloth impostor to add anchor to
  62652. * @param otherImpostor is the rigid impostor to anchor to
  62653. * @param width ratio across width from 0 to 1
  62654. * @param height ratio up height from 0 to 1
  62655. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62656. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62657. */
  62658. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62659. /**
  62660. * Append an hook to a rope object
  62661. * @param impostor is the rope impostor to add hook to
  62662. * @param otherImpostor is the rigid impostor to hook to
  62663. * @param length ratio along the rope from 0 to 1
  62664. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62666. */
  62667. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62668. /**
  62669. * Sleeps the physics body and stops it from being active
  62670. * @param impostor impostor to sleep
  62671. */
  62672. sleepBody(impostor: PhysicsImpostor): void;
  62673. /**
  62674. * Activates the physics body
  62675. * @param impostor impostor to activate
  62676. */
  62677. wakeUpBody(impostor: PhysicsImpostor): void;
  62678. /**
  62679. * Updates the distance parameters of the joint
  62680. * @param joint joint to update
  62681. * @param maxDistance maximum distance of the joint
  62682. * @param minDistance minimum distance of the joint
  62683. */
  62684. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62685. /**
  62686. * Sets a motor on the joint
  62687. * @param joint joint to set motor on
  62688. * @param speed speed of the motor
  62689. * @param maxForce maximum force of the motor
  62690. * @param motorIndex index of the motor
  62691. */
  62692. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62693. /**
  62694. * Sets the motors limit
  62695. * @param joint joint to set limit on
  62696. * @param upperLimit upper limit
  62697. * @param lowerLimit lower limit
  62698. */
  62699. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62700. /**
  62701. * Syncs the position and rotation of a mesh with the impostor
  62702. * @param mesh mesh to sync
  62703. * @param impostor impostor to update the mesh with
  62704. */
  62705. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62706. /**
  62707. * Gets the radius of the impostor
  62708. * @param impostor impostor to get radius from
  62709. * @returns the radius
  62710. */
  62711. getRadius(impostor: PhysicsImpostor): number;
  62712. /**
  62713. * Gets the box size of the impostor
  62714. * @param impostor impostor to get box size from
  62715. * @param result the resulting box size
  62716. */
  62717. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62718. /**
  62719. * Disposes of the impostor
  62720. */
  62721. dispose(): void;
  62722. /**
  62723. * Does a raycast in the physics world
  62724. * @param from when should the ray start?
  62725. * @param to when should the ray end?
  62726. * @returns PhysicsRaycastResult
  62727. */
  62728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62729. }
  62730. }
  62731. declare module "babylonjs/Probes/reflectionProbe" {
  62732. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62733. import { Vector3 } from "babylonjs/Maths/math.vector";
  62734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62735. import { Nullable } from "babylonjs/types";
  62736. import { Scene } from "babylonjs/scene";
  62737. module "babylonjs/abstractScene" {
  62738. interface AbstractScene {
  62739. /**
  62740. * The list of reflection probes added to the scene
  62741. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62742. */
  62743. reflectionProbes: Array<ReflectionProbe>;
  62744. /**
  62745. * Removes the given reflection probe from this scene.
  62746. * @param toRemove The reflection probe to remove
  62747. * @returns The index of the removed reflection probe
  62748. */
  62749. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62750. /**
  62751. * Adds the given reflection probe to this scene.
  62752. * @param newReflectionProbe The reflection probe to add
  62753. */
  62754. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62755. }
  62756. }
  62757. /**
  62758. * Class used to generate realtime reflection / refraction cube textures
  62759. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62760. */
  62761. export class ReflectionProbe {
  62762. /** defines the name of the probe */
  62763. name: string;
  62764. private _scene;
  62765. private _renderTargetTexture;
  62766. private _projectionMatrix;
  62767. private _viewMatrix;
  62768. private _target;
  62769. private _add;
  62770. private _attachedMesh;
  62771. private _invertYAxis;
  62772. /** Gets or sets probe position (center of the cube map) */
  62773. position: Vector3;
  62774. /**
  62775. * Creates a new reflection probe
  62776. * @param name defines the name of the probe
  62777. * @param size defines the texture resolution (for each face)
  62778. * @param scene defines the hosting scene
  62779. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62780. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62781. */
  62782. constructor(
  62783. /** defines the name of the probe */
  62784. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62785. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62786. get samples(): number;
  62787. set samples(value: number);
  62788. /** Gets or sets the refresh rate to use (on every frame by default) */
  62789. get refreshRate(): number;
  62790. set refreshRate(value: number);
  62791. /**
  62792. * Gets the hosting scene
  62793. * @returns a Scene
  62794. */
  62795. getScene(): Scene;
  62796. /** Gets the internal CubeTexture used to render to */
  62797. get cubeTexture(): RenderTargetTexture;
  62798. /** Gets the list of meshes to render */
  62799. get renderList(): Nullable<AbstractMesh[]>;
  62800. /**
  62801. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62802. * @param mesh defines the mesh to attach to
  62803. */
  62804. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62805. /**
  62806. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62807. * @param renderingGroupId The rendering group id corresponding to its index
  62808. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62809. */
  62810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62811. /**
  62812. * Clean all associated resources
  62813. */
  62814. dispose(): void;
  62815. /**
  62816. * Converts the reflection probe information to a readable string for debug purpose.
  62817. * @param fullDetails Supports for multiple levels of logging within scene loading
  62818. * @returns the human readable reflection probe info
  62819. */
  62820. toString(fullDetails?: boolean): string;
  62821. /**
  62822. * Get the class name of the relfection probe.
  62823. * @returns "ReflectionProbe"
  62824. */
  62825. getClassName(): string;
  62826. /**
  62827. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62828. * @returns The JSON representation of the texture
  62829. */
  62830. serialize(): any;
  62831. /**
  62832. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62833. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62834. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62835. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62836. * @returns The parsed reflection probe if successful
  62837. */
  62838. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62839. }
  62840. }
  62841. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62842. /** @hidden */
  62843. export var _BabylonLoaderRegistered: boolean;
  62844. /**
  62845. * Helps setting up some configuration for the babylon file loader.
  62846. */
  62847. export class BabylonFileLoaderConfiguration {
  62848. /**
  62849. * The loader does not allow injecting custom physix engine into the plugins.
  62850. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62851. * So you could set this variable to your engine import to make it work.
  62852. */
  62853. static LoaderInjectedPhysicsEngine: any;
  62854. }
  62855. }
  62856. declare module "babylonjs/Loading/Plugins/index" {
  62857. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62858. }
  62859. declare module "babylonjs/Loading/index" {
  62860. export * from "babylonjs/Loading/loadingScreen";
  62861. export * from "babylonjs/Loading/Plugins/index";
  62862. export * from "babylonjs/Loading/sceneLoader";
  62863. export * from "babylonjs/Loading/sceneLoaderFlags";
  62864. }
  62865. declare module "babylonjs/Materials/Background/index" {
  62866. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62867. }
  62868. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62869. import { Scene } from "babylonjs/scene";
  62870. import { Color3 } from "babylonjs/Maths/math.color";
  62871. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62873. /**
  62874. * The Physically based simple base material of BJS.
  62875. *
  62876. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62877. * It is used as the base class for both the specGloss and metalRough conventions.
  62878. */
  62879. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62880. /**
  62881. * Number of Simultaneous lights allowed on the material.
  62882. */
  62883. maxSimultaneousLights: number;
  62884. /**
  62885. * If sets to true, disables all the lights affecting the material.
  62886. */
  62887. disableLighting: boolean;
  62888. /**
  62889. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62890. */
  62891. environmentTexture: BaseTexture;
  62892. /**
  62893. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62894. */
  62895. invertNormalMapX: boolean;
  62896. /**
  62897. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62898. */
  62899. invertNormalMapY: boolean;
  62900. /**
  62901. * Normal map used in the model.
  62902. */
  62903. normalTexture: BaseTexture;
  62904. /**
  62905. * Emissivie color used to self-illuminate the model.
  62906. */
  62907. emissiveColor: Color3;
  62908. /**
  62909. * Emissivie texture used to self-illuminate the model.
  62910. */
  62911. emissiveTexture: BaseTexture;
  62912. /**
  62913. * Occlusion Channel Strenght.
  62914. */
  62915. occlusionStrength: number;
  62916. /**
  62917. * Occlusion Texture of the material (adding extra occlusion effects).
  62918. */
  62919. occlusionTexture: BaseTexture;
  62920. /**
  62921. * Defines the alpha limits in alpha test mode.
  62922. */
  62923. alphaCutOff: number;
  62924. /**
  62925. * Gets the current double sided mode.
  62926. */
  62927. get doubleSided(): boolean;
  62928. /**
  62929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62930. */
  62931. set doubleSided(value: boolean);
  62932. /**
  62933. * Stores the pre-calculated light information of a mesh in a texture.
  62934. */
  62935. lightmapTexture: BaseTexture;
  62936. /**
  62937. * If true, the light map contains occlusion information instead of lighting info.
  62938. */
  62939. useLightmapAsShadowmap: boolean;
  62940. /**
  62941. * Instantiates a new PBRMaterial instance.
  62942. *
  62943. * @param name The material name
  62944. * @param scene The scene the material will be use in.
  62945. */
  62946. constructor(name: string, scene: Scene);
  62947. getClassName(): string;
  62948. }
  62949. }
  62950. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62951. import { Scene } from "babylonjs/scene";
  62952. import { Color3 } from "babylonjs/Maths/math.color";
  62953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62954. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62955. /**
  62956. * The PBR material of BJS following the metal roughness convention.
  62957. *
  62958. * This fits to the PBR convention in the GLTF definition:
  62959. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62960. */
  62961. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62962. /**
  62963. * The base color has two different interpretations depending on the value of metalness.
  62964. * When the material is a metal, the base color is the specific measured reflectance value
  62965. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62966. * of the material.
  62967. */
  62968. baseColor: Color3;
  62969. /**
  62970. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62971. * well as opacity information in the alpha channel.
  62972. */
  62973. baseTexture: BaseTexture;
  62974. /**
  62975. * Specifies the metallic scalar value of the material.
  62976. * Can also be used to scale the metalness values of the metallic texture.
  62977. */
  62978. metallic: number;
  62979. /**
  62980. * Specifies the roughness scalar value of the material.
  62981. * Can also be used to scale the roughness values of the metallic texture.
  62982. */
  62983. roughness: number;
  62984. /**
  62985. * Texture containing both the metallic value in the B channel and the
  62986. * roughness value in the G channel to keep better precision.
  62987. */
  62988. metallicRoughnessTexture: BaseTexture;
  62989. /**
  62990. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62991. *
  62992. * @param name The material name
  62993. * @param scene The scene the material will be use in.
  62994. */
  62995. constructor(name: string, scene: Scene);
  62996. /**
  62997. * Return the currrent class name of the material.
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Makes a duplicate of the current material.
  63002. * @param name - name to use for the new material.
  63003. */
  63004. clone(name: string): PBRMetallicRoughnessMaterial;
  63005. /**
  63006. * Serialize the material to a parsable JSON object.
  63007. */
  63008. serialize(): any;
  63009. /**
  63010. * Parses a JSON object correponding to the serialize function.
  63011. */
  63012. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63013. }
  63014. }
  63015. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63016. import { Scene } from "babylonjs/scene";
  63017. import { Color3 } from "babylonjs/Maths/math.color";
  63018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63019. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63020. /**
  63021. * The PBR material of BJS following the specular glossiness convention.
  63022. *
  63023. * This fits to the PBR convention in the GLTF definition:
  63024. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63025. */
  63026. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63027. /**
  63028. * Specifies the diffuse color of the material.
  63029. */
  63030. diffuseColor: Color3;
  63031. /**
  63032. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63033. * channel.
  63034. */
  63035. diffuseTexture: BaseTexture;
  63036. /**
  63037. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63038. */
  63039. specularColor: Color3;
  63040. /**
  63041. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63042. */
  63043. glossiness: number;
  63044. /**
  63045. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63046. */
  63047. specularGlossinessTexture: BaseTexture;
  63048. /**
  63049. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63050. *
  63051. * @param name The material name
  63052. * @param scene The scene the material will be use in.
  63053. */
  63054. constructor(name: string, scene: Scene);
  63055. /**
  63056. * Return the currrent class name of the material.
  63057. */
  63058. getClassName(): string;
  63059. /**
  63060. * Makes a duplicate of the current material.
  63061. * @param name - name to use for the new material.
  63062. */
  63063. clone(name: string): PBRSpecularGlossinessMaterial;
  63064. /**
  63065. * Serialize the material to a parsable JSON object.
  63066. */
  63067. serialize(): any;
  63068. /**
  63069. * Parses a JSON object correponding to the serialize function.
  63070. */
  63071. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63072. }
  63073. }
  63074. declare module "babylonjs/Materials/PBR/index" {
  63075. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63076. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63077. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63078. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63079. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63080. }
  63081. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63082. import { Nullable } from "babylonjs/types";
  63083. import { Scene } from "babylonjs/scene";
  63084. import { Matrix } from "babylonjs/Maths/math.vector";
  63085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63086. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63087. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63088. /**
  63089. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63090. * It can help converting any input color in a desired output one. This can then be used to create effects
  63091. * from sepia, black and white to sixties or futuristic rendering...
  63092. *
  63093. * The only supported format is currently 3dl.
  63094. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63095. */
  63096. export class ColorGradingTexture extends BaseTexture {
  63097. /**
  63098. * The texture URL.
  63099. */
  63100. url: string;
  63101. /**
  63102. * Empty line regex stored for GC.
  63103. */
  63104. private static _noneEmptyLineRegex;
  63105. private _textureMatrix;
  63106. private _onLoad;
  63107. /**
  63108. * Instantiates a ColorGradingTexture from the following parameters.
  63109. *
  63110. * @param url The location of the color gradind data (currently only supporting 3dl)
  63111. * @param sceneOrEngine The scene or engine the texture will be used in
  63112. * @param onLoad defines a callback triggered when the texture has been loaded
  63113. */
  63114. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63115. /**
  63116. * Fires the onload event from the constructor if requested.
  63117. */
  63118. private _triggerOnLoad;
  63119. /**
  63120. * Returns the texture matrix used in most of the material.
  63121. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63122. */
  63123. getTextureMatrix(): Matrix;
  63124. /**
  63125. * Occurs when the file being loaded is a .3dl LUT file.
  63126. */
  63127. private load3dlTexture;
  63128. /**
  63129. * Starts the loading process of the texture.
  63130. */
  63131. private loadTexture;
  63132. /**
  63133. * Clones the color gradind texture.
  63134. */
  63135. clone(): ColorGradingTexture;
  63136. /**
  63137. * Called during delayed load for textures.
  63138. */
  63139. delayLoad(): void;
  63140. /**
  63141. * Parses a color grading texture serialized by Babylon.
  63142. * @param parsedTexture The texture information being parsedTexture
  63143. * @param scene The scene to load the texture in
  63144. * @param rootUrl The root url of the data assets to load
  63145. * @return A color gradind texture
  63146. */
  63147. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63148. /**
  63149. * Serializes the LUT texture to json format.
  63150. */
  63151. serialize(): any;
  63152. }
  63153. }
  63154. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63156. import { Scene } from "babylonjs/scene";
  63157. import { Nullable } from "babylonjs/types";
  63158. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63159. /**
  63160. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63161. */
  63162. export class EquiRectangularCubeTexture extends BaseTexture {
  63163. /** The six faces of the cube. */
  63164. private static _FacesMapping;
  63165. private _noMipmap;
  63166. private _onLoad;
  63167. private _onError;
  63168. /** The size of the cubemap. */
  63169. private _size;
  63170. /** The buffer of the image. */
  63171. private _buffer;
  63172. /** The width of the input image. */
  63173. private _width;
  63174. /** The height of the input image. */
  63175. private _height;
  63176. /** The URL to the image. */
  63177. url: string;
  63178. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63179. coordinatesMode: number;
  63180. /**
  63181. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63182. * @param url The location of the image
  63183. * @param scene The scene the texture will be used in
  63184. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63185. * @param noMipmap Forces to not generate the mipmap if true
  63186. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63187. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63188. * @param onLoad — defines a callback called when texture is loaded
  63189. * @param onError — defines a callback called if there is an error
  63190. */
  63191. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63192. /**
  63193. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63194. */
  63195. private loadImage;
  63196. /**
  63197. * Convert the image buffer into a cubemap and create a CubeTexture.
  63198. */
  63199. private loadTexture;
  63200. /**
  63201. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63202. * @param buffer The ArrayBuffer that should be converted.
  63203. * @returns The buffer as Float32Array.
  63204. */
  63205. private getFloat32ArrayFromArrayBuffer;
  63206. /**
  63207. * Get the current class name of the texture useful for serialization or dynamic coding.
  63208. * @returns "EquiRectangularCubeTexture"
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63213. * @returns A clone of the current EquiRectangularCubeTexture.
  63214. */
  63215. clone(): EquiRectangularCubeTexture;
  63216. }
  63217. }
  63218. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63219. import { Nullable } from "babylonjs/types";
  63220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63221. import { Matrix } from "babylonjs/Maths/math.vector";
  63222. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63223. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63225. import { Scene } from "babylonjs/scene";
  63226. /**
  63227. * Defines the options related to the creation of an HtmlElementTexture
  63228. */
  63229. export interface IHtmlElementTextureOptions {
  63230. /**
  63231. * Defines wether mip maps should be created or not.
  63232. */
  63233. generateMipMaps?: boolean;
  63234. /**
  63235. * Defines the sampling mode of the texture.
  63236. */
  63237. samplingMode?: number;
  63238. /**
  63239. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63240. */
  63241. engine: Nullable<ThinEngine>;
  63242. /**
  63243. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63244. */
  63245. scene: Nullable<Scene>;
  63246. }
  63247. /**
  63248. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63249. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63250. * is automatically managed.
  63251. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63252. * in your application.
  63253. *
  63254. * As the update is not automatic, you need to call them manually.
  63255. */
  63256. export class HtmlElementTexture extends BaseTexture {
  63257. /**
  63258. * The texture URL.
  63259. */
  63260. element: HTMLVideoElement | HTMLCanvasElement;
  63261. private static readonly DefaultOptions;
  63262. private _textureMatrix;
  63263. private _isVideo;
  63264. private _generateMipMaps;
  63265. private _samplingMode;
  63266. /**
  63267. * Instantiates a HtmlElementTexture from the following parameters.
  63268. *
  63269. * @param name Defines the name of the texture
  63270. * @param element Defines the video or canvas the texture is filled with
  63271. * @param options Defines the other none mandatory texture creation options
  63272. */
  63273. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63274. private _createInternalTexture;
  63275. /**
  63276. * Returns the texture matrix used in most of the material.
  63277. */
  63278. getTextureMatrix(): Matrix;
  63279. /**
  63280. * Updates the content of the texture.
  63281. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63282. */
  63283. update(invertY?: Nullable<boolean>): void;
  63284. }
  63285. }
  63286. declare module "babylonjs/Misc/tga" {
  63287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63288. /**
  63289. * Based on jsTGALoader - Javascript loader for TGA file
  63290. * By Vincent Thibault
  63291. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63292. */
  63293. export class TGATools {
  63294. private static _TYPE_INDEXED;
  63295. private static _TYPE_RGB;
  63296. private static _TYPE_GREY;
  63297. private static _TYPE_RLE_INDEXED;
  63298. private static _TYPE_RLE_RGB;
  63299. private static _TYPE_RLE_GREY;
  63300. private static _ORIGIN_MASK;
  63301. private static _ORIGIN_SHIFT;
  63302. private static _ORIGIN_BL;
  63303. private static _ORIGIN_BR;
  63304. private static _ORIGIN_UL;
  63305. private static _ORIGIN_UR;
  63306. /**
  63307. * Gets the header of a TGA file
  63308. * @param data defines the TGA data
  63309. * @returns the header
  63310. */
  63311. static GetTGAHeader(data: Uint8Array): any;
  63312. /**
  63313. * Uploads TGA content to a Babylon Texture
  63314. * @hidden
  63315. */
  63316. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63317. /** @hidden */
  63318. 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;
  63319. /** @hidden */
  63320. 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;
  63321. /** @hidden */
  63322. 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;
  63323. /** @hidden */
  63324. 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;
  63325. /** @hidden */
  63326. 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;
  63327. /** @hidden */
  63328. 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;
  63329. }
  63330. }
  63331. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63332. import { Nullable } from "babylonjs/types";
  63333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63334. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63335. /**
  63336. * Implementation of the TGA Texture Loader.
  63337. * @hidden
  63338. */
  63339. export class _TGATextureLoader implements IInternalTextureLoader {
  63340. /**
  63341. * Defines wether the loader supports cascade loading the different faces.
  63342. */
  63343. readonly supportCascades: boolean;
  63344. /**
  63345. * This returns if the loader support the current file information.
  63346. * @param extension defines the file extension of the file being loaded
  63347. * @returns true if the loader can load the specified file
  63348. */
  63349. canLoad(extension: string): boolean;
  63350. /**
  63351. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63352. * @param data contains the texture data
  63353. * @param texture defines the BabylonJS internal texture
  63354. * @param createPolynomials will be true if polynomials have been requested
  63355. * @param onLoad defines the callback to trigger once the texture is ready
  63356. * @param onError defines the callback to trigger in case of error
  63357. */
  63358. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63359. /**
  63360. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63361. * @param data contains the texture data
  63362. * @param texture defines the BabylonJS internal texture
  63363. * @param callback defines the method to call once ready to upload
  63364. */
  63365. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63366. }
  63367. }
  63368. declare module "babylonjs/Misc/basis" {
  63369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63370. /**
  63371. * Info about the .basis files
  63372. */
  63373. class BasisFileInfo {
  63374. /**
  63375. * If the file has alpha
  63376. */
  63377. hasAlpha: boolean;
  63378. /**
  63379. * Info about each image of the basis file
  63380. */
  63381. images: Array<{
  63382. levels: Array<{
  63383. width: number;
  63384. height: number;
  63385. transcodedPixels: ArrayBufferView;
  63386. }>;
  63387. }>;
  63388. }
  63389. /**
  63390. * Result of transcoding a basis file
  63391. */
  63392. class TranscodeResult {
  63393. /**
  63394. * Info about the .basis file
  63395. */
  63396. fileInfo: BasisFileInfo;
  63397. /**
  63398. * Format to use when loading the file
  63399. */
  63400. format: number;
  63401. }
  63402. /**
  63403. * Configuration options for the Basis transcoder
  63404. */
  63405. export class BasisTranscodeConfiguration {
  63406. /**
  63407. * Supported compression formats used to determine the supported output format of the transcoder
  63408. */
  63409. supportedCompressionFormats?: {
  63410. /**
  63411. * etc1 compression format
  63412. */
  63413. etc1?: boolean;
  63414. /**
  63415. * s3tc compression format
  63416. */
  63417. s3tc?: boolean;
  63418. /**
  63419. * pvrtc compression format
  63420. */
  63421. pvrtc?: boolean;
  63422. /**
  63423. * etc2 compression format
  63424. */
  63425. etc2?: boolean;
  63426. };
  63427. /**
  63428. * If mipmap levels should be loaded for transcoded images (Default: true)
  63429. */
  63430. loadMipmapLevels?: boolean;
  63431. /**
  63432. * Index of a single image to load (Default: all images)
  63433. */
  63434. loadSingleImage?: number;
  63435. }
  63436. /**
  63437. * Used to load .Basis files
  63438. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63439. */
  63440. export class BasisTools {
  63441. private static _IgnoreSupportedFormats;
  63442. /**
  63443. * URL to use when loading the basis transcoder
  63444. */
  63445. static JSModuleURL: string;
  63446. /**
  63447. * URL to use when loading the wasm module for the transcoder
  63448. */
  63449. static WasmModuleURL: string;
  63450. /**
  63451. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63452. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63453. * @returns internal format corresponding to the Basis format
  63454. */
  63455. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63456. private static _WorkerPromise;
  63457. private static _Worker;
  63458. private static _actionId;
  63459. private static _CreateWorkerAsync;
  63460. /**
  63461. * Transcodes a loaded image file to compressed pixel data
  63462. * @param data image data to transcode
  63463. * @param config configuration options for the transcoding
  63464. * @returns a promise resulting in the transcoded image
  63465. */
  63466. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63467. /**
  63468. * Loads a texture from the transcode result
  63469. * @param texture texture load to
  63470. * @param transcodeResult the result of transcoding the basis file to load from
  63471. */
  63472. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63473. }
  63474. }
  63475. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63476. import { Nullable } from "babylonjs/types";
  63477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63478. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63479. /**
  63480. * Loader for .basis file format
  63481. */
  63482. export class _BasisTextureLoader implements IInternalTextureLoader {
  63483. /**
  63484. * Defines whether the loader supports cascade loading the different faces.
  63485. */
  63486. readonly supportCascades: boolean;
  63487. /**
  63488. * This returns if the loader support the current file information.
  63489. * @param extension defines the file extension of the file being loaded
  63490. * @returns true if the loader can load the specified file
  63491. */
  63492. canLoad(extension: string): boolean;
  63493. /**
  63494. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63495. * @param data contains the texture data
  63496. * @param texture defines the BabylonJS internal texture
  63497. * @param createPolynomials will be true if polynomials have been requested
  63498. * @param onLoad defines the callback to trigger once the texture is ready
  63499. * @param onError defines the callback to trigger in case of error
  63500. */
  63501. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63502. /**
  63503. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63504. * @param data contains the texture data
  63505. * @param texture defines the BabylonJS internal texture
  63506. * @param callback defines the method to call once ready to upload
  63507. */
  63508. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63509. }
  63510. }
  63511. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63512. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63513. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63514. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63515. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63516. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63517. }
  63518. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63519. import { Vector2 } from "babylonjs/Maths/math.vector";
  63520. /**
  63521. * Defines the basic options interface of a TexturePacker Frame
  63522. */
  63523. export interface ITexturePackerFrame {
  63524. /**
  63525. * The frame ID
  63526. */
  63527. id: number;
  63528. /**
  63529. * The frames Scale
  63530. */
  63531. scale: Vector2;
  63532. /**
  63533. * The Frames offset
  63534. */
  63535. offset: Vector2;
  63536. }
  63537. /**
  63538. * This is a support class for frame Data on texture packer sets.
  63539. */
  63540. export class TexturePackerFrame implements ITexturePackerFrame {
  63541. /**
  63542. * The frame ID
  63543. */
  63544. id: number;
  63545. /**
  63546. * The frames Scale
  63547. */
  63548. scale: Vector2;
  63549. /**
  63550. * The Frames offset
  63551. */
  63552. offset: Vector2;
  63553. /**
  63554. * Initializes a texture package frame.
  63555. * @param id The numerical frame identifier
  63556. * @param scale Scalar Vector2 for UV frame
  63557. * @param offset Vector2 for the frame position in UV units.
  63558. * @returns TexturePackerFrame
  63559. */
  63560. constructor(id: number, scale: Vector2, offset: Vector2);
  63561. }
  63562. }
  63563. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63565. import { Scene } from "babylonjs/scene";
  63566. import { Nullable } from "babylonjs/types";
  63567. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63568. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63569. /**
  63570. * Defines the basic options interface of a TexturePacker
  63571. */
  63572. export interface ITexturePackerOptions {
  63573. /**
  63574. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63575. */
  63576. map?: string[];
  63577. /**
  63578. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63579. */
  63580. uvsIn?: string;
  63581. /**
  63582. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63583. */
  63584. uvsOut?: string;
  63585. /**
  63586. * number representing the layout style. Defaults to LAYOUT_STRIP
  63587. */
  63588. layout?: number;
  63589. /**
  63590. * number of columns if using custom column count layout(2). This defaults to 4.
  63591. */
  63592. colnum?: number;
  63593. /**
  63594. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63595. */
  63596. updateInputMeshes?: boolean;
  63597. /**
  63598. * boolean flag to dispose all the source textures. Defaults to true.
  63599. */
  63600. disposeSources?: boolean;
  63601. /**
  63602. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63603. */
  63604. fillBlanks?: boolean;
  63605. /**
  63606. * string value representing the context fill style color. Defaults to 'black'.
  63607. */
  63608. customFillColor?: string;
  63609. /**
  63610. * Width and Height Value of each Frame in the TexturePacker Sets
  63611. */
  63612. frameSize?: number;
  63613. /**
  63614. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63615. */
  63616. paddingRatio?: number;
  63617. /**
  63618. * Number that declares the fill method for the padding gutter.
  63619. */
  63620. paddingMode?: number;
  63621. /**
  63622. * If in SUBUV_COLOR padding mode what color to use.
  63623. */
  63624. paddingColor?: Color3 | Color4;
  63625. }
  63626. /**
  63627. * Defines the basic interface of a TexturePacker JSON File
  63628. */
  63629. export interface ITexturePackerJSON {
  63630. /**
  63631. * The frame ID
  63632. */
  63633. name: string;
  63634. /**
  63635. * The base64 channel data
  63636. */
  63637. sets: any;
  63638. /**
  63639. * The options of the Packer
  63640. */
  63641. options: ITexturePackerOptions;
  63642. /**
  63643. * The frame data of the Packer
  63644. */
  63645. frames: Array<number>;
  63646. }
  63647. /**
  63648. * This is a support class that generates a series of packed texture sets.
  63649. * @see https://doc.babylonjs.com/babylon101/materials
  63650. */
  63651. export class TexturePacker {
  63652. /** Packer Layout Constant 0 */
  63653. static readonly LAYOUT_STRIP: number;
  63654. /** Packer Layout Constant 1 */
  63655. static readonly LAYOUT_POWER2: number;
  63656. /** Packer Layout Constant 2 */
  63657. static readonly LAYOUT_COLNUM: number;
  63658. /** Packer Layout Constant 0 */
  63659. static readonly SUBUV_WRAP: number;
  63660. /** Packer Layout Constant 1 */
  63661. static readonly SUBUV_EXTEND: number;
  63662. /** Packer Layout Constant 2 */
  63663. static readonly SUBUV_COLOR: number;
  63664. /** The Name of the Texture Package */
  63665. name: string;
  63666. /** The scene scope of the TexturePacker */
  63667. scene: Scene;
  63668. /** The Meshes to target */
  63669. meshes: AbstractMesh[];
  63670. /** Arguments passed with the Constructor */
  63671. options: ITexturePackerOptions;
  63672. /** The promise that is started upon initialization */
  63673. promise: Nullable<Promise<TexturePacker | string>>;
  63674. /** The Container object for the channel sets that are generated */
  63675. sets: object;
  63676. /** The Container array for the frames that are generated */
  63677. frames: TexturePackerFrame[];
  63678. /** The expected number of textures the system is parsing. */
  63679. private _expecting;
  63680. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63681. private _paddingValue;
  63682. /**
  63683. * Initializes a texture package series from an array of meshes or a single mesh.
  63684. * @param name The name of the package
  63685. * @param meshes The target meshes to compose the package from
  63686. * @param options The arguments that texture packer should follow while building.
  63687. * @param scene The scene which the textures are scoped to.
  63688. * @returns TexturePacker
  63689. */
  63690. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63691. /**
  63692. * Starts the package process
  63693. * @param resolve The promises resolution function
  63694. * @returns TexturePacker
  63695. */
  63696. private _createFrames;
  63697. /**
  63698. * Calculates the Size of the Channel Sets
  63699. * @returns Vector2
  63700. */
  63701. private _calculateSize;
  63702. /**
  63703. * Calculates the UV data for the frames.
  63704. * @param baseSize the base frameSize
  63705. * @param padding the base frame padding
  63706. * @param dtSize size of the Dynamic Texture for that channel
  63707. * @param dtUnits is 1/dtSize
  63708. * @param update flag to update the input meshes
  63709. */
  63710. private _calculateMeshUVFrames;
  63711. /**
  63712. * Calculates the frames Offset.
  63713. * @param index of the frame
  63714. * @returns Vector2
  63715. */
  63716. private _getFrameOffset;
  63717. /**
  63718. * Updates a Mesh to the frame data
  63719. * @param mesh that is the target
  63720. * @param frameID or the frame index
  63721. */
  63722. private _updateMeshUV;
  63723. /**
  63724. * Updates a Meshes materials to use the texture packer channels
  63725. * @param m is the mesh to target
  63726. * @param force all channels on the packer to be set.
  63727. */
  63728. private _updateTextureReferences;
  63729. /**
  63730. * Public method to set a Mesh to a frame
  63731. * @param m that is the target
  63732. * @param frameID or the frame index
  63733. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63734. */
  63735. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63736. /**
  63737. * Starts the async promise to compile the texture packer.
  63738. * @returns Promise<void>
  63739. */
  63740. processAsync(): Promise<void>;
  63741. /**
  63742. * Disposes all textures associated with this packer
  63743. */
  63744. dispose(): void;
  63745. /**
  63746. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63747. * @param imageType is the image type to use.
  63748. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63749. */
  63750. download(imageType?: string, quality?: number): void;
  63751. /**
  63752. * Public method to load a texturePacker JSON file.
  63753. * @param data of the JSON file in string format.
  63754. */
  63755. updateFromJSON(data: string): void;
  63756. }
  63757. }
  63758. declare module "babylonjs/Materials/Textures/Packer/index" {
  63759. export * from "babylonjs/Materials/Textures/Packer/packer";
  63760. export * from "babylonjs/Materials/Textures/Packer/frame";
  63761. }
  63762. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63763. import { Scene } from "babylonjs/scene";
  63764. import { Texture } from "babylonjs/Materials/Textures/texture";
  63765. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63766. /**
  63767. * 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.
  63768. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63769. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63770. */
  63771. export class CustomProceduralTexture extends ProceduralTexture {
  63772. private _animate;
  63773. private _time;
  63774. private _config;
  63775. private _texturePath;
  63776. /**
  63777. * Instantiates a new Custom Procedural Texture.
  63778. * 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.
  63779. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63780. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63781. * @param name Define the name of the texture
  63782. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63783. * @param size Define the size of the texture to create
  63784. * @param scene Define the scene the texture belongs to
  63785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63786. * @param generateMipMaps Define if the texture should creates mip maps or not
  63787. */
  63788. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63789. private _loadJson;
  63790. /**
  63791. * Is the texture ready to be used ? (rendered at least once)
  63792. * @returns true if ready, otherwise, false.
  63793. */
  63794. isReady(): boolean;
  63795. /**
  63796. * Render the texture to its associated render target.
  63797. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63798. */
  63799. render(useCameraPostProcess?: boolean): void;
  63800. /**
  63801. * Update the list of dependant textures samplers in the shader.
  63802. */
  63803. updateTextures(): void;
  63804. /**
  63805. * Update the uniform values of the procedural texture in the shader.
  63806. */
  63807. updateShaderUniforms(): void;
  63808. /**
  63809. * Define if the texture animates or not.
  63810. */
  63811. get animate(): boolean;
  63812. set animate(value: boolean);
  63813. }
  63814. }
  63815. declare module "babylonjs/Shaders/noise.fragment" {
  63816. /** @hidden */
  63817. export var noisePixelShader: {
  63818. name: string;
  63819. shader: string;
  63820. };
  63821. }
  63822. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63823. import { Nullable } from "babylonjs/types";
  63824. import { Scene } from "babylonjs/scene";
  63825. import { Texture } from "babylonjs/Materials/Textures/texture";
  63826. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63827. import "babylonjs/Shaders/noise.fragment";
  63828. /**
  63829. * Class used to generate noise procedural textures
  63830. */
  63831. export class NoiseProceduralTexture extends ProceduralTexture {
  63832. private _time;
  63833. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63834. brightness: number;
  63835. /** Defines the number of octaves to process */
  63836. octaves: number;
  63837. /** Defines the level of persistence (0.8 by default) */
  63838. persistence: number;
  63839. /** Gets or sets animation speed factor (default is 1) */
  63840. animationSpeedFactor: number;
  63841. /**
  63842. * Creates a new NoiseProceduralTexture
  63843. * @param name defines the name fo the texture
  63844. * @param size defines the size of the texture (default is 256)
  63845. * @param scene defines the hosting scene
  63846. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63847. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63848. */
  63849. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63850. private _updateShaderUniforms;
  63851. protected _getDefines(): string;
  63852. /** Generate the current state of the procedural texture */
  63853. render(useCameraPostProcess?: boolean): void;
  63854. /**
  63855. * Serializes this noise procedural texture
  63856. * @returns a serialized noise procedural texture object
  63857. */
  63858. serialize(): any;
  63859. /**
  63860. * Clone the texture.
  63861. * @returns the cloned texture
  63862. */
  63863. clone(): NoiseProceduralTexture;
  63864. /**
  63865. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63866. * @param parsedTexture defines parsed texture data
  63867. * @param scene defines the current scene
  63868. * @param rootUrl defines the root URL containing noise procedural texture information
  63869. * @returns a parsed NoiseProceduralTexture
  63870. */
  63871. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63872. }
  63873. }
  63874. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63875. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63876. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63877. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63878. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63879. }
  63880. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63881. import { Nullable } from "babylonjs/types";
  63882. import { Scene } from "babylonjs/scene";
  63883. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63885. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63887. /**
  63888. * Raw cube texture where the raw buffers are passed in
  63889. */
  63890. export class RawCubeTexture extends CubeTexture {
  63891. /**
  63892. * Creates a cube texture where the raw buffers are passed in.
  63893. * @param scene defines the scene the texture is attached to
  63894. * @param data defines the array of data to use to create each face
  63895. * @param size defines the size of the textures
  63896. * @param format defines the format of the data
  63897. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63898. * @param generateMipMaps defines if the engine should generate the mip levels
  63899. * @param invertY defines if data must be stored with Y axis inverted
  63900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63901. * @param compression defines the compression used (null by default)
  63902. */
  63903. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63904. /**
  63905. * Updates the raw cube texture.
  63906. * @param data defines the data to store
  63907. * @param format defines the data format
  63908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63909. * @param invertY defines if data must be stored with Y axis inverted
  63910. * @param compression defines the compression used (null by default)
  63911. * @param level defines which level of the texture to update
  63912. */
  63913. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63914. /**
  63915. * Updates a raw cube texture with RGBD encoded data.
  63916. * @param data defines the array of data [mipmap][face] to use to create each face
  63917. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63918. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63919. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63920. * @returns a promsie that resolves when the operation is complete
  63921. */
  63922. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63923. /**
  63924. * Clones the raw cube texture.
  63925. * @return a new cube texture
  63926. */
  63927. clone(): CubeTexture;
  63928. /** @hidden */
  63929. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63930. }
  63931. }
  63932. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63933. import { Scene } from "babylonjs/scene";
  63934. import { Texture } from "babylonjs/Materials/Textures/texture";
  63935. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63936. /**
  63937. * Class used to store 2D array textures containing user data
  63938. */
  63939. export class RawTexture2DArray extends Texture {
  63940. /** Gets or sets the texture format to use */
  63941. format: number;
  63942. /**
  63943. * Create a new RawTexture2DArray
  63944. * @param data defines the data of the texture
  63945. * @param width defines the width of the texture
  63946. * @param height defines the height of the texture
  63947. * @param depth defines the number of layers of the texture
  63948. * @param format defines the texture format to use
  63949. * @param scene defines the hosting scene
  63950. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63951. * @param invertY defines if texture must be stored with Y axis inverted
  63952. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63953. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63954. */
  63955. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63956. /** Gets or sets the texture format to use */
  63957. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63958. /**
  63959. * Update the texture with new data
  63960. * @param data defines the data to store in the texture
  63961. */
  63962. update(data: ArrayBufferView): void;
  63963. }
  63964. }
  63965. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63966. import { Scene } from "babylonjs/scene";
  63967. import { Texture } from "babylonjs/Materials/Textures/texture";
  63968. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63969. /**
  63970. * Class used to store 3D textures containing user data
  63971. */
  63972. export class RawTexture3D extends Texture {
  63973. /** Gets or sets the texture format to use */
  63974. format: number;
  63975. /**
  63976. * Create a new RawTexture3D
  63977. * @param data defines the data of the texture
  63978. * @param width defines the width of the texture
  63979. * @param height defines the height of the texture
  63980. * @param depth defines the depth of the texture
  63981. * @param format defines the texture format to use
  63982. * @param scene defines the hosting scene
  63983. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63984. * @param invertY defines if texture must be stored with Y axis inverted
  63985. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63986. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63987. */
  63988. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63989. /** Gets or sets the texture format to use */
  63990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63991. /**
  63992. * Update the texture with new data
  63993. * @param data defines the data to store in the texture
  63994. */
  63995. update(data: ArrayBufferView): void;
  63996. }
  63997. }
  63998. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63999. import { Scene } from "babylonjs/scene";
  64000. import { Plane } from "babylonjs/Maths/math.plane";
  64001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64002. /**
  64003. * Creates a refraction texture used by refraction channel of the standard material.
  64004. * It is like a mirror but to see through a material.
  64005. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64006. */
  64007. export class RefractionTexture extends RenderTargetTexture {
  64008. /**
  64009. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64010. * 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.
  64011. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64012. */
  64013. refractionPlane: Plane;
  64014. /**
  64015. * Define how deep under the surface we should see.
  64016. */
  64017. depth: number;
  64018. /**
  64019. * Creates a refraction texture used by refraction channel of the standard material.
  64020. * It is like a mirror but to see through a material.
  64021. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64022. * @param name Define the texture name
  64023. * @param size Define the size of the underlying texture
  64024. * @param scene Define the scene the refraction belongs to
  64025. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64026. */
  64027. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64028. /**
  64029. * Clone the refraction texture.
  64030. * @returns the cloned texture
  64031. */
  64032. clone(): RefractionTexture;
  64033. /**
  64034. * Serialize the texture to a JSON representation you could use in Parse later on
  64035. * @returns the serialized JSON representation
  64036. */
  64037. serialize(): any;
  64038. }
  64039. }
  64040. declare module "babylonjs/Materials/Textures/index" {
  64041. export * from "babylonjs/Materials/Textures/baseTexture";
  64042. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64043. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64044. export * from "babylonjs/Materials/Textures/cubeTexture";
  64045. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64046. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64047. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64048. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64049. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64050. export * from "babylonjs/Materials/Textures/internalTexture";
  64051. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64052. export * from "babylonjs/Materials/Textures/Loaders/index";
  64053. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64054. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64055. export * from "babylonjs/Materials/Textures/Packer/index";
  64056. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64057. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64058. export * from "babylonjs/Materials/Textures/rawTexture";
  64059. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64060. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64061. export * from "babylonjs/Materials/Textures/refractionTexture";
  64062. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64063. export * from "babylonjs/Materials/Textures/texture";
  64064. export * from "babylonjs/Materials/Textures/videoTexture";
  64065. }
  64066. declare module "babylonjs/Materials/Node/Enums/index" {
  64067. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64068. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64069. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64070. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64071. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64072. }
  64073. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64077. import { Mesh } from "babylonjs/Meshes/mesh";
  64078. import { Effect } from "babylonjs/Materials/effect";
  64079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64081. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64082. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64084. /**
  64085. * Block used to add support for vertex skinning (bones)
  64086. */
  64087. export class BonesBlock extends NodeMaterialBlock {
  64088. /**
  64089. * Creates a new BonesBlock
  64090. * @param name defines the block name
  64091. */
  64092. constructor(name: string);
  64093. /**
  64094. * Initialize the block and prepare the context for build
  64095. * @param state defines the state that will be used for the build
  64096. */
  64097. initialize(state: NodeMaterialBuildState): void;
  64098. /**
  64099. * Gets the current class name
  64100. * @returns the class name
  64101. */
  64102. getClassName(): string;
  64103. /**
  64104. * Gets the matrix indices input component
  64105. */
  64106. get matricesIndices(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the matrix weights input component
  64109. */
  64110. get matricesWeights(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the extra matrix indices input component
  64113. */
  64114. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64115. /**
  64116. * Gets the extra matrix weights input component
  64117. */
  64118. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64119. /**
  64120. * Gets the world input component
  64121. */
  64122. get world(): NodeMaterialConnectionPoint;
  64123. /**
  64124. * Gets the output component
  64125. */
  64126. get output(): NodeMaterialConnectionPoint;
  64127. autoConfigure(material: NodeMaterial): void;
  64128. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64129. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64131. protected _buildBlock(state: NodeMaterialBuildState): this;
  64132. }
  64133. }
  64134. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64139. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64140. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64141. /**
  64142. * Block used to add support for instances
  64143. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64144. */
  64145. export class InstancesBlock extends NodeMaterialBlock {
  64146. /**
  64147. * Creates a new InstancesBlock
  64148. * @param name defines the block name
  64149. */
  64150. constructor(name: string);
  64151. /**
  64152. * Gets the current class name
  64153. * @returns the class name
  64154. */
  64155. getClassName(): string;
  64156. /**
  64157. * Gets the first world row input component
  64158. */
  64159. get world0(): NodeMaterialConnectionPoint;
  64160. /**
  64161. * Gets the second world row input component
  64162. */
  64163. get world1(): NodeMaterialConnectionPoint;
  64164. /**
  64165. * Gets the third world row input component
  64166. */
  64167. get world2(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Gets the forth world row input component
  64170. */
  64171. get world3(): NodeMaterialConnectionPoint;
  64172. /**
  64173. * Gets the world input component
  64174. */
  64175. get world(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the output component
  64178. */
  64179. get output(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the isntanceID component
  64182. */
  64183. get instanceID(): NodeMaterialConnectionPoint;
  64184. autoConfigure(material: NodeMaterial): void;
  64185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64186. protected _buildBlock(state: NodeMaterialBuildState): this;
  64187. }
  64188. }
  64189. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64195. import { Effect } from "babylonjs/Materials/effect";
  64196. import { Mesh } from "babylonjs/Meshes/mesh";
  64197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64199. /**
  64200. * Block used to add morph targets support to vertex shader
  64201. */
  64202. export class MorphTargetsBlock extends NodeMaterialBlock {
  64203. private _repeatableContentAnchor;
  64204. /**
  64205. * Create a new MorphTargetsBlock
  64206. * @param name defines the block name
  64207. */
  64208. constructor(name: string);
  64209. /**
  64210. * Gets the current class name
  64211. * @returns the class name
  64212. */
  64213. getClassName(): string;
  64214. /**
  64215. * Gets the position input component
  64216. */
  64217. get position(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the normal input component
  64220. */
  64221. get normal(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the tangent input component
  64224. */
  64225. get tangent(): NodeMaterialConnectionPoint;
  64226. /**
  64227. * Gets the tangent input component
  64228. */
  64229. get uv(): NodeMaterialConnectionPoint;
  64230. /**
  64231. * Gets the position output component
  64232. */
  64233. get positionOutput(): NodeMaterialConnectionPoint;
  64234. /**
  64235. * Gets the normal output component
  64236. */
  64237. get normalOutput(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the tangent output component
  64240. */
  64241. get tangentOutput(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the tangent output component
  64244. */
  64245. get uvOutput(): NodeMaterialConnectionPoint;
  64246. initialize(state: NodeMaterialBuildState): void;
  64247. autoConfigure(material: NodeMaterial): void;
  64248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64250. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64251. protected _buildBlock(state: NodeMaterialBuildState): this;
  64252. }
  64253. }
  64254. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64258. import { Nullable } from "babylonjs/types";
  64259. import { Scene } from "babylonjs/scene";
  64260. import { Effect } from "babylonjs/Materials/effect";
  64261. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64262. import { Mesh } from "babylonjs/Meshes/mesh";
  64263. import { Light } from "babylonjs/Lights/light";
  64264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64265. /**
  64266. * Block used to get data information from a light
  64267. */
  64268. export class LightInformationBlock extends NodeMaterialBlock {
  64269. private _lightDataUniformName;
  64270. private _lightColorUniformName;
  64271. private _lightTypeDefineName;
  64272. /**
  64273. * Gets or sets the light associated with this block
  64274. */
  64275. light: Nullable<Light>;
  64276. /**
  64277. * Creates a new LightInformationBlock
  64278. * @param name defines the block name
  64279. */
  64280. constructor(name: string);
  64281. /**
  64282. * Gets the current class name
  64283. * @returns the class name
  64284. */
  64285. getClassName(): string;
  64286. /**
  64287. * Gets the world position input component
  64288. */
  64289. get worldPosition(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the direction output component
  64292. */
  64293. get direction(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the direction output component
  64296. */
  64297. get color(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the direction output component
  64300. */
  64301. get intensity(): NodeMaterialConnectionPoint;
  64302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64304. protected _buildBlock(state: NodeMaterialBuildState): this;
  64305. serialize(): any;
  64306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64307. }
  64308. }
  64309. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64310. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64311. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64312. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64313. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64314. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64315. }
  64316. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64321. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64322. import { Effect } from "babylonjs/Materials/effect";
  64323. import { Mesh } from "babylonjs/Meshes/mesh";
  64324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64325. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64326. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64327. /**
  64328. * Block used to add image processing support to fragment shader
  64329. */
  64330. export class ImageProcessingBlock extends NodeMaterialBlock {
  64331. /**
  64332. * Create a new ImageProcessingBlock
  64333. * @param name defines the block name
  64334. */
  64335. constructor(name: string);
  64336. /**
  64337. * Gets the current class name
  64338. * @returns the class name
  64339. */
  64340. getClassName(): string;
  64341. /**
  64342. * Gets the color input component
  64343. */
  64344. get color(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the output component
  64347. */
  64348. get output(): NodeMaterialConnectionPoint;
  64349. /**
  64350. * Initialize the block and prepare the context for build
  64351. * @param state defines the state that will be used for the build
  64352. */
  64353. initialize(state: NodeMaterialBuildState): void;
  64354. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64357. protected _buildBlock(state: NodeMaterialBuildState): this;
  64358. }
  64359. }
  64360. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64364. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64366. import { Effect } from "babylonjs/Materials/effect";
  64367. import { Mesh } from "babylonjs/Meshes/mesh";
  64368. import { Scene } from "babylonjs/scene";
  64369. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64370. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64371. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64372. /**
  64373. * Block used to pertub normals based on a normal map
  64374. */
  64375. export class PerturbNormalBlock extends NodeMaterialBlock {
  64376. private _tangentSpaceParameterName;
  64377. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64378. invertX: boolean;
  64379. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64380. invertY: boolean;
  64381. /**
  64382. * Create a new PerturbNormalBlock
  64383. * @param name defines the block name
  64384. */
  64385. constructor(name: string);
  64386. /**
  64387. * Gets the current class name
  64388. * @returns the class name
  64389. */
  64390. getClassName(): string;
  64391. /**
  64392. * Gets the world position input component
  64393. */
  64394. get worldPosition(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the world normal input component
  64397. */
  64398. get worldNormal(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the world tangent input component
  64401. */
  64402. get worldTangent(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the uv input component
  64405. */
  64406. get uv(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the normal map color input component
  64409. */
  64410. get normalMapColor(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the strength input component
  64413. */
  64414. get strength(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the output component
  64417. */
  64418. get output(): NodeMaterialConnectionPoint;
  64419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64421. autoConfigure(material: NodeMaterial): void;
  64422. protected _buildBlock(state: NodeMaterialBuildState): this;
  64423. protected _dumpPropertiesCode(): string;
  64424. serialize(): any;
  64425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64426. }
  64427. }
  64428. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64432. /**
  64433. * Block used to discard a pixel if a value is smaller than a cutoff
  64434. */
  64435. export class DiscardBlock extends NodeMaterialBlock {
  64436. /**
  64437. * Create a new DiscardBlock
  64438. * @param name defines the block name
  64439. */
  64440. constructor(name: string);
  64441. /**
  64442. * Gets the current class name
  64443. * @returns the class name
  64444. */
  64445. getClassName(): string;
  64446. /**
  64447. * Gets the color input component
  64448. */
  64449. get value(): NodeMaterialConnectionPoint;
  64450. /**
  64451. * Gets the cutoff input component
  64452. */
  64453. get cutoff(): NodeMaterialConnectionPoint;
  64454. protected _buildBlock(state: NodeMaterialBuildState): this;
  64455. }
  64456. }
  64457. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64461. /**
  64462. * Block used to test if the fragment shader is front facing
  64463. */
  64464. export class FrontFacingBlock extends NodeMaterialBlock {
  64465. /**
  64466. * Creates a new FrontFacingBlock
  64467. * @param name defines the block name
  64468. */
  64469. constructor(name: string);
  64470. /**
  64471. * Gets the current class name
  64472. * @returns the class name
  64473. */
  64474. getClassName(): string;
  64475. /**
  64476. * Gets the output component
  64477. */
  64478. get output(): NodeMaterialConnectionPoint;
  64479. protected _buildBlock(state: NodeMaterialBuildState): this;
  64480. }
  64481. }
  64482. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64486. /**
  64487. * Block used to get the derivative value on x and y of a given input
  64488. */
  64489. export class DerivativeBlock extends NodeMaterialBlock {
  64490. /**
  64491. * Create a new DerivativeBlock
  64492. * @param name defines the block name
  64493. */
  64494. constructor(name: string);
  64495. /**
  64496. * Gets the current class name
  64497. * @returns the class name
  64498. */
  64499. getClassName(): string;
  64500. /**
  64501. * Gets the input component
  64502. */
  64503. get input(): NodeMaterialConnectionPoint;
  64504. /**
  64505. * Gets the derivative output on x
  64506. */
  64507. get dx(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the derivative output on y
  64510. */
  64511. get dy(): NodeMaterialConnectionPoint;
  64512. protected _buildBlock(state: NodeMaterialBuildState): this;
  64513. }
  64514. }
  64515. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64519. /**
  64520. * Block used to make gl_FragCoord available
  64521. */
  64522. export class FragCoordBlock extends NodeMaterialBlock {
  64523. /**
  64524. * Creates a new FragCoordBlock
  64525. * @param name defines the block name
  64526. */
  64527. constructor(name: string);
  64528. /**
  64529. * Gets the current class name
  64530. * @returns the class name
  64531. */
  64532. getClassName(): string;
  64533. /**
  64534. * Gets the xy component
  64535. */
  64536. get xy(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the xyz component
  64539. */
  64540. get xyz(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the xyzw component
  64543. */
  64544. get xyzw(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the x component
  64547. */
  64548. get x(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the y component
  64551. */
  64552. get y(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the z component
  64555. */
  64556. get z(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the w component
  64559. */
  64560. get output(): NodeMaterialConnectionPoint;
  64561. protected writeOutputs(state: NodeMaterialBuildState): string;
  64562. protected _buildBlock(state: NodeMaterialBuildState): this;
  64563. }
  64564. }
  64565. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64569. import { Effect } from "babylonjs/Materials/effect";
  64570. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64571. import { Mesh } from "babylonjs/Meshes/mesh";
  64572. /**
  64573. * Block used to get the screen sizes
  64574. */
  64575. export class ScreenSizeBlock extends NodeMaterialBlock {
  64576. private _varName;
  64577. private _scene;
  64578. /**
  64579. * Creates a new ScreenSizeBlock
  64580. * @param name defines the block name
  64581. */
  64582. constructor(name: string);
  64583. /**
  64584. * Gets the current class name
  64585. * @returns the class name
  64586. */
  64587. getClassName(): string;
  64588. /**
  64589. * Gets the xy component
  64590. */
  64591. get xy(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the x component
  64594. */
  64595. get x(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the y component
  64598. */
  64599. get y(): NodeMaterialConnectionPoint;
  64600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64601. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64602. protected _buildBlock(state: NodeMaterialBuildState): this;
  64603. }
  64604. }
  64605. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64606. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64607. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64608. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64609. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64610. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64611. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64612. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64613. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64614. }
  64615. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64618. import { Mesh } from "babylonjs/Meshes/mesh";
  64619. import { Effect } from "babylonjs/Materials/effect";
  64620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64622. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64623. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64624. /**
  64625. * Block used to add support for scene fog
  64626. */
  64627. export class FogBlock extends NodeMaterialBlock {
  64628. private _fogDistanceName;
  64629. private _fogParameters;
  64630. /**
  64631. * Create a new FogBlock
  64632. * @param name defines the block name
  64633. */
  64634. constructor(name: string);
  64635. /**
  64636. * Gets the current class name
  64637. * @returns the class name
  64638. */
  64639. getClassName(): string;
  64640. /**
  64641. * Gets the world position input component
  64642. */
  64643. get worldPosition(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the view input component
  64646. */
  64647. get view(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the color input component
  64650. */
  64651. get input(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the fog color input component
  64654. */
  64655. get fogColor(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the output component
  64658. */
  64659. get output(): NodeMaterialConnectionPoint;
  64660. autoConfigure(material: NodeMaterial): void;
  64661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64663. protected _buildBlock(state: NodeMaterialBuildState): this;
  64664. }
  64665. }
  64666. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64671. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64672. import { Effect } from "babylonjs/Materials/effect";
  64673. import { Mesh } from "babylonjs/Meshes/mesh";
  64674. import { Light } from "babylonjs/Lights/light";
  64675. import { Nullable } from "babylonjs/types";
  64676. import { Scene } from "babylonjs/scene";
  64677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64679. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64680. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64681. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64682. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64683. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64684. /**
  64685. * Block used to add light in the fragment shader
  64686. */
  64687. export class LightBlock extends NodeMaterialBlock {
  64688. private _lightId;
  64689. /**
  64690. * Gets or sets the light associated with this block
  64691. */
  64692. light: Nullable<Light>;
  64693. /**
  64694. * Create a new LightBlock
  64695. * @param name defines the block name
  64696. */
  64697. constructor(name: string);
  64698. /**
  64699. * Gets the current class name
  64700. * @returns the class name
  64701. */
  64702. getClassName(): string;
  64703. /**
  64704. * Gets the world position input component
  64705. */
  64706. get worldPosition(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the world normal input component
  64709. */
  64710. get worldNormal(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the camera (or eye) position component
  64713. */
  64714. get cameraPosition(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the glossiness component
  64717. */
  64718. get glossiness(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the glossinness power component
  64721. */
  64722. get glossPower(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the diffuse color component
  64725. */
  64726. get diffuseColor(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the specular color component
  64729. */
  64730. get specularColor(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the diffuse output component
  64733. */
  64734. get diffuseOutput(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the specular output component
  64737. */
  64738. get specularOutput(): NodeMaterialConnectionPoint;
  64739. /**
  64740. * Gets the shadow output component
  64741. */
  64742. get shadow(): NodeMaterialConnectionPoint;
  64743. autoConfigure(material: NodeMaterial): void;
  64744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64745. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64747. private _injectVertexCode;
  64748. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64749. serialize(): any;
  64750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64751. }
  64752. }
  64753. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64756. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64757. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64758. /**
  64759. * Block used to read a reflection texture from a sampler
  64760. */
  64761. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64762. /**
  64763. * Create a new ReflectionTextureBlock
  64764. * @param name defines the block name
  64765. */
  64766. constructor(name: string);
  64767. /**
  64768. * Gets the current class name
  64769. * @returns the class name
  64770. */
  64771. getClassName(): string;
  64772. /**
  64773. * Gets the world position input component
  64774. */
  64775. get position(): NodeMaterialConnectionPoint;
  64776. /**
  64777. * Gets the world position input component
  64778. */
  64779. get worldPosition(): NodeMaterialConnectionPoint;
  64780. /**
  64781. * Gets the world normal input component
  64782. */
  64783. get worldNormal(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the world input component
  64786. */
  64787. get world(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the camera (or eye) position component
  64790. */
  64791. get cameraPosition(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the view input component
  64794. */
  64795. get view(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the rgb output component
  64798. */
  64799. get rgb(): NodeMaterialConnectionPoint;
  64800. /**
  64801. * Gets the rgba output component
  64802. */
  64803. get rgba(): NodeMaterialConnectionPoint;
  64804. /**
  64805. * Gets the r output component
  64806. */
  64807. get r(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the g output component
  64810. */
  64811. get g(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the b output component
  64814. */
  64815. get b(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the a output component
  64818. */
  64819. get a(): NodeMaterialConnectionPoint;
  64820. autoConfigure(material: NodeMaterial): void;
  64821. protected _buildBlock(state: NodeMaterialBuildState): this;
  64822. }
  64823. }
  64824. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64825. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64826. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64827. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64828. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64829. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64830. }
  64831. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64832. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64833. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64834. }
  64835. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64839. /**
  64840. * Block used to add 2 vectors
  64841. */
  64842. export class AddBlock extends NodeMaterialBlock {
  64843. /**
  64844. * Creates a new AddBlock
  64845. * @param name defines the block name
  64846. */
  64847. constructor(name: string);
  64848. /**
  64849. * Gets the current class name
  64850. * @returns the class name
  64851. */
  64852. getClassName(): string;
  64853. /**
  64854. * Gets the left operand input component
  64855. */
  64856. get left(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the right operand input component
  64859. */
  64860. get right(): NodeMaterialConnectionPoint;
  64861. /**
  64862. * Gets the output component
  64863. */
  64864. get output(): NodeMaterialConnectionPoint;
  64865. protected _buildBlock(state: NodeMaterialBuildState): this;
  64866. }
  64867. }
  64868. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64872. /**
  64873. * Block used to scale a vector by a float
  64874. */
  64875. export class ScaleBlock extends NodeMaterialBlock {
  64876. /**
  64877. * Creates a new ScaleBlock
  64878. * @param name defines the block name
  64879. */
  64880. constructor(name: string);
  64881. /**
  64882. * Gets the current class name
  64883. * @returns the class name
  64884. */
  64885. getClassName(): string;
  64886. /**
  64887. * Gets the input component
  64888. */
  64889. get input(): NodeMaterialConnectionPoint;
  64890. /**
  64891. * Gets the factor input component
  64892. */
  64893. get factor(): NodeMaterialConnectionPoint;
  64894. /**
  64895. * Gets the output component
  64896. */
  64897. get output(): NodeMaterialConnectionPoint;
  64898. protected _buildBlock(state: NodeMaterialBuildState): this;
  64899. }
  64900. }
  64901. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64905. import { Scene } from "babylonjs/scene";
  64906. /**
  64907. * Block used to clamp a float
  64908. */
  64909. export class ClampBlock extends NodeMaterialBlock {
  64910. /** Gets or sets the minimum range */
  64911. minimum: number;
  64912. /** Gets or sets the maximum range */
  64913. maximum: number;
  64914. /**
  64915. * Creates a new ClampBlock
  64916. * @param name defines the block name
  64917. */
  64918. constructor(name: string);
  64919. /**
  64920. * Gets the current class name
  64921. * @returns the class name
  64922. */
  64923. getClassName(): string;
  64924. /**
  64925. * Gets the value input component
  64926. */
  64927. get value(): NodeMaterialConnectionPoint;
  64928. /**
  64929. * Gets the output component
  64930. */
  64931. get output(): NodeMaterialConnectionPoint;
  64932. protected _buildBlock(state: NodeMaterialBuildState): this;
  64933. protected _dumpPropertiesCode(): string;
  64934. serialize(): any;
  64935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64936. }
  64937. }
  64938. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64942. /**
  64943. * Block used to apply a cross product between 2 vectors
  64944. */
  64945. export class CrossBlock extends NodeMaterialBlock {
  64946. /**
  64947. * Creates a new CrossBlock
  64948. * @param name defines the block name
  64949. */
  64950. constructor(name: string);
  64951. /**
  64952. * Gets the current class name
  64953. * @returns the class name
  64954. */
  64955. getClassName(): string;
  64956. /**
  64957. * Gets the left operand input component
  64958. */
  64959. get left(): NodeMaterialConnectionPoint;
  64960. /**
  64961. * Gets the right operand input component
  64962. */
  64963. get right(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the output component
  64966. */
  64967. get output(): NodeMaterialConnectionPoint;
  64968. protected _buildBlock(state: NodeMaterialBuildState): this;
  64969. }
  64970. }
  64971. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64975. /**
  64976. * Block used to apply a dot product between 2 vectors
  64977. */
  64978. export class DotBlock extends NodeMaterialBlock {
  64979. /**
  64980. * Creates a new DotBlock
  64981. * @param name defines the block name
  64982. */
  64983. constructor(name: string);
  64984. /**
  64985. * Gets the current class name
  64986. * @returns the class name
  64987. */
  64988. getClassName(): string;
  64989. /**
  64990. * Gets the left operand input component
  64991. */
  64992. get left(): NodeMaterialConnectionPoint;
  64993. /**
  64994. * Gets the right operand input component
  64995. */
  64996. get right(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Gets the output component
  64999. */
  65000. get output(): NodeMaterialConnectionPoint;
  65001. protected _buildBlock(state: NodeMaterialBuildState): this;
  65002. }
  65003. }
  65004. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65008. /**
  65009. * Block used to normalize a vector
  65010. */
  65011. export class NormalizeBlock extends NodeMaterialBlock {
  65012. /**
  65013. * Creates a new NormalizeBlock
  65014. * @param name defines the block name
  65015. */
  65016. constructor(name: string);
  65017. /**
  65018. * Gets the current class name
  65019. * @returns the class name
  65020. */
  65021. getClassName(): string;
  65022. /**
  65023. * Gets the input component
  65024. */
  65025. get input(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the output component
  65028. */
  65029. get output(): NodeMaterialConnectionPoint;
  65030. protected _buildBlock(state: NodeMaterialBuildState): this;
  65031. }
  65032. }
  65033. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65037. import { Scene } from "babylonjs/scene";
  65038. /**
  65039. * Operations supported by the Trigonometry block
  65040. */
  65041. export enum TrigonometryBlockOperations {
  65042. /** Cos */
  65043. Cos = 0,
  65044. /** Sin */
  65045. Sin = 1,
  65046. /** Abs */
  65047. Abs = 2,
  65048. /** Exp */
  65049. Exp = 3,
  65050. /** Exp2 */
  65051. Exp2 = 4,
  65052. /** Round */
  65053. Round = 5,
  65054. /** Floor */
  65055. Floor = 6,
  65056. /** Ceiling */
  65057. Ceiling = 7,
  65058. /** Square root */
  65059. Sqrt = 8,
  65060. /** Log */
  65061. Log = 9,
  65062. /** Tangent */
  65063. Tan = 10,
  65064. /** Arc tangent */
  65065. ArcTan = 11,
  65066. /** Arc cosinus */
  65067. ArcCos = 12,
  65068. /** Arc sinus */
  65069. ArcSin = 13,
  65070. /** Fraction */
  65071. Fract = 14,
  65072. /** Sign */
  65073. Sign = 15,
  65074. /** To radians (from degrees) */
  65075. Radians = 16,
  65076. /** To degrees (from radians) */
  65077. Degrees = 17
  65078. }
  65079. /**
  65080. * Block used to apply trigonometry operation to floats
  65081. */
  65082. export class TrigonometryBlock extends NodeMaterialBlock {
  65083. /**
  65084. * Gets or sets the operation applied by the block
  65085. */
  65086. operation: TrigonometryBlockOperations;
  65087. /**
  65088. * Creates a new TrigonometryBlock
  65089. * @param name defines the block name
  65090. */
  65091. constructor(name: string);
  65092. /**
  65093. * Gets the current class name
  65094. * @returns the class name
  65095. */
  65096. getClassName(): string;
  65097. /**
  65098. * Gets the input component
  65099. */
  65100. get input(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the output component
  65103. */
  65104. get output(): NodeMaterialConnectionPoint;
  65105. protected _buildBlock(state: NodeMaterialBuildState): this;
  65106. serialize(): any;
  65107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65108. protected _dumpPropertiesCode(): string;
  65109. }
  65110. }
  65111. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65115. /**
  65116. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65117. */
  65118. export class ColorMergerBlock extends NodeMaterialBlock {
  65119. /**
  65120. * Create a new ColorMergerBlock
  65121. * @param name defines the block name
  65122. */
  65123. constructor(name: string);
  65124. /**
  65125. * Gets the current class name
  65126. * @returns the class name
  65127. */
  65128. getClassName(): string;
  65129. /**
  65130. * Gets the rgb component (input)
  65131. */
  65132. get rgbIn(): NodeMaterialConnectionPoint;
  65133. /**
  65134. * Gets the r component (input)
  65135. */
  65136. get r(): NodeMaterialConnectionPoint;
  65137. /**
  65138. * Gets the g component (input)
  65139. */
  65140. get g(): NodeMaterialConnectionPoint;
  65141. /**
  65142. * Gets the b component (input)
  65143. */
  65144. get b(): NodeMaterialConnectionPoint;
  65145. /**
  65146. * Gets the a component (input)
  65147. */
  65148. get a(): NodeMaterialConnectionPoint;
  65149. /**
  65150. * Gets the rgba component (output)
  65151. */
  65152. get rgba(): NodeMaterialConnectionPoint;
  65153. /**
  65154. * Gets the rgb component (output)
  65155. */
  65156. get rgbOut(): NodeMaterialConnectionPoint;
  65157. /**
  65158. * Gets the rgb component (output)
  65159. * @deprecated Please use rgbOut instead.
  65160. */
  65161. get rgb(): NodeMaterialConnectionPoint;
  65162. protected _buildBlock(state: NodeMaterialBuildState): this;
  65163. }
  65164. }
  65165. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65169. /**
  65170. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65171. */
  65172. export class VectorSplitterBlock extends NodeMaterialBlock {
  65173. /**
  65174. * Create a new VectorSplitterBlock
  65175. * @param name defines the block name
  65176. */
  65177. constructor(name: string);
  65178. /**
  65179. * Gets the current class name
  65180. * @returns the class name
  65181. */
  65182. getClassName(): string;
  65183. /**
  65184. * Gets the xyzw component (input)
  65185. */
  65186. get xyzw(): NodeMaterialConnectionPoint;
  65187. /**
  65188. * Gets the xyz component (input)
  65189. */
  65190. get xyzIn(): NodeMaterialConnectionPoint;
  65191. /**
  65192. * Gets the xy component (input)
  65193. */
  65194. get xyIn(): NodeMaterialConnectionPoint;
  65195. /**
  65196. * Gets the xyz component (output)
  65197. */
  65198. get xyzOut(): NodeMaterialConnectionPoint;
  65199. /**
  65200. * Gets the xy component (output)
  65201. */
  65202. get xyOut(): NodeMaterialConnectionPoint;
  65203. /**
  65204. * Gets the x component (output)
  65205. */
  65206. get x(): NodeMaterialConnectionPoint;
  65207. /**
  65208. * Gets the y component (output)
  65209. */
  65210. get y(): NodeMaterialConnectionPoint;
  65211. /**
  65212. * Gets the z component (output)
  65213. */
  65214. get z(): NodeMaterialConnectionPoint;
  65215. /**
  65216. * Gets the w component (output)
  65217. */
  65218. get w(): NodeMaterialConnectionPoint;
  65219. protected _inputRename(name: string): string;
  65220. protected _outputRename(name: string): string;
  65221. protected _buildBlock(state: NodeMaterialBuildState): this;
  65222. }
  65223. }
  65224. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65228. /**
  65229. * Block used to lerp between 2 values
  65230. */
  65231. export class LerpBlock extends NodeMaterialBlock {
  65232. /**
  65233. * Creates a new LerpBlock
  65234. * @param name defines the block name
  65235. */
  65236. constructor(name: string);
  65237. /**
  65238. * Gets the current class name
  65239. * @returns the class name
  65240. */
  65241. getClassName(): string;
  65242. /**
  65243. * Gets the left operand input component
  65244. */
  65245. get left(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the right operand input component
  65248. */
  65249. get right(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the gradient operand input component
  65252. */
  65253. get gradient(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the output component
  65256. */
  65257. get output(): NodeMaterialConnectionPoint;
  65258. protected _buildBlock(state: NodeMaterialBuildState): this;
  65259. }
  65260. }
  65261. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65265. /**
  65266. * Block used to divide 2 vectors
  65267. */
  65268. export class DivideBlock extends NodeMaterialBlock {
  65269. /**
  65270. * Creates a new DivideBlock
  65271. * @param name defines the block name
  65272. */
  65273. constructor(name: string);
  65274. /**
  65275. * Gets the current class name
  65276. * @returns the class name
  65277. */
  65278. getClassName(): string;
  65279. /**
  65280. * Gets the left operand input component
  65281. */
  65282. get left(): NodeMaterialConnectionPoint;
  65283. /**
  65284. * Gets the right operand input component
  65285. */
  65286. get right(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the output component
  65289. */
  65290. get output(): NodeMaterialConnectionPoint;
  65291. protected _buildBlock(state: NodeMaterialBuildState): this;
  65292. }
  65293. }
  65294. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65298. /**
  65299. * Block used to subtract 2 vectors
  65300. */
  65301. export class SubtractBlock extends NodeMaterialBlock {
  65302. /**
  65303. * Creates a new SubtractBlock
  65304. * @param name defines the block name
  65305. */
  65306. constructor(name: string);
  65307. /**
  65308. * Gets the current class name
  65309. * @returns the class name
  65310. */
  65311. getClassName(): string;
  65312. /**
  65313. * Gets the left operand input component
  65314. */
  65315. get left(): NodeMaterialConnectionPoint;
  65316. /**
  65317. * Gets the right operand input component
  65318. */
  65319. get right(): NodeMaterialConnectionPoint;
  65320. /**
  65321. * Gets the output component
  65322. */
  65323. get output(): NodeMaterialConnectionPoint;
  65324. protected _buildBlock(state: NodeMaterialBuildState): this;
  65325. }
  65326. }
  65327. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65331. /**
  65332. * Block used to step a value
  65333. */
  65334. export class StepBlock extends NodeMaterialBlock {
  65335. /**
  65336. * Creates a new StepBlock
  65337. * @param name defines the block name
  65338. */
  65339. constructor(name: string);
  65340. /**
  65341. * Gets the current class name
  65342. * @returns the class name
  65343. */
  65344. getClassName(): string;
  65345. /**
  65346. * Gets the value operand input component
  65347. */
  65348. get value(): NodeMaterialConnectionPoint;
  65349. /**
  65350. * Gets the edge operand input component
  65351. */
  65352. get edge(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the output component
  65355. */
  65356. get output(): NodeMaterialConnectionPoint;
  65357. protected _buildBlock(state: NodeMaterialBuildState): this;
  65358. }
  65359. }
  65360. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65364. /**
  65365. * Block used to get the opposite (1 - x) of a value
  65366. */
  65367. export class OneMinusBlock extends NodeMaterialBlock {
  65368. /**
  65369. * Creates a new OneMinusBlock
  65370. * @param name defines the block name
  65371. */
  65372. constructor(name: string);
  65373. /**
  65374. * Gets the current class name
  65375. * @returns the class name
  65376. */
  65377. getClassName(): string;
  65378. /**
  65379. * Gets the input component
  65380. */
  65381. get input(): NodeMaterialConnectionPoint;
  65382. /**
  65383. * Gets the output component
  65384. */
  65385. get output(): NodeMaterialConnectionPoint;
  65386. protected _buildBlock(state: NodeMaterialBuildState): this;
  65387. }
  65388. }
  65389. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65394. /**
  65395. * Block used to get the view direction
  65396. */
  65397. export class ViewDirectionBlock extends NodeMaterialBlock {
  65398. /**
  65399. * Creates a new ViewDirectionBlock
  65400. * @param name defines the block name
  65401. */
  65402. constructor(name: string);
  65403. /**
  65404. * Gets the current class name
  65405. * @returns the class name
  65406. */
  65407. getClassName(): string;
  65408. /**
  65409. * Gets the world position component
  65410. */
  65411. get worldPosition(): NodeMaterialConnectionPoint;
  65412. /**
  65413. * Gets the camera position component
  65414. */
  65415. get cameraPosition(): NodeMaterialConnectionPoint;
  65416. /**
  65417. * Gets the output component
  65418. */
  65419. get output(): NodeMaterialConnectionPoint;
  65420. autoConfigure(material: NodeMaterial): void;
  65421. protected _buildBlock(state: NodeMaterialBuildState): this;
  65422. }
  65423. }
  65424. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65428. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65429. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65430. /**
  65431. * Block used to compute fresnel value
  65432. */
  65433. export class FresnelBlock extends NodeMaterialBlock {
  65434. /**
  65435. * Create a new FresnelBlock
  65436. * @param name defines the block name
  65437. */
  65438. constructor(name: string);
  65439. /**
  65440. * Gets the current class name
  65441. * @returns the class name
  65442. */
  65443. getClassName(): string;
  65444. /**
  65445. * Gets the world normal input component
  65446. */
  65447. get worldNormal(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the view direction input component
  65450. */
  65451. get viewDirection(): NodeMaterialConnectionPoint;
  65452. /**
  65453. * Gets the bias input component
  65454. */
  65455. get bias(): NodeMaterialConnectionPoint;
  65456. /**
  65457. * Gets the camera (or eye) position component
  65458. */
  65459. get power(): NodeMaterialConnectionPoint;
  65460. /**
  65461. * Gets the fresnel output component
  65462. */
  65463. get fresnel(): NodeMaterialConnectionPoint;
  65464. autoConfigure(material: NodeMaterial): void;
  65465. protected _buildBlock(state: NodeMaterialBuildState): this;
  65466. }
  65467. }
  65468. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65472. /**
  65473. * Block used to get the max of 2 values
  65474. */
  65475. export class MaxBlock extends NodeMaterialBlock {
  65476. /**
  65477. * Creates a new MaxBlock
  65478. * @param name defines the block name
  65479. */
  65480. constructor(name: string);
  65481. /**
  65482. * Gets the current class name
  65483. * @returns the class name
  65484. */
  65485. getClassName(): string;
  65486. /**
  65487. * Gets the left operand input component
  65488. */
  65489. get left(): NodeMaterialConnectionPoint;
  65490. /**
  65491. * Gets the right operand input component
  65492. */
  65493. get right(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the output component
  65496. */
  65497. get output(): NodeMaterialConnectionPoint;
  65498. protected _buildBlock(state: NodeMaterialBuildState): this;
  65499. }
  65500. }
  65501. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65505. /**
  65506. * Block used to get the min of 2 values
  65507. */
  65508. export class MinBlock extends NodeMaterialBlock {
  65509. /**
  65510. * Creates a new MinBlock
  65511. * @param name defines the block name
  65512. */
  65513. constructor(name: string);
  65514. /**
  65515. * Gets the current class name
  65516. * @returns the class name
  65517. */
  65518. getClassName(): string;
  65519. /**
  65520. * Gets the left operand input component
  65521. */
  65522. get left(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the right operand input component
  65525. */
  65526. get right(): NodeMaterialConnectionPoint;
  65527. /**
  65528. * Gets the output component
  65529. */
  65530. get output(): NodeMaterialConnectionPoint;
  65531. protected _buildBlock(state: NodeMaterialBuildState): this;
  65532. }
  65533. }
  65534. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65538. /**
  65539. * Block used to get the distance between 2 values
  65540. */
  65541. export class DistanceBlock extends NodeMaterialBlock {
  65542. /**
  65543. * Creates a new DistanceBlock
  65544. * @param name defines the block name
  65545. */
  65546. constructor(name: string);
  65547. /**
  65548. * Gets the current class name
  65549. * @returns the class name
  65550. */
  65551. getClassName(): string;
  65552. /**
  65553. * Gets the left operand input component
  65554. */
  65555. get left(): NodeMaterialConnectionPoint;
  65556. /**
  65557. * Gets the right operand input component
  65558. */
  65559. get right(): NodeMaterialConnectionPoint;
  65560. /**
  65561. * Gets the output component
  65562. */
  65563. get output(): NodeMaterialConnectionPoint;
  65564. protected _buildBlock(state: NodeMaterialBuildState): this;
  65565. }
  65566. }
  65567. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65571. /**
  65572. * Block used to get the length of a vector
  65573. */
  65574. export class LengthBlock extends NodeMaterialBlock {
  65575. /**
  65576. * Creates a new LengthBlock
  65577. * @param name defines the block name
  65578. */
  65579. constructor(name: string);
  65580. /**
  65581. * Gets the current class name
  65582. * @returns the class name
  65583. */
  65584. getClassName(): string;
  65585. /**
  65586. * Gets the value input component
  65587. */
  65588. get value(): NodeMaterialConnectionPoint;
  65589. /**
  65590. * Gets the output component
  65591. */
  65592. get output(): NodeMaterialConnectionPoint;
  65593. protected _buildBlock(state: NodeMaterialBuildState): this;
  65594. }
  65595. }
  65596. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65600. /**
  65601. * Block used to get negative version of a value (i.e. x * -1)
  65602. */
  65603. export class NegateBlock extends NodeMaterialBlock {
  65604. /**
  65605. * Creates a new NegateBlock
  65606. * @param name defines the block name
  65607. */
  65608. constructor(name: string);
  65609. /**
  65610. * Gets the current class name
  65611. * @returns the class name
  65612. */
  65613. getClassName(): string;
  65614. /**
  65615. * Gets the value input component
  65616. */
  65617. get value(): NodeMaterialConnectionPoint;
  65618. /**
  65619. * Gets the output component
  65620. */
  65621. get output(): NodeMaterialConnectionPoint;
  65622. protected _buildBlock(state: NodeMaterialBuildState): this;
  65623. }
  65624. }
  65625. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65629. /**
  65630. * Block used to get the value of the first parameter raised to the power of the second
  65631. */
  65632. export class PowBlock extends NodeMaterialBlock {
  65633. /**
  65634. * Creates a new PowBlock
  65635. * @param name defines the block name
  65636. */
  65637. constructor(name: string);
  65638. /**
  65639. * Gets the current class name
  65640. * @returns the class name
  65641. */
  65642. getClassName(): string;
  65643. /**
  65644. * Gets the value operand input component
  65645. */
  65646. get value(): NodeMaterialConnectionPoint;
  65647. /**
  65648. * Gets the power operand input component
  65649. */
  65650. get power(): NodeMaterialConnectionPoint;
  65651. /**
  65652. * Gets the output component
  65653. */
  65654. get output(): NodeMaterialConnectionPoint;
  65655. protected _buildBlock(state: NodeMaterialBuildState): this;
  65656. }
  65657. }
  65658. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65663. /**
  65664. * Block used to get a random number
  65665. */
  65666. export class RandomNumberBlock extends NodeMaterialBlock {
  65667. /**
  65668. * Creates a new RandomNumberBlock
  65669. * @param name defines the block name
  65670. */
  65671. constructor(name: string);
  65672. /**
  65673. * Gets the current class name
  65674. * @returns the class name
  65675. */
  65676. getClassName(): string;
  65677. /**
  65678. * Gets the seed input component
  65679. */
  65680. get seed(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the output component
  65683. */
  65684. get output(): NodeMaterialConnectionPoint;
  65685. protected _buildBlock(state: NodeMaterialBuildState): this;
  65686. }
  65687. }
  65688. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65692. /**
  65693. * Block used to compute arc tangent of 2 values
  65694. */
  65695. export class ArcTan2Block extends NodeMaterialBlock {
  65696. /**
  65697. * Creates a new ArcTan2Block
  65698. * @param name defines the block name
  65699. */
  65700. constructor(name: string);
  65701. /**
  65702. * Gets the current class name
  65703. * @returns the class name
  65704. */
  65705. getClassName(): string;
  65706. /**
  65707. * Gets the x operand input component
  65708. */
  65709. get x(): NodeMaterialConnectionPoint;
  65710. /**
  65711. * Gets the y operand input component
  65712. */
  65713. get y(): NodeMaterialConnectionPoint;
  65714. /**
  65715. * Gets the output component
  65716. */
  65717. get output(): NodeMaterialConnectionPoint;
  65718. protected _buildBlock(state: NodeMaterialBuildState): this;
  65719. }
  65720. }
  65721. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65725. /**
  65726. * Block used to smooth step a value
  65727. */
  65728. export class SmoothStepBlock extends NodeMaterialBlock {
  65729. /**
  65730. * Creates a new SmoothStepBlock
  65731. * @param name defines the block name
  65732. */
  65733. constructor(name: string);
  65734. /**
  65735. * Gets the current class name
  65736. * @returns the class name
  65737. */
  65738. getClassName(): string;
  65739. /**
  65740. * Gets the value operand input component
  65741. */
  65742. get value(): NodeMaterialConnectionPoint;
  65743. /**
  65744. * Gets the first edge operand input component
  65745. */
  65746. get edge0(): NodeMaterialConnectionPoint;
  65747. /**
  65748. * Gets the second edge operand input component
  65749. */
  65750. get edge1(): NodeMaterialConnectionPoint;
  65751. /**
  65752. * Gets the output component
  65753. */
  65754. get output(): NodeMaterialConnectionPoint;
  65755. protected _buildBlock(state: NodeMaterialBuildState): this;
  65756. }
  65757. }
  65758. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65762. /**
  65763. * Block used to get the reciprocal (1 / x) of a value
  65764. */
  65765. export class ReciprocalBlock extends NodeMaterialBlock {
  65766. /**
  65767. * Creates a new ReciprocalBlock
  65768. * @param name defines the block name
  65769. */
  65770. constructor(name: string);
  65771. /**
  65772. * Gets the current class name
  65773. * @returns the class name
  65774. */
  65775. getClassName(): string;
  65776. /**
  65777. * Gets the input component
  65778. */
  65779. get input(): NodeMaterialConnectionPoint;
  65780. /**
  65781. * Gets the output component
  65782. */
  65783. get output(): NodeMaterialConnectionPoint;
  65784. protected _buildBlock(state: NodeMaterialBuildState): this;
  65785. }
  65786. }
  65787. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65791. /**
  65792. * Block used to replace a color by another one
  65793. */
  65794. export class ReplaceColorBlock extends NodeMaterialBlock {
  65795. /**
  65796. * Creates a new ReplaceColorBlock
  65797. * @param name defines the block name
  65798. */
  65799. constructor(name: string);
  65800. /**
  65801. * Gets the current class name
  65802. * @returns the class name
  65803. */
  65804. getClassName(): string;
  65805. /**
  65806. * Gets the value input component
  65807. */
  65808. get value(): NodeMaterialConnectionPoint;
  65809. /**
  65810. * Gets the reference input component
  65811. */
  65812. get reference(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the distance input component
  65815. */
  65816. get distance(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the replacement input component
  65819. */
  65820. get replacement(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the output component
  65823. */
  65824. get output(): NodeMaterialConnectionPoint;
  65825. protected _buildBlock(state: NodeMaterialBuildState): this;
  65826. }
  65827. }
  65828. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65832. /**
  65833. * Block used to posterize a value
  65834. * @see https://en.wikipedia.org/wiki/Posterization
  65835. */
  65836. export class PosterizeBlock extends NodeMaterialBlock {
  65837. /**
  65838. * Creates a new PosterizeBlock
  65839. * @param name defines the block name
  65840. */
  65841. constructor(name: string);
  65842. /**
  65843. * Gets the current class name
  65844. * @returns the class name
  65845. */
  65846. getClassName(): string;
  65847. /**
  65848. * Gets the value input component
  65849. */
  65850. get value(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the steps input component
  65853. */
  65854. get steps(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the output component
  65857. */
  65858. get output(): NodeMaterialConnectionPoint;
  65859. protected _buildBlock(state: NodeMaterialBuildState): this;
  65860. }
  65861. }
  65862. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65866. import { Scene } from "babylonjs/scene";
  65867. /**
  65868. * Operations supported by the Wave block
  65869. */
  65870. export enum WaveBlockKind {
  65871. /** SawTooth */
  65872. SawTooth = 0,
  65873. /** Square */
  65874. Square = 1,
  65875. /** Triangle */
  65876. Triangle = 2
  65877. }
  65878. /**
  65879. * Block used to apply wave operation to floats
  65880. */
  65881. export class WaveBlock extends NodeMaterialBlock {
  65882. /**
  65883. * Gets or sets the kibnd of wave to be applied by the block
  65884. */
  65885. kind: WaveBlockKind;
  65886. /**
  65887. * Creates a new WaveBlock
  65888. * @param name defines the block name
  65889. */
  65890. constructor(name: string);
  65891. /**
  65892. * Gets the current class name
  65893. * @returns the class name
  65894. */
  65895. getClassName(): string;
  65896. /**
  65897. * Gets the input component
  65898. */
  65899. get input(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the output component
  65902. */
  65903. get output(): NodeMaterialConnectionPoint;
  65904. protected _buildBlock(state: NodeMaterialBuildState): this;
  65905. serialize(): any;
  65906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65907. }
  65908. }
  65909. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65913. import { Color3 } from "babylonjs/Maths/math.color";
  65914. import { Scene } from "babylonjs/scene";
  65915. /**
  65916. * Class used to store a color step for the GradientBlock
  65917. */
  65918. export class GradientBlockColorStep {
  65919. /**
  65920. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65921. */
  65922. step: number;
  65923. /**
  65924. * Gets or sets the color associated with this step
  65925. */
  65926. color: Color3;
  65927. /**
  65928. * Creates a new GradientBlockColorStep
  65929. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65930. * @param color defines the color associated with this step
  65931. */
  65932. constructor(
  65933. /**
  65934. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65935. */
  65936. step: number,
  65937. /**
  65938. * Gets or sets the color associated with this step
  65939. */
  65940. color: Color3);
  65941. }
  65942. /**
  65943. * Block used to return a color from a gradient based on an input value between 0 and 1
  65944. */
  65945. export class GradientBlock extends NodeMaterialBlock {
  65946. /**
  65947. * Gets or sets the list of color steps
  65948. */
  65949. colorSteps: GradientBlockColorStep[];
  65950. /**
  65951. * Creates a new GradientBlock
  65952. * @param name defines the block name
  65953. */
  65954. constructor(name: string);
  65955. /**
  65956. * Gets the current class name
  65957. * @returns the class name
  65958. */
  65959. getClassName(): string;
  65960. /**
  65961. * Gets the gradient input component
  65962. */
  65963. get gradient(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the output component
  65966. */
  65967. get output(): NodeMaterialConnectionPoint;
  65968. private _writeColorConstant;
  65969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65970. serialize(): any;
  65971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65972. protected _dumpPropertiesCode(): string;
  65973. }
  65974. }
  65975. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65979. /**
  65980. * Block used to normalize lerp between 2 values
  65981. */
  65982. export class NLerpBlock extends NodeMaterialBlock {
  65983. /**
  65984. * Creates a new NLerpBlock
  65985. * @param name defines the block name
  65986. */
  65987. constructor(name: string);
  65988. /**
  65989. * Gets the current class name
  65990. * @returns the class name
  65991. */
  65992. getClassName(): string;
  65993. /**
  65994. * Gets the left operand input component
  65995. */
  65996. get left(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the right operand input component
  65999. */
  66000. get right(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the gradient operand input component
  66003. */
  66004. get gradient(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the output component
  66007. */
  66008. get output(): NodeMaterialConnectionPoint;
  66009. protected _buildBlock(state: NodeMaterialBuildState): this;
  66010. }
  66011. }
  66012. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66016. import { Scene } from "babylonjs/scene";
  66017. /**
  66018. * block used to Generate a Worley Noise 3D Noise Pattern
  66019. */
  66020. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66021. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66022. manhattanDistance: boolean;
  66023. /**
  66024. * Creates a new WorleyNoise3DBlock
  66025. * @param name defines the block name
  66026. */
  66027. constructor(name: string);
  66028. /**
  66029. * Gets the current class name
  66030. * @returns the class name
  66031. */
  66032. getClassName(): string;
  66033. /**
  66034. * Gets the seed input component
  66035. */
  66036. get seed(): NodeMaterialConnectionPoint;
  66037. /**
  66038. * Gets the jitter input component
  66039. */
  66040. get jitter(): NodeMaterialConnectionPoint;
  66041. /**
  66042. * Gets the output component
  66043. */
  66044. get output(): NodeMaterialConnectionPoint;
  66045. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66046. /**
  66047. * Exposes the properties to the UI?
  66048. */
  66049. protected _dumpPropertiesCode(): string;
  66050. /**
  66051. * Exposes the properties to the Seralize?
  66052. */
  66053. serialize(): any;
  66054. /**
  66055. * Exposes the properties to the deseralize?
  66056. */
  66057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66058. }
  66059. }
  66060. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66064. /**
  66065. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66066. */
  66067. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66068. /**
  66069. * Creates a new SimplexPerlin3DBlock
  66070. * @param name defines the block name
  66071. */
  66072. constructor(name: string);
  66073. /**
  66074. * Gets the current class name
  66075. * @returns the class name
  66076. */
  66077. getClassName(): string;
  66078. /**
  66079. * Gets the seed operand input component
  66080. */
  66081. get seed(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the output component
  66084. */
  66085. get output(): NodeMaterialConnectionPoint;
  66086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66087. }
  66088. }
  66089. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66093. /**
  66094. * Block used to blend normals
  66095. */
  66096. export class NormalBlendBlock extends NodeMaterialBlock {
  66097. /**
  66098. * Creates a new NormalBlendBlock
  66099. * @param name defines the block name
  66100. */
  66101. constructor(name: string);
  66102. /**
  66103. * Gets the current class name
  66104. * @returns the class name
  66105. */
  66106. getClassName(): string;
  66107. /**
  66108. * Gets the first input component
  66109. */
  66110. get normalMap0(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the second input component
  66113. */
  66114. get normalMap1(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the output component
  66117. */
  66118. get output(): NodeMaterialConnectionPoint;
  66119. protected _buildBlock(state: NodeMaterialBuildState): this;
  66120. }
  66121. }
  66122. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66126. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66127. /**
  66128. * Block used to rotate a 2d vector by a given angle
  66129. */
  66130. export class Rotate2dBlock extends NodeMaterialBlock {
  66131. /**
  66132. * Creates a new Rotate2dBlock
  66133. * @param name defines the block name
  66134. */
  66135. constructor(name: string);
  66136. /**
  66137. * Gets the current class name
  66138. * @returns the class name
  66139. */
  66140. getClassName(): string;
  66141. /**
  66142. * Gets the input vector
  66143. */
  66144. get input(): NodeMaterialConnectionPoint;
  66145. /**
  66146. * Gets the input angle
  66147. */
  66148. get angle(): NodeMaterialConnectionPoint;
  66149. /**
  66150. * Gets the output component
  66151. */
  66152. get output(): NodeMaterialConnectionPoint;
  66153. autoConfigure(material: NodeMaterial): void;
  66154. protected _buildBlock(state: NodeMaterialBuildState): this;
  66155. }
  66156. }
  66157. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  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. /**
  66162. * Block used to get the reflected vector from a direction and a normal
  66163. */
  66164. export class ReflectBlock extends NodeMaterialBlock {
  66165. /**
  66166. * Creates a new ReflectBlock
  66167. * @param name defines the block name
  66168. */
  66169. constructor(name: string);
  66170. /**
  66171. * Gets the current class name
  66172. * @returns the class name
  66173. */
  66174. getClassName(): string;
  66175. /**
  66176. * Gets the incident component
  66177. */
  66178. get incident(): NodeMaterialConnectionPoint;
  66179. /**
  66180. * Gets the normal component
  66181. */
  66182. get normal(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the output component
  66185. */
  66186. get output(): NodeMaterialConnectionPoint;
  66187. protected _buildBlock(state: NodeMaterialBuildState): this;
  66188. }
  66189. }
  66190. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66194. /**
  66195. * Block used to get the refracted vector from a direction and a normal
  66196. */
  66197. export class RefractBlock extends NodeMaterialBlock {
  66198. /**
  66199. * Creates a new RefractBlock
  66200. * @param name defines the block name
  66201. */
  66202. constructor(name: string);
  66203. /**
  66204. * Gets the current class name
  66205. * @returns the class name
  66206. */
  66207. getClassName(): string;
  66208. /**
  66209. * Gets the incident component
  66210. */
  66211. get incident(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the normal component
  66214. */
  66215. get normal(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the index of refraction component
  66218. */
  66219. get ior(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the output component
  66222. */
  66223. get output(): NodeMaterialConnectionPoint;
  66224. protected _buildBlock(state: NodeMaterialBuildState): this;
  66225. }
  66226. }
  66227. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66231. /**
  66232. * Block used to desaturate a color
  66233. */
  66234. export class DesaturateBlock extends NodeMaterialBlock {
  66235. /**
  66236. * Creates a new DesaturateBlock
  66237. * @param name defines the block name
  66238. */
  66239. constructor(name: string);
  66240. /**
  66241. * Gets the current class name
  66242. * @returns the class name
  66243. */
  66244. getClassName(): string;
  66245. /**
  66246. * Gets the color operand input component
  66247. */
  66248. get color(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the level operand input component
  66251. */
  66252. get level(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the output component
  66255. */
  66256. get output(): NodeMaterialConnectionPoint;
  66257. protected _buildBlock(state: NodeMaterialBuildState): this;
  66258. }
  66259. }
  66260. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66265. import { Nullable } from "babylonjs/types";
  66266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66267. import { Scene } from "babylonjs/scene";
  66268. /**
  66269. * Block used to implement the ambient occlusion module of the PBR material
  66270. */
  66271. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66272. /**
  66273. * Create a new AmbientOcclusionBlock
  66274. * @param name defines the block name
  66275. */
  66276. constructor(name: string);
  66277. /**
  66278. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66279. */
  66280. useAmbientInGrayScale: boolean;
  66281. /**
  66282. * Initialize the block and prepare the context for build
  66283. * @param state defines the state that will be used for the build
  66284. */
  66285. initialize(state: NodeMaterialBuildState): void;
  66286. /**
  66287. * Gets the current class name
  66288. * @returns the class name
  66289. */
  66290. getClassName(): string;
  66291. /**
  66292. * Gets the texture input component
  66293. */
  66294. get texture(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the texture intensity component
  66297. */
  66298. get intensity(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the direct light intensity input component
  66301. */
  66302. get directLightIntensity(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the ambient occlusion object output component
  66305. */
  66306. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66307. /**
  66308. * Gets the main code of the block (fragment side)
  66309. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66310. * @returns the shader code
  66311. */
  66312. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66314. protected _buildBlock(state: NodeMaterialBuildState): this;
  66315. protected _dumpPropertiesCode(): string;
  66316. serialize(): any;
  66317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66318. }
  66319. }
  66320. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66324. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66326. import { Nullable } from "babylonjs/types";
  66327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66328. import { Mesh } from "babylonjs/Meshes/mesh";
  66329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66330. import { Effect } from "babylonjs/Materials/effect";
  66331. import { Scene } from "babylonjs/scene";
  66332. /**
  66333. * Block used to implement the reflection module of the PBR material
  66334. */
  66335. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66336. /** @hidden */
  66337. _defineLODReflectionAlpha: string;
  66338. /** @hidden */
  66339. _defineLinearSpecularReflection: string;
  66340. private _vEnvironmentIrradianceName;
  66341. /** @hidden */
  66342. _vReflectionMicrosurfaceInfosName: string;
  66343. /** @hidden */
  66344. _vReflectionInfosName: string;
  66345. /** @hidden */
  66346. _vReflectionFilteringInfoName: string;
  66347. private _scene;
  66348. /**
  66349. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66350. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66351. * It's less burden on the user side in the editor part.
  66352. */
  66353. /** @hidden */
  66354. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66355. /** @hidden */
  66356. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66357. /** @hidden */
  66358. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66359. /**
  66360. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66361. * diffuse part of the IBL.
  66362. */
  66363. useSphericalHarmonics: boolean;
  66364. /**
  66365. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66366. */
  66367. forceIrradianceInFragment: boolean;
  66368. /**
  66369. * Create a new ReflectionBlock
  66370. * @param name defines the block name
  66371. */
  66372. constructor(name: string);
  66373. /**
  66374. * Gets the current class name
  66375. * @returns the class name
  66376. */
  66377. getClassName(): string;
  66378. /**
  66379. * Gets the position input component
  66380. */
  66381. get position(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the world position input component
  66384. */
  66385. get worldPosition(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the world normal input component
  66388. */
  66389. get worldNormal(): NodeMaterialConnectionPoint;
  66390. /**
  66391. * Gets the world input component
  66392. */
  66393. get world(): NodeMaterialConnectionPoint;
  66394. /**
  66395. * Gets the camera (or eye) position component
  66396. */
  66397. get cameraPosition(): NodeMaterialConnectionPoint;
  66398. /**
  66399. * Gets the view input component
  66400. */
  66401. get view(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the color input component
  66404. */
  66405. get color(): NodeMaterialConnectionPoint;
  66406. /**
  66407. * Gets the reflection object output component
  66408. */
  66409. get reflection(): NodeMaterialConnectionPoint;
  66410. /**
  66411. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66412. */
  66413. get hasTexture(): boolean;
  66414. /**
  66415. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66416. */
  66417. get reflectionColor(): string;
  66418. protected _getTexture(): Nullable<BaseTexture>;
  66419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66421. /**
  66422. * Gets the code to inject in the vertex shader
  66423. * @param state current state of the node material building
  66424. * @returns the shader code
  66425. */
  66426. handleVertexSide(state: NodeMaterialBuildState): string;
  66427. /**
  66428. * Gets the main code of the block (fragment side)
  66429. * @param state current state of the node material building
  66430. * @param normalVarName name of the existing variable corresponding to the normal
  66431. * @returns the shader code
  66432. */
  66433. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66434. protected _buildBlock(state: NodeMaterialBuildState): this;
  66435. protected _dumpPropertiesCode(): string;
  66436. serialize(): any;
  66437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66438. }
  66439. }
  66440. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66444. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66446. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66447. import { Scene } from "babylonjs/scene";
  66448. import { Nullable } from "babylonjs/types";
  66449. /**
  66450. * Block used to implement the sheen module of the PBR material
  66451. */
  66452. export class SheenBlock extends NodeMaterialBlock {
  66453. /**
  66454. * Create a new SheenBlock
  66455. * @param name defines the block name
  66456. */
  66457. constructor(name: string);
  66458. /**
  66459. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66460. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66461. * making it easier to setup and tweak the effect
  66462. */
  66463. albedoScaling: boolean;
  66464. /**
  66465. * Defines if the sheen is linked to the sheen color.
  66466. */
  66467. linkSheenWithAlbedo: boolean;
  66468. /**
  66469. * Initialize the block and prepare the context for build
  66470. * @param state defines the state that will be used for the build
  66471. */
  66472. initialize(state: NodeMaterialBuildState): void;
  66473. /**
  66474. * Gets the current class name
  66475. * @returns the class name
  66476. */
  66477. getClassName(): string;
  66478. /**
  66479. * Gets the intensity input component
  66480. */
  66481. get intensity(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the color input component
  66484. */
  66485. get color(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the roughness input component
  66488. */
  66489. get roughness(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the sheen object output component
  66492. */
  66493. get sheen(): NodeMaterialConnectionPoint;
  66494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66495. /**
  66496. * Gets the main code of the block (fragment side)
  66497. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66498. * @returns the shader code
  66499. */
  66500. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66501. protected _buildBlock(state: NodeMaterialBuildState): this;
  66502. protected _dumpPropertiesCode(): string;
  66503. serialize(): any;
  66504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66505. }
  66506. }
  66507. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66508. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66513. import { Scene } from "babylonjs/scene";
  66514. import { Nullable } from "babylonjs/types";
  66515. import { Mesh } from "babylonjs/Meshes/mesh";
  66516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66517. import { Effect } from "babylonjs/Materials/effect";
  66518. /**
  66519. * Block used to implement the reflectivity module of the PBR material
  66520. */
  66521. export class ReflectivityBlock extends NodeMaterialBlock {
  66522. private _metallicReflectanceColor;
  66523. private _metallicF0Factor;
  66524. /** @hidden */
  66525. _vMetallicReflectanceFactorsName: string;
  66526. /**
  66527. * The property below is set by the main PBR block prior to calling methods of this class.
  66528. */
  66529. /** @hidden */
  66530. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66531. /**
  66532. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66533. */
  66534. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66535. /**
  66536. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66537. */
  66538. useMetallnessFromMetallicTextureBlue: boolean;
  66539. /**
  66540. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66541. */
  66542. useRoughnessFromMetallicTextureAlpha: boolean;
  66543. /**
  66544. * Specifies if the metallic texture contains the roughness information in its green channel.
  66545. */
  66546. useRoughnessFromMetallicTextureGreen: boolean;
  66547. /**
  66548. * Create a new ReflectivityBlock
  66549. * @param name defines the block name
  66550. */
  66551. constructor(name: string);
  66552. /**
  66553. * Initialize the block and prepare the context for build
  66554. * @param state defines the state that will be used for the build
  66555. */
  66556. initialize(state: NodeMaterialBuildState): void;
  66557. /**
  66558. * Gets the current class name
  66559. * @returns the class name
  66560. */
  66561. getClassName(): string;
  66562. /**
  66563. * Gets the metallic input component
  66564. */
  66565. get metallic(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the roughness input component
  66568. */
  66569. get roughness(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the texture input component
  66572. */
  66573. get texture(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the reflectivity object output component
  66576. */
  66577. get reflectivity(): NodeMaterialConnectionPoint;
  66578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66579. /**
  66580. * Gets the main code of the block (fragment side)
  66581. * @param state current state of the node material building
  66582. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66583. * @returns the shader code
  66584. */
  66585. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66587. protected _buildBlock(state: NodeMaterialBuildState): this;
  66588. protected _dumpPropertiesCode(): string;
  66589. serialize(): any;
  66590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66591. }
  66592. }
  66593. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66599. /**
  66600. * Block used to implement the anisotropy module of the PBR material
  66601. */
  66602. export class AnisotropyBlock extends NodeMaterialBlock {
  66603. /**
  66604. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66605. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66606. * It's less burden on the user side in the editor part.
  66607. */
  66608. /** @hidden */
  66609. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66610. /** @hidden */
  66611. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66612. /**
  66613. * Create a new AnisotropyBlock
  66614. * @param name defines the block name
  66615. */
  66616. constructor(name: string);
  66617. /**
  66618. * Initialize the block and prepare the context for build
  66619. * @param state defines the state that will be used for the build
  66620. */
  66621. initialize(state: NodeMaterialBuildState): void;
  66622. /**
  66623. * Gets the current class name
  66624. * @returns the class name
  66625. */
  66626. getClassName(): string;
  66627. /**
  66628. * Gets the intensity input component
  66629. */
  66630. get intensity(): NodeMaterialConnectionPoint;
  66631. /**
  66632. * Gets the direction input component
  66633. */
  66634. get direction(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the texture input component
  66637. */
  66638. get texture(): NodeMaterialConnectionPoint;
  66639. /**
  66640. * Gets the uv input component
  66641. */
  66642. get uv(): NodeMaterialConnectionPoint;
  66643. /**
  66644. * Gets the worldTangent input component
  66645. */
  66646. get worldTangent(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the anisotropy object output component
  66649. */
  66650. get anisotropy(): NodeMaterialConnectionPoint;
  66651. private _generateTBNSpace;
  66652. /**
  66653. * Gets the main code of the block (fragment side)
  66654. * @param state current state of the node material building
  66655. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66656. * @returns the shader code
  66657. */
  66658. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66660. protected _buildBlock(state: NodeMaterialBuildState): this;
  66661. }
  66662. }
  66663. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66667. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66669. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66670. import { Nullable } from "babylonjs/types";
  66671. import { Mesh } from "babylonjs/Meshes/mesh";
  66672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66673. import { Effect } from "babylonjs/Materials/effect";
  66674. /**
  66675. * Block used to implement the clear coat module of the PBR material
  66676. */
  66677. export class ClearCoatBlock extends NodeMaterialBlock {
  66678. private _scene;
  66679. /**
  66680. * Create a new ClearCoatBlock
  66681. * @param name defines the block name
  66682. */
  66683. constructor(name: string);
  66684. /**
  66685. * Initialize the block and prepare the context for build
  66686. * @param state defines the state that will be used for the build
  66687. */
  66688. initialize(state: NodeMaterialBuildState): void;
  66689. /**
  66690. * Gets the current class name
  66691. * @returns the class name
  66692. */
  66693. getClassName(): string;
  66694. /**
  66695. * Gets the intensity input component
  66696. */
  66697. get intensity(): NodeMaterialConnectionPoint;
  66698. /**
  66699. * Gets the roughness input component
  66700. */
  66701. get roughness(): NodeMaterialConnectionPoint;
  66702. /**
  66703. * Gets the ior input component
  66704. */
  66705. get ior(): NodeMaterialConnectionPoint;
  66706. /**
  66707. * Gets the texture input component
  66708. */
  66709. get texture(): NodeMaterialConnectionPoint;
  66710. /**
  66711. * Gets the bump texture input component
  66712. */
  66713. get bumpTexture(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the uv input component
  66716. */
  66717. get uv(): NodeMaterialConnectionPoint;
  66718. /**
  66719. * Gets the tint color input component
  66720. */
  66721. get tintColor(): NodeMaterialConnectionPoint;
  66722. /**
  66723. * Gets the tint "at distance" input component
  66724. */
  66725. get tintAtDistance(): NodeMaterialConnectionPoint;
  66726. /**
  66727. * Gets the tint thickness input component
  66728. */
  66729. get tintThickness(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the world tangent input component
  66732. */
  66733. get worldTangent(): NodeMaterialConnectionPoint;
  66734. /**
  66735. * Gets the clear coat object output component
  66736. */
  66737. get clearcoat(): NodeMaterialConnectionPoint;
  66738. autoConfigure(material: NodeMaterial): void;
  66739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66741. private _generateTBNSpace;
  66742. /**
  66743. * Gets the main code of the block (fragment side)
  66744. * @param state current state of the node material building
  66745. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66746. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66747. * @param worldPosVarName name of the variable holding the world position
  66748. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66749. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66750. * @param worldNormalVarName name of the variable holding the world normal
  66751. * @returns the shader code
  66752. */
  66753. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66754. protected _buildBlock(state: NodeMaterialBuildState): this;
  66755. }
  66756. }
  66757. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66761. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66763. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66764. import { Nullable } from "babylonjs/types";
  66765. /**
  66766. * Block used to implement the sub surface module of the PBR material
  66767. */
  66768. export class SubSurfaceBlock extends NodeMaterialBlock {
  66769. /**
  66770. * Create a new SubSurfaceBlock
  66771. * @param name defines the block name
  66772. */
  66773. constructor(name: string);
  66774. /**
  66775. * Stores the intensity of the different subsurface effects in the thickness texture.
  66776. * * the green channel is the translucency intensity.
  66777. * * the blue channel is the scattering intensity.
  66778. * * the alpha channel is the refraction intensity.
  66779. */
  66780. useMaskFromThicknessTexture: boolean;
  66781. /**
  66782. * Initialize the block and prepare the context for build
  66783. * @param state defines the state that will be used for the build
  66784. */
  66785. initialize(state: NodeMaterialBuildState): void;
  66786. /**
  66787. * Gets the current class name
  66788. * @returns the class name
  66789. */
  66790. getClassName(): string;
  66791. /**
  66792. * Gets the min thickness input component
  66793. */
  66794. get minThickness(): NodeMaterialConnectionPoint;
  66795. /**
  66796. * Gets the max thickness input component
  66797. */
  66798. get maxThickness(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the thickness texture component
  66801. */
  66802. get thicknessTexture(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the tint color input component
  66805. */
  66806. get tintColor(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the translucency intensity input component
  66809. */
  66810. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the translucency diffusion distance input component
  66813. */
  66814. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66815. /**
  66816. * Gets the refraction object parameters
  66817. */
  66818. get refraction(): NodeMaterialConnectionPoint;
  66819. /**
  66820. * Gets the sub surface object output component
  66821. */
  66822. get subsurface(): NodeMaterialConnectionPoint;
  66823. autoConfigure(material: NodeMaterial): void;
  66824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66825. /**
  66826. * Gets the main code of the block (fragment side)
  66827. * @param state current state of the node material building
  66828. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66829. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66830. * @param worldPosVarName name of the variable holding the world position
  66831. * @returns the shader code
  66832. */
  66833. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66834. protected _buildBlock(state: NodeMaterialBuildState): this;
  66835. }
  66836. }
  66837. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66841. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66842. import { Light } from "babylonjs/Lights/light";
  66843. import { Nullable } from "babylonjs/types";
  66844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66845. import { Effect } from "babylonjs/Materials/effect";
  66846. import { Mesh } from "babylonjs/Meshes/mesh";
  66847. import { Scene } from "babylonjs/scene";
  66848. /**
  66849. * Block used to implement the PBR metallic/roughness model
  66850. */
  66851. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66852. /**
  66853. * Gets or sets the light associated with this block
  66854. */
  66855. light: Nullable<Light>;
  66856. private _lightId;
  66857. private _scene;
  66858. private _environmentBRDFTexture;
  66859. private _environmentBrdfSamplerName;
  66860. private _vNormalWName;
  66861. private _invertNormalName;
  66862. /**
  66863. * Create a new ReflectionBlock
  66864. * @param name defines the block name
  66865. */
  66866. constructor(name: string);
  66867. /**
  66868. * Intensity of the direct lights e.g. the four lights available in your scene.
  66869. * This impacts both the direct diffuse and specular highlights.
  66870. */
  66871. directIntensity: number;
  66872. /**
  66873. * Intensity of the environment e.g. how much the environment will light the object
  66874. * either through harmonics for rough material or through the refelction for shiny ones.
  66875. */
  66876. environmentIntensity: number;
  66877. /**
  66878. * This is a special control allowing the reduction of the specular highlights coming from the
  66879. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66880. */
  66881. specularIntensity: number;
  66882. /**
  66883. * Defines the falloff type used in this material.
  66884. * It by default is Physical.
  66885. */
  66886. lightFalloff: number;
  66887. /**
  66888. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66889. */
  66890. useAlphaFromAlbedoTexture: boolean;
  66891. /**
  66892. * Specifies that alpha test should be used
  66893. */
  66894. useAlphaTest: boolean;
  66895. /**
  66896. * Defines the alpha limits in alpha test mode.
  66897. */
  66898. alphaTestCutoff: number;
  66899. /**
  66900. * Specifies that alpha blending should be used
  66901. */
  66902. useAlphaBlending: boolean;
  66903. /**
  66904. * Defines if the alpha value should be determined via the rgb values.
  66905. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66906. */
  66907. opacityRGB: boolean;
  66908. /**
  66909. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66910. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66911. */
  66912. useRadianceOverAlpha: boolean;
  66913. /**
  66914. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66915. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66916. */
  66917. useSpecularOverAlpha: boolean;
  66918. /**
  66919. * Enables specular anti aliasing in the PBR shader.
  66920. * It will both interacts on the Geometry for analytical and IBL lighting.
  66921. * It also prefilter the roughness map based on the bump values.
  66922. */
  66923. enableSpecularAntiAliasing: boolean;
  66924. /**
  66925. * Enables realtime filtering on the texture.
  66926. */
  66927. realTimeFiltering: boolean;
  66928. /**
  66929. * Quality switch for realtime filtering
  66930. */
  66931. realTimeFilteringQuality: number;
  66932. /**
  66933. * Defines if the material uses energy conservation.
  66934. */
  66935. useEnergyConservation: boolean;
  66936. /**
  66937. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66938. * too much the area relying on ambient texture to define their ambient occlusion.
  66939. */
  66940. useRadianceOcclusion: boolean;
  66941. /**
  66942. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66943. * makes the reflect vector face the model (under horizon).
  66944. */
  66945. useHorizonOcclusion: boolean;
  66946. /**
  66947. * If set to true, no lighting calculations will be applied.
  66948. */
  66949. unlit: boolean;
  66950. /**
  66951. * Force normal to face away from face.
  66952. */
  66953. forceNormalForward: boolean;
  66954. /**
  66955. * Defines the material debug mode.
  66956. * It helps seeing only some components of the material while troubleshooting.
  66957. */
  66958. debugMode: number;
  66959. /**
  66960. * Specify from where on screen the debug mode should start.
  66961. * The value goes from -1 (full screen) to 1 (not visible)
  66962. * It helps with side by side comparison against the final render
  66963. * This defaults to 0
  66964. */
  66965. debugLimit: number;
  66966. /**
  66967. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66968. * You can use the factor to better multiply the final value.
  66969. */
  66970. debugFactor: number;
  66971. /**
  66972. * Initialize the block and prepare the context for build
  66973. * @param state defines the state that will be used for the build
  66974. */
  66975. initialize(state: NodeMaterialBuildState): void;
  66976. /**
  66977. * Gets the current class name
  66978. * @returns the class name
  66979. */
  66980. getClassName(): string;
  66981. /**
  66982. * Gets the world position input component
  66983. */
  66984. get worldPosition(): NodeMaterialConnectionPoint;
  66985. /**
  66986. * Gets the world normal input component
  66987. */
  66988. get worldNormal(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the perturbed normal input component
  66991. */
  66992. get perturbedNormal(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the camera position input component
  66995. */
  66996. get cameraPosition(): NodeMaterialConnectionPoint;
  66997. /**
  66998. * Gets the base color input component
  66999. */
  67000. get baseColor(): NodeMaterialConnectionPoint;
  67001. /**
  67002. * Gets the opacity texture input component
  67003. */
  67004. get opacityTexture(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the ambient color input component
  67007. */
  67008. get ambientColor(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the reflectivity object parameters
  67011. */
  67012. get reflectivity(): NodeMaterialConnectionPoint;
  67013. /**
  67014. * Gets the ambient occlusion object parameters
  67015. */
  67016. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67017. /**
  67018. * Gets the reflection object parameters
  67019. */
  67020. get reflection(): NodeMaterialConnectionPoint;
  67021. /**
  67022. * Gets the sheen object parameters
  67023. */
  67024. get sheen(): NodeMaterialConnectionPoint;
  67025. /**
  67026. * Gets the clear coat object parameters
  67027. */
  67028. get clearcoat(): NodeMaterialConnectionPoint;
  67029. /**
  67030. * Gets the sub surface object parameters
  67031. */
  67032. get subsurface(): NodeMaterialConnectionPoint;
  67033. /**
  67034. * Gets the anisotropy object parameters
  67035. */
  67036. get anisotropy(): NodeMaterialConnectionPoint;
  67037. /**
  67038. * Gets the ambient output component
  67039. */
  67040. get ambient(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the diffuse output component
  67043. */
  67044. get diffuse(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the specular output component
  67047. */
  67048. get specular(): NodeMaterialConnectionPoint;
  67049. /**
  67050. * Gets the sheen output component
  67051. */
  67052. get sheenDir(): NodeMaterialConnectionPoint;
  67053. /**
  67054. * Gets the clear coat output component
  67055. */
  67056. get clearcoatDir(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the indirect diffuse output component
  67059. */
  67060. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the indirect specular output component
  67063. */
  67064. get specularIndirect(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the indirect sheen output component
  67067. */
  67068. get sheenIndirect(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the indirect clear coat output component
  67071. */
  67072. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the refraction output component
  67075. */
  67076. get refraction(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the global lighting output component
  67079. */
  67080. get lighting(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the shadow output component
  67083. */
  67084. get shadow(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the alpha output component
  67087. */
  67088. get alpha(): NodeMaterialConnectionPoint;
  67089. autoConfigure(material: NodeMaterial): void;
  67090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67091. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67092. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67093. private _injectVertexCode;
  67094. /**
  67095. * Gets the code corresponding to the albedo/opacity module
  67096. * @returns the shader code
  67097. */
  67098. getAlbedoOpacityCode(): string;
  67099. protected _buildBlock(state: NodeMaterialBuildState): this;
  67100. protected _dumpPropertiesCode(): string;
  67101. serialize(): any;
  67102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67103. }
  67104. }
  67105. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67106. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67107. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67108. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67109. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67110. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67111. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67112. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67113. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67114. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67115. }
  67116. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67117. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67118. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67119. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67120. }
  67121. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67125. /**
  67126. * Block used to compute value of one parameter modulo another
  67127. */
  67128. export class ModBlock extends NodeMaterialBlock {
  67129. /**
  67130. * Creates a new ModBlock
  67131. * @param name defines the block name
  67132. */
  67133. constructor(name: string);
  67134. /**
  67135. * Gets the current class name
  67136. * @returns the class name
  67137. */
  67138. getClassName(): string;
  67139. /**
  67140. * Gets the left operand input component
  67141. */
  67142. get left(): NodeMaterialConnectionPoint;
  67143. /**
  67144. * Gets the right operand input component
  67145. */
  67146. get right(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the output component
  67149. */
  67150. get output(): NodeMaterialConnectionPoint;
  67151. protected _buildBlock(state: NodeMaterialBuildState): this;
  67152. }
  67153. }
  67154. declare module "babylonjs/Materials/Node/Blocks/index" {
  67155. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67156. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67157. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67158. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67159. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67160. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67161. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67162. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67163. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67164. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67165. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67166. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67167. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67168. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67169. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67170. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67171. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67172. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67173. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67174. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67175. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67176. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67177. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67178. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67179. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67180. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67181. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67182. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67183. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67184. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67185. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67186. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67187. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67188. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67189. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67190. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67191. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67192. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67193. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67194. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67199. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67200. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67201. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67202. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67203. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67204. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67205. }
  67206. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67207. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67208. }
  67209. declare module "babylonjs/Materials/Node/index" {
  67210. export * from "babylonjs/Materials/Node/Enums/index";
  67211. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67212. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67213. export * from "babylonjs/Materials/Node/nodeMaterial";
  67214. export * from "babylonjs/Materials/Node/Blocks/index";
  67215. export * from "babylonjs/Materials/Node/Optimizers/index";
  67216. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67217. }
  67218. declare module "babylonjs/Materials/index" {
  67219. export * from "babylonjs/Materials/Background/index";
  67220. export * from "babylonjs/Materials/colorCurves";
  67221. export * from "babylonjs/Materials/iEffectFallbacks";
  67222. export * from "babylonjs/Materials/effectFallbacks";
  67223. export * from "babylonjs/Materials/effect";
  67224. export * from "babylonjs/Materials/fresnelParameters";
  67225. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67226. export * from "babylonjs/Materials/material";
  67227. export * from "babylonjs/Materials/materialDefines";
  67228. export * from "babylonjs/Materials/materialHelper";
  67229. export * from "babylonjs/Materials/multiMaterial";
  67230. export * from "babylonjs/Materials/PBR/index";
  67231. export * from "babylonjs/Materials/pushMaterial";
  67232. export * from "babylonjs/Materials/shaderMaterial";
  67233. export * from "babylonjs/Materials/standardMaterial";
  67234. export * from "babylonjs/Materials/Textures/index";
  67235. export * from "babylonjs/Materials/uniformBuffer";
  67236. export * from "babylonjs/Materials/materialFlags";
  67237. export * from "babylonjs/Materials/Node/index";
  67238. export * from "babylonjs/Materials/effectRenderer";
  67239. export * from "babylonjs/Materials/shadowDepthWrapper";
  67240. }
  67241. declare module "babylonjs/Maths/index" {
  67242. export * from "babylonjs/Maths/math.scalar";
  67243. export * from "babylonjs/Maths/math";
  67244. export * from "babylonjs/Maths/sphericalPolynomial";
  67245. }
  67246. declare module "babylonjs/Misc/workerPool" {
  67247. import { IDisposable } from "babylonjs/scene";
  67248. /**
  67249. * Helper class to push actions to a pool of workers.
  67250. */
  67251. export class WorkerPool implements IDisposable {
  67252. private _workerInfos;
  67253. private _pendingActions;
  67254. /**
  67255. * Constructor
  67256. * @param workers Array of workers to use for actions
  67257. */
  67258. constructor(workers: Array<Worker>);
  67259. /**
  67260. * Terminates all workers and clears any pending actions.
  67261. */
  67262. dispose(): void;
  67263. /**
  67264. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67265. * pended until a worker has completed its action.
  67266. * @param action The action to perform. Call onComplete when the action is complete.
  67267. */
  67268. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67269. private _execute;
  67270. }
  67271. }
  67272. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67273. import { IDisposable } from "babylonjs/scene";
  67274. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67275. /**
  67276. * Configuration for Draco compression
  67277. */
  67278. export interface IDracoCompressionConfiguration {
  67279. /**
  67280. * Configuration for the decoder.
  67281. */
  67282. decoder: {
  67283. /**
  67284. * The url to the WebAssembly module.
  67285. */
  67286. wasmUrl?: string;
  67287. /**
  67288. * The url to the WebAssembly binary.
  67289. */
  67290. wasmBinaryUrl?: string;
  67291. /**
  67292. * The url to the fallback JavaScript module.
  67293. */
  67294. fallbackUrl?: string;
  67295. };
  67296. }
  67297. /**
  67298. * Draco compression (https://google.github.io/draco/)
  67299. *
  67300. * This class wraps the Draco module.
  67301. *
  67302. * **Encoder**
  67303. *
  67304. * The encoder is not currently implemented.
  67305. *
  67306. * **Decoder**
  67307. *
  67308. * 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.
  67309. *
  67310. * To update the configuration, use the following code:
  67311. * ```javascript
  67312. * DracoCompression.Configuration = {
  67313. * decoder: {
  67314. * wasmUrl: "<url to the WebAssembly library>",
  67315. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67316. * fallbackUrl: "<url to the fallback JavaScript library>",
  67317. * }
  67318. * };
  67319. * ```
  67320. *
  67321. * 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.
  67322. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67323. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67324. *
  67325. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67326. * ```javascript
  67327. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67328. * ```
  67329. *
  67330. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67331. */
  67332. export class DracoCompression implements IDisposable {
  67333. private _workerPoolPromise?;
  67334. private _decoderModulePromise?;
  67335. /**
  67336. * The configuration. Defaults to the following urls:
  67337. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67338. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67339. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67340. */
  67341. static Configuration: IDracoCompressionConfiguration;
  67342. /**
  67343. * Returns true if the decoder configuration is available.
  67344. */
  67345. static get DecoderAvailable(): boolean;
  67346. /**
  67347. * Default number of workers to create when creating the draco compression object.
  67348. */
  67349. static DefaultNumWorkers: number;
  67350. private static GetDefaultNumWorkers;
  67351. private static _Default;
  67352. /**
  67353. * Default instance for the draco compression object.
  67354. */
  67355. static get Default(): DracoCompression;
  67356. /**
  67357. * Constructor
  67358. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67359. */
  67360. constructor(numWorkers?: number);
  67361. /**
  67362. * Stop all async operations and release resources.
  67363. */
  67364. dispose(): void;
  67365. /**
  67366. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67367. * @returns a promise that resolves when ready
  67368. */
  67369. whenReadyAsync(): Promise<void>;
  67370. /**
  67371. * Decode Draco compressed mesh data to vertex data.
  67372. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67373. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67374. * @returns A promise that resolves with the decoded vertex data
  67375. */
  67376. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67377. [kind: string]: number;
  67378. }): Promise<VertexData>;
  67379. }
  67380. }
  67381. declare module "babylonjs/Meshes/Compression/index" {
  67382. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67383. }
  67384. declare module "babylonjs/Meshes/csg" {
  67385. import { Nullable } from "babylonjs/types";
  67386. import { Scene } from "babylonjs/scene";
  67387. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67388. import { Mesh } from "babylonjs/Meshes/mesh";
  67389. import { Material } from "babylonjs/Materials/material";
  67390. /**
  67391. * Class for building Constructive Solid Geometry
  67392. */
  67393. export class CSG {
  67394. private polygons;
  67395. /**
  67396. * The world matrix
  67397. */
  67398. matrix: Matrix;
  67399. /**
  67400. * Stores the position
  67401. */
  67402. position: Vector3;
  67403. /**
  67404. * Stores the rotation
  67405. */
  67406. rotation: Vector3;
  67407. /**
  67408. * Stores the rotation quaternion
  67409. */
  67410. rotationQuaternion: Nullable<Quaternion>;
  67411. /**
  67412. * Stores the scaling vector
  67413. */
  67414. scaling: Vector3;
  67415. /**
  67416. * Convert the Mesh to CSG
  67417. * @param mesh The Mesh to convert to CSG
  67418. * @returns A new CSG from the Mesh
  67419. */
  67420. static FromMesh(mesh: Mesh): CSG;
  67421. /**
  67422. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67423. * @param polygons Polygons used to construct a CSG solid
  67424. */
  67425. private static FromPolygons;
  67426. /**
  67427. * Clones, or makes a deep copy, of the CSG
  67428. * @returns A new CSG
  67429. */
  67430. clone(): CSG;
  67431. /**
  67432. * Unions this CSG with another CSG
  67433. * @param csg The CSG to union against this CSG
  67434. * @returns The unioned CSG
  67435. */
  67436. union(csg: CSG): CSG;
  67437. /**
  67438. * Unions this CSG with another CSG in place
  67439. * @param csg The CSG to union against this CSG
  67440. */
  67441. unionInPlace(csg: CSG): void;
  67442. /**
  67443. * Subtracts this CSG with another CSG
  67444. * @param csg The CSG to subtract against this CSG
  67445. * @returns A new CSG
  67446. */
  67447. subtract(csg: CSG): CSG;
  67448. /**
  67449. * Subtracts this CSG with another CSG in place
  67450. * @param csg The CSG to subtact against this CSG
  67451. */
  67452. subtractInPlace(csg: CSG): void;
  67453. /**
  67454. * Intersect this CSG with another CSG
  67455. * @param csg The CSG to intersect against this CSG
  67456. * @returns A new CSG
  67457. */
  67458. intersect(csg: CSG): CSG;
  67459. /**
  67460. * Intersects this CSG with another CSG in place
  67461. * @param csg The CSG to intersect against this CSG
  67462. */
  67463. intersectInPlace(csg: CSG): void;
  67464. /**
  67465. * Return a new CSG solid with solid and empty space switched. This solid is
  67466. * not modified.
  67467. * @returns A new CSG solid with solid and empty space switched
  67468. */
  67469. inverse(): CSG;
  67470. /**
  67471. * Inverses the CSG in place
  67472. */
  67473. inverseInPlace(): void;
  67474. /**
  67475. * This is used to keep meshes transformations so they can be restored
  67476. * when we build back a Babylon Mesh
  67477. * NB : All CSG operations are performed in world coordinates
  67478. * @param csg The CSG to copy the transform attributes from
  67479. * @returns This CSG
  67480. */
  67481. copyTransformAttributes(csg: CSG): CSG;
  67482. /**
  67483. * Build Raw mesh from CSG
  67484. * Coordinates here are in world space
  67485. * @param name The name of the mesh geometry
  67486. * @param scene The Scene
  67487. * @param keepSubMeshes Specifies if the submeshes should be kept
  67488. * @returns A new Mesh
  67489. */
  67490. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67491. /**
  67492. * Build Mesh from CSG taking material and transforms into account
  67493. * @param name The name of the Mesh
  67494. * @param material The material of the Mesh
  67495. * @param scene The Scene
  67496. * @param keepSubMeshes Specifies if submeshes should be kept
  67497. * @returns The new Mesh
  67498. */
  67499. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67500. }
  67501. }
  67502. declare module "babylonjs/Meshes/trailMesh" {
  67503. import { Mesh } from "babylonjs/Meshes/mesh";
  67504. import { Scene } from "babylonjs/scene";
  67505. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67506. /**
  67507. * Class used to create a trail following a mesh
  67508. */
  67509. export class TrailMesh extends Mesh {
  67510. private _generator;
  67511. private _autoStart;
  67512. private _running;
  67513. private _diameter;
  67514. private _length;
  67515. private _sectionPolygonPointsCount;
  67516. private _sectionVectors;
  67517. private _sectionNormalVectors;
  67518. private _beforeRenderObserver;
  67519. /**
  67520. * @constructor
  67521. * @param name The value used by scene.getMeshByName() to do a lookup.
  67522. * @param generator The mesh or transform node to generate a trail.
  67523. * @param scene The scene to add this mesh to.
  67524. * @param diameter Diameter of trailing mesh. Default is 1.
  67525. * @param length Length of trailing mesh. Default is 60.
  67526. * @param autoStart Automatically start trailing mesh. Default true.
  67527. */
  67528. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67529. /**
  67530. * "TrailMesh"
  67531. * @returns "TrailMesh"
  67532. */
  67533. getClassName(): string;
  67534. private _createMesh;
  67535. /**
  67536. * Start trailing mesh.
  67537. */
  67538. start(): void;
  67539. /**
  67540. * Stop trailing mesh.
  67541. */
  67542. stop(): void;
  67543. /**
  67544. * Update trailing mesh geometry.
  67545. */
  67546. update(): void;
  67547. /**
  67548. * Returns a new TrailMesh object.
  67549. * @param name is a string, the name given to the new mesh
  67550. * @param newGenerator use new generator object for cloned trail mesh
  67551. * @returns a new mesh
  67552. */
  67553. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67554. /**
  67555. * Serializes this trail mesh
  67556. * @param serializationObject object to write serialization to
  67557. */
  67558. serialize(serializationObject: any): void;
  67559. /**
  67560. * Parses a serialized trail mesh
  67561. * @param parsedMesh the serialized mesh
  67562. * @param scene the scene to create the trail mesh in
  67563. * @returns the created trail mesh
  67564. */
  67565. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67566. }
  67567. }
  67568. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67569. import { Nullable } from "babylonjs/types";
  67570. import { Scene } from "babylonjs/scene";
  67571. import { Vector4 } from "babylonjs/Maths/math.vector";
  67572. import { Color4 } from "babylonjs/Maths/math.color";
  67573. import { Mesh } from "babylonjs/Meshes/mesh";
  67574. /**
  67575. * Class containing static functions to help procedurally build meshes
  67576. */
  67577. export class TiledBoxBuilder {
  67578. /**
  67579. * Creates a box mesh
  67580. * 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)
  67581. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67585. * @param name defines the name of the mesh
  67586. * @param options defines the options used to create the mesh
  67587. * @param scene defines the hosting scene
  67588. * @returns the box mesh
  67589. */
  67590. static CreateTiledBox(name: string, options: {
  67591. pattern?: number;
  67592. width?: number;
  67593. height?: number;
  67594. depth?: number;
  67595. tileSize?: number;
  67596. tileWidth?: number;
  67597. tileHeight?: number;
  67598. alignHorizontal?: number;
  67599. alignVertical?: number;
  67600. faceUV?: Vector4[];
  67601. faceColors?: Color4[];
  67602. sideOrientation?: number;
  67603. updatable?: boolean;
  67604. }, scene?: Nullable<Scene>): Mesh;
  67605. }
  67606. }
  67607. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67608. import { Vector4 } from "babylonjs/Maths/math.vector";
  67609. import { Mesh } from "babylonjs/Meshes/mesh";
  67610. /**
  67611. * Class containing static functions to help procedurally build meshes
  67612. */
  67613. export class TorusKnotBuilder {
  67614. /**
  67615. * Creates a torus knot mesh
  67616. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67617. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67618. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67619. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67623. * @param name defines the name of the mesh
  67624. * @param options defines the options used to create the mesh
  67625. * @param scene defines the hosting scene
  67626. * @returns the torus knot mesh
  67627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67628. */
  67629. static CreateTorusKnot(name: string, options: {
  67630. radius?: number;
  67631. tube?: number;
  67632. radialSegments?: number;
  67633. tubularSegments?: number;
  67634. p?: number;
  67635. q?: number;
  67636. updatable?: boolean;
  67637. sideOrientation?: number;
  67638. frontUVs?: Vector4;
  67639. backUVs?: Vector4;
  67640. }, scene: any): Mesh;
  67641. }
  67642. }
  67643. declare module "babylonjs/Meshes/polygonMesh" {
  67644. import { Scene } from "babylonjs/scene";
  67645. import { Vector2 } from "babylonjs/Maths/math.vector";
  67646. import { Mesh } from "babylonjs/Meshes/mesh";
  67647. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67648. import { Path2 } from "babylonjs/Maths/math.path";
  67649. /**
  67650. * Polygon
  67651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67652. */
  67653. export class Polygon {
  67654. /**
  67655. * Creates a rectangle
  67656. * @param xmin bottom X coord
  67657. * @param ymin bottom Y coord
  67658. * @param xmax top X coord
  67659. * @param ymax top Y coord
  67660. * @returns points that make the resulting rectation
  67661. */
  67662. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67663. /**
  67664. * Creates a circle
  67665. * @param radius radius of circle
  67666. * @param cx scale in x
  67667. * @param cy scale in y
  67668. * @param numberOfSides number of sides that make up the circle
  67669. * @returns points that make the resulting circle
  67670. */
  67671. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67672. /**
  67673. * Creates a polygon from input string
  67674. * @param input Input polygon data
  67675. * @returns the parsed points
  67676. */
  67677. static Parse(input: string): Vector2[];
  67678. /**
  67679. * Starts building a polygon from x and y coordinates
  67680. * @param x x coordinate
  67681. * @param y y coordinate
  67682. * @returns the started path2
  67683. */
  67684. static StartingAt(x: number, y: number): Path2;
  67685. }
  67686. /**
  67687. * Builds a polygon
  67688. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67689. */
  67690. export class PolygonMeshBuilder {
  67691. private _points;
  67692. private _outlinepoints;
  67693. private _holes;
  67694. private _name;
  67695. private _scene;
  67696. private _epoints;
  67697. private _eholes;
  67698. private _addToepoint;
  67699. /**
  67700. * Babylon reference to the earcut plugin.
  67701. */
  67702. bjsEarcut: any;
  67703. /**
  67704. * Creates a PolygonMeshBuilder
  67705. * @param name name of the builder
  67706. * @param contours Path of the polygon
  67707. * @param scene scene to add to when creating the mesh
  67708. * @param earcutInjection can be used to inject your own earcut reference
  67709. */
  67710. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67711. /**
  67712. * Adds a whole within the polygon
  67713. * @param hole Array of points defining the hole
  67714. * @returns this
  67715. */
  67716. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67717. /**
  67718. * Creates the polygon
  67719. * @param updatable If the mesh should be updatable
  67720. * @param depth The depth of the mesh created
  67721. * @returns the created mesh
  67722. */
  67723. build(updatable?: boolean, depth?: number): Mesh;
  67724. /**
  67725. * Creates the polygon
  67726. * @param depth The depth of the mesh created
  67727. * @returns the created VertexData
  67728. */
  67729. buildVertexData(depth?: number): VertexData;
  67730. /**
  67731. * Adds a side to the polygon
  67732. * @param positions points that make the polygon
  67733. * @param normals normals of the polygon
  67734. * @param uvs uvs of the polygon
  67735. * @param indices indices of the polygon
  67736. * @param bounds bounds of the polygon
  67737. * @param points points of the polygon
  67738. * @param depth depth of the polygon
  67739. * @param flip flip of the polygon
  67740. */
  67741. private addSide;
  67742. }
  67743. }
  67744. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67745. import { Scene } from "babylonjs/scene";
  67746. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67747. import { Color4 } from "babylonjs/Maths/math.color";
  67748. import { Mesh } from "babylonjs/Meshes/mesh";
  67749. import { Nullable } from "babylonjs/types";
  67750. /**
  67751. * Class containing static functions to help procedurally build meshes
  67752. */
  67753. export class PolygonBuilder {
  67754. /**
  67755. * Creates a polygon mesh
  67756. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67757. * * 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
  67758. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67761. * * Remember you can only change the shape positions, not their number when updating a polygon
  67762. * @param name defines the name of the mesh
  67763. * @param options defines the options used to create the mesh
  67764. * @param scene defines the hosting scene
  67765. * @param earcutInjection can be used to inject your own earcut reference
  67766. * @returns the polygon mesh
  67767. */
  67768. static CreatePolygon(name: string, options: {
  67769. shape: Vector3[];
  67770. holes?: Vector3[][];
  67771. depth?: number;
  67772. faceUV?: Vector4[];
  67773. faceColors?: Color4[];
  67774. updatable?: boolean;
  67775. sideOrientation?: number;
  67776. frontUVs?: Vector4;
  67777. backUVs?: Vector4;
  67778. wrap?: boolean;
  67779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67780. /**
  67781. * Creates an extruded polygon mesh, with depth in the Y direction.
  67782. * * 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)
  67783. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67784. * @param name defines the name of the mesh
  67785. * @param options defines the options used to create the mesh
  67786. * @param scene defines the hosting scene
  67787. * @param earcutInjection can be used to inject your own earcut reference
  67788. * @returns the polygon mesh
  67789. */
  67790. static ExtrudePolygon(name: string, options: {
  67791. shape: Vector3[];
  67792. holes?: Vector3[][];
  67793. depth?: number;
  67794. faceUV?: Vector4[];
  67795. faceColors?: Color4[];
  67796. updatable?: boolean;
  67797. sideOrientation?: number;
  67798. frontUVs?: Vector4;
  67799. backUVs?: Vector4;
  67800. wrap?: boolean;
  67801. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67802. }
  67803. }
  67804. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67805. import { Scene } from "babylonjs/scene";
  67806. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67807. import { Mesh } from "babylonjs/Meshes/mesh";
  67808. import { Nullable } from "babylonjs/types";
  67809. /**
  67810. * Class containing static functions to help procedurally build meshes
  67811. */
  67812. export class LatheBuilder {
  67813. /**
  67814. * Creates lathe mesh.
  67815. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67816. * * 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
  67817. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67818. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67819. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67820. * * 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
  67821. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67822. * * 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
  67823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67827. * @param name defines the name of the mesh
  67828. * @param options defines the options used to create the mesh
  67829. * @param scene defines the hosting scene
  67830. * @returns the lathe mesh
  67831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67832. */
  67833. static CreateLathe(name: string, options: {
  67834. shape: Vector3[];
  67835. radius?: number;
  67836. tessellation?: number;
  67837. clip?: number;
  67838. arc?: number;
  67839. closed?: boolean;
  67840. updatable?: boolean;
  67841. sideOrientation?: number;
  67842. frontUVs?: Vector4;
  67843. backUVs?: Vector4;
  67844. cap?: number;
  67845. invertUV?: boolean;
  67846. }, scene?: Nullable<Scene>): Mesh;
  67847. }
  67848. }
  67849. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67850. import { Nullable } from "babylonjs/types";
  67851. import { Scene } from "babylonjs/scene";
  67852. import { Vector4 } from "babylonjs/Maths/math.vector";
  67853. import { Mesh } from "babylonjs/Meshes/mesh";
  67854. /**
  67855. * Class containing static functions to help procedurally build meshes
  67856. */
  67857. export class TiledPlaneBuilder {
  67858. /**
  67859. * Creates a tiled plane mesh
  67860. * * The parameter `pattern` will, depending on value, do nothing or
  67861. * * * flip (reflect about central vertical) alternate tiles across and up
  67862. * * * flip every tile on alternate rows
  67863. * * * rotate (180 degs) alternate tiles across and up
  67864. * * * rotate every tile on alternate rows
  67865. * * * flip and rotate alternate tiles across and up
  67866. * * * flip and rotate every tile on alternate rows
  67867. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67868. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67871. * * 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)
  67872. * * 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)
  67873. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67874. * @param name defines the name of the mesh
  67875. * @param options defines the options used to create the mesh
  67876. * @param scene defines the hosting scene
  67877. * @returns the box mesh
  67878. */
  67879. static CreateTiledPlane(name: string, options: {
  67880. pattern?: number;
  67881. tileSize?: number;
  67882. tileWidth?: number;
  67883. tileHeight?: number;
  67884. size?: number;
  67885. width?: number;
  67886. height?: number;
  67887. alignHorizontal?: number;
  67888. alignVertical?: number;
  67889. sideOrientation?: number;
  67890. frontUVs?: Vector4;
  67891. backUVs?: Vector4;
  67892. updatable?: boolean;
  67893. }, scene?: Nullable<Scene>): Mesh;
  67894. }
  67895. }
  67896. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67897. import { Nullable } from "babylonjs/types";
  67898. import { Scene } from "babylonjs/scene";
  67899. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67900. import { Mesh } from "babylonjs/Meshes/mesh";
  67901. /**
  67902. * Class containing static functions to help procedurally build meshes
  67903. */
  67904. export class TubeBuilder {
  67905. /**
  67906. * Creates a tube mesh.
  67907. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67908. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67909. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67910. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67911. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67912. * * 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)
  67913. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67914. * * 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
  67915. * * 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
  67916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67920. * @param name defines the name of the mesh
  67921. * @param options defines the options used to create the mesh
  67922. * @param scene defines the hosting scene
  67923. * @returns the tube mesh
  67924. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67925. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67926. */
  67927. static CreateTube(name: string, options: {
  67928. path: Vector3[];
  67929. radius?: number;
  67930. tessellation?: number;
  67931. radiusFunction?: {
  67932. (i: number, distance: number): number;
  67933. };
  67934. cap?: number;
  67935. arc?: number;
  67936. updatable?: boolean;
  67937. sideOrientation?: number;
  67938. frontUVs?: Vector4;
  67939. backUVs?: Vector4;
  67940. instance?: Mesh;
  67941. invertUV?: boolean;
  67942. }, scene?: Nullable<Scene>): Mesh;
  67943. }
  67944. }
  67945. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67946. import { Scene } from "babylonjs/scene";
  67947. import { Vector4 } from "babylonjs/Maths/math.vector";
  67948. import { Mesh } from "babylonjs/Meshes/mesh";
  67949. import { Nullable } from "babylonjs/types";
  67950. /**
  67951. * Class containing static functions to help procedurally build meshes
  67952. */
  67953. export class IcoSphereBuilder {
  67954. /**
  67955. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67956. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67957. * * 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`)
  67958. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67959. * * 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
  67960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67963. * @param name defines the name of the mesh
  67964. * @param options defines the options used to create the mesh
  67965. * @param scene defines the hosting scene
  67966. * @returns the icosahedron mesh
  67967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67968. */
  67969. static CreateIcoSphere(name: string, options: {
  67970. radius?: number;
  67971. radiusX?: number;
  67972. radiusY?: number;
  67973. radiusZ?: number;
  67974. flat?: boolean;
  67975. subdivisions?: number;
  67976. sideOrientation?: number;
  67977. frontUVs?: Vector4;
  67978. backUVs?: Vector4;
  67979. updatable?: boolean;
  67980. }, scene?: Nullable<Scene>): Mesh;
  67981. }
  67982. }
  67983. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67984. import { Vector3 } from "babylonjs/Maths/math.vector";
  67985. import { Mesh } from "babylonjs/Meshes/mesh";
  67986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67987. /**
  67988. * Class containing static functions to help procedurally build meshes
  67989. */
  67990. export class DecalBuilder {
  67991. /**
  67992. * Creates a decal mesh.
  67993. * 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
  67994. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67995. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67996. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67997. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67998. * @param name defines the name of the mesh
  67999. * @param sourceMesh defines the mesh where the decal must be applied
  68000. * @param options defines the options used to create the mesh
  68001. * @param scene defines the hosting scene
  68002. * @returns the decal mesh
  68003. * @see https://doc.babylonjs.com/how_to/decals
  68004. */
  68005. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68006. position?: Vector3;
  68007. normal?: Vector3;
  68008. size?: Vector3;
  68009. angle?: number;
  68010. }): Mesh;
  68011. }
  68012. }
  68013. declare module "babylonjs/Meshes/meshBuilder" {
  68014. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68015. import { Nullable } from "babylonjs/types";
  68016. import { Scene } from "babylonjs/scene";
  68017. import { Mesh } from "babylonjs/Meshes/mesh";
  68018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68019. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68021. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68022. import { Plane } from "babylonjs/Maths/math.plane";
  68023. /**
  68024. * Class containing static functions to help procedurally build meshes
  68025. */
  68026. export class MeshBuilder {
  68027. /**
  68028. * Creates a box mesh
  68029. * * The parameter `size` sets the size (float) of each box side (default 1)
  68030. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68031. * * 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)
  68032. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68037. * @param name defines the name of the mesh
  68038. * @param options defines the options used to create the mesh
  68039. * @param scene defines the hosting scene
  68040. * @returns the box mesh
  68041. */
  68042. static CreateBox(name: string, options: {
  68043. size?: number;
  68044. width?: number;
  68045. height?: number;
  68046. depth?: number;
  68047. faceUV?: Vector4[];
  68048. faceColors?: Color4[];
  68049. sideOrientation?: number;
  68050. frontUVs?: Vector4;
  68051. backUVs?: Vector4;
  68052. wrap?: boolean;
  68053. topBaseAt?: number;
  68054. bottomBaseAt?: number;
  68055. updatable?: boolean;
  68056. }, scene?: Nullable<Scene>): Mesh;
  68057. /**
  68058. * Creates a tiled box mesh
  68059. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68061. * @param name defines the name of the mesh
  68062. * @param options defines the options used to create the mesh
  68063. * @param scene defines the hosting scene
  68064. * @returns the tiled box mesh
  68065. */
  68066. static CreateTiledBox(name: string, options: {
  68067. pattern?: number;
  68068. size?: number;
  68069. width?: number;
  68070. height?: number;
  68071. depth: number;
  68072. tileSize?: number;
  68073. tileWidth?: number;
  68074. tileHeight?: number;
  68075. faceUV?: Vector4[];
  68076. faceColors?: Color4[];
  68077. alignHorizontal?: number;
  68078. alignVertical?: number;
  68079. sideOrientation?: number;
  68080. updatable?: boolean;
  68081. }, scene?: Nullable<Scene>): Mesh;
  68082. /**
  68083. * Creates a sphere mesh
  68084. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68085. * * 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`)
  68086. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68087. * * 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
  68088. * * 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)
  68089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68092. * @param name defines the name of the mesh
  68093. * @param options defines the options used to create the mesh
  68094. * @param scene defines the hosting scene
  68095. * @returns the sphere mesh
  68096. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68097. */
  68098. static CreateSphere(name: string, options: {
  68099. segments?: number;
  68100. diameter?: number;
  68101. diameterX?: number;
  68102. diameterY?: number;
  68103. diameterZ?: number;
  68104. arc?: number;
  68105. slice?: number;
  68106. sideOrientation?: number;
  68107. frontUVs?: Vector4;
  68108. backUVs?: Vector4;
  68109. updatable?: boolean;
  68110. }, scene?: Nullable<Scene>): Mesh;
  68111. /**
  68112. * Creates a plane polygonal mesh. By default, this is a disc
  68113. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68114. * * 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
  68115. * * 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
  68116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68119. * @param name defines the name of the mesh
  68120. * @param options defines the options used to create the mesh
  68121. * @param scene defines the hosting scene
  68122. * @returns the plane polygonal mesh
  68123. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68124. */
  68125. static CreateDisc(name: string, options: {
  68126. radius?: number;
  68127. tessellation?: number;
  68128. arc?: number;
  68129. updatable?: boolean;
  68130. sideOrientation?: number;
  68131. frontUVs?: Vector4;
  68132. backUVs?: Vector4;
  68133. }, scene?: Nullable<Scene>): Mesh;
  68134. /**
  68135. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68136. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68137. * * 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`)
  68138. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68139. * * 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
  68140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68143. * @param name defines the name of the mesh
  68144. * @param options defines the options used to create the mesh
  68145. * @param scene defines the hosting scene
  68146. * @returns the icosahedron mesh
  68147. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68148. */
  68149. static CreateIcoSphere(name: string, options: {
  68150. radius?: number;
  68151. radiusX?: number;
  68152. radiusY?: number;
  68153. radiusZ?: number;
  68154. flat?: boolean;
  68155. subdivisions?: number;
  68156. sideOrientation?: number;
  68157. frontUVs?: Vector4;
  68158. backUVs?: Vector4;
  68159. updatable?: boolean;
  68160. }, scene?: Nullable<Scene>): Mesh;
  68161. /**
  68162. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68163. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68164. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68165. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68166. * * 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
  68167. * * 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
  68168. * * 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
  68169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68171. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68172. * * 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
  68173. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68174. * * 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
  68175. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68177. * @param name defines the name of the mesh
  68178. * @param options defines the options used to create the mesh
  68179. * @param scene defines the hosting scene
  68180. * @returns the ribbon mesh
  68181. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68183. */
  68184. static CreateRibbon(name: string, options: {
  68185. pathArray: Vector3[][];
  68186. closeArray?: boolean;
  68187. closePath?: boolean;
  68188. offset?: number;
  68189. updatable?: boolean;
  68190. sideOrientation?: number;
  68191. frontUVs?: Vector4;
  68192. backUVs?: Vector4;
  68193. instance?: Mesh;
  68194. invertUV?: boolean;
  68195. uvs?: Vector2[];
  68196. colors?: Color4[];
  68197. }, scene?: Nullable<Scene>): Mesh;
  68198. /**
  68199. * Creates a cylinder or a cone mesh
  68200. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68201. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68202. * * 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.
  68203. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68204. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68205. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68206. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68207. * * 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).
  68208. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68209. * * 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).
  68210. * * 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
  68211. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68212. * * 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
  68213. * * 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.
  68214. * * If `enclose` is false, a ring surface is one element.
  68215. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68216. * * 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
  68217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68220. * @param name defines the name of the mesh
  68221. * @param options defines the options used to create the mesh
  68222. * @param scene defines the hosting scene
  68223. * @returns the cylinder mesh
  68224. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68225. */
  68226. static CreateCylinder(name: string, options: {
  68227. height?: number;
  68228. diameterTop?: number;
  68229. diameterBottom?: number;
  68230. diameter?: number;
  68231. tessellation?: number;
  68232. subdivisions?: number;
  68233. arc?: number;
  68234. faceColors?: Color4[];
  68235. faceUV?: Vector4[];
  68236. updatable?: boolean;
  68237. hasRings?: boolean;
  68238. enclose?: boolean;
  68239. cap?: number;
  68240. sideOrientation?: number;
  68241. frontUVs?: Vector4;
  68242. backUVs?: Vector4;
  68243. }, scene?: Nullable<Scene>): Mesh;
  68244. /**
  68245. * Creates a torus mesh
  68246. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68247. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68248. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68252. * @param name defines the name of the mesh
  68253. * @param options defines the options used to create the mesh
  68254. * @param scene defines the hosting scene
  68255. * @returns the torus mesh
  68256. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68257. */
  68258. static CreateTorus(name: string, options: {
  68259. diameter?: number;
  68260. thickness?: number;
  68261. tessellation?: number;
  68262. updatable?: boolean;
  68263. sideOrientation?: number;
  68264. frontUVs?: Vector4;
  68265. backUVs?: Vector4;
  68266. }, scene?: Nullable<Scene>): Mesh;
  68267. /**
  68268. * Creates a torus knot mesh
  68269. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68270. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68271. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68272. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68276. * @param name defines the name of the mesh
  68277. * @param options defines the options used to create the mesh
  68278. * @param scene defines the hosting scene
  68279. * @returns the torus knot mesh
  68280. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68281. */
  68282. static CreateTorusKnot(name: string, options: {
  68283. radius?: number;
  68284. tube?: number;
  68285. radialSegments?: number;
  68286. tubularSegments?: number;
  68287. p?: number;
  68288. q?: number;
  68289. updatable?: boolean;
  68290. sideOrientation?: number;
  68291. frontUVs?: Vector4;
  68292. backUVs?: Vector4;
  68293. }, scene?: Nullable<Scene>): Mesh;
  68294. /**
  68295. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68296. * * 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
  68297. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68298. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68299. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68300. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68301. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68302. * * 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
  68303. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68306. * @param name defines the name of the new line system
  68307. * @param options defines the options used to create the line system
  68308. * @param scene defines the hosting scene
  68309. * @returns a new line system mesh
  68310. */
  68311. static CreateLineSystem(name: string, options: {
  68312. lines: Vector3[][];
  68313. updatable?: boolean;
  68314. instance?: Nullable<LinesMesh>;
  68315. colors?: Nullable<Color4[][]>;
  68316. useVertexAlpha?: boolean;
  68317. }, scene: Nullable<Scene>): LinesMesh;
  68318. /**
  68319. * Creates a line mesh
  68320. * 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
  68321. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68322. * * The parameter `points` is an array successive Vector3
  68323. * * 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
  68324. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68325. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68326. * * When updating an instance, remember that only point positions can change, not the number of points
  68327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68329. * @param name defines the name of the new line system
  68330. * @param options defines the options used to create the line system
  68331. * @param scene defines the hosting scene
  68332. * @returns a new line mesh
  68333. */
  68334. static CreateLines(name: string, options: {
  68335. points: Vector3[];
  68336. updatable?: boolean;
  68337. instance?: Nullable<LinesMesh>;
  68338. colors?: Color4[];
  68339. useVertexAlpha?: boolean;
  68340. }, scene?: Nullable<Scene>): LinesMesh;
  68341. /**
  68342. * Creates a dashed line mesh
  68343. * * 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
  68344. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68345. * * The parameter `points` is an array successive Vector3
  68346. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68347. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68348. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68349. * * 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
  68350. * * When updating an instance, remember that only point positions can change, not the number of points
  68351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68352. * @param name defines the name of the mesh
  68353. * @param options defines the options used to create the mesh
  68354. * @param scene defines the hosting scene
  68355. * @returns the dashed line mesh
  68356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68357. */
  68358. static CreateDashedLines(name: string, options: {
  68359. points: Vector3[];
  68360. dashSize?: number;
  68361. gapSize?: number;
  68362. dashNb?: number;
  68363. updatable?: boolean;
  68364. instance?: LinesMesh;
  68365. }, scene?: Nullable<Scene>): LinesMesh;
  68366. /**
  68367. * 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.
  68368. * * 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.
  68369. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68370. * * 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.
  68371. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68372. * * 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
  68373. * * 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
  68374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68379. * @param name defines the name of the mesh
  68380. * @param options defines the options used to create the mesh
  68381. * @param scene defines the hosting scene
  68382. * @returns the extruded shape mesh
  68383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68385. */
  68386. static ExtrudeShape(name: string, options: {
  68387. shape: Vector3[];
  68388. path: Vector3[];
  68389. scale?: number;
  68390. rotation?: number;
  68391. cap?: number;
  68392. updatable?: boolean;
  68393. sideOrientation?: number;
  68394. frontUVs?: Vector4;
  68395. backUVs?: Vector4;
  68396. instance?: Mesh;
  68397. invertUV?: boolean;
  68398. }, scene?: Nullable<Scene>): Mesh;
  68399. /**
  68400. * Creates an custom extruded shape mesh.
  68401. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68402. * * 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.
  68403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68404. * * 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
  68405. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68406. * * 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
  68407. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68408. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68409. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68410. * * 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
  68411. * * 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
  68412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68417. * @param name defines the name of the mesh
  68418. * @param options defines the options used to create the mesh
  68419. * @param scene defines the hosting scene
  68420. * @returns the custom extruded shape mesh
  68421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68424. */
  68425. static ExtrudeShapeCustom(name: string, options: {
  68426. shape: Vector3[];
  68427. path: Vector3[];
  68428. scaleFunction?: any;
  68429. rotationFunction?: any;
  68430. ribbonCloseArray?: boolean;
  68431. ribbonClosePath?: boolean;
  68432. cap?: number;
  68433. updatable?: boolean;
  68434. sideOrientation?: number;
  68435. frontUVs?: Vector4;
  68436. backUVs?: Vector4;
  68437. instance?: Mesh;
  68438. invertUV?: boolean;
  68439. }, scene?: Nullable<Scene>): Mesh;
  68440. /**
  68441. * Creates lathe mesh.
  68442. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68443. * * 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
  68444. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68445. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68446. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68447. * * 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
  68448. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68449. * * 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
  68450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68454. * @param name defines the name of the mesh
  68455. * @param options defines the options used to create the mesh
  68456. * @param scene defines the hosting scene
  68457. * @returns the lathe mesh
  68458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68459. */
  68460. static CreateLathe(name: string, options: {
  68461. shape: Vector3[];
  68462. radius?: number;
  68463. tessellation?: number;
  68464. clip?: number;
  68465. arc?: number;
  68466. closed?: boolean;
  68467. updatable?: boolean;
  68468. sideOrientation?: number;
  68469. frontUVs?: Vector4;
  68470. backUVs?: Vector4;
  68471. cap?: number;
  68472. invertUV?: boolean;
  68473. }, scene?: Nullable<Scene>): Mesh;
  68474. /**
  68475. * Creates a tiled plane mesh
  68476. * * You can set a limited pattern arrangement with the tiles
  68477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68480. * @param name defines the name of the mesh
  68481. * @param options defines the options used to create the mesh
  68482. * @param scene defines the hosting scene
  68483. * @returns the plane mesh
  68484. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68485. */
  68486. static CreateTiledPlane(name: string, options: {
  68487. pattern?: number;
  68488. tileSize?: number;
  68489. tileWidth?: number;
  68490. tileHeight?: number;
  68491. size?: number;
  68492. width?: number;
  68493. height?: number;
  68494. alignHorizontal?: number;
  68495. alignVertical?: number;
  68496. sideOrientation?: number;
  68497. frontUVs?: Vector4;
  68498. backUVs?: Vector4;
  68499. updatable?: boolean;
  68500. }, scene?: Nullable<Scene>): Mesh;
  68501. /**
  68502. * Creates a plane mesh
  68503. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68504. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68505. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68509. * @param name defines the name of the mesh
  68510. * @param options defines the options used to create the mesh
  68511. * @param scene defines the hosting scene
  68512. * @returns the plane mesh
  68513. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68514. */
  68515. static CreatePlane(name: string, options: {
  68516. size?: number;
  68517. width?: number;
  68518. height?: number;
  68519. sideOrientation?: number;
  68520. frontUVs?: Vector4;
  68521. backUVs?: Vector4;
  68522. updatable?: boolean;
  68523. sourcePlane?: Plane;
  68524. }, scene?: Nullable<Scene>): Mesh;
  68525. /**
  68526. * Creates a ground mesh
  68527. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68528. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68530. * @param name defines the name of the mesh
  68531. * @param options defines the options used to create the mesh
  68532. * @param scene defines the hosting scene
  68533. * @returns the ground mesh
  68534. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68535. */
  68536. static CreateGround(name: string, options: {
  68537. width?: number;
  68538. height?: number;
  68539. subdivisions?: number;
  68540. subdivisionsX?: number;
  68541. subdivisionsY?: number;
  68542. updatable?: boolean;
  68543. }, scene?: Nullable<Scene>): Mesh;
  68544. /**
  68545. * Creates a tiled ground mesh
  68546. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68547. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68548. * * 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
  68549. * * 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
  68550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68551. * @param name defines the name of the mesh
  68552. * @param options defines the options used to create the mesh
  68553. * @param scene defines the hosting scene
  68554. * @returns the tiled ground mesh
  68555. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68556. */
  68557. static CreateTiledGround(name: string, options: {
  68558. xmin: number;
  68559. zmin: number;
  68560. xmax: number;
  68561. zmax: number;
  68562. subdivisions?: {
  68563. w: number;
  68564. h: number;
  68565. };
  68566. precision?: {
  68567. w: number;
  68568. h: number;
  68569. };
  68570. updatable?: boolean;
  68571. }, scene?: Nullable<Scene>): Mesh;
  68572. /**
  68573. * Creates a ground mesh from a height map
  68574. * * The parameter `url` sets the URL of the height map image resource.
  68575. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68576. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68577. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68578. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68579. * * 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.
  68580. * * 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).
  68581. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68583. * @param name defines the name of the mesh
  68584. * @param url defines the url to the height map
  68585. * @param options defines the options used to create the mesh
  68586. * @param scene defines the hosting scene
  68587. * @returns the ground mesh
  68588. * @see https://doc.babylonjs.com/babylon101/height_map
  68589. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68590. */
  68591. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68592. width?: number;
  68593. height?: number;
  68594. subdivisions?: number;
  68595. minHeight?: number;
  68596. maxHeight?: number;
  68597. colorFilter?: Color3;
  68598. alphaFilter?: number;
  68599. updatable?: boolean;
  68600. onReady?: (mesh: GroundMesh) => void;
  68601. }, scene?: Nullable<Scene>): GroundMesh;
  68602. /**
  68603. * Creates a polygon mesh
  68604. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68605. * * 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
  68606. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68609. * * Remember you can only change the shape positions, not their number when updating a polygon
  68610. * @param name defines the name of the mesh
  68611. * @param options defines the options used to create the mesh
  68612. * @param scene defines the hosting scene
  68613. * @param earcutInjection can be used to inject your own earcut reference
  68614. * @returns the polygon mesh
  68615. */
  68616. static CreatePolygon(name: string, options: {
  68617. shape: Vector3[];
  68618. holes?: Vector3[][];
  68619. depth?: number;
  68620. faceUV?: Vector4[];
  68621. faceColors?: Color4[];
  68622. updatable?: boolean;
  68623. sideOrientation?: number;
  68624. frontUVs?: Vector4;
  68625. backUVs?: Vector4;
  68626. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68627. /**
  68628. * Creates an extruded polygon mesh, with depth in the Y direction.
  68629. * * 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)
  68630. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68631. * @param name defines the name of the mesh
  68632. * @param options defines the options used to create the mesh
  68633. * @param scene defines the hosting scene
  68634. * @param earcutInjection can be used to inject your own earcut reference
  68635. * @returns the polygon mesh
  68636. */
  68637. static ExtrudePolygon(name: string, options: {
  68638. shape: Vector3[];
  68639. holes?: Vector3[][];
  68640. depth?: number;
  68641. faceUV?: Vector4[];
  68642. faceColors?: Color4[];
  68643. updatable?: boolean;
  68644. sideOrientation?: number;
  68645. frontUVs?: Vector4;
  68646. backUVs?: Vector4;
  68647. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68648. /**
  68649. * Creates a tube mesh.
  68650. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68651. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68652. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68653. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68654. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68655. * * 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)
  68656. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68657. * * 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
  68658. * * 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
  68659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68663. * @param name defines the name of the mesh
  68664. * @param options defines the options used to create the mesh
  68665. * @param scene defines the hosting scene
  68666. * @returns the tube mesh
  68667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68668. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68669. */
  68670. static CreateTube(name: string, options: {
  68671. path: Vector3[];
  68672. radius?: number;
  68673. tessellation?: number;
  68674. radiusFunction?: {
  68675. (i: number, distance: number): number;
  68676. };
  68677. cap?: number;
  68678. arc?: number;
  68679. updatable?: boolean;
  68680. sideOrientation?: number;
  68681. frontUVs?: Vector4;
  68682. backUVs?: Vector4;
  68683. instance?: Mesh;
  68684. invertUV?: boolean;
  68685. }, scene?: Nullable<Scene>): Mesh;
  68686. /**
  68687. * Creates a polyhedron mesh
  68688. * * 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
  68689. * * The parameter `size` (positive float, default 1) sets the polygon size
  68690. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68691. * * 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`
  68692. * * 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
  68693. * * 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)`)
  68694. * * 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
  68695. * * 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
  68696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68699. * @param name defines the name of the mesh
  68700. * @param options defines the options used to create the mesh
  68701. * @param scene defines the hosting scene
  68702. * @returns the polyhedron mesh
  68703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68704. */
  68705. static CreatePolyhedron(name: string, options: {
  68706. type?: number;
  68707. size?: number;
  68708. sizeX?: number;
  68709. sizeY?: number;
  68710. sizeZ?: number;
  68711. custom?: any;
  68712. faceUV?: Vector4[];
  68713. faceColors?: Color4[];
  68714. flat?: boolean;
  68715. updatable?: boolean;
  68716. sideOrientation?: number;
  68717. frontUVs?: Vector4;
  68718. backUVs?: Vector4;
  68719. }, scene?: Nullable<Scene>): Mesh;
  68720. /**
  68721. * Creates a decal mesh.
  68722. * 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
  68723. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68724. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68725. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68726. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68727. * @param name defines the name of the mesh
  68728. * @param sourceMesh defines the mesh where the decal must be applied
  68729. * @param options defines the options used to create the mesh
  68730. * @param scene defines the hosting scene
  68731. * @returns the decal mesh
  68732. * @see https://doc.babylonjs.com/how_to/decals
  68733. */
  68734. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68735. position?: Vector3;
  68736. normal?: Vector3;
  68737. size?: Vector3;
  68738. angle?: number;
  68739. }): Mesh;
  68740. }
  68741. }
  68742. declare module "babylonjs/Meshes/meshSimplification" {
  68743. import { Mesh } from "babylonjs/Meshes/mesh";
  68744. /**
  68745. * A simplifier interface for future simplification implementations
  68746. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68747. */
  68748. export interface ISimplifier {
  68749. /**
  68750. * Simplification of a given mesh according to the given settings.
  68751. * Since this requires computation, it is assumed that the function runs async.
  68752. * @param settings The settings of the simplification, including quality and distance
  68753. * @param successCallback A callback that will be called after the mesh was simplified.
  68754. * @param errorCallback in case of an error, this callback will be called. optional.
  68755. */
  68756. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68757. }
  68758. /**
  68759. * Expected simplification settings.
  68760. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68762. */
  68763. export interface ISimplificationSettings {
  68764. /**
  68765. * Gets or sets the expected quality
  68766. */
  68767. quality: number;
  68768. /**
  68769. * Gets or sets the distance when this optimized version should be used
  68770. */
  68771. distance: number;
  68772. /**
  68773. * Gets an already optimized mesh
  68774. */
  68775. optimizeMesh?: boolean;
  68776. }
  68777. /**
  68778. * Class used to specify simplification options
  68779. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68780. */
  68781. export class SimplificationSettings implements ISimplificationSettings {
  68782. /** expected quality */
  68783. quality: number;
  68784. /** distance when this optimized version should be used */
  68785. distance: number;
  68786. /** already optimized mesh */
  68787. optimizeMesh?: boolean | undefined;
  68788. /**
  68789. * Creates a SimplificationSettings
  68790. * @param quality expected quality
  68791. * @param distance distance when this optimized version should be used
  68792. * @param optimizeMesh already optimized mesh
  68793. */
  68794. constructor(
  68795. /** expected quality */
  68796. quality: number,
  68797. /** distance when this optimized version should be used */
  68798. distance: number,
  68799. /** already optimized mesh */
  68800. optimizeMesh?: boolean | undefined);
  68801. }
  68802. /**
  68803. * Interface used to define a simplification task
  68804. */
  68805. export interface ISimplificationTask {
  68806. /**
  68807. * Array of settings
  68808. */
  68809. settings: Array<ISimplificationSettings>;
  68810. /**
  68811. * Simplification type
  68812. */
  68813. simplificationType: SimplificationType;
  68814. /**
  68815. * Mesh to simplify
  68816. */
  68817. mesh: Mesh;
  68818. /**
  68819. * Callback called on success
  68820. */
  68821. successCallback?: () => void;
  68822. /**
  68823. * Defines if parallel processing can be used
  68824. */
  68825. parallelProcessing: boolean;
  68826. }
  68827. /**
  68828. * Queue used to order the simplification tasks
  68829. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68830. */
  68831. export class SimplificationQueue {
  68832. private _simplificationArray;
  68833. /**
  68834. * Gets a boolean indicating that the process is still running
  68835. */
  68836. running: boolean;
  68837. /**
  68838. * Creates a new queue
  68839. */
  68840. constructor();
  68841. /**
  68842. * Adds a new simplification task
  68843. * @param task defines a task to add
  68844. */
  68845. addTask(task: ISimplificationTask): void;
  68846. /**
  68847. * Execute next task
  68848. */
  68849. executeNext(): void;
  68850. /**
  68851. * Execute a simplification task
  68852. * @param task defines the task to run
  68853. */
  68854. runSimplification(task: ISimplificationTask): void;
  68855. private getSimplifier;
  68856. }
  68857. /**
  68858. * The implemented types of simplification
  68859. * At the moment only Quadratic Error Decimation is implemented
  68860. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68861. */
  68862. export enum SimplificationType {
  68863. /** Quadratic error decimation */
  68864. QUADRATIC = 0
  68865. }
  68866. /**
  68867. * An implementation of the Quadratic Error simplification algorithm.
  68868. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68869. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68870. * @author RaananW
  68871. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68872. */
  68873. export class QuadraticErrorSimplification implements ISimplifier {
  68874. private _mesh;
  68875. private triangles;
  68876. private vertices;
  68877. private references;
  68878. private _reconstructedMesh;
  68879. /** Gets or sets the number pf sync interations */
  68880. syncIterations: number;
  68881. /** Gets or sets the aggressiveness of the simplifier */
  68882. aggressiveness: number;
  68883. /** Gets or sets the number of allowed iterations for decimation */
  68884. decimationIterations: number;
  68885. /** Gets or sets the espilon to use for bounding box computation */
  68886. boundingBoxEpsilon: number;
  68887. /**
  68888. * Creates a new QuadraticErrorSimplification
  68889. * @param _mesh defines the target mesh
  68890. */
  68891. constructor(_mesh: Mesh);
  68892. /**
  68893. * Simplification of a given mesh according to the given settings.
  68894. * Since this requires computation, it is assumed that the function runs async.
  68895. * @param settings The settings of the simplification, including quality and distance
  68896. * @param successCallback A callback that will be called after the mesh was simplified.
  68897. */
  68898. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68899. private runDecimation;
  68900. private initWithMesh;
  68901. private init;
  68902. private reconstructMesh;
  68903. private initDecimatedMesh;
  68904. private isFlipped;
  68905. private updateTriangles;
  68906. private identifyBorder;
  68907. private updateMesh;
  68908. private vertexError;
  68909. private calculateError;
  68910. }
  68911. }
  68912. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68913. import { Scene } from "babylonjs/scene";
  68914. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68915. import { ISceneComponent } from "babylonjs/sceneComponent";
  68916. module "babylonjs/scene" {
  68917. interface Scene {
  68918. /** @hidden (Backing field) */
  68919. _simplificationQueue: SimplificationQueue;
  68920. /**
  68921. * Gets or sets the simplification queue attached to the scene
  68922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68923. */
  68924. simplificationQueue: SimplificationQueue;
  68925. }
  68926. }
  68927. module "babylonjs/Meshes/mesh" {
  68928. interface Mesh {
  68929. /**
  68930. * Simplify the mesh according to the given array of settings.
  68931. * Function will return immediately and will simplify async
  68932. * @param settings a collection of simplification settings
  68933. * @param parallelProcessing should all levels calculate parallel or one after the other
  68934. * @param simplificationType the type of simplification to run
  68935. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68936. * @returns the current mesh
  68937. */
  68938. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68939. }
  68940. }
  68941. /**
  68942. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68943. * created in a scene
  68944. */
  68945. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68946. /**
  68947. * The component name helpfull to identify the component in the list of scene components.
  68948. */
  68949. readonly name: string;
  68950. /**
  68951. * The scene the component belongs to.
  68952. */
  68953. scene: Scene;
  68954. /**
  68955. * Creates a new instance of the component for the given scene
  68956. * @param scene Defines the scene to register the component in
  68957. */
  68958. constructor(scene: Scene);
  68959. /**
  68960. * Registers the component in a given scene
  68961. */
  68962. register(): void;
  68963. /**
  68964. * Rebuilds the elements related to this component in case of
  68965. * context lost for instance.
  68966. */
  68967. rebuild(): void;
  68968. /**
  68969. * Disposes the component and the associated ressources
  68970. */
  68971. dispose(): void;
  68972. private _beforeCameraUpdate;
  68973. }
  68974. }
  68975. declare module "babylonjs/Meshes/Builders/index" {
  68976. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68977. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68978. export * from "babylonjs/Meshes/Builders/discBuilder";
  68979. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68980. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68981. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68982. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68983. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68984. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68985. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68986. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68987. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68988. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68989. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68990. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68991. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68992. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68993. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68994. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68995. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68996. }
  68997. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68998. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68999. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69000. import { Matrix } from "babylonjs/Maths/math.vector";
  69001. module "babylonjs/Meshes/mesh" {
  69002. interface Mesh {
  69003. /**
  69004. * Creates a new thin instance
  69005. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69006. * @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
  69007. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69008. */
  69009. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69010. /**
  69011. * Adds the transformation (matrix) of the current mesh as a thin instance
  69012. * @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
  69013. * @returns the thin instance index number
  69014. */
  69015. thinInstanceAddSelf(refresh: boolean): number;
  69016. /**
  69017. * Registers a custom attribute to be used with thin instances
  69018. * @param kind name of the attribute
  69019. * @param stride size in floats of the attribute
  69020. */
  69021. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69022. /**
  69023. * Sets the matrix of a thin instance
  69024. * @param index index of the thin instance
  69025. * @param matrix matrix to set
  69026. * @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
  69027. */
  69028. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69029. /**
  69030. * Sets the value of a custom attribute for a thin instance
  69031. * @param kind name of the attribute
  69032. * @param index index of the thin instance
  69033. * @param value value to set
  69034. * @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
  69035. */
  69036. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69037. /**
  69038. * 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.
  69039. */
  69040. thinInstanceCount: number;
  69041. /**
  69042. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69043. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69044. * @param buffer buffer to set
  69045. * @param stride size in floats of each value of the buffer
  69046. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69047. */
  69048. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69049. /**
  69050. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69051. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69052. */
  69053. thinInstanceBufferUpdated(kind: string): void;
  69054. /**
  69055. * Refreshes the bounding info, taking into account all the thin instances defined
  69056. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69057. */
  69058. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69059. /** @hidden */
  69060. _thinInstanceInitializeUserStorage(): void;
  69061. /** @hidden */
  69062. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69063. /** @hidden */
  69064. _userThinInstanceBuffersStorage: {
  69065. data: {
  69066. [key: string]: Float32Array;
  69067. };
  69068. sizes: {
  69069. [key: string]: number;
  69070. };
  69071. vertexBuffers: {
  69072. [key: string]: Nullable<VertexBuffer>;
  69073. };
  69074. strides: {
  69075. [key: string]: number;
  69076. };
  69077. };
  69078. }
  69079. }
  69080. }
  69081. declare module "babylonjs/Meshes/index" {
  69082. export * from "babylonjs/Meshes/abstractMesh";
  69083. export * from "babylonjs/Meshes/buffer";
  69084. export * from "babylonjs/Meshes/Compression/index";
  69085. export * from "babylonjs/Meshes/csg";
  69086. export * from "babylonjs/Meshes/geometry";
  69087. export * from "babylonjs/Meshes/groundMesh";
  69088. export * from "babylonjs/Meshes/trailMesh";
  69089. export * from "babylonjs/Meshes/instancedMesh";
  69090. export * from "babylonjs/Meshes/linesMesh";
  69091. export * from "babylonjs/Meshes/mesh";
  69092. export * from "babylonjs/Meshes/mesh.vertexData";
  69093. export * from "babylonjs/Meshes/meshBuilder";
  69094. export * from "babylonjs/Meshes/meshSimplification";
  69095. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69096. export * from "babylonjs/Meshes/polygonMesh";
  69097. export * from "babylonjs/Meshes/subMesh";
  69098. export * from "babylonjs/Meshes/meshLODLevel";
  69099. export * from "babylonjs/Meshes/transformNode";
  69100. export * from "babylonjs/Meshes/Builders/index";
  69101. export * from "babylonjs/Meshes/dataBuffer";
  69102. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69103. import "babylonjs/Meshes/thinInstanceMesh";
  69104. export * from "babylonjs/Meshes/thinInstanceMesh";
  69105. }
  69106. declare module "babylonjs/Morph/index" {
  69107. export * from "babylonjs/Morph/morphTarget";
  69108. export * from "babylonjs/Morph/morphTargetManager";
  69109. }
  69110. declare module "babylonjs/Navigation/INavigationEngine" {
  69111. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69112. import { Vector3 } from "babylonjs/Maths/math";
  69113. import { Mesh } from "babylonjs/Meshes/mesh";
  69114. import { Scene } from "babylonjs/scene";
  69115. /**
  69116. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69117. */
  69118. export interface INavigationEnginePlugin {
  69119. /**
  69120. * plugin name
  69121. */
  69122. name: string;
  69123. /**
  69124. * Creates a navigation mesh
  69125. * @param meshes array of all the geometry used to compute the navigatio mesh
  69126. * @param parameters bunch of parameters used to filter geometry
  69127. */
  69128. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69129. /**
  69130. * Create a navigation mesh debug mesh
  69131. * @param scene is where the mesh will be added
  69132. * @returns debug display mesh
  69133. */
  69134. createDebugNavMesh(scene: Scene): Mesh;
  69135. /**
  69136. * Get a navigation mesh constrained position, closest to the parameter position
  69137. * @param position world position
  69138. * @returns the closest point to position constrained by the navigation mesh
  69139. */
  69140. getClosestPoint(position: Vector3): Vector3;
  69141. /**
  69142. * Get a navigation mesh constrained position, closest to the parameter position
  69143. * @param position world position
  69144. * @param result output the closest point to position constrained by the navigation mesh
  69145. */
  69146. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69147. /**
  69148. * Get a navigation mesh constrained position, within a particular radius
  69149. * @param position world position
  69150. * @param maxRadius the maximum distance to the constrained world position
  69151. * @returns the closest point to position constrained by the navigation mesh
  69152. */
  69153. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69154. /**
  69155. * Get a navigation mesh constrained position, within a particular radius
  69156. * @param position world position
  69157. * @param maxRadius the maximum distance to the constrained world position
  69158. * @param result output the closest point to position constrained by the navigation mesh
  69159. */
  69160. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69161. /**
  69162. * Compute the final position from a segment made of destination-position
  69163. * @param position world position
  69164. * @param destination world position
  69165. * @returns the resulting point along the navmesh
  69166. */
  69167. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69168. /**
  69169. * Compute the final position from a segment made of destination-position
  69170. * @param position world position
  69171. * @param destination world position
  69172. * @param result output the resulting point along the navmesh
  69173. */
  69174. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69175. /**
  69176. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69177. * @param start world position
  69178. * @param end world position
  69179. * @returns array containing world position composing the path
  69180. */
  69181. computePath(start: Vector3, end: Vector3): Vector3[];
  69182. /**
  69183. * If this plugin is supported
  69184. * @returns true if plugin is supported
  69185. */
  69186. isSupported(): boolean;
  69187. /**
  69188. * Create a new Crowd so you can add agents
  69189. * @param maxAgents the maximum agent count in the crowd
  69190. * @param maxAgentRadius the maximum radius an agent can have
  69191. * @param scene to attach the crowd to
  69192. * @returns the crowd you can add agents to
  69193. */
  69194. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69195. /**
  69196. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69197. * The queries will try to find a solution within those bounds
  69198. * default is (1,1,1)
  69199. * @param extent x,y,z value that define the extent around the queries point of reference
  69200. */
  69201. setDefaultQueryExtent(extent: Vector3): void;
  69202. /**
  69203. * Get the Bounding box extent specified by setDefaultQueryExtent
  69204. * @returns the box extent values
  69205. */
  69206. getDefaultQueryExtent(): Vector3;
  69207. /**
  69208. * build the navmesh from a previously saved state using getNavmeshData
  69209. * @param data the Uint8Array returned by getNavmeshData
  69210. */
  69211. buildFromNavmeshData(data: Uint8Array): void;
  69212. /**
  69213. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69214. * @returns data the Uint8Array that can be saved and reused
  69215. */
  69216. getNavmeshData(): Uint8Array;
  69217. /**
  69218. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69219. * @param result output the box extent values
  69220. */
  69221. getDefaultQueryExtentToRef(result: Vector3): void;
  69222. /**
  69223. * Release all resources
  69224. */
  69225. dispose(): void;
  69226. }
  69227. /**
  69228. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69229. */
  69230. export interface ICrowd {
  69231. /**
  69232. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69233. * You can attach anything to that node. The node position is updated in the scene update tick.
  69234. * @param pos world position that will be constrained by the navigation mesh
  69235. * @param parameters agent parameters
  69236. * @param transform hooked to the agent that will be update by the scene
  69237. * @returns agent index
  69238. */
  69239. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69240. /**
  69241. * Returns the agent position in world space
  69242. * @param index agent index returned by addAgent
  69243. * @returns world space position
  69244. */
  69245. getAgentPosition(index: number): Vector3;
  69246. /**
  69247. * Gets the agent position result in world space
  69248. * @param index agent index returned by addAgent
  69249. * @param result output world space position
  69250. */
  69251. getAgentPositionToRef(index: number, result: Vector3): void;
  69252. /**
  69253. * Gets the agent velocity in world space
  69254. * @param index agent index returned by addAgent
  69255. * @returns world space velocity
  69256. */
  69257. getAgentVelocity(index: number): Vector3;
  69258. /**
  69259. * Gets the agent velocity result in world space
  69260. * @param index agent index returned by addAgent
  69261. * @param result output world space velocity
  69262. */
  69263. getAgentVelocityToRef(index: number, result: Vector3): void;
  69264. /**
  69265. * remove a particular agent previously created
  69266. * @param index agent index returned by addAgent
  69267. */
  69268. removeAgent(index: number): void;
  69269. /**
  69270. * get the list of all agents attached to this crowd
  69271. * @returns list of agent indices
  69272. */
  69273. getAgents(): number[];
  69274. /**
  69275. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69276. * @param deltaTime in seconds
  69277. */
  69278. update(deltaTime: number): void;
  69279. /**
  69280. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69281. * @param index agent index returned by addAgent
  69282. * @param destination targeted world position
  69283. */
  69284. agentGoto(index: number, destination: Vector3): void;
  69285. /**
  69286. * Teleport the agent to a new position
  69287. * @param index agent index returned by addAgent
  69288. * @param destination targeted world position
  69289. */
  69290. agentTeleport(index: number, destination: Vector3): void;
  69291. /**
  69292. * Update agent parameters
  69293. * @param index agent index returned by addAgent
  69294. * @param parameters agent parameters
  69295. */
  69296. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69297. /**
  69298. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69299. * The queries will try to find a solution within those bounds
  69300. * default is (1,1,1)
  69301. * @param extent x,y,z value that define the extent around the queries point of reference
  69302. */
  69303. setDefaultQueryExtent(extent: Vector3): void;
  69304. /**
  69305. * Get the Bounding box extent specified by setDefaultQueryExtent
  69306. * @returns the box extent values
  69307. */
  69308. getDefaultQueryExtent(): Vector3;
  69309. /**
  69310. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69311. * @param result output the box extent values
  69312. */
  69313. getDefaultQueryExtentToRef(result: Vector3): void;
  69314. /**
  69315. * Release all resources
  69316. */
  69317. dispose(): void;
  69318. }
  69319. /**
  69320. * Configures an agent
  69321. */
  69322. export interface IAgentParameters {
  69323. /**
  69324. * Agent radius. [Limit: >= 0]
  69325. */
  69326. radius: number;
  69327. /**
  69328. * Agent height. [Limit: > 0]
  69329. */
  69330. height: number;
  69331. /**
  69332. * Maximum allowed acceleration. [Limit: >= 0]
  69333. */
  69334. maxAcceleration: number;
  69335. /**
  69336. * Maximum allowed speed. [Limit: >= 0]
  69337. */
  69338. maxSpeed: number;
  69339. /**
  69340. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69341. */
  69342. collisionQueryRange: number;
  69343. /**
  69344. * The path visibility optimization range. [Limit: > 0]
  69345. */
  69346. pathOptimizationRange: number;
  69347. /**
  69348. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69349. */
  69350. separationWeight: number;
  69351. }
  69352. /**
  69353. * Configures the navigation mesh creation
  69354. */
  69355. export interface INavMeshParameters {
  69356. /**
  69357. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69358. */
  69359. cs: number;
  69360. /**
  69361. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69362. */
  69363. ch: number;
  69364. /**
  69365. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69366. */
  69367. walkableSlopeAngle: number;
  69368. /**
  69369. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69370. * be considered walkable. [Limit: >= 3] [Units: vx]
  69371. */
  69372. walkableHeight: number;
  69373. /**
  69374. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69375. */
  69376. walkableClimb: number;
  69377. /**
  69378. * The distance to erode/shrink the walkable area of the heightfield away from
  69379. * obstructions. [Limit: >=0] [Units: vx]
  69380. */
  69381. walkableRadius: number;
  69382. /**
  69383. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69384. */
  69385. maxEdgeLen: number;
  69386. /**
  69387. * The maximum distance a simplfied contour's border edges should deviate
  69388. * the original raw contour. [Limit: >=0] [Units: vx]
  69389. */
  69390. maxSimplificationError: number;
  69391. /**
  69392. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69393. */
  69394. minRegionArea: number;
  69395. /**
  69396. * Any regions with a span count smaller than this value will, if possible,
  69397. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69398. */
  69399. mergeRegionArea: number;
  69400. /**
  69401. * The maximum number of vertices allowed for polygons generated during the
  69402. * contour to polygon conversion process. [Limit: >= 3]
  69403. */
  69404. maxVertsPerPoly: number;
  69405. /**
  69406. * Sets the sampling distance to use when generating the detail mesh.
  69407. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69408. */
  69409. detailSampleDist: number;
  69410. /**
  69411. * The maximum distance the detail mesh surface should deviate from heightfield
  69412. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69413. */
  69414. detailSampleMaxError: number;
  69415. }
  69416. }
  69417. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69418. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69419. import { Mesh } from "babylonjs/Meshes/mesh";
  69420. import { Scene } from "babylonjs/scene";
  69421. import { Vector3 } from "babylonjs/Maths/math";
  69422. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69423. /**
  69424. * RecastJS navigation plugin
  69425. */
  69426. export class RecastJSPlugin implements INavigationEnginePlugin {
  69427. /**
  69428. * Reference to the Recast library
  69429. */
  69430. bjsRECAST: any;
  69431. /**
  69432. * plugin name
  69433. */
  69434. name: string;
  69435. /**
  69436. * the first navmesh created. We might extend this to support multiple navmeshes
  69437. */
  69438. navMesh: any;
  69439. /**
  69440. * Initializes the recastJS plugin
  69441. * @param recastInjection can be used to inject your own recast reference
  69442. */
  69443. constructor(recastInjection?: any);
  69444. /**
  69445. * Creates a navigation mesh
  69446. * @param meshes array of all the geometry used to compute the navigatio mesh
  69447. * @param parameters bunch of parameters used to filter geometry
  69448. */
  69449. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69450. /**
  69451. * Create a navigation mesh debug mesh
  69452. * @param scene is where the mesh will be added
  69453. * @returns debug display mesh
  69454. */
  69455. createDebugNavMesh(scene: Scene): Mesh;
  69456. /**
  69457. * Get a navigation mesh constrained position, closest to the parameter position
  69458. * @param position world position
  69459. * @returns the closest point to position constrained by the navigation mesh
  69460. */
  69461. getClosestPoint(position: Vector3): Vector3;
  69462. /**
  69463. * Get a navigation mesh constrained position, closest to the parameter position
  69464. * @param position world position
  69465. * @param result output the closest point to position constrained by the navigation mesh
  69466. */
  69467. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69468. /**
  69469. * Get a navigation mesh constrained position, within a particular radius
  69470. * @param position world position
  69471. * @param maxRadius the maximum distance to the constrained world position
  69472. * @returns the closest point to position constrained by the navigation mesh
  69473. */
  69474. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69475. /**
  69476. * Get a navigation mesh constrained position, within a particular radius
  69477. * @param position world position
  69478. * @param maxRadius the maximum distance to the constrained world position
  69479. * @param result output the closest point to position constrained by the navigation mesh
  69480. */
  69481. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69482. /**
  69483. * Compute the final position from a segment made of destination-position
  69484. * @param position world position
  69485. * @param destination world position
  69486. * @returns the resulting point along the navmesh
  69487. */
  69488. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69489. /**
  69490. * Compute the final position from a segment made of destination-position
  69491. * @param position world position
  69492. * @param destination world position
  69493. * @param result output the resulting point along the navmesh
  69494. */
  69495. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69496. /**
  69497. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69498. * @param start world position
  69499. * @param end world position
  69500. * @returns array containing world position composing the path
  69501. */
  69502. computePath(start: Vector3, end: Vector3): Vector3[];
  69503. /**
  69504. * Create a new Crowd so you can add agents
  69505. * @param maxAgents the maximum agent count in the crowd
  69506. * @param maxAgentRadius the maximum radius an agent can have
  69507. * @param scene to attach the crowd to
  69508. * @returns the crowd you can add agents to
  69509. */
  69510. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69511. /**
  69512. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69513. * The queries will try to find a solution within those bounds
  69514. * default is (1,1,1)
  69515. * @param extent x,y,z value that define the extent around the queries point of reference
  69516. */
  69517. setDefaultQueryExtent(extent: Vector3): void;
  69518. /**
  69519. * Get the Bounding box extent specified by setDefaultQueryExtent
  69520. * @returns the box extent values
  69521. */
  69522. getDefaultQueryExtent(): Vector3;
  69523. /**
  69524. * build the navmesh from a previously saved state using getNavmeshData
  69525. * @param data the Uint8Array returned by getNavmeshData
  69526. */
  69527. buildFromNavmeshData(data: Uint8Array): void;
  69528. /**
  69529. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69530. * @returns data the Uint8Array that can be saved and reused
  69531. */
  69532. getNavmeshData(): Uint8Array;
  69533. /**
  69534. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69535. * @param result output the box extent values
  69536. */
  69537. getDefaultQueryExtentToRef(result: Vector3): void;
  69538. /**
  69539. * Disposes
  69540. */
  69541. dispose(): void;
  69542. /**
  69543. * If this plugin is supported
  69544. * @returns true if plugin is supported
  69545. */
  69546. isSupported(): boolean;
  69547. }
  69548. /**
  69549. * Recast detour crowd implementation
  69550. */
  69551. export class RecastJSCrowd implements ICrowd {
  69552. /**
  69553. * Recast/detour plugin
  69554. */
  69555. bjsRECASTPlugin: RecastJSPlugin;
  69556. /**
  69557. * Link to the detour crowd
  69558. */
  69559. recastCrowd: any;
  69560. /**
  69561. * One transform per agent
  69562. */
  69563. transforms: TransformNode[];
  69564. /**
  69565. * All agents created
  69566. */
  69567. agents: number[];
  69568. /**
  69569. * Link to the scene is kept to unregister the crowd from the scene
  69570. */
  69571. private _scene;
  69572. /**
  69573. * Observer for crowd updates
  69574. */
  69575. private _onBeforeAnimationsObserver;
  69576. /**
  69577. * Constructor
  69578. * @param plugin recastJS plugin
  69579. * @param maxAgents the maximum agent count in the crowd
  69580. * @param maxAgentRadius the maximum radius an agent can have
  69581. * @param scene to attach the crowd to
  69582. * @returns the crowd you can add agents to
  69583. */
  69584. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69585. /**
  69586. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69587. * You can attach anything to that node. The node position is updated in the scene update tick.
  69588. * @param pos world position that will be constrained by the navigation mesh
  69589. * @param parameters agent parameters
  69590. * @param transform hooked to the agent that will be update by the scene
  69591. * @returns agent index
  69592. */
  69593. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69594. /**
  69595. * Returns the agent position in world space
  69596. * @param index agent index returned by addAgent
  69597. * @returns world space position
  69598. */
  69599. getAgentPosition(index: number): Vector3;
  69600. /**
  69601. * Returns the agent position result in world space
  69602. * @param index agent index returned by addAgent
  69603. * @param result output world space position
  69604. */
  69605. getAgentPositionToRef(index: number, result: Vector3): void;
  69606. /**
  69607. * Returns the agent velocity in world space
  69608. * @param index agent index returned by addAgent
  69609. * @returns world space velocity
  69610. */
  69611. getAgentVelocity(index: number): Vector3;
  69612. /**
  69613. * Returns the agent velocity result in world space
  69614. * @param index agent index returned by addAgent
  69615. * @param result output world space velocity
  69616. */
  69617. getAgentVelocityToRef(index: number, result: Vector3): void;
  69618. /**
  69619. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69620. * @param index agent index returned by addAgent
  69621. * @param destination targeted world position
  69622. */
  69623. agentGoto(index: number, destination: Vector3): void;
  69624. /**
  69625. * Teleport the agent to a new position
  69626. * @param index agent index returned by addAgent
  69627. * @param destination targeted world position
  69628. */
  69629. agentTeleport(index: number, destination: Vector3): void;
  69630. /**
  69631. * Update agent parameters
  69632. * @param index agent index returned by addAgent
  69633. * @param parameters agent parameters
  69634. */
  69635. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69636. /**
  69637. * remove a particular agent previously created
  69638. * @param index agent index returned by addAgent
  69639. */
  69640. removeAgent(index: number): void;
  69641. /**
  69642. * get the list of all agents attached to this crowd
  69643. * @returns list of agent indices
  69644. */
  69645. getAgents(): number[];
  69646. /**
  69647. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69648. * @param deltaTime in seconds
  69649. */
  69650. update(deltaTime: number): void;
  69651. /**
  69652. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69653. * The queries will try to find a solution within those bounds
  69654. * default is (1,1,1)
  69655. * @param extent x,y,z value that define the extent around the queries point of reference
  69656. */
  69657. setDefaultQueryExtent(extent: Vector3): void;
  69658. /**
  69659. * Get the Bounding box extent specified by setDefaultQueryExtent
  69660. * @returns the box extent values
  69661. */
  69662. getDefaultQueryExtent(): Vector3;
  69663. /**
  69664. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69665. * @param result output the box extent values
  69666. */
  69667. getDefaultQueryExtentToRef(result: Vector3): void;
  69668. /**
  69669. * Release all resources
  69670. */
  69671. dispose(): void;
  69672. }
  69673. }
  69674. declare module "babylonjs/Navigation/Plugins/index" {
  69675. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69676. }
  69677. declare module "babylonjs/Navigation/index" {
  69678. export * from "babylonjs/Navigation/INavigationEngine";
  69679. export * from "babylonjs/Navigation/Plugins/index";
  69680. }
  69681. declare module "babylonjs/Offline/database" {
  69682. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69683. /**
  69684. * Class used to enable access to IndexedDB
  69685. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69686. */
  69687. export class Database implements IOfflineProvider {
  69688. private _callbackManifestChecked;
  69689. private _currentSceneUrl;
  69690. private _db;
  69691. private _enableSceneOffline;
  69692. private _enableTexturesOffline;
  69693. private _manifestVersionFound;
  69694. private _mustUpdateRessources;
  69695. private _hasReachedQuota;
  69696. private _isSupported;
  69697. private _idbFactory;
  69698. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69699. private static IsUASupportingBlobStorage;
  69700. /**
  69701. * Gets a boolean indicating if Database storate is enabled (off by default)
  69702. */
  69703. static IDBStorageEnabled: boolean;
  69704. /**
  69705. * Gets a boolean indicating if scene must be saved in the database
  69706. */
  69707. get enableSceneOffline(): boolean;
  69708. /**
  69709. * Gets a boolean indicating if textures must be saved in the database
  69710. */
  69711. get enableTexturesOffline(): boolean;
  69712. /**
  69713. * Creates a new Database
  69714. * @param urlToScene defines the url to load the scene
  69715. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69716. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69717. */
  69718. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69719. private static _ParseURL;
  69720. private static _ReturnFullUrlLocation;
  69721. private _checkManifestFile;
  69722. /**
  69723. * Open the database and make it available
  69724. * @param successCallback defines the callback to call on success
  69725. * @param errorCallback defines the callback to call on error
  69726. */
  69727. open(successCallback: () => void, errorCallback: () => void): void;
  69728. /**
  69729. * Loads an image from the database
  69730. * @param url defines the url to load from
  69731. * @param image defines the target DOM image
  69732. */
  69733. loadImage(url: string, image: HTMLImageElement): void;
  69734. private _loadImageFromDBAsync;
  69735. private _saveImageIntoDBAsync;
  69736. private _checkVersionFromDB;
  69737. private _loadVersionFromDBAsync;
  69738. private _saveVersionIntoDBAsync;
  69739. /**
  69740. * Loads a file from database
  69741. * @param url defines the URL to load from
  69742. * @param sceneLoaded defines a callback to call on success
  69743. * @param progressCallBack defines a callback to call when progress changed
  69744. * @param errorCallback defines a callback to call on error
  69745. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69746. */
  69747. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69748. private _loadFileAsync;
  69749. private _saveFileAsync;
  69750. /**
  69751. * Validates if xhr data is correct
  69752. * @param xhr defines the request to validate
  69753. * @param dataType defines the expected data type
  69754. * @returns true if data is correct
  69755. */
  69756. private static _ValidateXHRData;
  69757. }
  69758. }
  69759. declare module "babylonjs/Offline/index" {
  69760. export * from "babylonjs/Offline/database";
  69761. export * from "babylonjs/Offline/IOfflineProvider";
  69762. }
  69763. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69764. /** @hidden */
  69765. export var gpuUpdateParticlesPixelShader: {
  69766. name: string;
  69767. shader: string;
  69768. };
  69769. }
  69770. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69771. /** @hidden */
  69772. export var gpuUpdateParticlesVertexShader: {
  69773. name: string;
  69774. shader: string;
  69775. };
  69776. }
  69777. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69778. /** @hidden */
  69779. export var clipPlaneFragmentDeclaration2: {
  69780. name: string;
  69781. shader: string;
  69782. };
  69783. }
  69784. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69785. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69786. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69787. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69788. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69789. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69790. /** @hidden */
  69791. export var gpuRenderParticlesPixelShader: {
  69792. name: string;
  69793. shader: string;
  69794. };
  69795. }
  69796. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69797. /** @hidden */
  69798. export var clipPlaneVertexDeclaration2: {
  69799. name: string;
  69800. shader: string;
  69801. };
  69802. }
  69803. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69804. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69806. /** @hidden */
  69807. export var gpuRenderParticlesVertexShader: {
  69808. name: string;
  69809. shader: string;
  69810. };
  69811. }
  69812. declare module "babylonjs/Particles/gpuParticleSystem" {
  69813. import { Nullable } from "babylonjs/types";
  69814. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69815. import { Observable } from "babylonjs/Misc/observable";
  69816. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69817. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69818. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69819. import { Scene, IDisposable } from "babylonjs/scene";
  69820. import { Effect } from "babylonjs/Materials/effect";
  69821. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69822. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69823. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69824. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69825. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69826. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69827. /**
  69828. * This represents a GPU particle system in Babylon
  69829. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69830. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69831. */
  69832. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69833. /**
  69834. * The layer mask we are rendering the particles through.
  69835. */
  69836. layerMask: number;
  69837. private _capacity;
  69838. private _activeCount;
  69839. private _currentActiveCount;
  69840. private _accumulatedCount;
  69841. private _renderEffect;
  69842. private _updateEffect;
  69843. private _buffer0;
  69844. private _buffer1;
  69845. private _spriteBuffer;
  69846. private _updateVAO;
  69847. private _renderVAO;
  69848. private _targetIndex;
  69849. private _sourceBuffer;
  69850. private _targetBuffer;
  69851. private _engine;
  69852. private _currentRenderId;
  69853. private _started;
  69854. private _stopped;
  69855. private _timeDelta;
  69856. private _randomTexture;
  69857. private _randomTexture2;
  69858. private _attributesStrideSize;
  69859. private _updateEffectOptions;
  69860. private _randomTextureSize;
  69861. private _actualFrame;
  69862. private _customEffect;
  69863. private readonly _rawTextureWidth;
  69864. /**
  69865. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69866. */
  69867. static get IsSupported(): boolean;
  69868. /**
  69869. * An event triggered when the system is disposed.
  69870. */
  69871. onDisposeObservable: Observable<IParticleSystem>;
  69872. /**
  69873. * Gets the maximum number of particles active at the same time.
  69874. * @returns The max number of active particles.
  69875. */
  69876. getCapacity(): number;
  69877. /**
  69878. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69879. * to override the particles.
  69880. */
  69881. forceDepthWrite: boolean;
  69882. /**
  69883. * Gets or set the number of active particles
  69884. */
  69885. get activeParticleCount(): number;
  69886. set activeParticleCount(value: number);
  69887. private _preWarmDone;
  69888. /**
  69889. * Specifies if the particles are updated in emitter local space or world space.
  69890. */
  69891. isLocal: boolean;
  69892. /**
  69893. * Is this system ready to be used/rendered
  69894. * @return true if the system is ready
  69895. */
  69896. isReady(): boolean;
  69897. /**
  69898. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69899. * @returns True if it has been started, otherwise false.
  69900. */
  69901. isStarted(): boolean;
  69902. /**
  69903. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69904. * @returns True if it has been stopped, otherwise false.
  69905. */
  69906. isStopped(): boolean;
  69907. /**
  69908. * Gets a boolean indicating that the system is stopping
  69909. * @returns true if the system is currently stopping
  69910. */
  69911. isStopping(): boolean;
  69912. /**
  69913. * Gets the number of particles active at the same time.
  69914. * @returns The number of active particles.
  69915. */
  69916. getActiveCount(): number;
  69917. /**
  69918. * Starts the particle system and begins to emit
  69919. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69920. */
  69921. start(delay?: number): void;
  69922. /**
  69923. * Stops the particle system.
  69924. */
  69925. stop(): void;
  69926. /**
  69927. * Remove all active particles
  69928. */
  69929. reset(): void;
  69930. /**
  69931. * Returns the string "GPUParticleSystem"
  69932. * @returns a string containing the class name
  69933. */
  69934. getClassName(): string;
  69935. /**
  69936. * Gets the custom effect used to render the particles
  69937. * @param blendMode Blend mode for which the effect should be retrieved
  69938. * @returns The effect
  69939. */
  69940. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69941. /**
  69942. * Sets the custom effect used to render the particles
  69943. * @param effect The effect to set
  69944. * @param blendMode Blend mode for which the effect should be set
  69945. */
  69946. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69947. /** @hidden */
  69948. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69949. /**
  69950. * Observable that will be called just before the particles are drawn
  69951. */
  69952. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69953. /**
  69954. * Gets the name of the particle vertex shader
  69955. */
  69956. get vertexShaderName(): string;
  69957. private _colorGradientsTexture;
  69958. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69959. /**
  69960. * Adds a new color gradient
  69961. * @param gradient defines the gradient to use (between 0 and 1)
  69962. * @param color1 defines the color to affect to the specified gradient
  69963. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69964. * @returns the current particle system
  69965. */
  69966. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69967. private _refreshColorGradient;
  69968. /** Force the system to rebuild all gradients that need to be resync */
  69969. forceRefreshGradients(): void;
  69970. /**
  69971. * Remove a specific color gradient
  69972. * @param gradient defines the gradient to remove
  69973. * @returns the current particle system
  69974. */
  69975. removeColorGradient(gradient: number): GPUParticleSystem;
  69976. private _angularSpeedGradientsTexture;
  69977. private _sizeGradientsTexture;
  69978. private _velocityGradientsTexture;
  69979. private _limitVelocityGradientsTexture;
  69980. private _dragGradientsTexture;
  69981. private _addFactorGradient;
  69982. /**
  69983. * Adds a new size gradient
  69984. * @param gradient defines the gradient to use (between 0 and 1)
  69985. * @param factor defines the size factor to affect to the specified gradient
  69986. * @returns the current particle system
  69987. */
  69988. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69989. /**
  69990. * Remove a specific size gradient
  69991. * @param gradient defines the gradient to remove
  69992. * @returns the current particle system
  69993. */
  69994. removeSizeGradient(gradient: number): GPUParticleSystem;
  69995. private _refreshFactorGradient;
  69996. /**
  69997. * Adds a new angular speed gradient
  69998. * @param gradient defines the gradient to use (between 0 and 1)
  69999. * @param factor defines the angular speed to affect to the specified gradient
  70000. * @returns the current particle system
  70001. */
  70002. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70003. /**
  70004. * Remove a specific angular speed gradient
  70005. * @param gradient defines the gradient to remove
  70006. * @returns the current particle system
  70007. */
  70008. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70009. /**
  70010. * Adds a new velocity gradient
  70011. * @param gradient defines the gradient to use (between 0 and 1)
  70012. * @param factor defines the velocity to affect to the specified gradient
  70013. * @returns the current particle system
  70014. */
  70015. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70016. /**
  70017. * Remove a specific velocity gradient
  70018. * @param gradient defines the gradient to remove
  70019. * @returns the current particle system
  70020. */
  70021. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70022. /**
  70023. * Adds a new limit velocity gradient
  70024. * @param gradient defines the gradient to use (between 0 and 1)
  70025. * @param factor defines the limit velocity value to affect to the specified gradient
  70026. * @returns the current particle system
  70027. */
  70028. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70029. /**
  70030. * Remove a specific limit velocity gradient
  70031. * @param gradient defines the gradient to remove
  70032. * @returns the current particle system
  70033. */
  70034. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70035. /**
  70036. * Adds a new drag gradient
  70037. * @param gradient defines the gradient to use (between 0 and 1)
  70038. * @param factor defines the drag value to affect to the specified gradient
  70039. * @returns the current particle system
  70040. */
  70041. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70042. /**
  70043. * Remove a specific drag gradient
  70044. * @param gradient defines the gradient to remove
  70045. * @returns the current particle system
  70046. */
  70047. removeDragGradient(gradient: number): GPUParticleSystem;
  70048. /**
  70049. * Not supported by GPUParticleSystem
  70050. * @param gradient defines the gradient to use (between 0 and 1)
  70051. * @param factor defines the emit rate value to affect to the specified gradient
  70052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70053. * @returns the current particle system
  70054. */
  70055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70056. /**
  70057. * Not supported by GPUParticleSystem
  70058. * @param gradient defines the gradient to remove
  70059. * @returns the current particle system
  70060. */
  70061. removeEmitRateGradient(gradient: number): IParticleSystem;
  70062. /**
  70063. * Not supported by GPUParticleSystem
  70064. * @param gradient defines the gradient to use (between 0 and 1)
  70065. * @param factor defines the start size value to affect to the specified gradient
  70066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70067. * @returns the current particle system
  70068. */
  70069. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70070. /**
  70071. * Not supported by GPUParticleSystem
  70072. * @param gradient defines the gradient to remove
  70073. * @returns the current particle system
  70074. */
  70075. removeStartSizeGradient(gradient: number): IParticleSystem;
  70076. /**
  70077. * Not supported by GPUParticleSystem
  70078. * @param gradient defines the gradient to use (between 0 and 1)
  70079. * @param min defines the color remap minimal range
  70080. * @param max defines the color remap maximal range
  70081. * @returns the current particle system
  70082. */
  70083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70084. /**
  70085. * Not supported by GPUParticleSystem
  70086. * @param gradient defines the gradient to remove
  70087. * @returns the current particle system
  70088. */
  70089. removeColorRemapGradient(): IParticleSystem;
  70090. /**
  70091. * Not supported by GPUParticleSystem
  70092. * @param gradient defines the gradient to use (between 0 and 1)
  70093. * @param min defines the alpha remap minimal range
  70094. * @param max defines the alpha remap maximal range
  70095. * @returns the current particle system
  70096. */
  70097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70098. /**
  70099. * Not supported by GPUParticleSystem
  70100. * @param gradient defines the gradient to remove
  70101. * @returns the current particle system
  70102. */
  70103. removeAlphaRemapGradient(): IParticleSystem;
  70104. /**
  70105. * Not supported by GPUParticleSystem
  70106. * @param gradient defines the gradient to use (between 0 and 1)
  70107. * @param color defines the color to affect to the specified gradient
  70108. * @returns the current particle system
  70109. */
  70110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70111. /**
  70112. * Not supported by GPUParticleSystem
  70113. * @param gradient defines the gradient to remove
  70114. * @returns the current particle system
  70115. */
  70116. removeRampGradient(): IParticleSystem;
  70117. /**
  70118. * Not supported by GPUParticleSystem
  70119. * @returns the list of ramp gradients
  70120. */
  70121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70122. /**
  70123. * Not supported by GPUParticleSystem
  70124. * Gets or sets a boolean indicating that ramp gradients must be used
  70125. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70126. */
  70127. get useRampGradients(): boolean;
  70128. set useRampGradients(value: boolean);
  70129. /**
  70130. * Not supported by GPUParticleSystem
  70131. * @param gradient defines the gradient to use (between 0 and 1)
  70132. * @param factor defines the life time factor to affect to the specified gradient
  70133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70134. * @returns the current particle system
  70135. */
  70136. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70137. /**
  70138. * Not supported by GPUParticleSystem
  70139. * @param gradient defines the gradient to remove
  70140. * @returns the current particle system
  70141. */
  70142. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70143. /**
  70144. * Instantiates a GPU particle system.
  70145. * 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.
  70146. * @param name The name of the particle system
  70147. * @param options The options used to create the system
  70148. * @param scene The scene the particle system belongs to
  70149. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70150. * @param customEffect a custom effect used to change the way particles are rendered by default
  70151. */
  70152. constructor(name: string, options: Partial<{
  70153. capacity: number;
  70154. randomTextureSize: number;
  70155. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70156. protected _reset(): void;
  70157. private _createUpdateVAO;
  70158. private _createRenderVAO;
  70159. private _initialize;
  70160. /** @hidden */
  70161. _recreateUpdateEffect(): void;
  70162. private _getEffect;
  70163. /**
  70164. * Fill the defines array according to the current settings of the particle system
  70165. * @param defines Array to be updated
  70166. * @param blendMode blend mode to take into account when updating the array
  70167. */
  70168. fillDefines(defines: Array<string>, blendMode?: number): void;
  70169. /**
  70170. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70171. * @param uniforms Uniforms array to fill
  70172. * @param attributes Attributes array to fill
  70173. * @param samplers Samplers array to fill
  70174. */
  70175. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70176. /** @hidden */
  70177. _recreateRenderEffect(): Effect;
  70178. /**
  70179. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70180. * @param preWarm defines if we are in the pre-warmimg phase
  70181. */
  70182. animate(preWarm?: boolean): void;
  70183. private _createFactorGradientTexture;
  70184. private _createSizeGradientTexture;
  70185. private _createAngularSpeedGradientTexture;
  70186. private _createVelocityGradientTexture;
  70187. private _createLimitVelocityGradientTexture;
  70188. private _createDragGradientTexture;
  70189. private _createColorGradientTexture;
  70190. /**
  70191. * Renders the particle system in its current state
  70192. * @param preWarm defines if the system should only update the particles but not render them
  70193. * @returns the current number of particles
  70194. */
  70195. render(preWarm?: boolean): number;
  70196. /**
  70197. * Rebuilds the particle system
  70198. */
  70199. rebuild(): void;
  70200. private _releaseBuffers;
  70201. private _releaseVAOs;
  70202. /**
  70203. * Disposes the particle system and free the associated resources
  70204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70205. */
  70206. dispose(disposeTexture?: boolean): void;
  70207. /**
  70208. * Clones the particle system.
  70209. * @param name The name of the cloned object
  70210. * @param newEmitter The new emitter to use
  70211. * @returns the cloned particle system
  70212. */
  70213. clone(name: string, newEmitter: any): GPUParticleSystem;
  70214. /**
  70215. * Serializes the particle system to a JSON object
  70216. * @param serializeTexture defines if the texture must be serialized as well
  70217. * @returns the JSON object
  70218. */
  70219. serialize(serializeTexture?: boolean): any;
  70220. /**
  70221. * Parses a JSON object to create a GPU particle system.
  70222. * @param parsedParticleSystem The JSON object to parse
  70223. * @param scene The scene to create the particle system in
  70224. * @param rootUrl The root url to use to load external dependencies like texture
  70225. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70226. * @returns the parsed GPU particle system
  70227. */
  70228. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70229. }
  70230. }
  70231. declare module "babylonjs/Particles/particleSystemSet" {
  70232. import { Nullable } from "babylonjs/types";
  70233. import { Color3 } from "babylonjs/Maths/math.color";
  70234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70237. import { Scene, IDisposable } from "babylonjs/scene";
  70238. /**
  70239. * Represents a set of particle systems working together to create a specific effect
  70240. */
  70241. export class ParticleSystemSet implements IDisposable {
  70242. /**
  70243. * Gets or sets base Assets URL
  70244. */
  70245. static BaseAssetsUrl: string;
  70246. private _emitterCreationOptions;
  70247. private _emitterNode;
  70248. /**
  70249. * Gets the particle system list
  70250. */
  70251. systems: IParticleSystem[];
  70252. /**
  70253. * Gets the emitter node used with this set
  70254. */
  70255. get emitterNode(): Nullable<TransformNode>;
  70256. /**
  70257. * Creates a new emitter mesh as a sphere
  70258. * @param options defines the options used to create the sphere
  70259. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70260. * @param scene defines the hosting scene
  70261. */
  70262. setEmitterAsSphere(options: {
  70263. diameter: number;
  70264. segments: number;
  70265. color: Color3;
  70266. }, renderingGroupId: number, scene: Scene): void;
  70267. /**
  70268. * Starts all particle systems of the set
  70269. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70270. */
  70271. start(emitter?: AbstractMesh): void;
  70272. /**
  70273. * Release all associated resources
  70274. */
  70275. dispose(): void;
  70276. /**
  70277. * Serialize the set into a JSON compatible object
  70278. * @param serializeTexture defines if the texture must be serialized as well
  70279. * @returns a JSON compatible representation of the set
  70280. */
  70281. serialize(serializeTexture?: boolean): any;
  70282. /**
  70283. * Parse a new ParticleSystemSet from a serialized source
  70284. * @param data defines a JSON compatible representation of the set
  70285. * @param scene defines the hosting scene
  70286. * @param gpu defines if we want GPU particles or CPU particles
  70287. * @returns a new ParticleSystemSet
  70288. */
  70289. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70290. }
  70291. }
  70292. declare module "babylonjs/Particles/particleHelper" {
  70293. import { Nullable } from "babylonjs/types";
  70294. import { Scene } from "babylonjs/scene";
  70295. import { Vector3 } from "babylonjs/Maths/math.vector";
  70296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70297. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70298. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70299. /**
  70300. * This class is made for on one-liner static method to help creating particle system set.
  70301. */
  70302. export class ParticleHelper {
  70303. /**
  70304. * Gets or sets base Assets URL
  70305. */
  70306. static BaseAssetsUrl: string;
  70307. /** Define the Url to load snippets */
  70308. static SnippetUrl: string;
  70309. /**
  70310. * Create a default particle system that you can tweak
  70311. * @param emitter defines the emitter to use
  70312. * @param capacity defines the system capacity (default is 500 particles)
  70313. * @param scene defines the hosting scene
  70314. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70315. * @returns the new Particle system
  70316. */
  70317. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70318. /**
  70319. * This is the main static method (one-liner) of this helper to create different particle systems
  70320. * @param type This string represents the type to the particle system to create
  70321. * @param scene The scene where the particle system should live
  70322. * @param gpu If the system will use gpu
  70323. * @returns the ParticleSystemSet created
  70324. */
  70325. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70326. /**
  70327. * Static function used to export a particle system to a ParticleSystemSet variable.
  70328. * Please note that the emitter shape is not exported
  70329. * @param systems defines the particle systems to export
  70330. * @returns the created particle system set
  70331. */
  70332. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70333. /**
  70334. * Creates a particle system from a snippet saved in a remote file
  70335. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70336. * @param url defines the url to load from
  70337. * @param scene defines the hosting scene
  70338. * @param gpu If the system will use gpu
  70339. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70340. * @returns a promise that will resolve to the new particle system
  70341. */
  70342. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70343. /**
  70344. * Creates a particle system from a snippet saved by the particle system editor
  70345. * @param snippetId defines the snippet to load
  70346. * @param scene defines the hosting scene
  70347. * @param gpu If the system will use gpu
  70348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70349. * @returns a promise that will resolve to the new particle system
  70350. */
  70351. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70352. }
  70353. }
  70354. declare module "babylonjs/Particles/particleSystemComponent" {
  70355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70356. import { Effect } from "babylonjs/Materials/effect";
  70357. import "babylonjs/Shaders/particles.vertex";
  70358. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70359. module "babylonjs/Engines/engine" {
  70360. interface Engine {
  70361. /**
  70362. * Create an effect to use with particle systems.
  70363. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70364. * the particle system for which you want to create a custom effect in the last parameter
  70365. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70366. * @param uniformsNames defines a list of attribute names
  70367. * @param samplers defines an array of string used to represent textures
  70368. * @param defines defines the string containing the defines to use to compile the shaders
  70369. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70370. * @param onCompiled defines a function to call when the effect creation is successful
  70371. * @param onError defines a function to call when the effect creation has failed
  70372. * @param particleSystem the particle system you want to create the effect for
  70373. * @returns the new Effect
  70374. */
  70375. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70376. }
  70377. }
  70378. module "babylonjs/Meshes/mesh" {
  70379. interface Mesh {
  70380. /**
  70381. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70382. * @returns an array of IParticleSystem
  70383. */
  70384. getEmittedParticleSystems(): IParticleSystem[];
  70385. /**
  70386. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70387. * @returns an array of IParticleSystem
  70388. */
  70389. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70390. }
  70391. }
  70392. }
  70393. declare module "babylonjs/Particles/pointsCloudSystem" {
  70394. import { Color4 } from "babylonjs/Maths/math";
  70395. import { Mesh } from "babylonjs/Meshes/mesh";
  70396. import { Scene, IDisposable } from "babylonjs/scene";
  70397. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70398. /** Defines the 4 color options */
  70399. export enum PointColor {
  70400. /** color value */
  70401. Color = 2,
  70402. /** uv value */
  70403. UV = 1,
  70404. /** random value */
  70405. Random = 0,
  70406. /** stated value */
  70407. Stated = 3
  70408. }
  70409. /**
  70410. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70411. * 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.
  70412. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70413. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70414. *
  70415. * Full documentation here : TO BE ENTERED
  70416. */
  70417. export class PointsCloudSystem implements IDisposable {
  70418. /**
  70419. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70420. * Example : var p = SPS.particles[i];
  70421. */
  70422. particles: CloudPoint[];
  70423. /**
  70424. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70425. */
  70426. nbParticles: number;
  70427. /**
  70428. * This a counter for your own usage. It's not set by any SPS functions.
  70429. */
  70430. counter: number;
  70431. /**
  70432. * The PCS name. This name is also given to the underlying mesh.
  70433. */
  70434. name: string;
  70435. /**
  70436. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70437. */
  70438. mesh: Mesh;
  70439. /**
  70440. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70441. * Please read :
  70442. */
  70443. vars: any;
  70444. /**
  70445. * @hidden
  70446. */
  70447. _size: number;
  70448. private _scene;
  70449. private _promises;
  70450. private _positions;
  70451. private _indices;
  70452. private _normals;
  70453. private _colors;
  70454. private _uvs;
  70455. private _indices32;
  70456. private _positions32;
  70457. private _colors32;
  70458. private _uvs32;
  70459. private _updatable;
  70460. private _isVisibilityBoxLocked;
  70461. private _alwaysVisible;
  70462. private _groups;
  70463. private _groupCounter;
  70464. private _computeParticleColor;
  70465. private _computeParticleTexture;
  70466. private _computeParticleRotation;
  70467. private _computeBoundingBox;
  70468. private _isReady;
  70469. /**
  70470. * Creates a PCS (Points Cloud System) object
  70471. * @param name (String) is the PCS name, this will be the underlying mesh name
  70472. * @param pointSize (number) is the size for each point
  70473. * @param scene (Scene) is the scene in which the PCS is added
  70474. * @param options defines the options of the PCS e.g.
  70475. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70476. */
  70477. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70478. updatable?: boolean;
  70479. });
  70480. /**
  70481. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70482. * If no points were added to the PCS, the returned mesh is just a single point.
  70483. * @returns a promise for the created mesh
  70484. */
  70485. buildMeshAsync(): Promise<Mesh>;
  70486. /**
  70487. * @hidden
  70488. */
  70489. private _buildMesh;
  70490. private _addParticle;
  70491. private _randomUnitVector;
  70492. private _getColorIndicesForCoord;
  70493. private _setPointsColorOrUV;
  70494. private _colorFromTexture;
  70495. private _calculateDensity;
  70496. /**
  70497. * Adds points to the PCS in random positions within a unit sphere
  70498. * @param nb (positive integer) the number of particles to be created from this model
  70499. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70500. * @returns the number of groups in the system
  70501. */
  70502. addPoints(nb: number, pointFunction?: any): number;
  70503. /**
  70504. * Adds points to the PCS from the surface of the model shape
  70505. * @param mesh is any Mesh object that will be used as a surface model for the points
  70506. * @param nb (positive integer) the number of particles to be created from this model
  70507. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70508. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70509. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70510. * @returns the number of groups in the system
  70511. */
  70512. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70513. /**
  70514. * Adds points to the PCS inside the model shape
  70515. * @param mesh is any Mesh object that will be used as a surface model for the points
  70516. * @param nb (positive integer) the number of particles to be created from this model
  70517. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70518. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70519. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70520. * @returns the number of groups in the system
  70521. */
  70522. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70523. /**
  70524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70525. * This method calls `updateParticle()` for each particle of the SPS.
  70526. * For an animated SPS, it is usually called within the render loop.
  70527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70530. * @returns the PCS.
  70531. */
  70532. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70533. /**
  70534. * Disposes the PCS.
  70535. */
  70536. dispose(): void;
  70537. /**
  70538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70539. * doc :
  70540. * @returns the PCS.
  70541. */
  70542. refreshVisibleSize(): PointsCloudSystem;
  70543. /**
  70544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70545. * @param size the size (float) of the visibility box
  70546. * note : this doesn't lock the PCS mesh bounding box.
  70547. * doc :
  70548. */
  70549. setVisibilityBox(size: number): void;
  70550. /**
  70551. * Gets whether the PCS is always visible or not
  70552. * doc :
  70553. */
  70554. get isAlwaysVisible(): boolean;
  70555. /**
  70556. * Sets the PCS as always visible or not
  70557. * doc :
  70558. */
  70559. set isAlwaysVisible(val: boolean);
  70560. /**
  70561. * Tells to `setParticles()` to compute the particle rotations or not
  70562. * Default value : false. The PCS is faster when it's set to false
  70563. * Note : particle rotations are only applied to parent particles
  70564. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70565. */
  70566. set computeParticleRotation(val: boolean);
  70567. /**
  70568. * Tells to `setParticles()` to compute the particle colors or not.
  70569. * Default value : true. The PCS is faster when it's set to false.
  70570. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70571. */
  70572. set computeParticleColor(val: boolean);
  70573. set computeParticleTexture(val: boolean);
  70574. /**
  70575. * Gets if `setParticles()` computes the particle colors or not.
  70576. * Default value : false. The PCS is faster when it's set to false.
  70577. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70578. */
  70579. get computeParticleColor(): boolean;
  70580. /**
  70581. * Gets if `setParticles()` computes the particle textures or not.
  70582. * Default value : false. The PCS is faster when it's set to false.
  70583. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70584. */
  70585. get computeParticleTexture(): boolean;
  70586. /**
  70587. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70588. */
  70589. set computeBoundingBox(val: boolean);
  70590. /**
  70591. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70592. */
  70593. get computeBoundingBox(): boolean;
  70594. /**
  70595. * This function does nothing. It may be overwritten to set all the particle first values.
  70596. * The PCS doesn't call this function, you may have to call it by your own.
  70597. * doc :
  70598. */
  70599. initParticles(): void;
  70600. /**
  70601. * This function does nothing. It may be overwritten to recycle a particle
  70602. * The PCS doesn't call this function, you can to call it
  70603. * doc :
  70604. * @param particle The particle to recycle
  70605. * @returns the recycled particle
  70606. */
  70607. recycleParticle(particle: CloudPoint): CloudPoint;
  70608. /**
  70609. * Updates a particle : this function should be overwritten by the user.
  70610. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70611. * doc :
  70612. * @example : just set a particle position or velocity and recycle conditions
  70613. * @param particle The particle to update
  70614. * @returns the updated particle
  70615. */
  70616. updateParticle(particle: CloudPoint): CloudPoint;
  70617. /**
  70618. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70619. * This does nothing and may be overwritten by the user.
  70620. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70621. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70622. * @param update the boolean update value actually passed to setParticles()
  70623. */
  70624. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70625. /**
  70626. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70627. * This will be passed three parameters.
  70628. * This does nothing and may be overwritten by the user.
  70629. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70630. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70631. * @param update the boolean update value actually passed to setParticles()
  70632. */
  70633. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70634. }
  70635. }
  70636. declare module "babylonjs/Particles/cloudPoint" {
  70637. import { Nullable } from "babylonjs/types";
  70638. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70639. import { Mesh } from "babylonjs/Meshes/mesh";
  70640. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70641. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70642. /**
  70643. * Represents one particle of a points cloud system.
  70644. */
  70645. export class CloudPoint {
  70646. /**
  70647. * particle global index
  70648. */
  70649. idx: number;
  70650. /**
  70651. * The color of the particle
  70652. */
  70653. color: Nullable<Color4>;
  70654. /**
  70655. * The world space position of the particle.
  70656. */
  70657. position: Vector3;
  70658. /**
  70659. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70660. */
  70661. rotation: Vector3;
  70662. /**
  70663. * The world space rotation quaternion of the particle.
  70664. */
  70665. rotationQuaternion: Nullable<Quaternion>;
  70666. /**
  70667. * The uv of the particle.
  70668. */
  70669. uv: Nullable<Vector2>;
  70670. /**
  70671. * The current speed of the particle.
  70672. */
  70673. velocity: Vector3;
  70674. /**
  70675. * The pivot point in the particle local space.
  70676. */
  70677. pivot: Vector3;
  70678. /**
  70679. * Must the particle be translated from its pivot point in its local space ?
  70680. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70681. * Default : false
  70682. */
  70683. translateFromPivot: boolean;
  70684. /**
  70685. * Index of this particle in the global "positions" array (Internal use)
  70686. * @hidden
  70687. */
  70688. _pos: number;
  70689. /**
  70690. * @hidden Index of this particle in the global "indices" array (Internal use)
  70691. */
  70692. _ind: number;
  70693. /**
  70694. * Group this particle belongs to
  70695. */
  70696. _group: PointsGroup;
  70697. /**
  70698. * Group id of this particle
  70699. */
  70700. groupId: number;
  70701. /**
  70702. * Index of the particle in its group id (Internal use)
  70703. */
  70704. idxInGroup: number;
  70705. /**
  70706. * @hidden Particle BoundingInfo object (Internal use)
  70707. */
  70708. _boundingInfo: BoundingInfo;
  70709. /**
  70710. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70711. */
  70712. _pcs: PointsCloudSystem;
  70713. /**
  70714. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70715. */
  70716. _stillInvisible: boolean;
  70717. /**
  70718. * @hidden Last computed particle rotation matrix
  70719. */
  70720. _rotationMatrix: number[];
  70721. /**
  70722. * Parent particle Id, if any.
  70723. * Default null.
  70724. */
  70725. parentId: Nullable<number>;
  70726. /**
  70727. * @hidden Internal global position in the PCS.
  70728. */
  70729. _globalPosition: Vector3;
  70730. /**
  70731. * Creates a Point Cloud object.
  70732. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70733. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70734. * @param group (PointsGroup) is the group the particle belongs to
  70735. * @param groupId (integer) is the group identifier in the PCS.
  70736. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70737. * @param pcs defines the PCS it is associated to
  70738. */
  70739. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70740. /**
  70741. * get point size
  70742. */
  70743. get size(): Vector3;
  70744. /**
  70745. * Set point size
  70746. */
  70747. set size(scale: Vector3);
  70748. /**
  70749. * Legacy support, changed quaternion to rotationQuaternion
  70750. */
  70751. get quaternion(): Nullable<Quaternion>;
  70752. /**
  70753. * Legacy support, changed quaternion to rotationQuaternion
  70754. */
  70755. set quaternion(q: Nullable<Quaternion>);
  70756. /**
  70757. * Returns a boolean. True if the particle intersects a mesh, else false
  70758. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70759. * @param target is the object (point or mesh) what the intersection is computed against
  70760. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70761. * @returns true if it intersects
  70762. */
  70763. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70764. /**
  70765. * get the rotation matrix of the particle
  70766. * @hidden
  70767. */
  70768. getRotationMatrix(m: Matrix): void;
  70769. }
  70770. /**
  70771. * Represents a group of points in a points cloud system
  70772. * * PCS internal tool, don't use it manually.
  70773. */
  70774. export class PointsGroup {
  70775. /**
  70776. * The group id
  70777. * @hidden
  70778. */
  70779. groupID: number;
  70780. /**
  70781. * image data for group (internal use)
  70782. * @hidden
  70783. */
  70784. _groupImageData: Nullable<ArrayBufferView>;
  70785. /**
  70786. * Image Width (internal use)
  70787. * @hidden
  70788. */
  70789. _groupImgWidth: number;
  70790. /**
  70791. * Image Height (internal use)
  70792. * @hidden
  70793. */
  70794. _groupImgHeight: number;
  70795. /**
  70796. * Custom position function (internal use)
  70797. * @hidden
  70798. */
  70799. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70800. /**
  70801. * density per facet for surface points
  70802. * @hidden
  70803. */
  70804. _groupDensity: number[];
  70805. /**
  70806. * Only when points are colored by texture carries pointer to texture list array
  70807. * @hidden
  70808. */
  70809. _textureNb: number;
  70810. /**
  70811. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70812. * PCS internal tool, don't use it manually.
  70813. * @hidden
  70814. */
  70815. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70816. }
  70817. }
  70818. declare module "babylonjs/Particles/index" {
  70819. export * from "babylonjs/Particles/baseParticleSystem";
  70820. export * from "babylonjs/Particles/EmitterTypes/index";
  70821. export * from "babylonjs/Particles/gpuParticleSystem";
  70822. export * from "babylonjs/Particles/IParticleSystem";
  70823. export * from "babylonjs/Particles/particle";
  70824. export * from "babylonjs/Particles/particleHelper";
  70825. export * from "babylonjs/Particles/particleSystem";
  70826. import "babylonjs/Particles/particleSystemComponent";
  70827. export * from "babylonjs/Particles/particleSystemComponent";
  70828. export * from "babylonjs/Particles/particleSystemSet";
  70829. export * from "babylonjs/Particles/solidParticle";
  70830. export * from "babylonjs/Particles/solidParticleSystem";
  70831. export * from "babylonjs/Particles/cloudPoint";
  70832. export * from "babylonjs/Particles/pointsCloudSystem";
  70833. export * from "babylonjs/Particles/subEmitter";
  70834. }
  70835. declare module "babylonjs/Physics/physicsEngineComponent" {
  70836. import { Nullable } from "babylonjs/types";
  70837. import { Observable, Observer } from "babylonjs/Misc/observable";
  70838. import { Vector3 } from "babylonjs/Maths/math.vector";
  70839. import { Mesh } from "babylonjs/Meshes/mesh";
  70840. import { ISceneComponent } from "babylonjs/sceneComponent";
  70841. import { Scene } from "babylonjs/scene";
  70842. import { Node } from "babylonjs/node";
  70843. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70844. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70845. module "babylonjs/scene" {
  70846. interface Scene {
  70847. /** @hidden (Backing field) */
  70848. _physicsEngine: Nullable<IPhysicsEngine>;
  70849. /** @hidden */
  70850. _physicsTimeAccumulator: number;
  70851. /**
  70852. * Gets the current physics engine
  70853. * @returns a IPhysicsEngine or null if none attached
  70854. */
  70855. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70856. /**
  70857. * Enables physics to the current scene
  70858. * @param gravity defines the scene's gravity for the physics engine
  70859. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70860. * @return a boolean indicating if the physics engine was initialized
  70861. */
  70862. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70863. /**
  70864. * Disables and disposes the physics engine associated with the scene
  70865. */
  70866. disablePhysicsEngine(): void;
  70867. /**
  70868. * Gets a boolean indicating if there is an active physics engine
  70869. * @returns a boolean indicating if there is an active physics engine
  70870. */
  70871. isPhysicsEnabled(): boolean;
  70872. /**
  70873. * Deletes a physics compound impostor
  70874. * @param compound defines the compound to delete
  70875. */
  70876. deleteCompoundImpostor(compound: any): void;
  70877. /**
  70878. * An event triggered when physic simulation is about to be run
  70879. */
  70880. onBeforePhysicsObservable: Observable<Scene>;
  70881. /**
  70882. * An event triggered when physic simulation has been done
  70883. */
  70884. onAfterPhysicsObservable: Observable<Scene>;
  70885. }
  70886. }
  70887. module "babylonjs/Meshes/abstractMesh" {
  70888. interface AbstractMesh {
  70889. /** @hidden */
  70890. _physicsImpostor: Nullable<PhysicsImpostor>;
  70891. /**
  70892. * Gets or sets impostor used for physic simulation
  70893. * @see http://doc.babylonjs.com/features/physics_engine
  70894. */
  70895. physicsImpostor: Nullable<PhysicsImpostor>;
  70896. /**
  70897. * Gets the current physics impostor
  70898. * @see http://doc.babylonjs.com/features/physics_engine
  70899. * @returns a physics impostor or null
  70900. */
  70901. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70902. /** Apply a physic impulse to the mesh
  70903. * @param force defines the force to apply
  70904. * @param contactPoint defines where to apply the force
  70905. * @returns the current mesh
  70906. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70907. */
  70908. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70909. /**
  70910. * Creates a physic joint between two meshes
  70911. * @param otherMesh defines the other mesh to use
  70912. * @param pivot1 defines the pivot to use on this mesh
  70913. * @param pivot2 defines the pivot to use on the other mesh
  70914. * @param options defines additional options (can be plugin dependent)
  70915. * @returns the current mesh
  70916. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70917. */
  70918. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70919. /** @hidden */
  70920. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70921. }
  70922. }
  70923. /**
  70924. * Defines the physics engine scene component responsible to manage a physics engine
  70925. */
  70926. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70927. /**
  70928. * The component name helpful to identify the component in the list of scene components.
  70929. */
  70930. readonly name: string;
  70931. /**
  70932. * The scene the component belongs to.
  70933. */
  70934. scene: Scene;
  70935. /**
  70936. * Creates a new instance of the component for the given scene
  70937. * @param scene Defines the scene to register the component in
  70938. */
  70939. constructor(scene: Scene);
  70940. /**
  70941. * Registers the component in a given scene
  70942. */
  70943. register(): void;
  70944. /**
  70945. * Rebuilds the elements related to this component in case of
  70946. * context lost for instance.
  70947. */
  70948. rebuild(): void;
  70949. /**
  70950. * Disposes the component and the associated ressources
  70951. */
  70952. dispose(): void;
  70953. }
  70954. }
  70955. declare module "babylonjs/Physics/physicsHelper" {
  70956. import { Nullable } from "babylonjs/types";
  70957. import { Vector3 } from "babylonjs/Maths/math.vector";
  70958. import { Mesh } from "babylonjs/Meshes/mesh";
  70959. import { Scene } from "babylonjs/scene";
  70960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70961. /**
  70962. * A helper for physics simulations
  70963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70964. */
  70965. export class PhysicsHelper {
  70966. private _scene;
  70967. private _physicsEngine;
  70968. /**
  70969. * Initializes the Physics helper
  70970. * @param scene Babylon.js scene
  70971. */
  70972. constructor(scene: Scene);
  70973. /**
  70974. * Applies a radial explosion impulse
  70975. * @param origin the origin of the explosion
  70976. * @param radiusOrEventOptions the radius or the options of radial explosion
  70977. * @param strength the explosion strength
  70978. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70979. * @returns A physics radial explosion event, or null
  70980. */
  70981. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70982. /**
  70983. * Applies a radial explosion force
  70984. * @param origin the origin of the explosion
  70985. * @param radiusOrEventOptions the radius or the options of radial explosion
  70986. * @param strength the explosion strength
  70987. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70988. * @returns A physics radial explosion event, or null
  70989. */
  70990. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70991. /**
  70992. * Creates a gravitational field
  70993. * @param origin the origin of the explosion
  70994. * @param radiusOrEventOptions the radius or the options of radial explosion
  70995. * @param strength the explosion strength
  70996. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70997. * @returns A physics gravitational field event, or null
  70998. */
  70999. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71000. /**
  71001. * Creates a physics updraft event
  71002. * @param origin the origin of the updraft
  71003. * @param radiusOrEventOptions the radius or the options of the updraft
  71004. * @param strength the strength of the updraft
  71005. * @param height the height of the updraft
  71006. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71007. * @returns A physics updraft event, or null
  71008. */
  71009. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71010. /**
  71011. * Creates a physics vortex event
  71012. * @param origin the of the vortex
  71013. * @param radiusOrEventOptions the radius or the options of the vortex
  71014. * @param strength the strength of the vortex
  71015. * @param height the height of the vortex
  71016. * @returns a Physics vortex event, or null
  71017. * A physics vortex event or null
  71018. */
  71019. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71020. }
  71021. /**
  71022. * Represents a physics radial explosion event
  71023. */
  71024. class PhysicsRadialExplosionEvent {
  71025. private _scene;
  71026. private _options;
  71027. private _sphere;
  71028. private _dataFetched;
  71029. /**
  71030. * Initializes a radial explosioin event
  71031. * @param _scene BabylonJS scene
  71032. * @param _options The options for the vortex event
  71033. */
  71034. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71035. /**
  71036. * Returns the data related to the radial explosion event (sphere).
  71037. * @returns The radial explosion event data
  71038. */
  71039. getData(): PhysicsRadialExplosionEventData;
  71040. /**
  71041. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71042. * @param impostor A physics imposter
  71043. * @param origin the origin of the explosion
  71044. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71045. */
  71046. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71047. /**
  71048. * Triggers affecterd impostors callbacks
  71049. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71050. */
  71051. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71052. /**
  71053. * Disposes the sphere.
  71054. * @param force Specifies if the sphere should be disposed by force
  71055. */
  71056. dispose(force?: boolean): void;
  71057. /*** Helpers ***/
  71058. private _prepareSphere;
  71059. private _intersectsWithSphere;
  71060. }
  71061. /**
  71062. * Represents a gravitational field event
  71063. */
  71064. class PhysicsGravitationalFieldEvent {
  71065. private _physicsHelper;
  71066. private _scene;
  71067. private _origin;
  71068. private _options;
  71069. private _tickCallback;
  71070. private _sphere;
  71071. private _dataFetched;
  71072. /**
  71073. * Initializes the physics gravitational field event
  71074. * @param _physicsHelper A physics helper
  71075. * @param _scene BabylonJS scene
  71076. * @param _origin The origin position of the gravitational field event
  71077. * @param _options The options for the vortex event
  71078. */
  71079. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71080. /**
  71081. * Returns the data related to the gravitational field event (sphere).
  71082. * @returns A gravitational field event
  71083. */
  71084. getData(): PhysicsGravitationalFieldEventData;
  71085. /**
  71086. * Enables the gravitational field.
  71087. */
  71088. enable(): void;
  71089. /**
  71090. * Disables the gravitational field.
  71091. */
  71092. disable(): void;
  71093. /**
  71094. * Disposes the sphere.
  71095. * @param force The force to dispose from the gravitational field event
  71096. */
  71097. dispose(force?: boolean): void;
  71098. private _tick;
  71099. }
  71100. /**
  71101. * Represents a physics updraft event
  71102. */
  71103. class PhysicsUpdraftEvent {
  71104. private _scene;
  71105. private _origin;
  71106. private _options;
  71107. private _physicsEngine;
  71108. private _originTop;
  71109. private _originDirection;
  71110. private _tickCallback;
  71111. private _cylinder;
  71112. private _cylinderPosition;
  71113. private _dataFetched;
  71114. /**
  71115. * Initializes the physics updraft event
  71116. * @param _scene BabylonJS scene
  71117. * @param _origin The origin position of the updraft
  71118. * @param _options The options for the updraft event
  71119. */
  71120. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71121. /**
  71122. * Returns the data related to the updraft event (cylinder).
  71123. * @returns A physics updraft event
  71124. */
  71125. getData(): PhysicsUpdraftEventData;
  71126. /**
  71127. * Enables the updraft.
  71128. */
  71129. enable(): void;
  71130. /**
  71131. * Disables the updraft.
  71132. */
  71133. disable(): void;
  71134. /**
  71135. * Disposes the cylinder.
  71136. * @param force Specifies if the updraft should be disposed by force
  71137. */
  71138. dispose(force?: boolean): void;
  71139. private getImpostorHitData;
  71140. private _tick;
  71141. /*** Helpers ***/
  71142. private _prepareCylinder;
  71143. private _intersectsWithCylinder;
  71144. }
  71145. /**
  71146. * Represents a physics vortex event
  71147. */
  71148. class PhysicsVortexEvent {
  71149. private _scene;
  71150. private _origin;
  71151. private _options;
  71152. private _physicsEngine;
  71153. private _originTop;
  71154. private _tickCallback;
  71155. private _cylinder;
  71156. private _cylinderPosition;
  71157. private _dataFetched;
  71158. /**
  71159. * Initializes the physics vortex event
  71160. * @param _scene The BabylonJS scene
  71161. * @param _origin The origin position of the vortex
  71162. * @param _options The options for the vortex event
  71163. */
  71164. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71165. /**
  71166. * Returns the data related to the vortex event (cylinder).
  71167. * @returns The physics vortex event data
  71168. */
  71169. getData(): PhysicsVortexEventData;
  71170. /**
  71171. * Enables the vortex.
  71172. */
  71173. enable(): void;
  71174. /**
  71175. * Disables the cortex.
  71176. */
  71177. disable(): void;
  71178. /**
  71179. * Disposes the sphere.
  71180. * @param force
  71181. */
  71182. dispose(force?: boolean): void;
  71183. private getImpostorHitData;
  71184. private _tick;
  71185. /*** Helpers ***/
  71186. private _prepareCylinder;
  71187. private _intersectsWithCylinder;
  71188. }
  71189. /**
  71190. * Options fot the radial explosion event
  71191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71192. */
  71193. export class PhysicsRadialExplosionEventOptions {
  71194. /**
  71195. * The radius of the sphere for the radial explosion.
  71196. */
  71197. radius: number;
  71198. /**
  71199. * The strenth of the explosion.
  71200. */
  71201. strength: number;
  71202. /**
  71203. * The strenght of the force in correspondence to the distance of the affected object
  71204. */
  71205. falloff: PhysicsRadialImpulseFalloff;
  71206. /**
  71207. * Sphere options for the radial explosion.
  71208. */
  71209. sphere: {
  71210. segments: number;
  71211. diameter: number;
  71212. };
  71213. /**
  71214. * Sphere options for the radial explosion.
  71215. */
  71216. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71217. }
  71218. /**
  71219. * Options fot the updraft event
  71220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71221. */
  71222. export class PhysicsUpdraftEventOptions {
  71223. /**
  71224. * The radius of the cylinder for the vortex
  71225. */
  71226. radius: number;
  71227. /**
  71228. * The strenth of the updraft.
  71229. */
  71230. strength: number;
  71231. /**
  71232. * The height of the cylinder for the updraft.
  71233. */
  71234. height: number;
  71235. /**
  71236. * The mode for the the updraft.
  71237. */
  71238. updraftMode: PhysicsUpdraftMode;
  71239. }
  71240. /**
  71241. * Options fot the vortex event
  71242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71243. */
  71244. export class PhysicsVortexEventOptions {
  71245. /**
  71246. * The radius of the cylinder for the vortex
  71247. */
  71248. radius: number;
  71249. /**
  71250. * The strenth of the vortex.
  71251. */
  71252. strength: number;
  71253. /**
  71254. * The height of the cylinder for the vortex.
  71255. */
  71256. height: number;
  71257. /**
  71258. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71259. */
  71260. centripetalForceThreshold: number;
  71261. /**
  71262. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71263. */
  71264. centripetalForceMultiplier: number;
  71265. /**
  71266. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71267. */
  71268. centrifugalForceMultiplier: number;
  71269. /**
  71270. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71271. */
  71272. updraftForceMultiplier: number;
  71273. }
  71274. /**
  71275. * The strenght of the force in correspondence to the distance of the affected object
  71276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71277. */
  71278. export enum PhysicsRadialImpulseFalloff {
  71279. /** Defines that impulse is constant in strength across it's whole radius */
  71280. Constant = 0,
  71281. /** Defines that impulse gets weaker if it's further from the origin */
  71282. Linear = 1
  71283. }
  71284. /**
  71285. * The strength of the force in correspondence to the distance of the affected object
  71286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71287. */
  71288. export enum PhysicsUpdraftMode {
  71289. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71290. Center = 0,
  71291. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71292. Perpendicular = 1
  71293. }
  71294. /**
  71295. * Interface for a physics hit data
  71296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71297. */
  71298. export interface PhysicsHitData {
  71299. /**
  71300. * The force applied at the contact point
  71301. */
  71302. force: Vector3;
  71303. /**
  71304. * The contact point
  71305. */
  71306. contactPoint: Vector3;
  71307. /**
  71308. * The distance from the origin to the contact point
  71309. */
  71310. distanceFromOrigin: number;
  71311. }
  71312. /**
  71313. * Interface for radial explosion event data
  71314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71315. */
  71316. export interface PhysicsRadialExplosionEventData {
  71317. /**
  71318. * A sphere used for the radial explosion event
  71319. */
  71320. sphere: Mesh;
  71321. }
  71322. /**
  71323. * Interface for gravitational field event data
  71324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71325. */
  71326. export interface PhysicsGravitationalFieldEventData {
  71327. /**
  71328. * A sphere mesh used for the gravitational field event
  71329. */
  71330. sphere: Mesh;
  71331. }
  71332. /**
  71333. * Interface for updraft event data
  71334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71335. */
  71336. export interface PhysicsUpdraftEventData {
  71337. /**
  71338. * A cylinder used for the updraft event
  71339. */
  71340. cylinder: Mesh;
  71341. }
  71342. /**
  71343. * Interface for vortex event data
  71344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71345. */
  71346. export interface PhysicsVortexEventData {
  71347. /**
  71348. * A cylinder used for the vortex event
  71349. */
  71350. cylinder: Mesh;
  71351. }
  71352. /**
  71353. * Interface for an affected physics impostor
  71354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71355. */
  71356. export interface PhysicsAffectedImpostorWithData {
  71357. /**
  71358. * The impostor affected by the effect
  71359. */
  71360. impostor: PhysicsImpostor;
  71361. /**
  71362. * The data about the hit/horce from the explosion
  71363. */
  71364. hitData: PhysicsHitData;
  71365. }
  71366. }
  71367. declare module "babylonjs/Physics/Plugins/index" {
  71368. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71369. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71370. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71371. }
  71372. declare module "babylonjs/Physics/index" {
  71373. export * from "babylonjs/Physics/IPhysicsEngine";
  71374. export * from "babylonjs/Physics/physicsEngine";
  71375. export * from "babylonjs/Physics/physicsEngineComponent";
  71376. export * from "babylonjs/Physics/physicsHelper";
  71377. export * from "babylonjs/Physics/physicsImpostor";
  71378. export * from "babylonjs/Physics/physicsJoint";
  71379. export * from "babylonjs/Physics/Plugins/index";
  71380. }
  71381. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71382. /** @hidden */
  71383. export var blackAndWhitePixelShader: {
  71384. name: string;
  71385. shader: string;
  71386. };
  71387. }
  71388. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71390. import { Camera } from "babylonjs/Cameras/camera";
  71391. import { Engine } from "babylonjs/Engines/engine";
  71392. import "babylonjs/Shaders/blackAndWhite.fragment";
  71393. /**
  71394. * Post process used to render in black and white
  71395. */
  71396. export class BlackAndWhitePostProcess extends PostProcess {
  71397. /**
  71398. * Linear about to convert he result to black and white (default: 1)
  71399. */
  71400. degree: number;
  71401. /**
  71402. * Creates a black and white post process
  71403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71404. * @param name The name of the effect.
  71405. * @param options The required width/height ratio to downsize to before computing the render pass.
  71406. * @param camera The camera to apply the render pass to.
  71407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71408. * @param engine The engine which the post process will be applied. (default: current engine)
  71409. * @param reusable If the post process can be reused on the same frame. (default: false)
  71410. */
  71411. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71412. }
  71413. }
  71414. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71415. import { Nullable } from "babylonjs/types";
  71416. import { Camera } from "babylonjs/Cameras/camera";
  71417. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71418. import { Engine } from "babylonjs/Engines/engine";
  71419. /**
  71420. * This represents a set of one or more post processes in Babylon.
  71421. * A post process can be used to apply a shader to a texture after it is rendered.
  71422. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71423. */
  71424. export class PostProcessRenderEffect {
  71425. private _postProcesses;
  71426. private _getPostProcesses;
  71427. private _singleInstance;
  71428. private _cameras;
  71429. private _indicesForCamera;
  71430. /**
  71431. * Name of the effect
  71432. * @hidden
  71433. */
  71434. _name: string;
  71435. /**
  71436. * Instantiates a post process render effect.
  71437. * A post process can be used to apply a shader to a texture after it is rendered.
  71438. * @param engine The engine the effect is tied to
  71439. * @param name The name of the effect
  71440. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71441. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71442. */
  71443. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71444. /**
  71445. * Checks if all the post processes in the effect are supported.
  71446. */
  71447. get isSupported(): boolean;
  71448. /**
  71449. * Updates the current state of the effect
  71450. * @hidden
  71451. */
  71452. _update(): void;
  71453. /**
  71454. * Attaches the effect on cameras
  71455. * @param cameras The camera to attach to.
  71456. * @hidden
  71457. */
  71458. _attachCameras(cameras: Camera): void;
  71459. /**
  71460. * Attaches the effect on cameras
  71461. * @param cameras The camera to attach to.
  71462. * @hidden
  71463. */
  71464. _attachCameras(cameras: Camera[]): void;
  71465. /**
  71466. * Detaches the effect on cameras
  71467. * @param cameras The camera to detatch from.
  71468. * @hidden
  71469. */
  71470. _detachCameras(cameras: Camera): void;
  71471. /**
  71472. * Detatches the effect on cameras
  71473. * @param cameras The camera to detatch from.
  71474. * @hidden
  71475. */
  71476. _detachCameras(cameras: Camera[]): void;
  71477. /**
  71478. * Enables the effect on given cameras
  71479. * @param cameras The camera to enable.
  71480. * @hidden
  71481. */
  71482. _enable(cameras: Camera): void;
  71483. /**
  71484. * Enables the effect on given cameras
  71485. * @param cameras The camera to enable.
  71486. * @hidden
  71487. */
  71488. _enable(cameras: Nullable<Camera[]>): void;
  71489. /**
  71490. * Disables the effect on the given cameras
  71491. * @param cameras The camera to disable.
  71492. * @hidden
  71493. */
  71494. _disable(cameras: Camera): void;
  71495. /**
  71496. * Disables the effect on the given cameras
  71497. * @param cameras The camera to disable.
  71498. * @hidden
  71499. */
  71500. _disable(cameras: Nullable<Camera[]>): void;
  71501. /**
  71502. * Gets a list of the post processes contained in the effect.
  71503. * @param camera The camera to get the post processes on.
  71504. * @returns The list of the post processes in the effect.
  71505. */
  71506. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71507. }
  71508. }
  71509. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71511. /** @hidden */
  71512. export var extractHighlightsPixelShader: {
  71513. name: string;
  71514. shader: string;
  71515. };
  71516. }
  71517. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71518. import { Nullable } from "babylonjs/types";
  71519. import { Camera } from "babylonjs/Cameras/camera";
  71520. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71521. import { Engine } from "babylonjs/Engines/engine";
  71522. import "babylonjs/Shaders/extractHighlights.fragment";
  71523. /**
  71524. * 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.
  71525. */
  71526. export class ExtractHighlightsPostProcess extends PostProcess {
  71527. /**
  71528. * The luminance threshold, pixels below this value will be set to black.
  71529. */
  71530. threshold: number;
  71531. /** @hidden */
  71532. _exposure: number;
  71533. /**
  71534. * Post process which has the input texture to be used when performing highlight extraction
  71535. * @hidden
  71536. */
  71537. _inputPostProcess: Nullable<PostProcess>;
  71538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71539. }
  71540. }
  71541. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71542. /** @hidden */
  71543. export var bloomMergePixelShader: {
  71544. name: string;
  71545. shader: string;
  71546. };
  71547. }
  71548. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71550. import { Nullable } from "babylonjs/types";
  71551. import { Engine } from "babylonjs/Engines/engine";
  71552. import { Camera } from "babylonjs/Cameras/camera";
  71553. import "babylonjs/Shaders/bloomMerge.fragment";
  71554. /**
  71555. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71556. */
  71557. export class BloomMergePostProcess extends PostProcess {
  71558. /** Weight of the bloom to be added to the original input. */
  71559. weight: number;
  71560. /**
  71561. * Creates a new instance of @see BloomMergePostProcess
  71562. * @param name The name of the effect.
  71563. * @param originalFromInput Post process which's input will be used for the merge.
  71564. * @param blurred Blurred highlights post process which's output will be used.
  71565. * @param weight Weight of the bloom to be added to the original input.
  71566. * @param options The required width/height ratio to downsize to before computing the render pass.
  71567. * @param camera The camera to apply the render pass to.
  71568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71569. * @param engine The engine which the post process will be applied. (default: current engine)
  71570. * @param reusable If the post process can be reused on the same frame. (default: false)
  71571. * @param textureType Type of textures used when performing the post process. (default: 0)
  71572. * @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)
  71573. */
  71574. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71575. /** Weight of the bloom to be added to the original input. */
  71576. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71577. }
  71578. }
  71579. declare module "babylonjs/PostProcesses/bloomEffect" {
  71580. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71582. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71583. import { Camera } from "babylonjs/Cameras/camera";
  71584. import { Scene } from "babylonjs/scene";
  71585. /**
  71586. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71587. */
  71588. export class BloomEffect extends PostProcessRenderEffect {
  71589. private bloomScale;
  71590. /**
  71591. * @hidden Internal
  71592. */
  71593. _effects: Array<PostProcess>;
  71594. /**
  71595. * @hidden Internal
  71596. */
  71597. _downscale: ExtractHighlightsPostProcess;
  71598. private _blurX;
  71599. private _blurY;
  71600. private _merge;
  71601. /**
  71602. * The luminance threshold to find bright areas of the image to bloom.
  71603. */
  71604. get threshold(): number;
  71605. set threshold(value: number);
  71606. /**
  71607. * The strength of the bloom.
  71608. */
  71609. get weight(): number;
  71610. set weight(value: number);
  71611. /**
  71612. * Specifies the size of the bloom blur kernel, relative to the final output size
  71613. */
  71614. get kernel(): number;
  71615. set kernel(value: number);
  71616. /**
  71617. * Creates a new instance of @see BloomEffect
  71618. * @param scene The scene the effect belongs to.
  71619. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71620. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71621. * @param bloomWeight The the strength of bloom.
  71622. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71623. * @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)
  71624. */
  71625. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71626. /**
  71627. * Disposes each of the internal effects for a given camera.
  71628. * @param camera The camera to dispose the effect on.
  71629. */
  71630. disposeEffects(camera: Camera): void;
  71631. /**
  71632. * @hidden Internal
  71633. */
  71634. _updateEffects(): void;
  71635. /**
  71636. * Internal
  71637. * @returns if all the contained post processes are ready.
  71638. * @hidden
  71639. */
  71640. _isReady(): boolean;
  71641. }
  71642. }
  71643. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71644. /** @hidden */
  71645. export var chromaticAberrationPixelShader: {
  71646. name: string;
  71647. shader: string;
  71648. };
  71649. }
  71650. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71651. import { Vector2 } from "babylonjs/Maths/math.vector";
  71652. import { Nullable } from "babylonjs/types";
  71653. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71654. import { Camera } from "babylonjs/Cameras/camera";
  71655. import { Engine } from "babylonjs/Engines/engine";
  71656. import "babylonjs/Shaders/chromaticAberration.fragment";
  71657. /**
  71658. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71659. */
  71660. export class ChromaticAberrationPostProcess extends PostProcess {
  71661. /**
  71662. * The amount of seperation of rgb channels (default: 30)
  71663. */
  71664. aberrationAmount: number;
  71665. /**
  71666. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71667. */
  71668. radialIntensity: number;
  71669. /**
  71670. * 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))
  71671. */
  71672. direction: Vector2;
  71673. /**
  71674. * 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))
  71675. */
  71676. centerPosition: Vector2;
  71677. /**
  71678. * Creates a new instance ChromaticAberrationPostProcess
  71679. * @param name The name of the effect.
  71680. * @param screenWidth The width of the screen to apply the effect on.
  71681. * @param screenHeight The height of the screen to apply the effect on.
  71682. * @param options The required width/height ratio to downsize to before computing the render pass.
  71683. * @param camera The camera to apply the render pass to.
  71684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71685. * @param engine The engine which the post process will be applied. (default: current engine)
  71686. * @param reusable If the post process can be reused on the same frame. (default: false)
  71687. * @param textureType Type of textures used when performing the post process. (default: 0)
  71688. * @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)
  71689. */
  71690. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71691. }
  71692. }
  71693. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71694. /** @hidden */
  71695. export var circleOfConfusionPixelShader: {
  71696. name: string;
  71697. shader: string;
  71698. };
  71699. }
  71700. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71701. import { Nullable } from "babylonjs/types";
  71702. import { Engine } from "babylonjs/Engines/engine";
  71703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71705. import { Camera } from "babylonjs/Cameras/camera";
  71706. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71707. /**
  71708. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71709. */
  71710. export class CircleOfConfusionPostProcess extends PostProcess {
  71711. /**
  71712. * 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.
  71713. */
  71714. lensSize: number;
  71715. /**
  71716. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71717. */
  71718. fStop: number;
  71719. /**
  71720. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71721. */
  71722. focusDistance: number;
  71723. /**
  71724. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71725. */
  71726. focalLength: number;
  71727. private _depthTexture;
  71728. /**
  71729. * Creates a new instance CircleOfConfusionPostProcess
  71730. * @param name The name of the effect.
  71731. * @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.
  71732. * @param options The required width/height ratio to downsize to before computing the render pass.
  71733. * @param camera The camera to apply the render pass to.
  71734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71735. * @param engine The engine which the post process will be applied. (default: current engine)
  71736. * @param reusable If the post process can be reused on the same frame. (default: false)
  71737. * @param textureType Type of textures used when performing the post process. (default: 0)
  71738. * @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)
  71739. */
  71740. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71741. /**
  71742. * 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.
  71743. */
  71744. set depthTexture(value: RenderTargetTexture);
  71745. }
  71746. }
  71747. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71748. /** @hidden */
  71749. export var colorCorrectionPixelShader: {
  71750. name: string;
  71751. shader: string;
  71752. };
  71753. }
  71754. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71755. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71756. import { Engine } from "babylonjs/Engines/engine";
  71757. import { Camera } from "babylonjs/Cameras/camera";
  71758. import "babylonjs/Shaders/colorCorrection.fragment";
  71759. /**
  71760. *
  71761. * This post-process allows the modification of rendered colors by using
  71762. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71763. *
  71764. * The object needs to be provided an url to a texture containing the color
  71765. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71766. * Use an image editing software to tweak the LUT to match your needs.
  71767. *
  71768. * For an example of a color LUT, see here:
  71769. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71770. * For explanations on color grading, see here:
  71771. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71772. *
  71773. */
  71774. export class ColorCorrectionPostProcess extends PostProcess {
  71775. private _colorTableTexture;
  71776. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71777. }
  71778. }
  71779. declare module "babylonjs/Shaders/convolution.fragment" {
  71780. /** @hidden */
  71781. export var convolutionPixelShader: {
  71782. name: string;
  71783. shader: string;
  71784. };
  71785. }
  71786. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71788. import { Nullable } from "babylonjs/types";
  71789. import { Camera } from "babylonjs/Cameras/camera";
  71790. import { Engine } from "babylonjs/Engines/engine";
  71791. import "babylonjs/Shaders/convolution.fragment";
  71792. /**
  71793. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71794. * input texture to perform effects such as edge detection or sharpening
  71795. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71796. */
  71797. export class ConvolutionPostProcess extends PostProcess {
  71798. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71799. kernel: number[];
  71800. /**
  71801. * Creates a new instance ConvolutionPostProcess
  71802. * @param name The name of the effect.
  71803. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71804. * @param options The required width/height ratio to downsize to before computing the render pass.
  71805. * @param camera The camera to apply the render pass to.
  71806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71807. * @param engine The engine which the post process will be applied. (default: current engine)
  71808. * @param reusable If the post process can be reused on the same frame. (default: false)
  71809. * @param textureType Type of textures used when performing the post process. (default: 0)
  71810. */
  71811. constructor(name: string,
  71812. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71813. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71814. /**
  71815. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71816. */
  71817. static EdgeDetect0Kernel: number[];
  71818. /**
  71819. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71820. */
  71821. static EdgeDetect1Kernel: number[];
  71822. /**
  71823. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71824. */
  71825. static EdgeDetect2Kernel: number[];
  71826. /**
  71827. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71828. */
  71829. static SharpenKernel: number[];
  71830. /**
  71831. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71832. */
  71833. static EmbossKernel: number[];
  71834. /**
  71835. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71836. */
  71837. static GaussianKernel: number[];
  71838. }
  71839. }
  71840. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71841. import { Nullable } from "babylonjs/types";
  71842. import { Vector2 } from "babylonjs/Maths/math.vector";
  71843. import { Camera } from "babylonjs/Cameras/camera";
  71844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71845. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71846. import { Engine } from "babylonjs/Engines/engine";
  71847. import { Scene } from "babylonjs/scene";
  71848. /**
  71849. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71850. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71851. * based on samples that have a large difference in distance than the center pixel.
  71852. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71853. */
  71854. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71855. direction: Vector2;
  71856. /**
  71857. * Creates a new instance CircleOfConfusionPostProcess
  71858. * @param name The name of the effect.
  71859. * @param scene The scene the effect belongs to.
  71860. * @param direction The direction the blur should be applied.
  71861. * @param kernel The size of the kernel used to blur.
  71862. * @param options The required width/height ratio to downsize to before computing the render pass.
  71863. * @param camera The camera to apply the render pass to.
  71864. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71865. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71867. * @param engine The engine which the post process will be applied. (default: current engine)
  71868. * @param reusable If the post process can be reused on the same frame. (default: false)
  71869. * @param textureType Type of textures used when performing the post process. (default: 0)
  71870. * @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)
  71871. */
  71872. 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);
  71873. }
  71874. }
  71875. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71876. /** @hidden */
  71877. export var depthOfFieldMergePixelShader: {
  71878. name: string;
  71879. shader: string;
  71880. };
  71881. }
  71882. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71883. import { Nullable } from "babylonjs/types";
  71884. import { Camera } from "babylonjs/Cameras/camera";
  71885. import { Effect } from "babylonjs/Materials/effect";
  71886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71887. import { Engine } from "babylonjs/Engines/engine";
  71888. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71889. /**
  71890. * Options to be set when merging outputs from the default pipeline.
  71891. */
  71892. export class DepthOfFieldMergePostProcessOptions {
  71893. /**
  71894. * The original image to merge on top of
  71895. */
  71896. originalFromInput: PostProcess;
  71897. /**
  71898. * Parameters to perform the merge of the depth of field effect
  71899. */
  71900. depthOfField?: {
  71901. circleOfConfusion: PostProcess;
  71902. blurSteps: Array<PostProcess>;
  71903. };
  71904. /**
  71905. * Parameters to perform the merge of bloom effect
  71906. */
  71907. bloom?: {
  71908. blurred: PostProcess;
  71909. weight: number;
  71910. };
  71911. }
  71912. /**
  71913. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71914. */
  71915. export class DepthOfFieldMergePostProcess extends PostProcess {
  71916. private blurSteps;
  71917. /**
  71918. * Creates a new instance of DepthOfFieldMergePostProcess
  71919. * @param name The name of the effect.
  71920. * @param originalFromInput Post process which's input will be used for the merge.
  71921. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71922. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71923. * @param options The required width/height ratio to downsize to before computing the render pass.
  71924. * @param camera The camera to apply the render pass to.
  71925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71926. * @param engine The engine which the post process will be applied. (default: current engine)
  71927. * @param reusable If the post process can be reused on the same frame. (default: false)
  71928. * @param textureType Type of textures used when performing the post process. (default: 0)
  71929. * @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)
  71930. */
  71931. 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);
  71932. /**
  71933. * Updates the effect with the current post process compile time values and recompiles the shader.
  71934. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71935. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71936. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71937. * @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
  71938. * @param onCompiled Called when the shader has been compiled.
  71939. * @param onError Called if there is an error when compiling a shader.
  71940. */
  71941. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71942. }
  71943. }
  71944. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71945. import { Nullable } from "babylonjs/types";
  71946. import { Camera } from "babylonjs/Cameras/camera";
  71947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71949. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71950. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71951. import { Scene } from "babylonjs/scene";
  71952. /**
  71953. * Specifies the level of max blur that should be applied when using the depth of field effect
  71954. */
  71955. export enum DepthOfFieldEffectBlurLevel {
  71956. /**
  71957. * Subtle blur
  71958. */
  71959. Low = 0,
  71960. /**
  71961. * Medium blur
  71962. */
  71963. Medium = 1,
  71964. /**
  71965. * Large blur
  71966. */
  71967. High = 2
  71968. }
  71969. /**
  71970. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71971. */
  71972. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71973. private _circleOfConfusion;
  71974. /**
  71975. * @hidden Internal, blurs from high to low
  71976. */
  71977. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71978. private _depthOfFieldBlurY;
  71979. private _dofMerge;
  71980. /**
  71981. * @hidden Internal post processes in depth of field effect
  71982. */
  71983. _effects: Array<PostProcess>;
  71984. /**
  71985. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71986. */
  71987. set focalLength(value: number);
  71988. get focalLength(): number;
  71989. /**
  71990. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71991. */
  71992. set fStop(value: number);
  71993. get fStop(): number;
  71994. /**
  71995. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71996. */
  71997. set focusDistance(value: number);
  71998. get focusDistance(): number;
  71999. /**
  72000. * 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.
  72001. */
  72002. set lensSize(value: number);
  72003. get lensSize(): number;
  72004. /**
  72005. * Creates a new instance DepthOfFieldEffect
  72006. * @param scene The scene the effect belongs to.
  72007. * @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.
  72008. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72009. * @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)
  72010. */
  72011. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72012. /**
  72013. * Get the current class name of the current effet
  72014. * @returns "DepthOfFieldEffect"
  72015. */
  72016. getClassName(): string;
  72017. /**
  72018. * 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.
  72019. */
  72020. set depthTexture(value: RenderTargetTexture);
  72021. /**
  72022. * Disposes each of the internal effects for a given camera.
  72023. * @param camera The camera to dispose the effect on.
  72024. */
  72025. disposeEffects(camera: Camera): void;
  72026. /**
  72027. * @hidden Internal
  72028. */
  72029. _updateEffects(): void;
  72030. /**
  72031. * Internal
  72032. * @returns if all the contained post processes are ready.
  72033. * @hidden
  72034. */
  72035. _isReady(): boolean;
  72036. }
  72037. }
  72038. declare module "babylonjs/Shaders/displayPass.fragment" {
  72039. /** @hidden */
  72040. export var displayPassPixelShader: {
  72041. name: string;
  72042. shader: string;
  72043. };
  72044. }
  72045. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72046. import { Nullable } from "babylonjs/types";
  72047. import { Camera } from "babylonjs/Cameras/camera";
  72048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72049. import { Engine } from "babylonjs/Engines/engine";
  72050. import "babylonjs/Shaders/displayPass.fragment";
  72051. /**
  72052. * DisplayPassPostProcess which produces an output the same as it's input
  72053. */
  72054. export class DisplayPassPostProcess extends PostProcess {
  72055. /**
  72056. * Creates the DisplayPassPostProcess
  72057. * @param name The name of the effect.
  72058. * @param options The required width/height ratio to downsize to before computing the render pass.
  72059. * @param camera The camera to apply the render pass to.
  72060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72061. * @param engine The engine which the post process will be applied. (default: current engine)
  72062. * @param reusable If the post process can be reused on the same frame. (default: false)
  72063. */
  72064. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72065. }
  72066. }
  72067. declare module "babylonjs/Shaders/filter.fragment" {
  72068. /** @hidden */
  72069. export var filterPixelShader: {
  72070. name: string;
  72071. shader: string;
  72072. };
  72073. }
  72074. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72075. import { Nullable } from "babylonjs/types";
  72076. import { Matrix } from "babylonjs/Maths/math.vector";
  72077. import { Camera } from "babylonjs/Cameras/camera";
  72078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72079. import { Engine } from "babylonjs/Engines/engine";
  72080. import "babylonjs/Shaders/filter.fragment";
  72081. /**
  72082. * Applies a kernel filter to the image
  72083. */
  72084. export class FilterPostProcess extends PostProcess {
  72085. /** The matrix to be applied to the image */
  72086. kernelMatrix: Matrix;
  72087. /**
  72088. *
  72089. * @param name The name of the effect.
  72090. * @param kernelMatrix The matrix to be applied to the image
  72091. * @param options The required width/height ratio to downsize to before computing the render pass.
  72092. * @param camera The camera to apply the render pass to.
  72093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72094. * @param engine The engine which the post process will be applied. (default: current engine)
  72095. * @param reusable If the post process can be reused on the same frame. (default: false)
  72096. */
  72097. constructor(name: string,
  72098. /** The matrix to be applied to the image */
  72099. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72100. }
  72101. }
  72102. declare module "babylonjs/Shaders/fxaa.fragment" {
  72103. /** @hidden */
  72104. export var fxaaPixelShader: {
  72105. name: string;
  72106. shader: string;
  72107. };
  72108. }
  72109. declare module "babylonjs/Shaders/fxaa.vertex" {
  72110. /** @hidden */
  72111. export var fxaaVertexShader: {
  72112. name: string;
  72113. shader: string;
  72114. };
  72115. }
  72116. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72117. import { Nullable } from "babylonjs/types";
  72118. import { Camera } from "babylonjs/Cameras/camera";
  72119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72120. import { Engine } from "babylonjs/Engines/engine";
  72121. import "babylonjs/Shaders/fxaa.fragment";
  72122. import "babylonjs/Shaders/fxaa.vertex";
  72123. /**
  72124. * Fxaa post process
  72125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72126. */
  72127. export class FxaaPostProcess extends PostProcess {
  72128. /** @hidden */
  72129. texelWidth: number;
  72130. /** @hidden */
  72131. texelHeight: number;
  72132. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72133. private _getDefines;
  72134. }
  72135. }
  72136. declare module "babylonjs/Shaders/grain.fragment" {
  72137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72138. /** @hidden */
  72139. export var grainPixelShader: {
  72140. name: string;
  72141. shader: string;
  72142. };
  72143. }
  72144. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72145. import { Nullable } from "babylonjs/types";
  72146. import { Camera } from "babylonjs/Cameras/camera";
  72147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72148. import { Engine } from "babylonjs/Engines/engine";
  72149. import "babylonjs/Shaders/grain.fragment";
  72150. /**
  72151. * The GrainPostProcess adds noise to the image at mid luminance levels
  72152. */
  72153. export class GrainPostProcess extends PostProcess {
  72154. /**
  72155. * The intensity of the grain added (default: 30)
  72156. */
  72157. intensity: number;
  72158. /**
  72159. * If the grain should be randomized on every frame
  72160. */
  72161. animated: boolean;
  72162. /**
  72163. * Creates a new instance of @see GrainPostProcess
  72164. * @param name The name of the effect.
  72165. * @param options The required width/height ratio to downsize to before computing the render pass.
  72166. * @param camera The camera to apply the render pass to.
  72167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72168. * @param engine The engine which the post process will be applied. (default: current engine)
  72169. * @param reusable If the post process can be reused on the same frame. (default: false)
  72170. * @param textureType Type of textures used when performing the post process. (default: 0)
  72171. * @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)
  72172. */
  72173. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72174. }
  72175. }
  72176. declare module "babylonjs/Shaders/highlights.fragment" {
  72177. /** @hidden */
  72178. export var highlightsPixelShader: {
  72179. name: string;
  72180. shader: string;
  72181. };
  72182. }
  72183. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72184. import { Nullable } from "babylonjs/types";
  72185. import { Camera } from "babylonjs/Cameras/camera";
  72186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72187. import { Engine } from "babylonjs/Engines/engine";
  72188. import "babylonjs/Shaders/highlights.fragment";
  72189. /**
  72190. * Extracts highlights from the image
  72191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72192. */
  72193. export class HighlightsPostProcess extends PostProcess {
  72194. /**
  72195. * Extracts highlights from the image
  72196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72197. * @param name The name of the effect.
  72198. * @param options The required width/height ratio to downsize to before computing the render pass.
  72199. * @param camera The camera to apply the render pass to.
  72200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72201. * @param engine The engine which the post process will be applied. (default: current engine)
  72202. * @param reusable If the post process can be reused on the same frame. (default: false)
  72203. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72204. */
  72205. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72206. }
  72207. }
  72208. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72209. /** @hidden */
  72210. export var mrtFragmentDeclaration: {
  72211. name: string;
  72212. shader: string;
  72213. };
  72214. }
  72215. declare module "babylonjs/Shaders/geometry.fragment" {
  72216. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72217. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72218. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72219. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72220. /** @hidden */
  72221. export var geometryPixelShader: {
  72222. name: string;
  72223. shader: string;
  72224. };
  72225. }
  72226. declare module "babylonjs/Shaders/geometry.vertex" {
  72227. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72230. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72231. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72232. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72233. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72234. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72235. /** @hidden */
  72236. export var geometryVertexShader: {
  72237. name: string;
  72238. shader: string;
  72239. };
  72240. }
  72241. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72242. import { Matrix } from "babylonjs/Maths/math.vector";
  72243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72244. import { Mesh } from "babylonjs/Meshes/mesh";
  72245. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72246. import { Effect } from "babylonjs/Materials/effect";
  72247. import { Scene } from "babylonjs/scene";
  72248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72249. import "babylonjs/Shaders/geometry.fragment";
  72250. import "babylonjs/Shaders/geometry.vertex";
  72251. /** @hidden */
  72252. interface ISavedTransformationMatrix {
  72253. world: Matrix;
  72254. viewProjection: Matrix;
  72255. }
  72256. /**
  72257. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72258. */
  72259. export class GeometryBufferRenderer {
  72260. /**
  72261. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72262. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72263. */
  72264. static readonly POSITION_TEXTURE_TYPE: number;
  72265. /**
  72266. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72267. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72268. */
  72269. static readonly VELOCITY_TEXTURE_TYPE: number;
  72270. /**
  72271. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72272. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72273. */
  72274. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72275. /**
  72276. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72277. * in order to compute objects velocities when enableVelocity is set to "true"
  72278. * @hidden
  72279. */
  72280. _previousTransformationMatrices: {
  72281. [index: number]: ISavedTransformationMatrix;
  72282. };
  72283. /**
  72284. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72285. * in order to compute objects velocities when enableVelocity is set to "true"
  72286. * @hidden
  72287. */
  72288. _previousBonesTransformationMatrices: {
  72289. [index: number]: Float32Array;
  72290. };
  72291. /**
  72292. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72293. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72294. */
  72295. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72296. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72297. renderTransparentMeshes: boolean;
  72298. private _scene;
  72299. private _multiRenderTarget;
  72300. private _ratio;
  72301. private _enablePosition;
  72302. private _enableVelocity;
  72303. private _enableReflectivity;
  72304. private _positionIndex;
  72305. private _velocityIndex;
  72306. private _reflectivityIndex;
  72307. protected _effect: Effect;
  72308. protected _cachedDefines: string;
  72309. /**
  72310. * Set the render list (meshes to be rendered) used in the G buffer.
  72311. */
  72312. set renderList(meshes: Mesh[]);
  72313. /**
  72314. * Gets wether or not G buffer are supported by the running hardware.
  72315. * This requires draw buffer supports
  72316. */
  72317. get isSupported(): boolean;
  72318. /**
  72319. * Returns the index of the given texture type in the G-Buffer textures array
  72320. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72321. * @returns the index of the given texture type in the G-Buffer textures array
  72322. */
  72323. getTextureIndex(textureType: number): number;
  72324. /**
  72325. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72326. */
  72327. get enablePosition(): boolean;
  72328. /**
  72329. * Sets whether or not objects positions are enabled for the G buffer.
  72330. */
  72331. set enablePosition(enable: boolean);
  72332. /**
  72333. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72334. */
  72335. get enableVelocity(): boolean;
  72336. /**
  72337. * Sets wether or not objects velocities are enabled for the G buffer.
  72338. */
  72339. set enableVelocity(enable: boolean);
  72340. /**
  72341. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72342. */
  72343. get enableReflectivity(): boolean;
  72344. /**
  72345. * Sets wether or not objects roughness are enabled for the G buffer.
  72346. */
  72347. set enableReflectivity(enable: boolean);
  72348. /**
  72349. * Gets the scene associated with the buffer.
  72350. */
  72351. get scene(): Scene;
  72352. /**
  72353. * Gets the ratio used by the buffer during its creation.
  72354. * How big is the buffer related to the main canvas.
  72355. */
  72356. get ratio(): number;
  72357. /** @hidden */
  72358. static _SceneComponentInitialization: (scene: Scene) => void;
  72359. /**
  72360. * Creates a new G Buffer for the scene
  72361. * @param scene The scene the buffer belongs to
  72362. * @param ratio How big is the buffer related to the main canvas.
  72363. */
  72364. constructor(scene: Scene, ratio?: number);
  72365. /**
  72366. * Checks wether everything is ready to render a submesh to the G buffer.
  72367. * @param subMesh the submesh to check readiness for
  72368. * @param useInstances is the mesh drawn using instance or not
  72369. * @returns true if ready otherwise false
  72370. */
  72371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72372. /**
  72373. * Gets the current underlying G Buffer.
  72374. * @returns the buffer
  72375. */
  72376. getGBuffer(): MultiRenderTarget;
  72377. /**
  72378. * Gets the number of samples used to render the buffer (anti aliasing).
  72379. */
  72380. get samples(): number;
  72381. /**
  72382. * Sets the number of samples used to render the buffer (anti aliasing).
  72383. */
  72384. set samples(value: number);
  72385. /**
  72386. * Disposes the renderer and frees up associated resources.
  72387. */
  72388. dispose(): void;
  72389. protected _createRenderTargets(): void;
  72390. private _copyBonesTransformationMatrices;
  72391. }
  72392. }
  72393. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72394. import { Nullable } from "babylonjs/types";
  72395. import { Scene } from "babylonjs/scene";
  72396. import { ISceneComponent } from "babylonjs/sceneComponent";
  72397. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72398. module "babylonjs/scene" {
  72399. interface Scene {
  72400. /** @hidden (Backing field) */
  72401. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72402. /**
  72403. * Gets or Sets the current geometry buffer associated to the scene.
  72404. */
  72405. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72406. /**
  72407. * Enables a GeometryBufferRender and associates it with the scene
  72408. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72409. * @returns the GeometryBufferRenderer
  72410. */
  72411. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72412. /**
  72413. * Disables the GeometryBufferRender associated with the scene
  72414. */
  72415. disableGeometryBufferRenderer(): void;
  72416. }
  72417. }
  72418. /**
  72419. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72420. * in several rendering techniques.
  72421. */
  72422. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72423. /**
  72424. * The component name helpful to identify the component in the list of scene components.
  72425. */
  72426. readonly name: string;
  72427. /**
  72428. * The scene the component belongs to.
  72429. */
  72430. scene: Scene;
  72431. /**
  72432. * Creates a new instance of the component for the given scene
  72433. * @param scene Defines the scene to register the component in
  72434. */
  72435. constructor(scene: Scene);
  72436. /**
  72437. * Registers the component in a given scene
  72438. */
  72439. register(): void;
  72440. /**
  72441. * Rebuilds the elements related to this component in case of
  72442. * context lost for instance.
  72443. */
  72444. rebuild(): void;
  72445. /**
  72446. * Disposes the component and the associated ressources
  72447. */
  72448. dispose(): void;
  72449. private _gatherRenderTargets;
  72450. }
  72451. }
  72452. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72453. /** @hidden */
  72454. export var motionBlurPixelShader: {
  72455. name: string;
  72456. shader: string;
  72457. };
  72458. }
  72459. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72460. import { Nullable } from "babylonjs/types";
  72461. import { Camera } from "babylonjs/Cameras/camera";
  72462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72463. import { Scene } from "babylonjs/scene";
  72464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72465. import "babylonjs/Animations/animatable";
  72466. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72467. import "babylonjs/Shaders/motionBlur.fragment";
  72468. import { Engine } from "babylonjs/Engines/engine";
  72469. /**
  72470. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72471. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72472. * As an example, all you have to do is to create the post-process:
  72473. * var mb = new BABYLON.MotionBlurPostProcess(
  72474. * 'mb', // The name of the effect.
  72475. * scene, // The scene containing the objects to blur according to their velocity.
  72476. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72477. * camera // The camera to apply the render pass to.
  72478. * );
  72479. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72480. */
  72481. export class MotionBlurPostProcess extends PostProcess {
  72482. /**
  72483. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72484. */
  72485. motionStrength: number;
  72486. /**
  72487. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72488. */
  72489. get motionBlurSamples(): number;
  72490. /**
  72491. * Sets the number of iterations to be used for motion blur quality
  72492. */
  72493. set motionBlurSamples(samples: number);
  72494. private _motionBlurSamples;
  72495. private _geometryBufferRenderer;
  72496. /**
  72497. * Creates a new instance MotionBlurPostProcess
  72498. * @param name The name of the effect.
  72499. * @param scene The scene containing the objects to blur according to their velocity.
  72500. * @param options The required width/height ratio to downsize to before computing the render pass.
  72501. * @param camera The camera to apply the render pass to.
  72502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72503. * @param engine The engine which the post process will be applied. (default: current engine)
  72504. * @param reusable If the post process can be reused on the same frame. (default: false)
  72505. * @param textureType Type of textures used when performing the post process. (default: 0)
  72506. * @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)
  72507. */
  72508. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72509. /**
  72510. * Excludes the given skinned mesh from computing bones velocities.
  72511. * 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.
  72512. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72513. */
  72514. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72515. /**
  72516. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72517. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72518. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72519. */
  72520. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72521. /**
  72522. * Disposes the post process.
  72523. * @param camera The camera to dispose the post process on.
  72524. */
  72525. dispose(camera?: Camera): void;
  72526. }
  72527. }
  72528. declare module "babylonjs/Shaders/refraction.fragment" {
  72529. /** @hidden */
  72530. export var refractionPixelShader: {
  72531. name: string;
  72532. shader: string;
  72533. };
  72534. }
  72535. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72536. import { Color3 } from "babylonjs/Maths/math.color";
  72537. import { Camera } from "babylonjs/Cameras/camera";
  72538. import { Texture } from "babylonjs/Materials/Textures/texture";
  72539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72540. import { Engine } from "babylonjs/Engines/engine";
  72541. import "babylonjs/Shaders/refraction.fragment";
  72542. /**
  72543. * Post process which applies a refractin texture
  72544. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72545. */
  72546. export class RefractionPostProcess extends PostProcess {
  72547. /** the base color of the refraction (used to taint the rendering) */
  72548. color: Color3;
  72549. /** simulated refraction depth */
  72550. depth: number;
  72551. /** the coefficient of the base color (0 to remove base color tainting) */
  72552. colorLevel: number;
  72553. private _refTexture;
  72554. private _ownRefractionTexture;
  72555. /**
  72556. * Gets or sets the refraction texture
  72557. * Please note that you are responsible for disposing the texture if you set it manually
  72558. */
  72559. get refractionTexture(): Texture;
  72560. set refractionTexture(value: Texture);
  72561. /**
  72562. * Initializes the RefractionPostProcess
  72563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72564. * @param name The name of the effect.
  72565. * @param refractionTextureUrl Url of the refraction texture to use
  72566. * @param color the base color of the refraction (used to taint the rendering)
  72567. * @param depth simulated refraction depth
  72568. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72569. * @param camera The camera to apply the render pass to.
  72570. * @param options The required width/height ratio to downsize to before computing the render pass.
  72571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72572. * @param engine The engine which the post process will be applied. (default: current engine)
  72573. * @param reusable If the post process can be reused on the same frame. (default: false)
  72574. */
  72575. constructor(name: string, refractionTextureUrl: string,
  72576. /** the base color of the refraction (used to taint the rendering) */
  72577. color: Color3,
  72578. /** simulated refraction depth */
  72579. depth: number,
  72580. /** the coefficient of the base color (0 to remove base color tainting) */
  72581. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72582. /**
  72583. * Disposes of the post process
  72584. * @param camera Camera to dispose post process on
  72585. */
  72586. dispose(camera: Camera): void;
  72587. }
  72588. }
  72589. declare module "babylonjs/Shaders/sharpen.fragment" {
  72590. /** @hidden */
  72591. export var sharpenPixelShader: {
  72592. name: string;
  72593. shader: string;
  72594. };
  72595. }
  72596. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72597. import { Nullable } from "babylonjs/types";
  72598. import { Camera } from "babylonjs/Cameras/camera";
  72599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72600. import "babylonjs/Shaders/sharpen.fragment";
  72601. import { Engine } from "babylonjs/Engines/engine";
  72602. /**
  72603. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72604. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72605. */
  72606. export class SharpenPostProcess extends PostProcess {
  72607. /**
  72608. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72609. */
  72610. colorAmount: number;
  72611. /**
  72612. * How much sharpness should be applied (default: 0.3)
  72613. */
  72614. edgeAmount: number;
  72615. /**
  72616. * Creates a new instance ConvolutionPostProcess
  72617. * @param name The name of the effect.
  72618. * @param options The required width/height ratio to downsize to before computing the render pass.
  72619. * @param camera The camera to apply the render pass to.
  72620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72621. * @param engine The engine which the post process will be applied. (default: current engine)
  72622. * @param reusable If the post process can be reused on the same frame. (default: false)
  72623. * @param textureType Type of textures used when performing the post process. (default: 0)
  72624. * @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)
  72625. */
  72626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72627. }
  72628. }
  72629. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72630. import { Nullable } from "babylonjs/types";
  72631. import { Camera } from "babylonjs/Cameras/camera";
  72632. import { Engine } from "babylonjs/Engines/engine";
  72633. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72634. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72635. /**
  72636. * PostProcessRenderPipeline
  72637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72638. */
  72639. export class PostProcessRenderPipeline {
  72640. private engine;
  72641. private _renderEffects;
  72642. private _renderEffectsForIsolatedPass;
  72643. /**
  72644. * List of inspectable custom properties (used by the Inspector)
  72645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72646. */
  72647. inspectableCustomProperties: IInspectable[];
  72648. /**
  72649. * @hidden
  72650. */
  72651. protected _cameras: Camera[];
  72652. /** @hidden */
  72653. _name: string;
  72654. /**
  72655. * Gets pipeline name
  72656. */
  72657. get name(): string;
  72658. /** Gets the list of attached cameras */
  72659. get cameras(): Camera[];
  72660. /**
  72661. * Initializes a PostProcessRenderPipeline
  72662. * @param engine engine to add the pipeline to
  72663. * @param name name of the pipeline
  72664. */
  72665. constructor(engine: Engine, name: string);
  72666. /**
  72667. * Gets the class name
  72668. * @returns "PostProcessRenderPipeline"
  72669. */
  72670. getClassName(): string;
  72671. /**
  72672. * If all the render effects in the pipeline are supported
  72673. */
  72674. get isSupported(): boolean;
  72675. /**
  72676. * Adds an effect to the pipeline
  72677. * @param renderEffect the effect to add
  72678. */
  72679. addEffect(renderEffect: PostProcessRenderEffect): void;
  72680. /** @hidden */
  72681. _rebuild(): void;
  72682. /** @hidden */
  72683. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72684. /** @hidden */
  72685. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72686. /** @hidden */
  72687. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72688. /** @hidden */
  72689. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72690. /** @hidden */
  72691. _attachCameras(cameras: Camera, unique: boolean): void;
  72692. /** @hidden */
  72693. _attachCameras(cameras: Camera[], unique: boolean): void;
  72694. /** @hidden */
  72695. _detachCameras(cameras: Camera): void;
  72696. /** @hidden */
  72697. _detachCameras(cameras: Nullable<Camera[]>): void;
  72698. /** @hidden */
  72699. _update(): void;
  72700. /** @hidden */
  72701. _reset(): void;
  72702. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72703. /**
  72704. * Disposes of the pipeline
  72705. */
  72706. dispose(): void;
  72707. }
  72708. }
  72709. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72710. import { Camera } from "babylonjs/Cameras/camera";
  72711. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72712. /**
  72713. * PostProcessRenderPipelineManager class
  72714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72715. */
  72716. export class PostProcessRenderPipelineManager {
  72717. private _renderPipelines;
  72718. /**
  72719. * Initializes a PostProcessRenderPipelineManager
  72720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72721. */
  72722. constructor();
  72723. /**
  72724. * Gets the list of supported render pipelines
  72725. */
  72726. get supportedPipelines(): PostProcessRenderPipeline[];
  72727. /**
  72728. * Adds a pipeline to the manager
  72729. * @param renderPipeline The pipeline to add
  72730. */
  72731. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72732. /**
  72733. * Attaches a camera to the pipeline
  72734. * @param renderPipelineName The name of the pipeline to attach to
  72735. * @param cameras the camera to attach
  72736. * @param unique if the camera can be attached multiple times to the pipeline
  72737. */
  72738. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72739. /**
  72740. * Detaches a camera from the pipeline
  72741. * @param renderPipelineName The name of the pipeline to detach from
  72742. * @param cameras the camera to detach
  72743. */
  72744. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72745. /**
  72746. * Enables an effect by name on a pipeline
  72747. * @param renderPipelineName the name of the pipeline to enable the effect in
  72748. * @param renderEffectName the name of the effect to enable
  72749. * @param cameras the cameras that the effect should be enabled on
  72750. */
  72751. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72752. /**
  72753. * Disables an effect by name on a pipeline
  72754. * @param renderPipelineName the name of the pipeline to disable the effect in
  72755. * @param renderEffectName the name of the effect to disable
  72756. * @param cameras the cameras that the effect should be disabled on
  72757. */
  72758. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72759. /**
  72760. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72761. */
  72762. update(): void;
  72763. /** @hidden */
  72764. _rebuild(): void;
  72765. /**
  72766. * Disposes of the manager and pipelines
  72767. */
  72768. dispose(): void;
  72769. }
  72770. }
  72771. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72772. import { ISceneComponent } from "babylonjs/sceneComponent";
  72773. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72774. import { Scene } from "babylonjs/scene";
  72775. module "babylonjs/scene" {
  72776. interface Scene {
  72777. /** @hidden (Backing field) */
  72778. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72779. /**
  72780. * Gets the postprocess render pipeline manager
  72781. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72782. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72783. */
  72784. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72785. }
  72786. }
  72787. /**
  72788. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72789. */
  72790. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72791. /**
  72792. * The component name helpfull to identify the component in the list of scene components.
  72793. */
  72794. readonly name: string;
  72795. /**
  72796. * The scene the component belongs to.
  72797. */
  72798. scene: Scene;
  72799. /**
  72800. * Creates a new instance of the component for the given scene
  72801. * @param scene Defines the scene to register the component in
  72802. */
  72803. constructor(scene: Scene);
  72804. /**
  72805. * Registers the component in a given scene
  72806. */
  72807. register(): void;
  72808. /**
  72809. * Rebuilds the elements related to this component in case of
  72810. * context lost for instance.
  72811. */
  72812. rebuild(): void;
  72813. /**
  72814. * Disposes the component and the associated ressources
  72815. */
  72816. dispose(): void;
  72817. private _gatherRenderTargets;
  72818. }
  72819. }
  72820. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72821. import { Nullable } from "babylonjs/types";
  72822. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72823. import { Camera } from "babylonjs/Cameras/camera";
  72824. import { IDisposable } from "babylonjs/scene";
  72825. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72826. import { Scene } from "babylonjs/scene";
  72827. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72828. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72829. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72830. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72831. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72832. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72833. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72834. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72835. import { Animation } from "babylonjs/Animations/animation";
  72836. /**
  72837. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72838. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72839. */
  72840. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72841. private _scene;
  72842. private _camerasToBeAttached;
  72843. /**
  72844. * ID of the sharpen post process,
  72845. */
  72846. private readonly SharpenPostProcessId;
  72847. /**
  72848. * @ignore
  72849. * ID of the image processing post process;
  72850. */
  72851. readonly ImageProcessingPostProcessId: string;
  72852. /**
  72853. * @ignore
  72854. * ID of the Fast Approximate Anti-Aliasing post process;
  72855. */
  72856. readonly FxaaPostProcessId: string;
  72857. /**
  72858. * ID of the chromatic aberration post process,
  72859. */
  72860. private readonly ChromaticAberrationPostProcessId;
  72861. /**
  72862. * ID of the grain post process
  72863. */
  72864. private readonly GrainPostProcessId;
  72865. /**
  72866. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72867. */
  72868. sharpen: SharpenPostProcess;
  72869. private _sharpenEffect;
  72870. private bloom;
  72871. /**
  72872. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72873. */
  72874. depthOfField: DepthOfFieldEffect;
  72875. /**
  72876. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72877. */
  72878. fxaa: FxaaPostProcess;
  72879. /**
  72880. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72881. */
  72882. imageProcessing: ImageProcessingPostProcess;
  72883. /**
  72884. * Chromatic aberration post process which will shift rgb colors in the image
  72885. */
  72886. chromaticAberration: ChromaticAberrationPostProcess;
  72887. private _chromaticAberrationEffect;
  72888. /**
  72889. * Grain post process which add noise to the image
  72890. */
  72891. grain: GrainPostProcess;
  72892. private _grainEffect;
  72893. /**
  72894. * Glow post process which adds a glow to emissive areas of the image
  72895. */
  72896. private _glowLayer;
  72897. /**
  72898. * Animations which can be used to tweak settings over a period of time
  72899. */
  72900. animations: Animation[];
  72901. private _imageProcessingConfigurationObserver;
  72902. private _sharpenEnabled;
  72903. private _bloomEnabled;
  72904. private _depthOfFieldEnabled;
  72905. private _depthOfFieldBlurLevel;
  72906. private _fxaaEnabled;
  72907. private _imageProcessingEnabled;
  72908. private _defaultPipelineTextureType;
  72909. private _bloomScale;
  72910. private _chromaticAberrationEnabled;
  72911. private _grainEnabled;
  72912. private _buildAllowed;
  72913. /**
  72914. * Gets active scene
  72915. */
  72916. get scene(): Scene;
  72917. /**
  72918. * Enable or disable the sharpen process from the pipeline
  72919. */
  72920. set sharpenEnabled(enabled: boolean);
  72921. get sharpenEnabled(): boolean;
  72922. private _resizeObserver;
  72923. private _hardwareScaleLevel;
  72924. private _bloomKernel;
  72925. /**
  72926. * Specifies the size of the bloom blur kernel, relative to the final output size
  72927. */
  72928. get bloomKernel(): number;
  72929. set bloomKernel(value: number);
  72930. /**
  72931. * Specifies the weight of the bloom in the final rendering
  72932. */
  72933. private _bloomWeight;
  72934. /**
  72935. * Specifies the luma threshold for the area that will be blurred by the bloom
  72936. */
  72937. private _bloomThreshold;
  72938. private _hdr;
  72939. /**
  72940. * The strength of the bloom.
  72941. */
  72942. set bloomWeight(value: number);
  72943. get bloomWeight(): number;
  72944. /**
  72945. * The strength of the bloom.
  72946. */
  72947. set bloomThreshold(value: number);
  72948. get bloomThreshold(): number;
  72949. /**
  72950. * The scale of the bloom, lower value will provide better performance.
  72951. */
  72952. set bloomScale(value: number);
  72953. get bloomScale(): number;
  72954. /**
  72955. * Enable or disable the bloom from the pipeline
  72956. */
  72957. set bloomEnabled(enabled: boolean);
  72958. get bloomEnabled(): boolean;
  72959. private _rebuildBloom;
  72960. /**
  72961. * If the depth of field is enabled.
  72962. */
  72963. get depthOfFieldEnabled(): boolean;
  72964. set depthOfFieldEnabled(enabled: boolean);
  72965. /**
  72966. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72967. */
  72968. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72969. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72970. /**
  72971. * If the anti aliasing is enabled.
  72972. */
  72973. set fxaaEnabled(enabled: boolean);
  72974. get fxaaEnabled(): boolean;
  72975. private _samples;
  72976. /**
  72977. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72978. */
  72979. set samples(sampleCount: number);
  72980. get samples(): number;
  72981. /**
  72982. * If image processing is enabled.
  72983. */
  72984. set imageProcessingEnabled(enabled: boolean);
  72985. get imageProcessingEnabled(): boolean;
  72986. /**
  72987. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72988. */
  72989. set glowLayerEnabled(enabled: boolean);
  72990. get glowLayerEnabled(): boolean;
  72991. /**
  72992. * Gets the glow layer (or null if not defined)
  72993. */
  72994. get glowLayer(): Nullable<GlowLayer>;
  72995. /**
  72996. * Enable or disable the chromaticAberration process from the pipeline
  72997. */
  72998. set chromaticAberrationEnabled(enabled: boolean);
  72999. get chromaticAberrationEnabled(): boolean;
  73000. /**
  73001. * Enable or disable the grain process from the pipeline
  73002. */
  73003. set grainEnabled(enabled: boolean);
  73004. get grainEnabled(): boolean;
  73005. /**
  73006. * @constructor
  73007. * @param name - The rendering pipeline name (default: "")
  73008. * @param hdr - If high dynamic range textures should be used (default: true)
  73009. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73010. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73011. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73012. */
  73013. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73014. /**
  73015. * Get the class name
  73016. * @returns "DefaultRenderingPipeline"
  73017. */
  73018. getClassName(): string;
  73019. /**
  73020. * Force the compilation of the entire pipeline.
  73021. */
  73022. prepare(): void;
  73023. private _hasCleared;
  73024. private _prevPostProcess;
  73025. private _prevPrevPostProcess;
  73026. private _setAutoClearAndTextureSharing;
  73027. private _depthOfFieldSceneObserver;
  73028. private _buildPipeline;
  73029. private _disposePostProcesses;
  73030. /**
  73031. * Adds a camera to the pipeline
  73032. * @param camera the camera to be added
  73033. */
  73034. addCamera(camera: Camera): void;
  73035. /**
  73036. * Removes a camera from the pipeline
  73037. * @param camera the camera to remove
  73038. */
  73039. removeCamera(camera: Camera): void;
  73040. /**
  73041. * Dispose of the pipeline and stop all post processes
  73042. */
  73043. dispose(): void;
  73044. /**
  73045. * Serialize the rendering pipeline (Used when exporting)
  73046. * @returns the serialized object
  73047. */
  73048. serialize(): any;
  73049. /**
  73050. * Parse the serialized pipeline
  73051. * @param source Source pipeline.
  73052. * @param scene The scene to load the pipeline to.
  73053. * @param rootUrl The URL of the serialized pipeline.
  73054. * @returns An instantiated pipeline from the serialized object.
  73055. */
  73056. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73057. }
  73058. }
  73059. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73060. /** @hidden */
  73061. export var lensHighlightsPixelShader: {
  73062. name: string;
  73063. shader: string;
  73064. };
  73065. }
  73066. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73067. /** @hidden */
  73068. export var depthOfFieldPixelShader: {
  73069. name: string;
  73070. shader: string;
  73071. };
  73072. }
  73073. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73074. import { Camera } from "babylonjs/Cameras/camera";
  73075. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73076. import { Scene } from "babylonjs/scene";
  73077. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73078. import "babylonjs/Shaders/chromaticAberration.fragment";
  73079. import "babylonjs/Shaders/lensHighlights.fragment";
  73080. import "babylonjs/Shaders/depthOfField.fragment";
  73081. /**
  73082. * BABYLON.JS Chromatic Aberration GLSL Shader
  73083. * Author: Olivier Guyot
  73084. * Separates very slightly R, G and B colors on the edges of the screen
  73085. * Inspired by Francois Tarlier & Martins Upitis
  73086. */
  73087. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73088. /**
  73089. * @ignore
  73090. * The chromatic aberration PostProcess id in the pipeline
  73091. */
  73092. LensChromaticAberrationEffect: string;
  73093. /**
  73094. * @ignore
  73095. * The highlights enhancing PostProcess id in the pipeline
  73096. */
  73097. HighlightsEnhancingEffect: string;
  73098. /**
  73099. * @ignore
  73100. * The depth-of-field PostProcess id in the pipeline
  73101. */
  73102. LensDepthOfFieldEffect: string;
  73103. private _scene;
  73104. private _depthTexture;
  73105. private _grainTexture;
  73106. private _chromaticAberrationPostProcess;
  73107. private _highlightsPostProcess;
  73108. private _depthOfFieldPostProcess;
  73109. private _edgeBlur;
  73110. private _grainAmount;
  73111. private _chromaticAberration;
  73112. private _distortion;
  73113. private _highlightsGain;
  73114. private _highlightsThreshold;
  73115. private _dofDistance;
  73116. private _dofAperture;
  73117. private _dofDarken;
  73118. private _dofPentagon;
  73119. private _blurNoise;
  73120. /**
  73121. * @constructor
  73122. *
  73123. * Effect parameters are as follow:
  73124. * {
  73125. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73126. * edge_blur: number; // from 0 to x (1 for realism)
  73127. * distortion: number; // from 0 to x (1 for realism)
  73128. * grain_amount: number; // from 0 to 1
  73129. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73130. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73131. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73132. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73133. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73134. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73135. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73136. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73137. * }
  73138. * Note: if an effect parameter is unset, effect is disabled
  73139. *
  73140. * @param name The rendering pipeline name
  73141. * @param parameters - An object containing all parameters (see above)
  73142. * @param scene The scene linked to this pipeline
  73143. * @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)
  73144. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73145. */
  73146. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73147. /**
  73148. * Get the class name
  73149. * @returns "LensRenderingPipeline"
  73150. */
  73151. getClassName(): string;
  73152. /**
  73153. * Gets associated scene
  73154. */
  73155. get scene(): Scene;
  73156. /**
  73157. * Gets or sets the edge blur
  73158. */
  73159. get edgeBlur(): number;
  73160. set edgeBlur(value: number);
  73161. /**
  73162. * Gets or sets the grain amount
  73163. */
  73164. get grainAmount(): number;
  73165. set grainAmount(value: number);
  73166. /**
  73167. * Gets or sets the chromatic aberration amount
  73168. */
  73169. get chromaticAberration(): number;
  73170. set chromaticAberration(value: number);
  73171. /**
  73172. * Gets or sets the depth of field aperture
  73173. */
  73174. get dofAperture(): number;
  73175. set dofAperture(value: number);
  73176. /**
  73177. * Gets or sets the edge distortion
  73178. */
  73179. get edgeDistortion(): number;
  73180. set edgeDistortion(value: number);
  73181. /**
  73182. * Gets or sets the depth of field distortion
  73183. */
  73184. get dofDistortion(): number;
  73185. set dofDistortion(value: number);
  73186. /**
  73187. * Gets or sets the darken out of focus amount
  73188. */
  73189. get darkenOutOfFocus(): number;
  73190. set darkenOutOfFocus(value: number);
  73191. /**
  73192. * Gets or sets a boolean indicating if blur noise is enabled
  73193. */
  73194. get blurNoise(): boolean;
  73195. set blurNoise(value: boolean);
  73196. /**
  73197. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73198. */
  73199. get pentagonBokeh(): boolean;
  73200. set pentagonBokeh(value: boolean);
  73201. /**
  73202. * Gets or sets the highlight grain amount
  73203. */
  73204. get highlightsGain(): number;
  73205. set highlightsGain(value: number);
  73206. /**
  73207. * Gets or sets the highlight threshold
  73208. */
  73209. get highlightsThreshold(): number;
  73210. set highlightsThreshold(value: number);
  73211. /**
  73212. * Sets the amount of blur at the edges
  73213. * @param amount blur amount
  73214. */
  73215. setEdgeBlur(amount: number): void;
  73216. /**
  73217. * Sets edge blur to 0
  73218. */
  73219. disableEdgeBlur(): void;
  73220. /**
  73221. * Sets the amout of grain
  73222. * @param amount Amount of grain
  73223. */
  73224. setGrainAmount(amount: number): void;
  73225. /**
  73226. * Set grain amount to 0
  73227. */
  73228. disableGrain(): void;
  73229. /**
  73230. * Sets the chromatic aberration amount
  73231. * @param amount amount of chromatic aberration
  73232. */
  73233. setChromaticAberration(amount: number): void;
  73234. /**
  73235. * Sets chromatic aberration amount to 0
  73236. */
  73237. disableChromaticAberration(): void;
  73238. /**
  73239. * Sets the EdgeDistortion amount
  73240. * @param amount amount of EdgeDistortion
  73241. */
  73242. setEdgeDistortion(amount: number): void;
  73243. /**
  73244. * Sets edge distortion to 0
  73245. */
  73246. disableEdgeDistortion(): void;
  73247. /**
  73248. * Sets the FocusDistance amount
  73249. * @param amount amount of FocusDistance
  73250. */
  73251. setFocusDistance(amount: number): void;
  73252. /**
  73253. * Disables depth of field
  73254. */
  73255. disableDepthOfField(): void;
  73256. /**
  73257. * Sets the Aperture amount
  73258. * @param amount amount of Aperture
  73259. */
  73260. setAperture(amount: number): void;
  73261. /**
  73262. * Sets the DarkenOutOfFocus amount
  73263. * @param amount amount of DarkenOutOfFocus
  73264. */
  73265. setDarkenOutOfFocus(amount: number): void;
  73266. private _pentagonBokehIsEnabled;
  73267. /**
  73268. * Creates a pentagon bokeh effect
  73269. */
  73270. enablePentagonBokeh(): void;
  73271. /**
  73272. * Disables the pentagon bokeh effect
  73273. */
  73274. disablePentagonBokeh(): void;
  73275. /**
  73276. * Enables noise blur
  73277. */
  73278. enableNoiseBlur(): void;
  73279. /**
  73280. * Disables noise blur
  73281. */
  73282. disableNoiseBlur(): void;
  73283. /**
  73284. * Sets the HighlightsGain amount
  73285. * @param amount amount of HighlightsGain
  73286. */
  73287. setHighlightsGain(amount: number): void;
  73288. /**
  73289. * Sets the HighlightsThreshold amount
  73290. * @param amount amount of HighlightsThreshold
  73291. */
  73292. setHighlightsThreshold(amount: number): void;
  73293. /**
  73294. * Disables highlights
  73295. */
  73296. disableHighlights(): void;
  73297. /**
  73298. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73299. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73300. */
  73301. dispose(disableDepthRender?: boolean): void;
  73302. private _createChromaticAberrationPostProcess;
  73303. private _createHighlightsPostProcess;
  73304. private _createDepthOfFieldPostProcess;
  73305. private _createGrainTexture;
  73306. }
  73307. }
  73308. declare module "babylonjs/Shaders/ssao2.fragment" {
  73309. /** @hidden */
  73310. export var ssao2PixelShader: {
  73311. name: string;
  73312. shader: string;
  73313. };
  73314. }
  73315. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73316. /** @hidden */
  73317. export var ssaoCombinePixelShader: {
  73318. name: string;
  73319. shader: string;
  73320. };
  73321. }
  73322. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73323. import { Camera } from "babylonjs/Cameras/camera";
  73324. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73325. import { Scene } from "babylonjs/scene";
  73326. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73327. import "babylonjs/Shaders/ssao2.fragment";
  73328. import "babylonjs/Shaders/ssaoCombine.fragment";
  73329. /**
  73330. * Render pipeline to produce ssao effect
  73331. */
  73332. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73333. /**
  73334. * @ignore
  73335. * The PassPostProcess id in the pipeline that contains the original scene color
  73336. */
  73337. SSAOOriginalSceneColorEffect: string;
  73338. /**
  73339. * @ignore
  73340. * The SSAO PostProcess id in the pipeline
  73341. */
  73342. SSAORenderEffect: string;
  73343. /**
  73344. * @ignore
  73345. * The horizontal blur PostProcess id in the pipeline
  73346. */
  73347. SSAOBlurHRenderEffect: string;
  73348. /**
  73349. * @ignore
  73350. * The vertical blur PostProcess id in the pipeline
  73351. */
  73352. SSAOBlurVRenderEffect: string;
  73353. /**
  73354. * @ignore
  73355. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73356. */
  73357. SSAOCombineRenderEffect: string;
  73358. /**
  73359. * The output strength of the SSAO post-process. Default value is 1.0.
  73360. */
  73361. totalStrength: number;
  73362. /**
  73363. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73364. */
  73365. maxZ: number;
  73366. /**
  73367. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73368. */
  73369. minZAspect: number;
  73370. private _samples;
  73371. /**
  73372. * Number of samples used for the SSAO calculations. Default value is 8
  73373. */
  73374. set samples(n: number);
  73375. get samples(): number;
  73376. private _textureSamples;
  73377. /**
  73378. * Number of samples to use for antialiasing
  73379. */
  73380. set textureSamples(n: number);
  73381. get textureSamples(): number;
  73382. /**
  73383. * Ratio object used for SSAO ratio and blur ratio
  73384. */
  73385. private _ratio;
  73386. /**
  73387. * Dynamically generated sphere sampler.
  73388. */
  73389. private _sampleSphere;
  73390. /**
  73391. * Blur filter offsets
  73392. */
  73393. private _samplerOffsets;
  73394. private _expensiveBlur;
  73395. /**
  73396. * If bilateral blur should be used
  73397. */
  73398. set expensiveBlur(b: boolean);
  73399. get expensiveBlur(): boolean;
  73400. /**
  73401. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73402. */
  73403. radius: number;
  73404. /**
  73405. * The base color of the SSAO post-process
  73406. * The final result is "base + ssao" between [0, 1]
  73407. */
  73408. base: number;
  73409. /**
  73410. * Support test.
  73411. */
  73412. static get IsSupported(): boolean;
  73413. private _scene;
  73414. private _depthTexture;
  73415. private _normalTexture;
  73416. private _randomTexture;
  73417. private _originalColorPostProcess;
  73418. private _ssaoPostProcess;
  73419. private _blurHPostProcess;
  73420. private _blurVPostProcess;
  73421. private _ssaoCombinePostProcess;
  73422. /**
  73423. * Gets active scene
  73424. */
  73425. get scene(): Scene;
  73426. /**
  73427. * @constructor
  73428. * @param name The rendering pipeline name
  73429. * @param scene The scene linked to this pipeline
  73430. * @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 }
  73431. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73432. */
  73433. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73434. /**
  73435. * Get the class name
  73436. * @returns "SSAO2RenderingPipeline"
  73437. */
  73438. getClassName(): string;
  73439. /**
  73440. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73441. */
  73442. dispose(disableGeometryBufferRenderer?: boolean): void;
  73443. private _createBlurPostProcess;
  73444. /** @hidden */
  73445. _rebuild(): void;
  73446. private _bits;
  73447. private _radicalInverse_VdC;
  73448. private _hammersley;
  73449. private _hemisphereSample_uniform;
  73450. private _generateHemisphere;
  73451. private _createSSAOPostProcess;
  73452. private _createSSAOCombinePostProcess;
  73453. private _createRandomTexture;
  73454. /**
  73455. * Serialize the rendering pipeline (Used when exporting)
  73456. * @returns the serialized object
  73457. */
  73458. serialize(): any;
  73459. /**
  73460. * Parse the serialized pipeline
  73461. * @param source Source pipeline.
  73462. * @param scene The scene to load the pipeline to.
  73463. * @param rootUrl The URL of the serialized pipeline.
  73464. * @returns An instantiated pipeline from the serialized object.
  73465. */
  73466. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73467. }
  73468. }
  73469. declare module "babylonjs/Shaders/ssao.fragment" {
  73470. /** @hidden */
  73471. export var ssaoPixelShader: {
  73472. name: string;
  73473. shader: string;
  73474. };
  73475. }
  73476. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73477. import { Camera } from "babylonjs/Cameras/camera";
  73478. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73479. import { Scene } from "babylonjs/scene";
  73480. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73481. import "babylonjs/Shaders/ssao.fragment";
  73482. import "babylonjs/Shaders/ssaoCombine.fragment";
  73483. /**
  73484. * Render pipeline to produce ssao effect
  73485. */
  73486. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73487. /**
  73488. * @ignore
  73489. * The PassPostProcess id in the pipeline that contains the original scene color
  73490. */
  73491. SSAOOriginalSceneColorEffect: string;
  73492. /**
  73493. * @ignore
  73494. * The SSAO PostProcess id in the pipeline
  73495. */
  73496. SSAORenderEffect: string;
  73497. /**
  73498. * @ignore
  73499. * The horizontal blur PostProcess id in the pipeline
  73500. */
  73501. SSAOBlurHRenderEffect: string;
  73502. /**
  73503. * @ignore
  73504. * The vertical blur PostProcess id in the pipeline
  73505. */
  73506. SSAOBlurVRenderEffect: string;
  73507. /**
  73508. * @ignore
  73509. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73510. */
  73511. SSAOCombineRenderEffect: string;
  73512. /**
  73513. * The output strength of the SSAO post-process. Default value is 1.0.
  73514. */
  73515. totalStrength: number;
  73516. /**
  73517. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73518. */
  73519. radius: number;
  73520. /**
  73521. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73522. * Must not be equal to fallOff and superior to fallOff.
  73523. * Default value is 0.0075
  73524. */
  73525. area: number;
  73526. /**
  73527. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73528. * Must not be equal to area and inferior to area.
  73529. * Default value is 0.000001
  73530. */
  73531. fallOff: number;
  73532. /**
  73533. * The base color of the SSAO post-process
  73534. * The final result is "base + ssao" between [0, 1]
  73535. */
  73536. base: number;
  73537. private _scene;
  73538. private _depthTexture;
  73539. private _randomTexture;
  73540. private _originalColorPostProcess;
  73541. private _ssaoPostProcess;
  73542. private _blurHPostProcess;
  73543. private _blurVPostProcess;
  73544. private _ssaoCombinePostProcess;
  73545. private _firstUpdate;
  73546. /**
  73547. * Gets active scene
  73548. */
  73549. get scene(): Scene;
  73550. /**
  73551. * @constructor
  73552. * @param name - The rendering pipeline name
  73553. * @param scene - The scene linked to this pipeline
  73554. * @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 }
  73555. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73556. */
  73557. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73558. /**
  73559. * Get the class name
  73560. * @returns "SSAORenderingPipeline"
  73561. */
  73562. getClassName(): string;
  73563. /**
  73564. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73565. */
  73566. dispose(disableDepthRender?: boolean): void;
  73567. private _createBlurPostProcess;
  73568. /** @hidden */
  73569. _rebuild(): void;
  73570. private _createSSAOPostProcess;
  73571. private _createSSAOCombinePostProcess;
  73572. private _createRandomTexture;
  73573. }
  73574. }
  73575. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73576. /** @hidden */
  73577. export var screenSpaceReflectionPixelShader: {
  73578. name: string;
  73579. shader: string;
  73580. };
  73581. }
  73582. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73583. import { Nullable } from "babylonjs/types";
  73584. import { Camera } from "babylonjs/Cameras/camera";
  73585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73586. import { Scene } from "babylonjs/scene";
  73587. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73588. import { Engine } from "babylonjs/Engines/engine";
  73589. /**
  73590. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73591. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73592. */
  73593. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73594. /**
  73595. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73596. */
  73597. threshold: number;
  73598. /**
  73599. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73600. */
  73601. strength: number;
  73602. /**
  73603. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73604. */
  73605. reflectionSpecularFalloffExponent: number;
  73606. /**
  73607. * 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]
  73608. */
  73609. step: number;
  73610. /**
  73611. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73612. */
  73613. roughnessFactor: number;
  73614. private _geometryBufferRenderer;
  73615. private _enableSmoothReflections;
  73616. private _reflectionSamples;
  73617. private _smoothSteps;
  73618. /**
  73619. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73620. * @param name The name of the effect.
  73621. * @param scene The scene containing the objects to calculate reflections.
  73622. * @param options The required width/height ratio to downsize to before computing the render pass.
  73623. * @param camera The camera to apply the render pass to.
  73624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73625. * @param engine The engine which the post process will be applied. (default: current engine)
  73626. * @param reusable If the post process can be reused on the same frame. (default: false)
  73627. * @param textureType Type of textures used when performing the post process. (default: 0)
  73628. * @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)
  73629. */
  73630. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73631. /**
  73632. * Gets wether or not smoothing reflections is enabled.
  73633. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73634. */
  73635. get enableSmoothReflections(): boolean;
  73636. /**
  73637. * Sets wether or not smoothing reflections is enabled.
  73638. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73639. */
  73640. set enableSmoothReflections(enabled: boolean);
  73641. /**
  73642. * Gets the number of samples taken while computing reflections. More samples count is high,
  73643. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73644. */
  73645. get reflectionSamples(): number;
  73646. /**
  73647. * Sets the number of samples taken while computing reflections. More samples count is high,
  73648. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73649. */
  73650. set reflectionSamples(samples: number);
  73651. /**
  73652. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73653. * more the post-process will require GPU power and can generate a drop in FPS.
  73654. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73655. */
  73656. get smoothSteps(): number;
  73657. set smoothSteps(steps: number);
  73658. private _updateEffectDefines;
  73659. }
  73660. }
  73661. declare module "babylonjs/Shaders/standard.fragment" {
  73662. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73663. /** @hidden */
  73664. export var standardPixelShader: {
  73665. name: string;
  73666. shader: string;
  73667. };
  73668. }
  73669. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73670. import { Nullable } from "babylonjs/types";
  73671. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73672. import { Camera } from "babylonjs/Cameras/camera";
  73673. import { Texture } from "babylonjs/Materials/Textures/texture";
  73674. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73675. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73676. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73677. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73678. import { IDisposable } from "babylonjs/scene";
  73679. import { SpotLight } from "babylonjs/Lights/spotLight";
  73680. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73681. import { Scene } from "babylonjs/scene";
  73682. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73683. import { Animation } from "babylonjs/Animations/animation";
  73684. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73685. import "babylonjs/Shaders/standard.fragment";
  73686. /**
  73687. * Standard rendering pipeline
  73688. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73689. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73690. */
  73691. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73692. /**
  73693. * Public members
  73694. */
  73695. /**
  73696. * Post-process which contains the original scene color before the pipeline applies all the effects
  73697. */
  73698. originalPostProcess: Nullable<PostProcess>;
  73699. /**
  73700. * Post-process used to down scale an image x4
  73701. */
  73702. downSampleX4PostProcess: Nullable<PostProcess>;
  73703. /**
  73704. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73705. */
  73706. brightPassPostProcess: Nullable<PostProcess>;
  73707. /**
  73708. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73709. */
  73710. blurHPostProcesses: PostProcess[];
  73711. /**
  73712. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73713. */
  73714. blurVPostProcesses: PostProcess[];
  73715. /**
  73716. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73717. */
  73718. textureAdderPostProcess: Nullable<PostProcess>;
  73719. /**
  73720. * Post-process used to create volumetric lighting effect
  73721. */
  73722. volumetricLightPostProcess: Nullable<PostProcess>;
  73723. /**
  73724. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73725. */
  73726. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73727. /**
  73728. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73729. */
  73730. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73731. /**
  73732. * Post-process used to merge the volumetric light effect and the real scene color
  73733. */
  73734. volumetricLightMergePostProces: Nullable<PostProcess>;
  73735. /**
  73736. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73737. */
  73738. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73739. /**
  73740. * Base post-process used to calculate the average luminance of the final image for HDR
  73741. */
  73742. luminancePostProcess: Nullable<PostProcess>;
  73743. /**
  73744. * Post-processes used to create down sample post-processes in order to get
  73745. * the average luminance of the final image for HDR
  73746. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73747. */
  73748. luminanceDownSamplePostProcesses: PostProcess[];
  73749. /**
  73750. * Post-process used to create a HDR effect (light adaptation)
  73751. */
  73752. hdrPostProcess: Nullable<PostProcess>;
  73753. /**
  73754. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73755. */
  73756. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73757. /**
  73758. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73759. */
  73760. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73761. /**
  73762. * Post-process used to merge the final HDR post-process and the real scene color
  73763. */
  73764. hdrFinalPostProcess: Nullable<PostProcess>;
  73765. /**
  73766. * Post-process used to create a lens flare effect
  73767. */
  73768. lensFlarePostProcess: Nullable<PostProcess>;
  73769. /**
  73770. * Post-process that merges the result of the lens flare post-process and the real scene color
  73771. */
  73772. lensFlareComposePostProcess: Nullable<PostProcess>;
  73773. /**
  73774. * Post-process used to create a motion blur effect
  73775. */
  73776. motionBlurPostProcess: Nullable<PostProcess>;
  73777. /**
  73778. * Post-process used to create a depth of field effect
  73779. */
  73780. depthOfFieldPostProcess: Nullable<PostProcess>;
  73781. /**
  73782. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73783. */
  73784. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73785. /**
  73786. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73787. */
  73788. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73789. /**
  73790. * Represents the brightness threshold in order to configure the illuminated surfaces
  73791. */
  73792. brightThreshold: number;
  73793. /**
  73794. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73795. */
  73796. blurWidth: number;
  73797. /**
  73798. * Sets if the blur for highlighted surfaces must be only horizontal
  73799. */
  73800. horizontalBlur: boolean;
  73801. /**
  73802. * Gets the overall exposure used by the pipeline
  73803. */
  73804. get exposure(): number;
  73805. /**
  73806. * Sets the overall exposure used by the pipeline
  73807. */
  73808. set exposure(value: number);
  73809. /**
  73810. * Texture used typically to simulate "dirty" on camera lens
  73811. */
  73812. lensTexture: Nullable<Texture>;
  73813. /**
  73814. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73815. */
  73816. volumetricLightCoefficient: number;
  73817. /**
  73818. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73819. */
  73820. volumetricLightPower: number;
  73821. /**
  73822. * Used the set the blur intensity to smooth the volumetric lights
  73823. */
  73824. volumetricLightBlurScale: number;
  73825. /**
  73826. * Light (spot or directional) used to generate the volumetric lights rays
  73827. * The source light must have a shadow generate so the pipeline can get its
  73828. * depth map
  73829. */
  73830. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73831. /**
  73832. * For eye adaptation, represents the minimum luminance the eye can see
  73833. */
  73834. hdrMinimumLuminance: number;
  73835. /**
  73836. * For eye adaptation, represents the decrease luminance speed
  73837. */
  73838. hdrDecreaseRate: number;
  73839. /**
  73840. * For eye adaptation, represents the increase luminance speed
  73841. */
  73842. hdrIncreaseRate: number;
  73843. /**
  73844. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73845. */
  73846. get hdrAutoExposure(): boolean;
  73847. /**
  73848. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73849. */
  73850. set hdrAutoExposure(value: boolean);
  73851. /**
  73852. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73853. */
  73854. lensColorTexture: Nullable<Texture>;
  73855. /**
  73856. * The overall strengh for the lens flare effect
  73857. */
  73858. lensFlareStrength: number;
  73859. /**
  73860. * Dispersion coefficient for lens flare ghosts
  73861. */
  73862. lensFlareGhostDispersal: number;
  73863. /**
  73864. * Main lens flare halo width
  73865. */
  73866. lensFlareHaloWidth: number;
  73867. /**
  73868. * Based on the lens distortion effect, defines how much the lens flare result
  73869. * is distorted
  73870. */
  73871. lensFlareDistortionStrength: number;
  73872. /**
  73873. * Configures the blur intensity used for for lens flare (halo)
  73874. */
  73875. lensFlareBlurWidth: number;
  73876. /**
  73877. * Lens star texture must be used to simulate rays on the flares and is available
  73878. * in the documentation
  73879. */
  73880. lensStarTexture: Nullable<Texture>;
  73881. /**
  73882. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73883. * flare effect by taking account of the dirt texture
  73884. */
  73885. lensFlareDirtTexture: Nullable<Texture>;
  73886. /**
  73887. * Represents the focal length for the depth of field effect
  73888. */
  73889. depthOfFieldDistance: number;
  73890. /**
  73891. * Represents the blur intensity for the blurred part of the depth of field effect
  73892. */
  73893. depthOfFieldBlurWidth: number;
  73894. /**
  73895. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73896. */
  73897. get motionStrength(): number;
  73898. /**
  73899. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73900. */
  73901. set motionStrength(strength: number);
  73902. /**
  73903. * Gets wether or not the motion blur post-process is object based or screen based.
  73904. */
  73905. get objectBasedMotionBlur(): boolean;
  73906. /**
  73907. * Sets wether or not the motion blur post-process should be object based or screen based
  73908. */
  73909. set objectBasedMotionBlur(value: boolean);
  73910. /**
  73911. * List of animations for the pipeline (IAnimatable implementation)
  73912. */
  73913. animations: Animation[];
  73914. /**
  73915. * Private members
  73916. */
  73917. private _scene;
  73918. private _currentDepthOfFieldSource;
  73919. private _basePostProcess;
  73920. private _fixedExposure;
  73921. private _currentExposure;
  73922. private _hdrAutoExposure;
  73923. private _hdrCurrentLuminance;
  73924. private _motionStrength;
  73925. private _isObjectBasedMotionBlur;
  73926. private _floatTextureType;
  73927. private _camerasToBeAttached;
  73928. private _ratio;
  73929. private _bloomEnabled;
  73930. private _depthOfFieldEnabled;
  73931. private _vlsEnabled;
  73932. private _lensFlareEnabled;
  73933. private _hdrEnabled;
  73934. private _motionBlurEnabled;
  73935. private _fxaaEnabled;
  73936. private _screenSpaceReflectionsEnabled;
  73937. private _motionBlurSamples;
  73938. private _volumetricLightStepsCount;
  73939. private _samples;
  73940. /**
  73941. * @ignore
  73942. * Specifies if the bloom pipeline is enabled
  73943. */
  73944. get BloomEnabled(): boolean;
  73945. set BloomEnabled(enabled: boolean);
  73946. /**
  73947. * @ignore
  73948. * Specifies if the depth of field pipeline is enabed
  73949. */
  73950. get DepthOfFieldEnabled(): boolean;
  73951. set DepthOfFieldEnabled(enabled: boolean);
  73952. /**
  73953. * @ignore
  73954. * Specifies if the lens flare pipeline is enabed
  73955. */
  73956. get LensFlareEnabled(): boolean;
  73957. set LensFlareEnabled(enabled: boolean);
  73958. /**
  73959. * @ignore
  73960. * Specifies if the HDR pipeline is enabled
  73961. */
  73962. get HDREnabled(): boolean;
  73963. set HDREnabled(enabled: boolean);
  73964. /**
  73965. * @ignore
  73966. * Specifies if the volumetric lights scattering effect is enabled
  73967. */
  73968. get VLSEnabled(): boolean;
  73969. set VLSEnabled(enabled: boolean);
  73970. /**
  73971. * @ignore
  73972. * Specifies if the motion blur effect is enabled
  73973. */
  73974. get MotionBlurEnabled(): boolean;
  73975. set MotionBlurEnabled(enabled: boolean);
  73976. /**
  73977. * Specifies if anti-aliasing is enabled
  73978. */
  73979. get fxaaEnabled(): boolean;
  73980. set fxaaEnabled(enabled: boolean);
  73981. /**
  73982. * Specifies if screen space reflections are enabled.
  73983. */
  73984. get screenSpaceReflectionsEnabled(): boolean;
  73985. set screenSpaceReflectionsEnabled(enabled: boolean);
  73986. /**
  73987. * Specifies the number of steps used to calculate the volumetric lights
  73988. * Typically in interval [50, 200]
  73989. */
  73990. get volumetricLightStepsCount(): number;
  73991. set volumetricLightStepsCount(count: number);
  73992. /**
  73993. * Specifies the number of samples used for the motion blur effect
  73994. * Typically in interval [16, 64]
  73995. */
  73996. get motionBlurSamples(): number;
  73997. set motionBlurSamples(samples: number);
  73998. /**
  73999. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74000. */
  74001. get samples(): number;
  74002. set samples(sampleCount: number);
  74003. /**
  74004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74005. * @constructor
  74006. * @param name The rendering pipeline name
  74007. * @param scene The scene linked to this pipeline
  74008. * @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)
  74009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74011. */
  74012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74013. private _buildPipeline;
  74014. private _createDownSampleX4PostProcess;
  74015. private _createBrightPassPostProcess;
  74016. private _createBlurPostProcesses;
  74017. private _createTextureAdderPostProcess;
  74018. private _createVolumetricLightPostProcess;
  74019. private _createLuminancePostProcesses;
  74020. private _createHdrPostProcess;
  74021. private _createLensFlarePostProcess;
  74022. private _createDepthOfFieldPostProcess;
  74023. private _createMotionBlurPostProcess;
  74024. private _getDepthTexture;
  74025. private _disposePostProcesses;
  74026. /**
  74027. * Dispose of the pipeline and stop all post processes
  74028. */
  74029. dispose(): void;
  74030. /**
  74031. * Serialize the rendering pipeline (Used when exporting)
  74032. * @returns the serialized object
  74033. */
  74034. serialize(): any;
  74035. /**
  74036. * Parse the serialized pipeline
  74037. * @param source Source pipeline.
  74038. * @param scene The scene to load the pipeline to.
  74039. * @param rootUrl The URL of the serialized pipeline.
  74040. * @returns An instantiated pipeline from the serialized object.
  74041. */
  74042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74043. /**
  74044. * Luminance steps
  74045. */
  74046. static LuminanceSteps: number;
  74047. }
  74048. }
  74049. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74050. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74051. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74052. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74053. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74054. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74055. }
  74056. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74057. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74058. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74059. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74060. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74061. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74062. }
  74063. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74064. /** @hidden */
  74065. export var stereoscopicInterlacePixelShader: {
  74066. name: string;
  74067. shader: string;
  74068. };
  74069. }
  74070. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74071. import { Camera } from "babylonjs/Cameras/camera";
  74072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74073. import { Engine } from "babylonjs/Engines/engine";
  74074. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74075. /**
  74076. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74077. */
  74078. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74079. private _stepSize;
  74080. private _passedProcess;
  74081. /**
  74082. * Initializes a StereoscopicInterlacePostProcessI
  74083. * @param name The name of the effect.
  74084. * @param rigCameras The rig cameras to be appled to the post process
  74085. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74086. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74088. * @param engine The engine which the post process will be applied. (default: current engine)
  74089. * @param reusable If the post process can be reused on the same frame. (default: false)
  74090. */
  74091. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74092. }
  74093. /**
  74094. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74095. */
  74096. export class StereoscopicInterlacePostProcess extends PostProcess {
  74097. private _stepSize;
  74098. private _passedProcess;
  74099. /**
  74100. * Initializes a StereoscopicInterlacePostProcess
  74101. * @param name The name of the effect.
  74102. * @param rigCameras The rig cameras to be appled to the post process
  74103. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74105. * @param engine The engine which the post process will be applied. (default: current engine)
  74106. * @param reusable If the post process can be reused on the same frame. (default: false)
  74107. */
  74108. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74109. }
  74110. }
  74111. declare module "babylonjs/Shaders/tonemap.fragment" {
  74112. /** @hidden */
  74113. export var tonemapPixelShader: {
  74114. name: string;
  74115. shader: string;
  74116. };
  74117. }
  74118. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74119. import { Camera } from "babylonjs/Cameras/camera";
  74120. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74121. import "babylonjs/Shaders/tonemap.fragment";
  74122. import { Engine } from "babylonjs/Engines/engine";
  74123. /** Defines operator used for tonemapping */
  74124. export enum TonemappingOperator {
  74125. /** Hable */
  74126. Hable = 0,
  74127. /** Reinhard */
  74128. Reinhard = 1,
  74129. /** HejiDawson */
  74130. HejiDawson = 2,
  74131. /** Photographic */
  74132. Photographic = 3
  74133. }
  74134. /**
  74135. * Defines a post process to apply tone mapping
  74136. */
  74137. export class TonemapPostProcess extends PostProcess {
  74138. private _operator;
  74139. /** Defines the required exposure adjustement */
  74140. exposureAdjustment: number;
  74141. /**
  74142. * Creates a new TonemapPostProcess
  74143. * @param name defines the name of the postprocess
  74144. * @param _operator defines the operator to use
  74145. * @param exposureAdjustment defines the required exposure adjustement
  74146. * @param camera defines the camera to use (can be null)
  74147. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74148. * @param engine defines the hosting engine (can be ignore if camera is set)
  74149. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74150. */
  74151. constructor(name: string, _operator: TonemappingOperator,
  74152. /** Defines the required exposure adjustement */
  74153. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74154. }
  74155. }
  74156. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74157. /** @hidden */
  74158. export var volumetricLightScatteringPixelShader: {
  74159. name: string;
  74160. shader: string;
  74161. };
  74162. }
  74163. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74164. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74166. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74167. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74169. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74170. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74171. /** @hidden */
  74172. export var volumetricLightScatteringPassVertexShader: {
  74173. name: string;
  74174. shader: string;
  74175. };
  74176. }
  74177. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74178. /** @hidden */
  74179. export var volumetricLightScatteringPassPixelShader: {
  74180. name: string;
  74181. shader: string;
  74182. };
  74183. }
  74184. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74185. import { Vector3 } from "babylonjs/Maths/math.vector";
  74186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74187. import { Mesh } from "babylonjs/Meshes/mesh";
  74188. import { Camera } from "babylonjs/Cameras/camera";
  74189. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74191. import { Scene } from "babylonjs/scene";
  74192. import "babylonjs/Meshes/Builders/planeBuilder";
  74193. import "babylonjs/Shaders/depth.vertex";
  74194. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74195. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74196. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74197. import { Engine } from "babylonjs/Engines/engine";
  74198. /**
  74199. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74200. */
  74201. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74202. private _volumetricLightScatteringPass;
  74203. private _volumetricLightScatteringRTT;
  74204. private _viewPort;
  74205. private _screenCoordinates;
  74206. private _cachedDefines;
  74207. /**
  74208. * If not undefined, the mesh position is computed from the attached node position
  74209. */
  74210. attachedNode: {
  74211. position: Vector3;
  74212. };
  74213. /**
  74214. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74215. */
  74216. customMeshPosition: Vector3;
  74217. /**
  74218. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74219. */
  74220. useCustomMeshPosition: boolean;
  74221. /**
  74222. * If the post-process should inverse the light scattering direction
  74223. */
  74224. invert: boolean;
  74225. /**
  74226. * The internal mesh used by the post-process
  74227. */
  74228. mesh: Mesh;
  74229. /**
  74230. * @hidden
  74231. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74232. */
  74233. get useDiffuseColor(): boolean;
  74234. set useDiffuseColor(useDiffuseColor: boolean);
  74235. /**
  74236. * Array containing the excluded meshes not rendered in the internal pass
  74237. */
  74238. excludedMeshes: AbstractMesh[];
  74239. /**
  74240. * Controls the overall intensity of the post-process
  74241. */
  74242. exposure: number;
  74243. /**
  74244. * Dissipates each sample's contribution in range [0, 1]
  74245. */
  74246. decay: number;
  74247. /**
  74248. * Controls the overall intensity of each sample
  74249. */
  74250. weight: number;
  74251. /**
  74252. * Controls the density of each sample
  74253. */
  74254. density: number;
  74255. /**
  74256. * @constructor
  74257. * @param name The post-process name
  74258. * @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)
  74259. * @param camera The camera that the post-process will be attached to
  74260. * @param mesh The mesh used to create the light scattering
  74261. * @param samples The post-process quality, default 100
  74262. * @param samplingModeThe post-process filtering mode
  74263. * @param engine The babylon engine
  74264. * @param reusable If the post-process is reusable
  74265. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74266. */
  74267. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74268. /**
  74269. * Returns the string "VolumetricLightScatteringPostProcess"
  74270. * @returns "VolumetricLightScatteringPostProcess"
  74271. */
  74272. getClassName(): string;
  74273. private _isReady;
  74274. /**
  74275. * Sets the new light position for light scattering effect
  74276. * @param position The new custom light position
  74277. */
  74278. setCustomMeshPosition(position: Vector3): void;
  74279. /**
  74280. * Returns the light position for light scattering effect
  74281. * @return Vector3 The custom light position
  74282. */
  74283. getCustomMeshPosition(): Vector3;
  74284. /**
  74285. * Disposes the internal assets and detaches the post-process from the camera
  74286. */
  74287. dispose(camera: Camera): void;
  74288. /**
  74289. * Returns the render target texture used by the post-process
  74290. * @return the render target texture used by the post-process
  74291. */
  74292. getPass(): RenderTargetTexture;
  74293. private _meshExcluded;
  74294. private _createPass;
  74295. private _updateMeshScreenCoordinates;
  74296. /**
  74297. * Creates a default mesh for the Volumeric Light Scattering post-process
  74298. * @param name The mesh name
  74299. * @param scene The scene where to create the mesh
  74300. * @return the default mesh
  74301. */
  74302. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74303. }
  74304. }
  74305. declare module "babylonjs/PostProcesses/index" {
  74306. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74307. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74308. export * from "babylonjs/PostProcesses/bloomEffect";
  74309. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74310. export * from "babylonjs/PostProcesses/blurPostProcess";
  74311. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74312. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74313. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74314. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74315. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74316. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74317. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74318. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74319. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74320. export * from "babylonjs/PostProcesses/filterPostProcess";
  74321. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74322. export * from "babylonjs/PostProcesses/grainPostProcess";
  74323. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74324. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74325. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74326. export * from "babylonjs/PostProcesses/passPostProcess";
  74327. export * from "babylonjs/PostProcesses/postProcess";
  74328. export * from "babylonjs/PostProcesses/postProcessManager";
  74329. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74330. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74331. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74332. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74333. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74334. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74335. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74336. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74337. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74338. }
  74339. declare module "babylonjs/Probes/index" {
  74340. export * from "babylonjs/Probes/reflectionProbe";
  74341. }
  74342. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74343. import { Scene } from "babylonjs/scene";
  74344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74345. import { SmartArray } from "babylonjs/Misc/smartArray";
  74346. import { ISceneComponent } from "babylonjs/sceneComponent";
  74347. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74348. import "babylonjs/Meshes/Builders/boxBuilder";
  74349. import "babylonjs/Shaders/color.fragment";
  74350. import "babylonjs/Shaders/color.vertex";
  74351. import { Color3 } from "babylonjs/Maths/math.color";
  74352. import { Observable } from "babylonjs/Misc/observable";
  74353. module "babylonjs/scene" {
  74354. interface Scene {
  74355. /** @hidden (Backing field) */
  74356. _boundingBoxRenderer: BoundingBoxRenderer;
  74357. /** @hidden (Backing field) */
  74358. _forceShowBoundingBoxes: boolean;
  74359. /**
  74360. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74361. */
  74362. forceShowBoundingBoxes: boolean;
  74363. /**
  74364. * Gets the bounding box renderer associated with the scene
  74365. * @returns a BoundingBoxRenderer
  74366. */
  74367. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74368. }
  74369. }
  74370. module "babylonjs/Meshes/abstractMesh" {
  74371. interface AbstractMesh {
  74372. /** @hidden (Backing field) */
  74373. _showBoundingBox: boolean;
  74374. /**
  74375. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74376. */
  74377. showBoundingBox: boolean;
  74378. }
  74379. }
  74380. /**
  74381. * Component responsible of rendering the bounding box of the meshes in a scene.
  74382. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74383. */
  74384. export class BoundingBoxRenderer implements ISceneComponent {
  74385. /**
  74386. * The component name helpfull to identify the component in the list of scene components.
  74387. */
  74388. readonly name: string;
  74389. /**
  74390. * The scene the component belongs to.
  74391. */
  74392. scene: Scene;
  74393. /**
  74394. * Color of the bounding box lines placed in front of an object
  74395. */
  74396. frontColor: Color3;
  74397. /**
  74398. * Color of the bounding box lines placed behind an object
  74399. */
  74400. backColor: Color3;
  74401. /**
  74402. * Defines if the renderer should show the back lines or not
  74403. */
  74404. showBackLines: boolean;
  74405. /**
  74406. * Observable raised before rendering a bounding box
  74407. */
  74408. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74409. /**
  74410. * Observable raised after rendering a bounding box
  74411. */
  74412. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74413. /**
  74414. * @hidden
  74415. */
  74416. renderList: SmartArray<BoundingBox>;
  74417. private _colorShader;
  74418. private _vertexBuffers;
  74419. private _indexBuffer;
  74420. private _fillIndexBuffer;
  74421. private _fillIndexData;
  74422. /**
  74423. * Instantiates a new bounding box renderer in a scene.
  74424. * @param scene the scene the renderer renders in
  74425. */
  74426. constructor(scene: Scene);
  74427. /**
  74428. * Registers the component in a given scene
  74429. */
  74430. register(): void;
  74431. private _evaluateSubMesh;
  74432. private _activeMesh;
  74433. private _prepareRessources;
  74434. private _createIndexBuffer;
  74435. /**
  74436. * Rebuilds the elements related to this component in case of
  74437. * context lost for instance.
  74438. */
  74439. rebuild(): void;
  74440. /**
  74441. * @hidden
  74442. */
  74443. reset(): void;
  74444. /**
  74445. * Render the bounding boxes of a specific rendering group
  74446. * @param renderingGroupId defines the rendering group to render
  74447. */
  74448. render(renderingGroupId: number): void;
  74449. /**
  74450. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74451. * @param mesh Define the mesh to render the occlusion bounding box for
  74452. */
  74453. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74454. /**
  74455. * Dispose and release the resources attached to this renderer.
  74456. */
  74457. dispose(): void;
  74458. }
  74459. }
  74460. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74461. import { Nullable } from "babylonjs/types";
  74462. import { Scene } from "babylonjs/scene";
  74463. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74464. import { Camera } from "babylonjs/Cameras/camera";
  74465. import { ISceneComponent } from "babylonjs/sceneComponent";
  74466. module "babylonjs/scene" {
  74467. interface Scene {
  74468. /** @hidden (Backing field) */
  74469. _depthRenderer: {
  74470. [id: string]: DepthRenderer;
  74471. };
  74472. /**
  74473. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74474. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74475. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74476. * @returns the created depth renderer
  74477. */
  74478. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74479. /**
  74480. * Disables a depth renderer for a given camera
  74481. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74482. */
  74483. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74484. }
  74485. }
  74486. /**
  74487. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74488. * in several rendering techniques.
  74489. */
  74490. export class DepthRendererSceneComponent implements ISceneComponent {
  74491. /**
  74492. * The component name helpfull to identify the component in the list of scene components.
  74493. */
  74494. readonly name: string;
  74495. /**
  74496. * The scene the component belongs to.
  74497. */
  74498. scene: Scene;
  74499. /**
  74500. * Creates a new instance of the component for the given scene
  74501. * @param scene Defines the scene to register the component in
  74502. */
  74503. constructor(scene: Scene);
  74504. /**
  74505. * Registers the component in a given scene
  74506. */
  74507. register(): void;
  74508. /**
  74509. * Rebuilds the elements related to this component in case of
  74510. * context lost for instance.
  74511. */
  74512. rebuild(): void;
  74513. /**
  74514. * Disposes the component and the associated ressources
  74515. */
  74516. dispose(): void;
  74517. private _gatherRenderTargets;
  74518. private _gatherActiveCameraRenderTargets;
  74519. }
  74520. }
  74521. declare module "babylonjs/Shaders/outline.fragment" {
  74522. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74523. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74524. /** @hidden */
  74525. export var outlinePixelShader: {
  74526. name: string;
  74527. shader: string;
  74528. };
  74529. }
  74530. declare module "babylonjs/Shaders/outline.vertex" {
  74531. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74535. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74537. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74538. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74539. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74540. /** @hidden */
  74541. export var outlineVertexShader: {
  74542. name: string;
  74543. shader: string;
  74544. };
  74545. }
  74546. declare module "babylonjs/Rendering/outlineRenderer" {
  74547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74548. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74549. import { Scene } from "babylonjs/scene";
  74550. import { ISceneComponent } from "babylonjs/sceneComponent";
  74551. import "babylonjs/Shaders/outline.fragment";
  74552. import "babylonjs/Shaders/outline.vertex";
  74553. module "babylonjs/scene" {
  74554. interface Scene {
  74555. /** @hidden */
  74556. _outlineRenderer: OutlineRenderer;
  74557. /**
  74558. * Gets the outline renderer associated with the scene
  74559. * @returns a OutlineRenderer
  74560. */
  74561. getOutlineRenderer(): OutlineRenderer;
  74562. }
  74563. }
  74564. module "babylonjs/Meshes/abstractMesh" {
  74565. interface AbstractMesh {
  74566. /** @hidden (Backing field) */
  74567. _renderOutline: boolean;
  74568. /**
  74569. * Gets or sets a boolean indicating if the outline must be rendered as well
  74570. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74571. */
  74572. renderOutline: boolean;
  74573. /** @hidden (Backing field) */
  74574. _renderOverlay: boolean;
  74575. /**
  74576. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74577. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74578. */
  74579. renderOverlay: boolean;
  74580. }
  74581. }
  74582. /**
  74583. * This class is responsible to draw bothe outline/overlay of meshes.
  74584. * It should not be used directly but through the available method on mesh.
  74585. */
  74586. export class OutlineRenderer implements ISceneComponent {
  74587. /**
  74588. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74589. */
  74590. private static _StencilReference;
  74591. /**
  74592. * The name of the component. Each component must have a unique name.
  74593. */
  74594. name: string;
  74595. /**
  74596. * The scene the component belongs to.
  74597. */
  74598. scene: Scene;
  74599. /**
  74600. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74601. */
  74602. zOffset: number;
  74603. private _engine;
  74604. private _effect;
  74605. private _cachedDefines;
  74606. private _savedDepthWrite;
  74607. /**
  74608. * Instantiates a new outline renderer. (There could be only one per scene).
  74609. * @param scene Defines the scene it belongs to
  74610. */
  74611. constructor(scene: Scene);
  74612. /**
  74613. * Register the component to one instance of a scene.
  74614. */
  74615. register(): void;
  74616. /**
  74617. * Rebuilds the elements related to this component in case of
  74618. * context lost for instance.
  74619. */
  74620. rebuild(): void;
  74621. /**
  74622. * Disposes the component and the associated ressources.
  74623. */
  74624. dispose(): void;
  74625. /**
  74626. * Renders the outline in the canvas.
  74627. * @param subMesh Defines the sumesh to render
  74628. * @param batch Defines the batch of meshes in case of instances
  74629. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74630. */
  74631. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74632. /**
  74633. * Returns whether or not the outline renderer is ready for a given submesh.
  74634. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74635. * @param subMesh Defines the submesh to check readyness for
  74636. * @param useInstances Defines wheter wee are trying to render instances or not
  74637. * @returns true if ready otherwise false
  74638. */
  74639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74640. private _beforeRenderingMesh;
  74641. private _afterRenderingMesh;
  74642. }
  74643. }
  74644. declare module "babylonjs/Rendering/index" {
  74645. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74646. export * from "babylonjs/Rendering/depthRenderer";
  74647. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74648. export * from "babylonjs/Rendering/edgesRenderer";
  74649. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74650. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74651. export * from "babylonjs/Rendering/outlineRenderer";
  74652. export * from "babylonjs/Rendering/renderingGroup";
  74653. export * from "babylonjs/Rendering/renderingManager";
  74654. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74655. }
  74656. declare module "babylonjs/Sprites/ISprites" {
  74657. /**
  74658. * Defines the basic options interface of a Sprite Frame Source Size.
  74659. */
  74660. export interface ISpriteJSONSpriteSourceSize {
  74661. /**
  74662. * number of the original width of the Frame
  74663. */
  74664. w: number;
  74665. /**
  74666. * number of the original height of the Frame
  74667. */
  74668. h: number;
  74669. }
  74670. /**
  74671. * Defines the basic options interface of a Sprite Frame Data.
  74672. */
  74673. export interface ISpriteJSONSpriteFrameData {
  74674. /**
  74675. * number of the x offset of the Frame
  74676. */
  74677. x: number;
  74678. /**
  74679. * number of the y offset of the Frame
  74680. */
  74681. y: number;
  74682. /**
  74683. * number of the width of the Frame
  74684. */
  74685. w: number;
  74686. /**
  74687. * number of the height of the Frame
  74688. */
  74689. h: number;
  74690. }
  74691. /**
  74692. * Defines the basic options interface of a JSON Sprite.
  74693. */
  74694. export interface ISpriteJSONSprite {
  74695. /**
  74696. * string name of the Frame
  74697. */
  74698. filename: string;
  74699. /**
  74700. * ISpriteJSONSpriteFrame basic object of the frame data
  74701. */
  74702. frame: ISpriteJSONSpriteFrameData;
  74703. /**
  74704. * boolean to flag is the frame was rotated.
  74705. */
  74706. rotated: boolean;
  74707. /**
  74708. * boolean to flag is the frame was trimmed.
  74709. */
  74710. trimmed: boolean;
  74711. /**
  74712. * ISpriteJSONSpriteFrame basic object of the source data
  74713. */
  74714. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74715. /**
  74716. * ISpriteJSONSpriteFrame basic object of the source data
  74717. */
  74718. sourceSize: ISpriteJSONSpriteSourceSize;
  74719. }
  74720. /**
  74721. * Defines the basic options interface of a JSON atlas.
  74722. */
  74723. export interface ISpriteJSONAtlas {
  74724. /**
  74725. * Array of objects that contain the frame data.
  74726. */
  74727. frames: Array<ISpriteJSONSprite>;
  74728. /**
  74729. * object basic object containing the sprite meta data.
  74730. */
  74731. meta?: object;
  74732. }
  74733. }
  74734. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74735. /** @hidden */
  74736. export var spriteMapPixelShader: {
  74737. name: string;
  74738. shader: string;
  74739. };
  74740. }
  74741. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74742. /** @hidden */
  74743. export var spriteMapVertexShader: {
  74744. name: string;
  74745. shader: string;
  74746. };
  74747. }
  74748. declare module "babylonjs/Sprites/spriteMap" {
  74749. import { IDisposable, Scene } from "babylonjs/scene";
  74750. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74751. import { Texture } from "babylonjs/Materials/Textures/texture";
  74752. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74753. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74754. import "babylonjs/Meshes/Builders/planeBuilder";
  74755. import "babylonjs/Shaders/spriteMap.fragment";
  74756. import "babylonjs/Shaders/spriteMap.vertex";
  74757. /**
  74758. * Defines the basic options interface of a SpriteMap
  74759. */
  74760. export interface ISpriteMapOptions {
  74761. /**
  74762. * Vector2 of the number of cells in the grid.
  74763. */
  74764. stageSize?: Vector2;
  74765. /**
  74766. * Vector2 of the size of the output plane in World Units.
  74767. */
  74768. outputSize?: Vector2;
  74769. /**
  74770. * Vector3 of the position of the output plane in World Units.
  74771. */
  74772. outputPosition?: Vector3;
  74773. /**
  74774. * Vector3 of the rotation of the output plane.
  74775. */
  74776. outputRotation?: Vector3;
  74777. /**
  74778. * number of layers that the system will reserve in resources.
  74779. */
  74780. layerCount?: number;
  74781. /**
  74782. * number of max animation frames a single cell will reserve in resources.
  74783. */
  74784. maxAnimationFrames?: number;
  74785. /**
  74786. * number cell index of the base tile when the system compiles.
  74787. */
  74788. baseTile?: number;
  74789. /**
  74790. * boolean flip the sprite after its been repositioned by the framing data.
  74791. */
  74792. flipU?: boolean;
  74793. /**
  74794. * Vector3 scalar of the global RGB values of the SpriteMap.
  74795. */
  74796. colorMultiply?: Vector3;
  74797. }
  74798. /**
  74799. * Defines the IDisposable interface in order to be cleanable from resources.
  74800. */
  74801. export interface ISpriteMap extends IDisposable {
  74802. /**
  74803. * String name of the SpriteMap.
  74804. */
  74805. name: string;
  74806. /**
  74807. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74808. */
  74809. atlasJSON: ISpriteJSONAtlas;
  74810. /**
  74811. * Texture of the SpriteMap.
  74812. */
  74813. spriteSheet: Texture;
  74814. /**
  74815. * The parameters to initialize the SpriteMap with.
  74816. */
  74817. options: ISpriteMapOptions;
  74818. }
  74819. /**
  74820. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74821. */
  74822. export class SpriteMap implements ISpriteMap {
  74823. /** The Name of the spriteMap */
  74824. name: string;
  74825. /** The JSON file with the frame and meta data */
  74826. atlasJSON: ISpriteJSONAtlas;
  74827. /** The systems Sprite Sheet Texture */
  74828. spriteSheet: Texture;
  74829. /** Arguments passed with the Constructor */
  74830. options: ISpriteMapOptions;
  74831. /** Public Sprite Storage array, parsed from atlasJSON */
  74832. sprites: Array<ISpriteJSONSprite>;
  74833. /** Returns the Number of Sprites in the System */
  74834. get spriteCount(): number;
  74835. /** Returns the Position of Output Plane*/
  74836. get position(): Vector3;
  74837. /** Returns the Position of Output Plane*/
  74838. set position(v: Vector3);
  74839. /** Returns the Rotation of Output Plane*/
  74840. get rotation(): Vector3;
  74841. /** Returns the Rotation of Output Plane*/
  74842. set rotation(v: Vector3);
  74843. /** Sets the AnimationMap*/
  74844. get animationMap(): RawTexture;
  74845. /** Sets the AnimationMap*/
  74846. set animationMap(v: RawTexture);
  74847. /** Scene that the SpriteMap was created in */
  74848. private _scene;
  74849. /** Texture Buffer of Float32 that holds tile frame data*/
  74850. private _frameMap;
  74851. /** Texture Buffers of Float32 that holds tileMap data*/
  74852. private _tileMaps;
  74853. /** Texture Buffer of Float32 that holds Animation Data*/
  74854. private _animationMap;
  74855. /** Custom ShaderMaterial Central to the System*/
  74856. private _material;
  74857. /** Custom ShaderMaterial Central to the System*/
  74858. private _output;
  74859. /** Systems Time Ticker*/
  74860. private _time;
  74861. /**
  74862. * Creates a new SpriteMap
  74863. * @param name defines the SpriteMaps Name
  74864. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74865. * @param spriteSheet is the Texture that the Sprites are on.
  74866. * @param options a basic deployment configuration
  74867. * @param scene The Scene that the map is deployed on
  74868. */
  74869. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74870. /**
  74871. * Returns tileID location
  74872. * @returns Vector2 the cell position ID
  74873. */
  74874. getTileID(): Vector2;
  74875. /**
  74876. * Gets the UV location of the mouse over the SpriteMap.
  74877. * @returns Vector2 the UV position of the mouse interaction
  74878. */
  74879. getMousePosition(): Vector2;
  74880. /**
  74881. * Creates the "frame" texture Buffer
  74882. * -------------------------------------
  74883. * Structure of frames
  74884. * "filename": "Falling-Water-2.png",
  74885. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74886. * "rotated": true,
  74887. * "trimmed": true,
  74888. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74889. * "sourceSize": {"w":32,"h":32}
  74890. * @returns RawTexture of the frameMap
  74891. */
  74892. private _createFrameBuffer;
  74893. /**
  74894. * Creates the tileMap texture Buffer
  74895. * @param buffer normally and array of numbers, or a false to generate from scratch
  74896. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74897. * @returns RawTexture of the tileMap
  74898. */
  74899. private _createTileBuffer;
  74900. /**
  74901. * Modifies the data of the tileMaps
  74902. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74903. * @param pos is the iVector2 Coordinates of the Tile
  74904. * @param tile The SpriteIndex of the new Tile
  74905. */
  74906. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74907. /**
  74908. * Creates the animationMap texture Buffer
  74909. * @param buffer normally and array of numbers, or a false to generate from scratch
  74910. * @returns RawTexture of the animationMap
  74911. */
  74912. private _createTileAnimationBuffer;
  74913. /**
  74914. * Modifies the data of the animationMap
  74915. * @param cellID is the Index of the Sprite
  74916. * @param _frame is the target Animation frame
  74917. * @param toCell is the Target Index of the next frame of the animation
  74918. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74919. * @param speed is a global scalar of the time variable on the map.
  74920. */
  74921. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74922. /**
  74923. * Exports the .tilemaps file
  74924. */
  74925. saveTileMaps(): void;
  74926. /**
  74927. * Imports the .tilemaps file
  74928. * @param url of the .tilemaps file
  74929. */
  74930. loadTileMaps(url: string): void;
  74931. /**
  74932. * Release associated resources
  74933. */
  74934. dispose(): void;
  74935. }
  74936. }
  74937. declare module "babylonjs/Sprites/spritePackedManager" {
  74938. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74939. import { Scene } from "babylonjs/scene";
  74940. /**
  74941. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74942. * @see http://doc.babylonjs.com/babylon101/sprites
  74943. */
  74944. export class SpritePackedManager extends SpriteManager {
  74945. /** defines the packed manager's name */
  74946. name: string;
  74947. /**
  74948. * Creates a new sprite manager from a packed sprite sheet
  74949. * @param name defines the manager's name
  74950. * @param imgUrl defines the sprite sheet url
  74951. * @param capacity defines the maximum allowed number of sprites
  74952. * @param scene defines the hosting scene
  74953. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74954. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74955. * @param samplingMode defines the smapling mode to use with spritesheet
  74956. * @param fromPacked set to true; do not alter
  74957. */
  74958. constructor(
  74959. /** defines the packed manager's name */
  74960. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74961. }
  74962. }
  74963. declare module "babylonjs/Sprites/index" {
  74964. export * from "babylonjs/Sprites/sprite";
  74965. export * from "babylonjs/Sprites/ISprites";
  74966. export * from "babylonjs/Sprites/spriteManager";
  74967. export * from "babylonjs/Sprites/spriteMap";
  74968. export * from "babylonjs/Sprites/spritePackedManager";
  74969. export * from "babylonjs/Sprites/spriteSceneComponent";
  74970. }
  74971. declare module "babylonjs/States/index" {
  74972. export * from "babylonjs/States/alphaCullingState";
  74973. export * from "babylonjs/States/depthCullingState";
  74974. export * from "babylonjs/States/stencilState";
  74975. }
  74976. declare module "babylonjs/Misc/assetsManager" {
  74977. import { Scene } from "babylonjs/scene";
  74978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74979. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74980. import { Skeleton } from "babylonjs/Bones/skeleton";
  74981. import { Observable } from "babylonjs/Misc/observable";
  74982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74983. import { Texture } from "babylonjs/Materials/Textures/texture";
  74984. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74985. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74986. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74987. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74988. /**
  74989. * Defines the list of states available for a task inside a AssetsManager
  74990. */
  74991. export enum AssetTaskState {
  74992. /**
  74993. * Initialization
  74994. */
  74995. INIT = 0,
  74996. /**
  74997. * Running
  74998. */
  74999. RUNNING = 1,
  75000. /**
  75001. * Done
  75002. */
  75003. DONE = 2,
  75004. /**
  75005. * Error
  75006. */
  75007. ERROR = 3
  75008. }
  75009. /**
  75010. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75011. */
  75012. export abstract class AbstractAssetTask {
  75013. /**
  75014. * Task name
  75015. */ name: string;
  75016. /**
  75017. * Callback called when the task is successful
  75018. */
  75019. onSuccess: (task: any) => void;
  75020. /**
  75021. * Callback called when the task is not successful
  75022. */
  75023. onError: (task: any, message?: string, exception?: any) => void;
  75024. /**
  75025. * Creates a new AssetsManager
  75026. * @param name defines the name of the task
  75027. */
  75028. constructor(
  75029. /**
  75030. * Task name
  75031. */ name: string);
  75032. private _isCompleted;
  75033. private _taskState;
  75034. private _errorObject;
  75035. /**
  75036. * Get if the task is completed
  75037. */
  75038. get isCompleted(): boolean;
  75039. /**
  75040. * Gets the current state of the task
  75041. */
  75042. get taskState(): AssetTaskState;
  75043. /**
  75044. * Gets the current error object (if task is in error)
  75045. */
  75046. get errorObject(): {
  75047. message?: string;
  75048. exception?: any;
  75049. };
  75050. /**
  75051. * Internal only
  75052. * @hidden
  75053. */
  75054. _setErrorObject(message?: string, exception?: any): void;
  75055. /**
  75056. * Execute the current task
  75057. * @param scene defines the scene where you want your assets to be loaded
  75058. * @param onSuccess is a callback called when the task is successfully executed
  75059. * @param onError is a callback called if an error occurs
  75060. */
  75061. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75062. /**
  75063. * Execute the current task
  75064. * @param scene defines the scene where you want your assets to be loaded
  75065. * @param onSuccess is a callback called when the task is successfully executed
  75066. * @param onError is a callback called if an error occurs
  75067. */
  75068. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75069. /**
  75070. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75071. * This can be used with failed tasks that have the reason for failure fixed.
  75072. */
  75073. reset(): void;
  75074. private onErrorCallback;
  75075. private onDoneCallback;
  75076. }
  75077. /**
  75078. * Define the interface used by progress events raised during assets loading
  75079. */
  75080. export interface IAssetsProgressEvent {
  75081. /**
  75082. * Defines the number of remaining tasks to process
  75083. */
  75084. remainingCount: number;
  75085. /**
  75086. * Defines the total number of tasks
  75087. */
  75088. totalCount: number;
  75089. /**
  75090. * Defines the task that was just processed
  75091. */
  75092. task: AbstractAssetTask;
  75093. }
  75094. /**
  75095. * Class used to share progress information about assets loading
  75096. */
  75097. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75098. /**
  75099. * Defines the number of remaining tasks to process
  75100. */
  75101. remainingCount: number;
  75102. /**
  75103. * Defines the total number of tasks
  75104. */
  75105. totalCount: number;
  75106. /**
  75107. * Defines the task that was just processed
  75108. */
  75109. task: AbstractAssetTask;
  75110. /**
  75111. * Creates a AssetsProgressEvent
  75112. * @param remainingCount defines the number of remaining tasks to process
  75113. * @param totalCount defines the total number of tasks
  75114. * @param task defines the task that was just processed
  75115. */
  75116. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75117. }
  75118. /**
  75119. * Define a task used by AssetsManager to load meshes
  75120. */
  75121. export class MeshAssetTask extends AbstractAssetTask {
  75122. /**
  75123. * Defines the name of the task
  75124. */
  75125. name: string;
  75126. /**
  75127. * Defines the list of mesh's names you want to load
  75128. */
  75129. meshesNames: any;
  75130. /**
  75131. * Defines the root url to use as a base to load your meshes and associated resources
  75132. */
  75133. rootUrl: string;
  75134. /**
  75135. * Defines the filename or File of the scene to load from
  75136. */
  75137. sceneFilename: string | File;
  75138. /**
  75139. * Gets the list of loaded meshes
  75140. */
  75141. loadedMeshes: Array<AbstractMesh>;
  75142. /**
  75143. * Gets the list of loaded particle systems
  75144. */
  75145. loadedParticleSystems: Array<IParticleSystem>;
  75146. /**
  75147. * Gets the list of loaded skeletons
  75148. */
  75149. loadedSkeletons: Array<Skeleton>;
  75150. /**
  75151. * Gets the list of loaded animation groups
  75152. */
  75153. loadedAnimationGroups: Array<AnimationGroup>;
  75154. /**
  75155. * Callback called when the task is successful
  75156. */
  75157. onSuccess: (task: MeshAssetTask) => void;
  75158. /**
  75159. * Callback called when the task is successful
  75160. */
  75161. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75162. /**
  75163. * Creates a new MeshAssetTask
  75164. * @param name defines the name of the task
  75165. * @param meshesNames defines the list of mesh's names you want to load
  75166. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75167. * @param sceneFilename defines the filename or File of the scene to load from
  75168. */
  75169. constructor(
  75170. /**
  75171. * Defines the name of the task
  75172. */
  75173. name: string,
  75174. /**
  75175. * Defines the list of mesh's names you want to load
  75176. */
  75177. meshesNames: any,
  75178. /**
  75179. * Defines the root url to use as a base to load your meshes and associated resources
  75180. */
  75181. rootUrl: string,
  75182. /**
  75183. * Defines the filename or File of the scene to load from
  75184. */
  75185. sceneFilename: string | File);
  75186. /**
  75187. * Execute the current task
  75188. * @param scene defines the scene where you want your assets to be loaded
  75189. * @param onSuccess is a callback called when the task is successfully executed
  75190. * @param onError is a callback called if an error occurs
  75191. */
  75192. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75193. }
  75194. /**
  75195. * Define a task used by AssetsManager to load text content
  75196. */
  75197. export class TextFileAssetTask extends AbstractAssetTask {
  75198. /**
  75199. * Defines the name of the task
  75200. */
  75201. name: string;
  75202. /**
  75203. * Defines the location of the file to load
  75204. */
  75205. url: string;
  75206. /**
  75207. * Gets the loaded text string
  75208. */
  75209. text: string;
  75210. /**
  75211. * Callback called when the task is successful
  75212. */
  75213. onSuccess: (task: TextFileAssetTask) => void;
  75214. /**
  75215. * Callback called when the task is successful
  75216. */
  75217. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75218. /**
  75219. * Creates a new TextFileAssetTask object
  75220. * @param name defines the name of the task
  75221. * @param url defines the location of the file to load
  75222. */
  75223. constructor(
  75224. /**
  75225. * Defines the name of the task
  75226. */
  75227. name: string,
  75228. /**
  75229. * Defines the location of the file to load
  75230. */
  75231. url: string);
  75232. /**
  75233. * Execute the current task
  75234. * @param scene defines the scene where you want your assets to be loaded
  75235. * @param onSuccess is a callback called when the task is successfully executed
  75236. * @param onError is a callback called if an error occurs
  75237. */
  75238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75239. }
  75240. /**
  75241. * Define a task used by AssetsManager to load binary data
  75242. */
  75243. export class BinaryFileAssetTask extends AbstractAssetTask {
  75244. /**
  75245. * Defines the name of the task
  75246. */
  75247. name: string;
  75248. /**
  75249. * Defines the location of the file to load
  75250. */
  75251. url: string;
  75252. /**
  75253. * Gets the lodaded data (as an array buffer)
  75254. */
  75255. data: ArrayBuffer;
  75256. /**
  75257. * Callback called when the task is successful
  75258. */
  75259. onSuccess: (task: BinaryFileAssetTask) => void;
  75260. /**
  75261. * Callback called when the task is successful
  75262. */
  75263. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75264. /**
  75265. * Creates a new BinaryFileAssetTask object
  75266. * @param name defines the name of the new task
  75267. * @param url defines the location of the file to load
  75268. */
  75269. constructor(
  75270. /**
  75271. * Defines the name of the task
  75272. */
  75273. name: string,
  75274. /**
  75275. * Defines the location of the file to load
  75276. */
  75277. url: string);
  75278. /**
  75279. * Execute the current task
  75280. * @param scene defines the scene where you want your assets to be loaded
  75281. * @param onSuccess is a callback called when the task is successfully executed
  75282. * @param onError is a callback called if an error occurs
  75283. */
  75284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75285. }
  75286. /**
  75287. * Define a task used by AssetsManager to load images
  75288. */
  75289. export class ImageAssetTask extends AbstractAssetTask {
  75290. /**
  75291. * Defines the name of the task
  75292. */
  75293. name: string;
  75294. /**
  75295. * Defines the location of the image to load
  75296. */
  75297. url: string;
  75298. /**
  75299. * Gets the loaded images
  75300. */
  75301. image: HTMLImageElement;
  75302. /**
  75303. * Callback called when the task is successful
  75304. */
  75305. onSuccess: (task: ImageAssetTask) => void;
  75306. /**
  75307. * Callback called when the task is successful
  75308. */
  75309. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75310. /**
  75311. * Creates a new ImageAssetTask
  75312. * @param name defines the name of the task
  75313. * @param url defines the location of the image to load
  75314. */
  75315. constructor(
  75316. /**
  75317. * Defines the name of the task
  75318. */
  75319. name: string,
  75320. /**
  75321. * Defines the location of the image to load
  75322. */
  75323. url: string);
  75324. /**
  75325. * Execute the current task
  75326. * @param scene defines the scene where you want your assets to be loaded
  75327. * @param onSuccess is a callback called when the task is successfully executed
  75328. * @param onError is a callback called if an error occurs
  75329. */
  75330. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75331. }
  75332. /**
  75333. * Defines the interface used by texture loading tasks
  75334. */
  75335. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75336. /**
  75337. * Gets the loaded texture
  75338. */
  75339. texture: TEX;
  75340. }
  75341. /**
  75342. * Define a task used by AssetsManager to load 2D textures
  75343. */
  75344. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75345. /**
  75346. * Defines the name of the task
  75347. */
  75348. name: string;
  75349. /**
  75350. * Defines the location of the file to load
  75351. */
  75352. url: string;
  75353. /**
  75354. * Defines if mipmap should not be generated (default is false)
  75355. */
  75356. noMipmap?: boolean | undefined;
  75357. /**
  75358. * Defines if texture must be inverted on Y axis (default is true)
  75359. */
  75360. invertY: boolean;
  75361. /**
  75362. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75363. */
  75364. samplingMode: number;
  75365. /**
  75366. * Gets the loaded texture
  75367. */
  75368. texture: Texture;
  75369. /**
  75370. * Callback called when the task is successful
  75371. */
  75372. onSuccess: (task: TextureAssetTask) => void;
  75373. /**
  75374. * Callback called when the task is successful
  75375. */
  75376. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75377. /**
  75378. * Creates a new TextureAssetTask object
  75379. * @param name defines the name of the task
  75380. * @param url defines the location of the file to load
  75381. * @param noMipmap defines if mipmap should not be generated (default is false)
  75382. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75383. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75384. */
  75385. constructor(
  75386. /**
  75387. * Defines the name of the task
  75388. */
  75389. name: string,
  75390. /**
  75391. * Defines the location of the file to load
  75392. */
  75393. url: string,
  75394. /**
  75395. * Defines if mipmap should not be generated (default is false)
  75396. */
  75397. noMipmap?: boolean | undefined,
  75398. /**
  75399. * Defines if texture must be inverted on Y axis (default is true)
  75400. */
  75401. invertY?: boolean,
  75402. /**
  75403. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75404. */
  75405. samplingMode?: number);
  75406. /**
  75407. * Execute the current task
  75408. * @param scene defines the scene where you want your assets to be loaded
  75409. * @param onSuccess is a callback called when the task is successfully executed
  75410. * @param onError is a callback called if an error occurs
  75411. */
  75412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75413. }
  75414. /**
  75415. * Define a task used by AssetsManager to load cube textures
  75416. */
  75417. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75418. /**
  75419. * Defines the name of the task
  75420. */
  75421. name: string;
  75422. /**
  75423. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75424. */
  75425. url: string;
  75426. /**
  75427. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75428. */
  75429. extensions?: string[] | undefined;
  75430. /**
  75431. * Defines if mipmaps should not be generated (default is false)
  75432. */
  75433. noMipmap?: boolean | undefined;
  75434. /**
  75435. * Defines the explicit list of files (undefined by default)
  75436. */
  75437. files?: string[] | undefined;
  75438. /**
  75439. * Gets the loaded texture
  75440. */
  75441. texture: CubeTexture;
  75442. /**
  75443. * Callback called when the task is successful
  75444. */
  75445. onSuccess: (task: CubeTextureAssetTask) => void;
  75446. /**
  75447. * Callback called when the task is successful
  75448. */
  75449. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75450. /**
  75451. * Creates a new CubeTextureAssetTask
  75452. * @param name defines the name of the task
  75453. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75454. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75455. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75456. * @param files defines the explicit list of files (undefined by default)
  75457. */
  75458. constructor(
  75459. /**
  75460. * Defines the name of the task
  75461. */
  75462. name: string,
  75463. /**
  75464. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75465. */
  75466. url: string,
  75467. /**
  75468. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75469. */
  75470. extensions?: string[] | undefined,
  75471. /**
  75472. * Defines if mipmaps should not be generated (default is false)
  75473. */
  75474. noMipmap?: boolean | undefined,
  75475. /**
  75476. * Defines the explicit list of files (undefined by default)
  75477. */
  75478. files?: string[] | undefined);
  75479. /**
  75480. * Execute the current task
  75481. * @param scene defines the scene where you want your assets to be loaded
  75482. * @param onSuccess is a callback called when the task is successfully executed
  75483. * @param onError is a callback called if an error occurs
  75484. */
  75485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75486. }
  75487. /**
  75488. * Define a task used by AssetsManager to load HDR cube textures
  75489. */
  75490. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75491. /**
  75492. * Defines the name of the task
  75493. */
  75494. name: string;
  75495. /**
  75496. * Defines the location of the file to load
  75497. */
  75498. url: string;
  75499. /**
  75500. * Defines the desired size (the more it increases the longer the generation will be)
  75501. */
  75502. size: number;
  75503. /**
  75504. * Defines if mipmaps should not be generated (default is false)
  75505. */
  75506. noMipmap: boolean;
  75507. /**
  75508. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75509. */
  75510. generateHarmonics: boolean;
  75511. /**
  75512. * 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)
  75513. */
  75514. gammaSpace: boolean;
  75515. /**
  75516. * Internal Use Only
  75517. */
  75518. reserved: boolean;
  75519. /**
  75520. * Gets the loaded texture
  75521. */
  75522. texture: HDRCubeTexture;
  75523. /**
  75524. * Callback called when the task is successful
  75525. */
  75526. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75527. /**
  75528. * Callback called when the task is successful
  75529. */
  75530. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75531. /**
  75532. * Creates a new HDRCubeTextureAssetTask object
  75533. * @param name defines the name of the task
  75534. * @param url defines the location of the file to load
  75535. * @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.
  75536. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75537. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75538. * @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)
  75539. * @param reserved Internal use only
  75540. */
  75541. constructor(
  75542. /**
  75543. * Defines the name of the task
  75544. */
  75545. name: string,
  75546. /**
  75547. * Defines the location of the file to load
  75548. */
  75549. url: string,
  75550. /**
  75551. * Defines the desired size (the more it increases the longer the generation will be)
  75552. */
  75553. size: number,
  75554. /**
  75555. * Defines if mipmaps should not be generated (default is false)
  75556. */
  75557. noMipmap?: boolean,
  75558. /**
  75559. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75560. */
  75561. generateHarmonics?: boolean,
  75562. /**
  75563. * 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)
  75564. */
  75565. gammaSpace?: boolean,
  75566. /**
  75567. * Internal Use Only
  75568. */
  75569. reserved?: boolean);
  75570. /**
  75571. * Execute the current task
  75572. * @param scene defines the scene where you want your assets to be loaded
  75573. * @param onSuccess is a callback called when the task is successfully executed
  75574. * @param onError is a callback called if an error occurs
  75575. */
  75576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75577. }
  75578. /**
  75579. * Define a task used by AssetsManager to load Equirectangular cube textures
  75580. */
  75581. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75582. /**
  75583. * Defines the name of the task
  75584. */
  75585. name: string;
  75586. /**
  75587. * Defines the location of the file to load
  75588. */
  75589. url: string;
  75590. /**
  75591. * Defines the desired size (the more it increases the longer the generation will be)
  75592. */
  75593. size: number;
  75594. /**
  75595. * Defines if mipmaps should not be generated (default is false)
  75596. */
  75597. noMipmap: boolean;
  75598. /**
  75599. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75600. * but the standard material would require them in Gamma space) (default is true)
  75601. */
  75602. gammaSpace: boolean;
  75603. /**
  75604. * Gets the loaded texture
  75605. */
  75606. texture: EquiRectangularCubeTexture;
  75607. /**
  75608. * Callback called when the task is successful
  75609. */
  75610. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75611. /**
  75612. * Callback called when the task is successful
  75613. */
  75614. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75615. /**
  75616. * Creates a new EquiRectangularCubeTextureAssetTask object
  75617. * @param name defines the name of the task
  75618. * @param url defines the location of the file to load
  75619. * @param size defines the desired size (the more it increases the longer the generation will be)
  75620. * If the size is omitted this implies you are using a preprocessed cubemap.
  75621. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75622. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75623. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75624. * (default is true)
  75625. */
  75626. constructor(
  75627. /**
  75628. * Defines the name of the task
  75629. */
  75630. name: string,
  75631. /**
  75632. * Defines the location of the file to load
  75633. */
  75634. url: string,
  75635. /**
  75636. * Defines the desired size (the more it increases the longer the generation will be)
  75637. */
  75638. size: number,
  75639. /**
  75640. * Defines if mipmaps should not be generated (default is false)
  75641. */
  75642. noMipmap?: boolean,
  75643. /**
  75644. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75645. * but the standard material would require them in Gamma space) (default is true)
  75646. */
  75647. gammaSpace?: boolean);
  75648. /**
  75649. * Execute the current task
  75650. * @param scene defines the scene where you want your assets to be loaded
  75651. * @param onSuccess is a callback called when the task is successfully executed
  75652. * @param onError is a callback called if an error occurs
  75653. */
  75654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75655. }
  75656. /**
  75657. * This class can be used to easily import assets into a scene
  75658. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75659. */
  75660. export class AssetsManager {
  75661. private _scene;
  75662. private _isLoading;
  75663. protected _tasks: AbstractAssetTask[];
  75664. protected _waitingTasksCount: number;
  75665. protected _totalTasksCount: number;
  75666. /**
  75667. * Callback called when all tasks are processed
  75668. */
  75669. onFinish: (tasks: AbstractAssetTask[]) => void;
  75670. /**
  75671. * Callback called when a task is successful
  75672. */
  75673. onTaskSuccess: (task: AbstractAssetTask) => void;
  75674. /**
  75675. * Callback called when a task had an error
  75676. */
  75677. onTaskError: (task: AbstractAssetTask) => void;
  75678. /**
  75679. * Callback called when a task is done (whatever the result is)
  75680. */
  75681. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75682. /**
  75683. * Observable called when all tasks are processed
  75684. */
  75685. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75686. /**
  75687. * Observable called when a task had an error
  75688. */
  75689. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75690. /**
  75691. * Observable called when all tasks were executed
  75692. */
  75693. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75694. /**
  75695. * Observable called when a task is done (whatever the result is)
  75696. */
  75697. onProgressObservable: Observable<IAssetsProgressEvent>;
  75698. /**
  75699. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75700. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75701. */
  75702. useDefaultLoadingScreen: boolean;
  75703. /**
  75704. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75705. * when all assets have been downloaded.
  75706. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75707. */
  75708. autoHideLoadingUI: boolean;
  75709. /**
  75710. * Creates a new AssetsManager
  75711. * @param scene defines the scene to work on
  75712. */
  75713. constructor(scene: Scene);
  75714. /**
  75715. * Add a MeshAssetTask to the list of active tasks
  75716. * @param taskName defines the name of the new task
  75717. * @param meshesNames defines the name of meshes to load
  75718. * @param rootUrl defines the root url to use to locate files
  75719. * @param sceneFilename defines the filename of the scene file
  75720. * @returns a new MeshAssetTask object
  75721. */
  75722. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75723. /**
  75724. * Add a TextFileAssetTask to the list of active tasks
  75725. * @param taskName defines the name of the new task
  75726. * @param url defines the url of the file to load
  75727. * @returns a new TextFileAssetTask object
  75728. */
  75729. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75730. /**
  75731. * Add a BinaryFileAssetTask to the list of active tasks
  75732. * @param taskName defines the name of the new task
  75733. * @param url defines the url of the file to load
  75734. * @returns a new BinaryFileAssetTask object
  75735. */
  75736. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75737. /**
  75738. * Add a ImageAssetTask to the list of active tasks
  75739. * @param taskName defines the name of the new task
  75740. * @param url defines the url of the file to load
  75741. * @returns a new ImageAssetTask object
  75742. */
  75743. addImageTask(taskName: string, url: string): ImageAssetTask;
  75744. /**
  75745. * Add a TextureAssetTask to the list of active tasks
  75746. * @param taskName defines the name of the new task
  75747. * @param url defines the url of the file to load
  75748. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75749. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75750. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75751. * @returns a new TextureAssetTask object
  75752. */
  75753. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75754. /**
  75755. * Add a CubeTextureAssetTask to the list of active tasks
  75756. * @param taskName defines the name of the new task
  75757. * @param url defines the url of the file to load
  75758. * @param extensions defines the extension to use to load the cube map (can be null)
  75759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75760. * @param files defines the list of files to load (can be null)
  75761. * @returns a new CubeTextureAssetTask object
  75762. */
  75763. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75764. /**
  75765. *
  75766. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75767. * @param taskName defines the name of the new task
  75768. * @param url defines the url of the file to load
  75769. * @param size defines the size you want for the cubemap (can be null)
  75770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75771. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75772. * @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)
  75773. * @param reserved Internal use only
  75774. * @returns a new HDRCubeTextureAssetTask object
  75775. */
  75776. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75777. /**
  75778. *
  75779. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75780. * @param taskName defines the name of the new task
  75781. * @param url defines the url of the file to load
  75782. * @param size defines the size you want for the cubemap (can be null)
  75783. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75784. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75785. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75786. * @returns a new EquiRectangularCubeTextureAssetTask object
  75787. */
  75788. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75789. /**
  75790. * Remove a task from the assets manager.
  75791. * @param task the task to remove
  75792. */
  75793. removeTask(task: AbstractAssetTask): void;
  75794. private _decreaseWaitingTasksCount;
  75795. private _runTask;
  75796. /**
  75797. * Reset the AssetsManager and remove all tasks
  75798. * @return the current instance of the AssetsManager
  75799. */
  75800. reset(): AssetsManager;
  75801. /**
  75802. * Start the loading process
  75803. * @return the current instance of the AssetsManager
  75804. */
  75805. load(): AssetsManager;
  75806. /**
  75807. * Start the loading process as an async operation
  75808. * @return a promise returning the list of failed tasks
  75809. */
  75810. loadAsync(): Promise<void>;
  75811. }
  75812. }
  75813. declare module "babylonjs/Misc/deferred" {
  75814. /**
  75815. * Wrapper class for promise with external resolve and reject.
  75816. */
  75817. export class Deferred<T> {
  75818. /**
  75819. * The promise associated with this deferred object.
  75820. */
  75821. readonly promise: Promise<T>;
  75822. private _resolve;
  75823. private _reject;
  75824. /**
  75825. * The resolve method of the promise associated with this deferred object.
  75826. */
  75827. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75828. /**
  75829. * The reject method of the promise associated with this deferred object.
  75830. */
  75831. get reject(): (reason?: any) => void;
  75832. /**
  75833. * Constructor for this deferred object.
  75834. */
  75835. constructor();
  75836. }
  75837. }
  75838. declare module "babylonjs/Misc/meshExploder" {
  75839. import { Mesh } from "babylonjs/Meshes/mesh";
  75840. /**
  75841. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75842. */
  75843. export class MeshExploder {
  75844. private _centerMesh;
  75845. private _meshes;
  75846. private _meshesOrigins;
  75847. private _toCenterVectors;
  75848. private _scaledDirection;
  75849. private _newPosition;
  75850. private _centerPosition;
  75851. /**
  75852. * Explodes meshes from a center mesh.
  75853. * @param meshes The meshes to explode.
  75854. * @param centerMesh The mesh to be center of explosion.
  75855. */
  75856. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75857. private _setCenterMesh;
  75858. /**
  75859. * Get class name
  75860. * @returns "MeshExploder"
  75861. */
  75862. getClassName(): string;
  75863. /**
  75864. * "Exploded meshes"
  75865. * @returns Array of meshes with the centerMesh at index 0.
  75866. */
  75867. getMeshes(): Array<Mesh>;
  75868. /**
  75869. * Explodes meshes giving a specific direction
  75870. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75871. */
  75872. explode(direction?: number): void;
  75873. }
  75874. }
  75875. declare module "babylonjs/Misc/filesInput" {
  75876. import { Engine } from "babylonjs/Engines/engine";
  75877. import { Scene } from "babylonjs/scene";
  75878. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75879. import { Nullable } from "babylonjs/types";
  75880. /**
  75881. * Class used to help managing file picking and drag'n'drop
  75882. */
  75883. export class FilesInput {
  75884. /**
  75885. * List of files ready to be loaded
  75886. */
  75887. static get FilesToLoad(): {
  75888. [key: string]: File;
  75889. };
  75890. /**
  75891. * Callback called when a file is processed
  75892. */
  75893. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  75894. private _engine;
  75895. private _currentScene;
  75896. private _sceneLoadedCallback;
  75897. private _progressCallback;
  75898. private _additionalRenderLoopLogicCallback;
  75899. private _textureLoadingCallback;
  75900. private _startingProcessingFilesCallback;
  75901. private _onReloadCallback;
  75902. private _errorCallback;
  75903. private _elementToMonitor;
  75904. private _sceneFileToLoad;
  75905. private _filesToLoad;
  75906. /**
  75907. * Creates a new FilesInput
  75908. * @param engine defines the rendering engine
  75909. * @param scene defines the hosting scene
  75910. * @param sceneLoadedCallback callback called when scene is loaded
  75911. * @param progressCallback callback called to track progress
  75912. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75913. * @param textureLoadingCallback callback called when a texture is loading
  75914. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75915. * @param onReloadCallback callback called when a reload is requested
  75916. * @param errorCallback callback call if an error occurs
  75917. */
  75918. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  75919. private _dragEnterHandler;
  75920. private _dragOverHandler;
  75921. private _dropHandler;
  75922. /**
  75923. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75924. * @param elementToMonitor defines the DOM element to track
  75925. */
  75926. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75927. /** Gets the current list of files to load */
  75928. get filesToLoad(): File[];
  75929. /**
  75930. * Release all associated resources
  75931. */
  75932. dispose(): void;
  75933. private renderFunction;
  75934. private drag;
  75935. private drop;
  75936. private _traverseFolder;
  75937. private _processFiles;
  75938. /**
  75939. * Load files from a drop event
  75940. * @param event defines the drop event to use as source
  75941. */
  75942. loadFiles(event: any): void;
  75943. private _processReload;
  75944. /**
  75945. * Reload the current scene from the loaded files
  75946. */
  75947. reload(): void;
  75948. }
  75949. }
  75950. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75951. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75952. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75953. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75954. }
  75955. declare module "babylonjs/Misc/sceneOptimizer" {
  75956. import { Scene, IDisposable } from "babylonjs/scene";
  75957. import { Observable } from "babylonjs/Misc/observable";
  75958. /**
  75959. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75961. */
  75962. export class SceneOptimization {
  75963. /**
  75964. * Defines the priority of this optimization (0 by default which means first in the list)
  75965. */
  75966. priority: number;
  75967. /**
  75968. * Gets a string describing the action executed by the current optimization
  75969. * @returns description string
  75970. */
  75971. getDescription(): string;
  75972. /**
  75973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75974. * @param scene defines the current scene where to apply this optimization
  75975. * @param optimizer defines the current optimizer
  75976. * @returns true if everything that can be done was applied
  75977. */
  75978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75979. /**
  75980. * Creates the SceneOptimization object
  75981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75982. * @param desc defines the description associated with the optimization
  75983. */
  75984. constructor(
  75985. /**
  75986. * Defines the priority of this optimization (0 by default which means first in the list)
  75987. */
  75988. priority?: number);
  75989. }
  75990. /**
  75991. * Defines an optimization used to reduce the size of render target textures
  75992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75993. */
  75994. export class TextureOptimization extends SceneOptimization {
  75995. /**
  75996. * Defines the priority of this optimization (0 by default which means first in the list)
  75997. */
  75998. priority: number;
  75999. /**
  76000. * 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
  76001. */
  76002. maximumSize: number;
  76003. /**
  76004. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76005. */
  76006. step: number;
  76007. /**
  76008. * Gets a string describing the action executed by the current optimization
  76009. * @returns description string
  76010. */
  76011. getDescription(): string;
  76012. /**
  76013. * Creates the TextureOptimization object
  76014. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76015. * @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
  76016. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76017. */
  76018. constructor(
  76019. /**
  76020. * Defines the priority of this optimization (0 by default which means first in the list)
  76021. */
  76022. priority?: number,
  76023. /**
  76024. * 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
  76025. */
  76026. maximumSize?: number,
  76027. /**
  76028. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76029. */
  76030. step?: number);
  76031. /**
  76032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76033. * @param scene defines the current scene where to apply this optimization
  76034. * @param optimizer defines the current optimizer
  76035. * @returns true if everything that can be done was applied
  76036. */
  76037. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76038. }
  76039. /**
  76040. * Defines an optimization used to increase or decrease the rendering resolution
  76041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76042. */
  76043. export class HardwareScalingOptimization extends SceneOptimization {
  76044. /**
  76045. * Defines the priority of this optimization (0 by default which means first in the list)
  76046. */
  76047. priority: number;
  76048. /**
  76049. * Defines the maximum scale to use (2 by default)
  76050. */
  76051. maximumScale: number;
  76052. /**
  76053. * Defines the step to use between two passes (0.5 by default)
  76054. */
  76055. step: number;
  76056. private _currentScale;
  76057. private _directionOffset;
  76058. /**
  76059. * Gets a string describing the action executed by the current optimization
  76060. * @return description string
  76061. */
  76062. getDescription(): string;
  76063. /**
  76064. * Creates the HardwareScalingOptimization object
  76065. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76066. * @param maximumScale defines the maximum scale to use (2 by default)
  76067. * @param step defines the step to use between two passes (0.5 by default)
  76068. */
  76069. constructor(
  76070. /**
  76071. * Defines the priority of this optimization (0 by default which means first in the list)
  76072. */
  76073. priority?: number,
  76074. /**
  76075. * Defines the maximum scale to use (2 by default)
  76076. */
  76077. maximumScale?: number,
  76078. /**
  76079. * Defines the step to use between two passes (0.5 by default)
  76080. */
  76081. step?: number);
  76082. /**
  76083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76084. * @param scene defines the current scene where to apply this optimization
  76085. * @param optimizer defines the current optimizer
  76086. * @returns true if everything that can be done was applied
  76087. */
  76088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76089. }
  76090. /**
  76091. * Defines an optimization used to remove shadows
  76092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76093. */
  76094. export class ShadowsOptimization extends SceneOptimization {
  76095. /**
  76096. * Gets a string describing the action executed by the current optimization
  76097. * @return description string
  76098. */
  76099. getDescription(): string;
  76100. /**
  76101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76102. * @param scene defines the current scene where to apply this optimization
  76103. * @param optimizer defines the current optimizer
  76104. * @returns true if everything that can be done was applied
  76105. */
  76106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76107. }
  76108. /**
  76109. * Defines an optimization used to turn post-processes off
  76110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76111. */
  76112. export class PostProcessesOptimization extends SceneOptimization {
  76113. /**
  76114. * Gets a string describing the action executed by the current optimization
  76115. * @return description string
  76116. */
  76117. getDescription(): string;
  76118. /**
  76119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76120. * @param scene defines the current scene where to apply this optimization
  76121. * @param optimizer defines the current optimizer
  76122. * @returns true if everything that can be done was applied
  76123. */
  76124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76125. }
  76126. /**
  76127. * Defines an optimization used to turn lens flares off
  76128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76129. */
  76130. export class LensFlaresOptimization extends SceneOptimization {
  76131. /**
  76132. * Gets a string describing the action executed by the current optimization
  76133. * @return description string
  76134. */
  76135. getDescription(): string;
  76136. /**
  76137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76138. * @param scene defines the current scene where to apply this optimization
  76139. * @param optimizer defines the current optimizer
  76140. * @returns true if everything that can be done was applied
  76141. */
  76142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76143. }
  76144. /**
  76145. * Defines an optimization based on user defined callback.
  76146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76147. */
  76148. export class CustomOptimization extends SceneOptimization {
  76149. /**
  76150. * Callback called to apply the custom optimization.
  76151. */
  76152. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76153. /**
  76154. * Callback called to get custom description
  76155. */
  76156. onGetDescription: () => string;
  76157. /**
  76158. * Gets a string describing the action executed by the current optimization
  76159. * @returns description string
  76160. */
  76161. getDescription(): string;
  76162. /**
  76163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76164. * @param scene defines the current scene where to apply this optimization
  76165. * @param optimizer defines the current optimizer
  76166. * @returns true if everything that can be done was applied
  76167. */
  76168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76169. }
  76170. /**
  76171. * Defines an optimization used to turn particles off
  76172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76173. */
  76174. export class ParticlesOptimization extends SceneOptimization {
  76175. /**
  76176. * Gets a string describing the action executed by the current optimization
  76177. * @return description string
  76178. */
  76179. getDescription(): string;
  76180. /**
  76181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76182. * @param scene defines the current scene where to apply this optimization
  76183. * @param optimizer defines the current optimizer
  76184. * @returns true if everything that can be done was applied
  76185. */
  76186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76187. }
  76188. /**
  76189. * Defines an optimization used to turn render targets off
  76190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76191. */
  76192. export class RenderTargetsOptimization extends SceneOptimization {
  76193. /**
  76194. * Gets a string describing the action executed by the current optimization
  76195. * @return description string
  76196. */
  76197. getDescription(): string;
  76198. /**
  76199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76200. * @param scene defines the current scene where to apply this optimization
  76201. * @param optimizer defines the current optimizer
  76202. * @returns true if everything that can be done was applied
  76203. */
  76204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76205. }
  76206. /**
  76207. * Defines an optimization used to merge meshes with compatible materials
  76208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76209. */
  76210. export class MergeMeshesOptimization extends SceneOptimization {
  76211. private static _UpdateSelectionTree;
  76212. /**
  76213. * Gets or sets a boolean which defines if optimization octree has to be updated
  76214. */
  76215. static get UpdateSelectionTree(): boolean;
  76216. /**
  76217. * Gets or sets a boolean which defines if optimization octree has to be updated
  76218. */
  76219. static set UpdateSelectionTree(value: boolean);
  76220. /**
  76221. * Gets a string describing the action executed by the current optimization
  76222. * @return description string
  76223. */
  76224. getDescription(): string;
  76225. private _canBeMerged;
  76226. /**
  76227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76228. * @param scene defines the current scene where to apply this optimization
  76229. * @param optimizer defines the current optimizer
  76230. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76231. * @returns true if everything that can be done was applied
  76232. */
  76233. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76234. }
  76235. /**
  76236. * Defines a list of options used by SceneOptimizer
  76237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76238. */
  76239. export class SceneOptimizerOptions {
  76240. /**
  76241. * Defines the target frame rate to reach (60 by default)
  76242. */
  76243. targetFrameRate: number;
  76244. /**
  76245. * Defines the interval between two checkes (2000ms by default)
  76246. */
  76247. trackerDuration: number;
  76248. /**
  76249. * Gets the list of optimizations to apply
  76250. */
  76251. optimizations: SceneOptimization[];
  76252. /**
  76253. * Creates a new list of options used by SceneOptimizer
  76254. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76255. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76256. */
  76257. constructor(
  76258. /**
  76259. * Defines the target frame rate to reach (60 by default)
  76260. */
  76261. targetFrameRate?: number,
  76262. /**
  76263. * Defines the interval between two checkes (2000ms by default)
  76264. */
  76265. trackerDuration?: number);
  76266. /**
  76267. * Add a new optimization
  76268. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76269. * @returns the current SceneOptimizerOptions
  76270. */
  76271. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76272. /**
  76273. * Add a new custom optimization
  76274. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76275. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76276. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76277. * @returns the current SceneOptimizerOptions
  76278. */
  76279. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76280. /**
  76281. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76282. * @param targetFrameRate defines the target frame rate (60 by default)
  76283. * @returns a SceneOptimizerOptions object
  76284. */
  76285. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76286. /**
  76287. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76288. * @param targetFrameRate defines the target frame rate (60 by default)
  76289. * @returns a SceneOptimizerOptions object
  76290. */
  76291. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76292. /**
  76293. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76294. * @param targetFrameRate defines the target frame rate (60 by default)
  76295. * @returns a SceneOptimizerOptions object
  76296. */
  76297. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76298. }
  76299. /**
  76300. * Class used to run optimizations in order to reach a target frame rate
  76301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76302. */
  76303. export class SceneOptimizer implements IDisposable {
  76304. private _isRunning;
  76305. private _options;
  76306. private _scene;
  76307. private _currentPriorityLevel;
  76308. private _targetFrameRate;
  76309. private _trackerDuration;
  76310. private _currentFrameRate;
  76311. private _sceneDisposeObserver;
  76312. private _improvementMode;
  76313. /**
  76314. * Defines an observable called when the optimizer reaches the target frame rate
  76315. */
  76316. onSuccessObservable: Observable<SceneOptimizer>;
  76317. /**
  76318. * Defines an observable called when the optimizer enables an optimization
  76319. */
  76320. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76321. /**
  76322. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76323. */
  76324. onFailureObservable: Observable<SceneOptimizer>;
  76325. /**
  76326. * Gets a boolean indicating if the optimizer is in improvement mode
  76327. */
  76328. get isInImprovementMode(): boolean;
  76329. /**
  76330. * Gets the current priority level (0 at start)
  76331. */
  76332. get currentPriorityLevel(): number;
  76333. /**
  76334. * Gets the current frame rate checked by the SceneOptimizer
  76335. */
  76336. get currentFrameRate(): number;
  76337. /**
  76338. * Gets or sets the current target frame rate (60 by default)
  76339. */
  76340. get targetFrameRate(): number;
  76341. /**
  76342. * Gets or sets the current target frame rate (60 by default)
  76343. */
  76344. set targetFrameRate(value: number);
  76345. /**
  76346. * Gets or sets the current interval between two checks (every 2000ms by default)
  76347. */
  76348. get trackerDuration(): number;
  76349. /**
  76350. * Gets or sets the current interval between two checks (every 2000ms by default)
  76351. */
  76352. set trackerDuration(value: number);
  76353. /**
  76354. * Gets the list of active optimizations
  76355. */
  76356. get optimizations(): SceneOptimization[];
  76357. /**
  76358. * Creates a new SceneOptimizer
  76359. * @param scene defines the scene to work on
  76360. * @param options defines the options to use with the SceneOptimizer
  76361. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76362. * @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)
  76363. */
  76364. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76365. /**
  76366. * Stops the current optimizer
  76367. */
  76368. stop(): void;
  76369. /**
  76370. * Reset the optimizer to initial step (current priority level = 0)
  76371. */
  76372. reset(): void;
  76373. /**
  76374. * Start the optimizer. By default it will try to reach a specific framerate
  76375. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76376. */
  76377. start(): void;
  76378. private _checkCurrentState;
  76379. /**
  76380. * Release all resources
  76381. */
  76382. dispose(): void;
  76383. /**
  76384. * Helper function to create a SceneOptimizer with one single line of code
  76385. * @param scene defines the scene to work on
  76386. * @param options defines the options to use with the SceneOptimizer
  76387. * @param onSuccess defines a callback to call on success
  76388. * @param onFailure defines a callback to call on failure
  76389. * @returns the new SceneOptimizer object
  76390. */
  76391. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76392. }
  76393. }
  76394. declare module "babylonjs/Misc/sceneSerializer" {
  76395. import { Scene } from "babylonjs/scene";
  76396. /**
  76397. * Class used to serialize a scene into a string
  76398. */
  76399. export class SceneSerializer {
  76400. /**
  76401. * Clear cache used by a previous serialization
  76402. */
  76403. static ClearCache(): void;
  76404. /**
  76405. * Serialize a scene into a JSON compatible object
  76406. * @param scene defines the scene to serialize
  76407. * @returns a JSON compatible object
  76408. */
  76409. static Serialize(scene: Scene): any;
  76410. /**
  76411. * Serialize a mesh into a JSON compatible object
  76412. * @param toSerialize defines the mesh to serialize
  76413. * @param withParents defines if parents must be serialized as well
  76414. * @param withChildren defines if children must be serialized as well
  76415. * @returns a JSON compatible object
  76416. */
  76417. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76418. }
  76419. }
  76420. declare module "babylonjs/Misc/textureTools" {
  76421. import { Texture } from "babylonjs/Materials/Textures/texture";
  76422. /**
  76423. * Class used to host texture specific utilities
  76424. */
  76425. export class TextureTools {
  76426. /**
  76427. * Uses the GPU to create a copy texture rescaled at a given size
  76428. * @param texture Texture to copy from
  76429. * @param width defines the desired width
  76430. * @param height defines the desired height
  76431. * @param useBilinearMode defines if bilinear mode has to be used
  76432. * @return the generated texture
  76433. */
  76434. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76435. }
  76436. }
  76437. declare module "babylonjs/Misc/videoRecorder" {
  76438. import { Nullable } from "babylonjs/types";
  76439. import { Engine } from "babylonjs/Engines/engine";
  76440. /**
  76441. * This represents the different options available for the video capture.
  76442. */
  76443. export interface VideoRecorderOptions {
  76444. /** Defines the mime type of the video. */
  76445. mimeType: string;
  76446. /** Defines the FPS the video should be recorded at. */
  76447. fps: number;
  76448. /** Defines the chunk size for the recording data. */
  76449. recordChunckSize: number;
  76450. /** The audio tracks to attach to the recording. */
  76451. audioTracks?: MediaStreamTrack[];
  76452. }
  76453. /**
  76454. * This can help with recording videos from BabylonJS.
  76455. * This is based on the available WebRTC functionalities of the browser.
  76456. *
  76457. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76458. */
  76459. export class VideoRecorder {
  76460. private static readonly _defaultOptions;
  76461. /**
  76462. * Returns whether or not the VideoRecorder is available in your browser.
  76463. * @param engine Defines the Babylon Engine.
  76464. * @returns true if supported otherwise false.
  76465. */
  76466. static IsSupported(engine: Engine): boolean;
  76467. private readonly _options;
  76468. private _canvas;
  76469. private _mediaRecorder;
  76470. private _recordedChunks;
  76471. private _fileName;
  76472. private _resolve;
  76473. private _reject;
  76474. /**
  76475. * True when a recording is already in progress.
  76476. */
  76477. get isRecording(): boolean;
  76478. /**
  76479. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76480. * @param engine Defines the BabylonJS Engine you wish to record.
  76481. * @param options Defines options that can be used to customize the capture.
  76482. */
  76483. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76484. /**
  76485. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76486. */
  76487. stopRecording(): void;
  76488. /**
  76489. * Starts recording the canvas for a max duration specified in parameters.
  76490. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76491. * If null no automatic download will start and you can rely on the promise to get the data back.
  76492. * @param maxDuration Defines the maximum recording time in seconds.
  76493. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76494. * @return A promise callback at the end of the recording with the video data in Blob.
  76495. */
  76496. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76497. /**
  76498. * Releases internal resources used during the recording.
  76499. */
  76500. dispose(): void;
  76501. private _handleDataAvailable;
  76502. private _handleError;
  76503. private _handleStop;
  76504. }
  76505. }
  76506. declare module "babylonjs/Misc/screenshotTools" {
  76507. import { Camera } from "babylonjs/Cameras/camera";
  76508. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76509. import { Engine } from "babylonjs/Engines/engine";
  76510. /**
  76511. * Class containing a set of static utilities functions for screenshots
  76512. */
  76513. export class ScreenshotTools {
  76514. /**
  76515. * Captures a screenshot of the current rendering
  76516. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76517. * @param engine defines the rendering engine
  76518. * @param camera defines the source camera
  76519. * @param size This parameter can be set to a single number or to an object with the
  76520. * following (optional) properties: precision, width, height. If a single number is passed,
  76521. * it will be used for both width and height. If an object is passed, the screenshot size
  76522. * will be derived from the parameters. The precision property is a multiplier allowing
  76523. * rendering at a higher or lower resolution
  76524. * @param successCallback defines the callback receives a single parameter which contains the
  76525. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76526. * src parameter of an <img> to display it
  76527. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76528. * Check your browser for supported MIME types
  76529. */
  76530. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76531. /**
  76532. * Captures a screenshot of the current rendering
  76533. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76534. * @param engine defines the rendering engine
  76535. * @param camera defines the source camera
  76536. * @param size This parameter can be set to a single number or to an object with the
  76537. * following (optional) properties: precision, width, height. If a single number is passed,
  76538. * it will be used for both width and height. If an object is passed, the screenshot size
  76539. * will be derived from the parameters. The precision property is a multiplier allowing
  76540. * rendering at a higher or lower resolution
  76541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76542. * Check your browser for supported MIME types
  76543. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76544. * to the src parameter of an <img> to display it
  76545. */
  76546. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76547. /**
  76548. * Generates an image screenshot from the specified camera.
  76549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76550. * @param engine The engine to use for rendering
  76551. * @param camera The camera to use for rendering
  76552. * @param size This parameter can be set to a single number or to an object with the
  76553. * following (optional) properties: precision, width, height. If a single number is passed,
  76554. * it will be used for both width and height. If an object is passed, the screenshot size
  76555. * will be derived from the parameters. The precision property is a multiplier allowing
  76556. * rendering at a higher or lower resolution
  76557. * @param successCallback The callback receives a single parameter which contains the
  76558. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76559. * src parameter of an <img> to display it
  76560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76561. * Check your browser for supported MIME types
  76562. * @param samples Texture samples (default: 1)
  76563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76564. * @param fileName A name for for the downloaded file.
  76565. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76566. */
  76567. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76568. /**
  76569. * Generates an image screenshot from the specified camera.
  76570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76571. * @param engine The engine to use for rendering
  76572. * @param camera The camera to use for rendering
  76573. * @param size This parameter can be set to a single number or to an object with the
  76574. * following (optional) properties: precision, width, height. If a single number is passed,
  76575. * it will be used for both width and height. If an object is passed, the screenshot size
  76576. * will be derived from the parameters. The precision property is a multiplier allowing
  76577. * rendering at a higher or lower resolution
  76578. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76579. * Check your browser for supported MIME types
  76580. * @param samples Texture samples (default: 1)
  76581. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76582. * @param fileName A name for for the downloaded file.
  76583. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76585. * to the src parameter of an <img> to display it
  76586. */
  76587. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76588. /**
  76589. * Gets height and width for screenshot size
  76590. * @private
  76591. */
  76592. private static _getScreenshotSize;
  76593. }
  76594. }
  76595. declare module "babylonjs/Misc/dataReader" {
  76596. /**
  76597. * Interface for a data buffer
  76598. */
  76599. export interface IDataBuffer {
  76600. /**
  76601. * Reads bytes from the data buffer.
  76602. * @param byteOffset The byte offset to read
  76603. * @param byteLength The byte length to read
  76604. * @returns A promise that resolves when the bytes are read
  76605. */
  76606. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76607. /**
  76608. * The byte length of the buffer.
  76609. */
  76610. readonly byteLength: number;
  76611. }
  76612. /**
  76613. * Utility class for reading from a data buffer
  76614. */
  76615. export class DataReader {
  76616. /**
  76617. * The data buffer associated with this data reader.
  76618. */
  76619. readonly buffer: IDataBuffer;
  76620. /**
  76621. * The current byte offset from the beginning of the data buffer.
  76622. */
  76623. byteOffset: number;
  76624. private _dataView;
  76625. private _dataByteOffset;
  76626. /**
  76627. * Constructor
  76628. * @param buffer The buffer to read
  76629. */
  76630. constructor(buffer: IDataBuffer);
  76631. /**
  76632. * Loads the given byte length.
  76633. * @param byteLength The byte length to load
  76634. * @returns A promise that resolves when the load is complete
  76635. */
  76636. loadAsync(byteLength: number): Promise<void>;
  76637. /**
  76638. * Read a unsigned 32-bit integer from the currently loaded data range.
  76639. * @returns The 32-bit integer read
  76640. */
  76641. readUint32(): number;
  76642. /**
  76643. * Read a byte array from the currently loaded data range.
  76644. * @param byteLength The byte length to read
  76645. * @returns The byte array read
  76646. */
  76647. readUint8Array(byteLength: number): Uint8Array;
  76648. /**
  76649. * Read a string from the currently loaded data range.
  76650. * @param byteLength The byte length to read
  76651. * @returns The string read
  76652. */
  76653. readString(byteLength: number): string;
  76654. /**
  76655. * Skips the given byte length the currently loaded data range.
  76656. * @param byteLength The byte length to skip
  76657. */
  76658. skipBytes(byteLength: number): void;
  76659. }
  76660. }
  76661. declare module "babylonjs/Misc/dataStorage" {
  76662. /**
  76663. * Class for storing data to local storage if available or in-memory storage otherwise
  76664. */
  76665. export class DataStorage {
  76666. private static _Storage;
  76667. private static _GetStorage;
  76668. /**
  76669. * Reads a string from the data storage
  76670. * @param key The key to read
  76671. * @param defaultValue The value if the key doesn't exist
  76672. * @returns The string value
  76673. */
  76674. static ReadString(key: string, defaultValue: string): string;
  76675. /**
  76676. * Writes a string to the data storage
  76677. * @param key The key to write
  76678. * @param value The value to write
  76679. */
  76680. static WriteString(key: string, value: string): void;
  76681. /**
  76682. * Reads a boolean from the data storage
  76683. * @param key The key to read
  76684. * @param defaultValue The value if the key doesn't exist
  76685. * @returns The boolean value
  76686. */
  76687. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76688. /**
  76689. * Writes a boolean to the data storage
  76690. * @param key The key to write
  76691. * @param value The value to write
  76692. */
  76693. static WriteBoolean(key: string, value: boolean): void;
  76694. /**
  76695. * Reads a number from the data storage
  76696. * @param key The key to read
  76697. * @param defaultValue The value if the key doesn't exist
  76698. * @returns The number value
  76699. */
  76700. static ReadNumber(key: string, defaultValue: number): number;
  76701. /**
  76702. * Writes a number to the data storage
  76703. * @param key The key to write
  76704. * @param value The value to write
  76705. */
  76706. static WriteNumber(key: string, value: number): void;
  76707. }
  76708. }
  76709. declare module "babylonjs/Misc/index" {
  76710. export * from "babylonjs/Misc/andOrNotEvaluator";
  76711. export * from "babylonjs/Misc/assetsManager";
  76712. export * from "babylonjs/Misc/basis";
  76713. export * from "babylonjs/Misc/dds";
  76714. export * from "babylonjs/Misc/decorators";
  76715. export * from "babylonjs/Misc/deferred";
  76716. export * from "babylonjs/Misc/environmentTextureTools";
  76717. export * from "babylonjs/Misc/meshExploder";
  76718. export * from "babylonjs/Misc/filesInput";
  76719. export * from "babylonjs/Misc/HighDynamicRange/index";
  76720. export * from "babylonjs/Misc/khronosTextureContainer";
  76721. export * from "babylonjs/Misc/observable";
  76722. export * from "babylonjs/Misc/performanceMonitor";
  76723. export * from "babylonjs/Misc/promise";
  76724. export * from "babylonjs/Misc/sceneOptimizer";
  76725. export * from "babylonjs/Misc/sceneSerializer";
  76726. export * from "babylonjs/Misc/smartArray";
  76727. export * from "babylonjs/Misc/stringDictionary";
  76728. export * from "babylonjs/Misc/tags";
  76729. export * from "babylonjs/Misc/textureTools";
  76730. export * from "babylonjs/Misc/tga";
  76731. export * from "babylonjs/Misc/tools";
  76732. export * from "babylonjs/Misc/videoRecorder";
  76733. export * from "babylonjs/Misc/virtualJoystick";
  76734. export * from "babylonjs/Misc/workerPool";
  76735. export * from "babylonjs/Misc/logger";
  76736. export * from "babylonjs/Misc/typeStore";
  76737. export * from "babylonjs/Misc/filesInputStore";
  76738. export * from "babylonjs/Misc/deepCopier";
  76739. export * from "babylonjs/Misc/pivotTools";
  76740. export * from "babylonjs/Misc/precisionDate";
  76741. export * from "babylonjs/Misc/screenshotTools";
  76742. export * from "babylonjs/Misc/typeStore";
  76743. export * from "babylonjs/Misc/webRequest";
  76744. export * from "babylonjs/Misc/iInspectable";
  76745. export * from "babylonjs/Misc/brdfTextureTools";
  76746. export * from "babylonjs/Misc/rgbdTextureTools";
  76747. export * from "babylonjs/Misc/gradients";
  76748. export * from "babylonjs/Misc/perfCounter";
  76749. export * from "babylonjs/Misc/fileRequest";
  76750. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76751. export * from "babylonjs/Misc/retryStrategy";
  76752. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76753. export * from "babylonjs/Misc/canvasGenerator";
  76754. export * from "babylonjs/Misc/fileTools";
  76755. export * from "babylonjs/Misc/stringTools";
  76756. export * from "babylonjs/Misc/dataReader";
  76757. export * from "babylonjs/Misc/minMaxReducer";
  76758. export * from "babylonjs/Misc/depthReducer";
  76759. export * from "babylonjs/Misc/dataStorage";
  76760. }
  76761. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76762. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76763. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76764. import { Observable } from "babylonjs/Misc/observable";
  76765. import { Matrix } from "babylonjs/Maths/math.vector";
  76766. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76767. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76768. /**
  76769. * An interface for all Hit test features
  76770. */
  76771. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76772. /**
  76773. * Triggered when new babylon (transformed) hit test results are available
  76774. */
  76775. onHitTestResultObservable: Observable<T[]>;
  76776. }
  76777. /**
  76778. * Options used for hit testing
  76779. */
  76780. export interface IWebXRLegacyHitTestOptions {
  76781. /**
  76782. * Only test when user interacted with the scene. Default - hit test every frame
  76783. */
  76784. testOnPointerDownOnly?: boolean;
  76785. /**
  76786. * The node to use to transform the local results to world coordinates
  76787. */
  76788. worldParentNode?: TransformNode;
  76789. }
  76790. /**
  76791. * Interface defining the babylon result of raycasting/hit-test
  76792. */
  76793. export interface IWebXRLegacyHitResult {
  76794. /**
  76795. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76796. */
  76797. transformationMatrix: Matrix;
  76798. /**
  76799. * The native hit test result
  76800. */
  76801. xrHitResult: XRHitResult | XRHitTestResult;
  76802. }
  76803. /**
  76804. * The currently-working hit-test module.
  76805. * Hit test (or Ray-casting) is used to interact with the real world.
  76806. * For further information read here - https://github.com/immersive-web/hit-test
  76807. */
  76808. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76809. /**
  76810. * options to use when constructing this feature
  76811. */
  76812. readonly options: IWebXRLegacyHitTestOptions;
  76813. private _direction;
  76814. private _mat;
  76815. private _onSelectEnabled;
  76816. private _origin;
  76817. /**
  76818. * The module's name
  76819. */
  76820. static readonly Name: string;
  76821. /**
  76822. * The (Babylon) version of this module.
  76823. * This is an integer representing the implementation version.
  76824. * This number does not correspond to the WebXR specs version
  76825. */
  76826. static readonly Version: number;
  76827. /**
  76828. * Populated with the last native XR Hit Results
  76829. */
  76830. lastNativeXRHitResults: XRHitResult[];
  76831. /**
  76832. * Triggered when new babylon (transformed) hit test results are available
  76833. */
  76834. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76835. /**
  76836. * Creates a new instance of the (legacy version) hit test feature
  76837. * @param _xrSessionManager an instance of WebXRSessionManager
  76838. * @param options options to use when constructing this feature
  76839. */
  76840. constructor(_xrSessionManager: WebXRSessionManager,
  76841. /**
  76842. * options to use when constructing this feature
  76843. */
  76844. options?: IWebXRLegacyHitTestOptions);
  76845. /**
  76846. * execute a hit test with an XR Ray
  76847. *
  76848. * @param xrSession a native xrSession that will execute this hit test
  76849. * @param xrRay the ray (position and direction) to use for ray-casting
  76850. * @param referenceSpace native XR reference space to use for the hit-test
  76851. * @param filter filter function that will filter the results
  76852. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76853. */
  76854. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76855. /**
  76856. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76857. * @param event the (select) event to use to select with
  76858. * @param referenceSpace the reference space to use for this hit test
  76859. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76860. */
  76861. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76862. /**
  76863. * attach this feature
  76864. * Will usually be called by the features manager
  76865. *
  76866. * @returns true if successful.
  76867. */
  76868. attach(): boolean;
  76869. /**
  76870. * detach this feature.
  76871. * Will usually be called by the features manager
  76872. *
  76873. * @returns true if successful.
  76874. */
  76875. detach(): boolean;
  76876. /**
  76877. * Dispose this feature and all of the resources attached
  76878. */
  76879. dispose(): void;
  76880. protected _onXRFrame(frame: XRFrame): void;
  76881. private _onHitTestResults;
  76882. private _onSelect;
  76883. }
  76884. }
  76885. declare module "babylonjs/XR/features/WebXRHitTest" {
  76886. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76887. import { Observable } from "babylonjs/Misc/observable";
  76888. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76889. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76890. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76891. /**
  76892. * Options used for hit testing (version 2)
  76893. */
  76894. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76895. /**
  76896. * Do not create a permanent hit test. Will usually be used when only
  76897. * transient inputs are needed.
  76898. */
  76899. disablePermanentHitTest?: boolean;
  76900. /**
  76901. * Enable transient (for example touch-based) hit test inspections
  76902. */
  76903. enableTransientHitTest?: boolean;
  76904. /**
  76905. * Offset ray for the permanent hit test
  76906. */
  76907. offsetRay?: Vector3;
  76908. /**
  76909. * Offset ray for the transient hit test
  76910. */
  76911. transientOffsetRay?: Vector3;
  76912. /**
  76913. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76914. */
  76915. useReferenceSpace?: boolean;
  76916. }
  76917. /**
  76918. * Interface defining the babylon result of hit-test
  76919. */
  76920. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76921. /**
  76922. * The input source that generated this hit test (if transient)
  76923. */
  76924. inputSource?: XRInputSource;
  76925. /**
  76926. * Is this a transient hit test
  76927. */
  76928. isTransient?: boolean;
  76929. /**
  76930. * Position of the hit test result
  76931. */
  76932. position: Vector3;
  76933. /**
  76934. * Rotation of the hit test result
  76935. */
  76936. rotationQuaternion: Quaternion;
  76937. /**
  76938. * The native hit test result
  76939. */
  76940. xrHitResult: XRHitTestResult;
  76941. }
  76942. /**
  76943. * The currently-working hit-test module.
  76944. * Hit test (or Ray-casting) is used to interact with the real world.
  76945. * For further information read here - https://github.com/immersive-web/hit-test
  76946. *
  76947. * Tested on chrome (mobile) 80.
  76948. */
  76949. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76950. /**
  76951. * options to use when constructing this feature
  76952. */
  76953. readonly options: IWebXRHitTestOptions;
  76954. private _tmpMat;
  76955. private _tmpPos;
  76956. private _tmpQuat;
  76957. private _transientXrHitTestSource;
  76958. private _xrHitTestSource;
  76959. private initHitTestSource;
  76960. /**
  76961. * The module's name
  76962. */
  76963. static readonly Name: string;
  76964. /**
  76965. * The (Babylon) version of this module.
  76966. * This is an integer representing the implementation version.
  76967. * This number does not correspond to the WebXR specs version
  76968. */
  76969. static readonly Version: number;
  76970. /**
  76971. * When set to true, each hit test will have its own position/rotation objects
  76972. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76973. * the developers will clone them or copy them as they see fit.
  76974. */
  76975. autoCloneTransformation: boolean;
  76976. /**
  76977. * Triggered when new babylon (transformed) hit test results are available
  76978. */
  76979. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76980. /**
  76981. * Use this to temporarily pause hit test checks.
  76982. */
  76983. paused: boolean;
  76984. /**
  76985. * Creates a new instance of the hit test feature
  76986. * @param _xrSessionManager an instance of WebXRSessionManager
  76987. * @param options options to use when constructing this feature
  76988. */
  76989. constructor(_xrSessionManager: WebXRSessionManager,
  76990. /**
  76991. * options to use when constructing this feature
  76992. */
  76993. options?: IWebXRHitTestOptions);
  76994. /**
  76995. * attach this feature
  76996. * Will usually be called by the features manager
  76997. *
  76998. * @returns true if successful.
  76999. */
  77000. attach(): boolean;
  77001. /**
  77002. * detach this feature.
  77003. * Will usually be called by the features manager
  77004. *
  77005. * @returns true if successful.
  77006. */
  77007. detach(): boolean;
  77008. /**
  77009. * Dispose this feature and all of the resources attached
  77010. */
  77011. dispose(): void;
  77012. protected _onXRFrame(frame: XRFrame): void;
  77013. private _processWebXRHitTestResult;
  77014. }
  77015. }
  77016. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77017. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77018. import { Observable } from "babylonjs/Misc/observable";
  77019. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77021. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77022. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77023. /**
  77024. * Configuration options of the anchor system
  77025. */
  77026. export interface IWebXRAnchorSystemOptions {
  77027. /**
  77028. * a node that will be used to convert local to world coordinates
  77029. */
  77030. worldParentNode?: TransformNode;
  77031. /**
  77032. * If set to true a reference of the created anchors will be kept until the next session starts
  77033. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77034. */
  77035. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77036. }
  77037. /**
  77038. * A babylon container for an XR Anchor
  77039. */
  77040. export interface IWebXRAnchor {
  77041. /**
  77042. * A babylon-assigned ID for this anchor
  77043. */
  77044. id: number;
  77045. /**
  77046. * Transformation matrix to apply to an object attached to this anchor
  77047. */
  77048. transformationMatrix: Matrix;
  77049. /**
  77050. * The native anchor object
  77051. */
  77052. xrAnchor: XRAnchor;
  77053. /**
  77054. * if defined, this object will be constantly updated by the anchor's position and rotation
  77055. */
  77056. attachedNode?: TransformNode;
  77057. }
  77058. /**
  77059. * An implementation of the anchor system for WebXR.
  77060. * For further information see https://github.com/immersive-web/anchors/
  77061. */
  77062. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77063. private _options;
  77064. private _lastFrameDetected;
  77065. private _trackedAnchors;
  77066. private _referenceSpaceForFrameAnchors;
  77067. private _futureAnchors;
  77068. /**
  77069. * The module's name
  77070. */
  77071. static readonly Name: string;
  77072. /**
  77073. * The (Babylon) version of this module.
  77074. * This is an integer representing the implementation version.
  77075. * This number does not correspond to the WebXR specs version
  77076. */
  77077. static readonly Version: number;
  77078. /**
  77079. * Observers registered here will be executed when a new anchor was added to the session
  77080. */
  77081. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77082. /**
  77083. * Observers registered here will be executed when an anchor was removed from the session
  77084. */
  77085. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77086. /**
  77087. * Observers registered here will be executed when an existing anchor updates
  77088. * This can execute N times every frame
  77089. */
  77090. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77091. /**
  77092. * Set the reference space to use for anchor creation, when not using a hit test.
  77093. * Will default to the session's reference space if not defined
  77094. */
  77095. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77096. /**
  77097. * constructs a new anchor system
  77098. * @param _xrSessionManager an instance of WebXRSessionManager
  77099. * @param _options configuration object for this feature
  77100. */
  77101. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77102. private _tmpVector;
  77103. private _tmpQuaternion;
  77104. private _populateTmpTransformation;
  77105. /**
  77106. * Create a new anchor point using a hit test result at a specific point in the scene
  77107. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77108. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77109. *
  77110. * @param hitTestResult The hit test result to use for this anchor creation
  77111. * @param position an optional position offset for this anchor
  77112. * @param rotationQuaternion an optional rotation offset for this anchor
  77113. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77114. */
  77115. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77116. /**
  77117. * Add a new anchor at a specific position and rotation
  77118. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77119. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77120. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77121. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77122. *
  77123. * @param position the position in which to add an anchor
  77124. * @param rotationQuaternion an optional rotation for the anchor transformation
  77125. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77126. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77127. */
  77128. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77129. /**
  77130. * detach this feature.
  77131. * Will usually be called by the features manager
  77132. *
  77133. * @returns true if successful.
  77134. */
  77135. detach(): boolean;
  77136. /**
  77137. * Dispose this feature and all of the resources attached
  77138. */
  77139. dispose(): void;
  77140. protected _onXRFrame(frame: XRFrame): void;
  77141. /**
  77142. * avoiding using Array.find for global support.
  77143. * @param xrAnchor the plane to find in the array
  77144. */
  77145. private _findIndexInAnchorArray;
  77146. private _updateAnchorWithXRFrame;
  77147. private _createAnchorAtTransformation;
  77148. }
  77149. }
  77150. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77151. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77152. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77153. import { Observable } from "babylonjs/Misc/observable";
  77154. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77155. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77156. /**
  77157. * Options used in the plane detector module
  77158. */
  77159. export interface IWebXRPlaneDetectorOptions {
  77160. /**
  77161. * The node to use to transform the local results to world coordinates
  77162. */
  77163. worldParentNode?: TransformNode;
  77164. /**
  77165. * If set to true a reference of the created planes will be kept until the next session starts
  77166. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77167. */
  77168. doNotRemovePlanesOnSessionEnded?: boolean;
  77169. }
  77170. /**
  77171. * A babylon interface for a WebXR plane.
  77172. * A Plane is actually a polygon, built from N points in space
  77173. *
  77174. * Supported in chrome 79, not supported in canary 81 ATM
  77175. */
  77176. export interface IWebXRPlane {
  77177. /**
  77178. * a babylon-assigned ID for this polygon
  77179. */
  77180. id: number;
  77181. /**
  77182. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77183. */
  77184. polygonDefinition: Array<Vector3>;
  77185. /**
  77186. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77187. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77188. */
  77189. transformationMatrix: Matrix;
  77190. /**
  77191. * the native xr-plane object
  77192. */
  77193. xrPlane: XRPlane;
  77194. }
  77195. /**
  77196. * The plane detector is used to detect planes in the real world when in AR
  77197. * For more information see https://github.com/immersive-web/real-world-geometry/
  77198. */
  77199. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77200. private _options;
  77201. private _detectedPlanes;
  77202. private _enabled;
  77203. private _lastFrameDetected;
  77204. /**
  77205. * The module's name
  77206. */
  77207. static readonly Name: string;
  77208. /**
  77209. * The (Babylon) version of this module.
  77210. * This is an integer representing the implementation version.
  77211. * This number does not correspond to the WebXR specs version
  77212. */
  77213. static readonly Version: number;
  77214. /**
  77215. * Observers registered here will be executed when a new plane was added to the session
  77216. */
  77217. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77218. /**
  77219. * Observers registered here will be executed when a plane is no longer detected in the session
  77220. */
  77221. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77222. /**
  77223. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77224. * This can execute N times every frame
  77225. */
  77226. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77227. /**
  77228. * construct a new Plane Detector
  77229. * @param _xrSessionManager an instance of xr Session manager
  77230. * @param _options configuration to use when constructing this feature
  77231. */
  77232. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77233. /**
  77234. * detach this feature.
  77235. * Will usually be called by the features manager
  77236. *
  77237. * @returns true if successful.
  77238. */
  77239. detach(): boolean;
  77240. /**
  77241. * Dispose this feature and all of the resources attached
  77242. */
  77243. dispose(): void;
  77244. protected _onXRFrame(frame: XRFrame): void;
  77245. private _init;
  77246. private _updatePlaneWithXRPlane;
  77247. /**
  77248. * avoiding using Array.find for global support.
  77249. * @param xrPlane the plane to find in the array
  77250. */
  77251. private findIndexInPlaneArray;
  77252. }
  77253. }
  77254. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77255. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77257. import { Observable } from "babylonjs/Misc/observable";
  77258. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77259. /**
  77260. * Options interface for the background remover plugin
  77261. */
  77262. export interface IWebXRBackgroundRemoverOptions {
  77263. /**
  77264. * Further background meshes to disable when entering AR
  77265. */
  77266. backgroundMeshes?: AbstractMesh[];
  77267. /**
  77268. * flags to configure the removal of the environment helper.
  77269. * If not set, the entire background will be removed. If set, flags should be set as well.
  77270. */
  77271. environmentHelperRemovalFlags?: {
  77272. /**
  77273. * Should the skybox be removed (default false)
  77274. */
  77275. skyBox?: boolean;
  77276. /**
  77277. * Should the ground be removed (default false)
  77278. */
  77279. ground?: boolean;
  77280. };
  77281. /**
  77282. * don't disable the environment helper
  77283. */
  77284. ignoreEnvironmentHelper?: boolean;
  77285. }
  77286. /**
  77287. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77288. */
  77289. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77290. /**
  77291. * read-only options to be used in this module
  77292. */
  77293. readonly options: IWebXRBackgroundRemoverOptions;
  77294. /**
  77295. * The module's name
  77296. */
  77297. static readonly Name: string;
  77298. /**
  77299. * The (Babylon) version of this module.
  77300. * This is an integer representing the implementation version.
  77301. * This number does not correspond to the WebXR specs version
  77302. */
  77303. static readonly Version: number;
  77304. /**
  77305. * registered observers will be triggered when the background state changes
  77306. */
  77307. onBackgroundStateChangedObservable: Observable<boolean>;
  77308. /**
  77309. * constructs a new background remover module
  77310. * @param _xrSessionManager the session manager for this module
  77311. * @param options read-only options to be used in this module
  77312. */
  77313. constructor(_xrSessionManager: WebXRSessionManager,
  77314. /**
  77315. * read-only options to be used in this module
  77316. */
  77317. options?: IWebXRBackgroundRemoverOptions);
  77318. /**
  77319. * attach this feature
  77320. * Will usually be called by the features manager
  77321. *
  77322. * @returns true if successful.
  77323. */
  77324. attach(): boolean;
  77325. /**
  77326. * detach this feature.
  77327. * Will usually be called by the features manager
  77328. *
  77329. * @returns true if successful.
  77330. */
  77331. detach(): boolean;
  77332. /**
  77333. * Dispose this feature and all of the resources attached
  77334. */
  77335. dispose(): void;
  77336. protected _onXRFrame(_xrFrame: XRFrame): void;
  77337. private _setBackgroundState;
  77338. }
  77339. }
  77340. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77341. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77342. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77343. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77344. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77345. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77346. import { Nullable } from "babylonjs/types";
  77347. /**
  77348. * Options for the controller physics feature
  77349. */
  77350. export class IWebXRControllerPhysicsOptions {
  77351. /**
  77352. * Should the headset get its own impostor
  77353. */
  77354. enableHeadsetImpostor?: boolean;
  77355. /**
  77356. * Optional parameters for the headset impostor
  77357. */
  77358. headsetImpostorParams?: {
  77359. /**
  77360. * The type of impostor to create. Default is sphere
  77361. */
  77362. impostorType: number;
  77363. /**
  77364. * the size of the impostor. Defaults to 10cm
  77365. */
  77366. impostorSize?: number | {
  77367. width: number;
  77368. height: number;
  77369. depth: number;
  77370. };
  77371. /**
  77372. * Friction definitions
  77373. */
  77374. friction?: number;
  77375. /**
  77376. * Restitution
  77377. */
  77378. restitution?: number;
  77379. };
  77380. /**
  77381. * The physics properties of the future impostors
  77382. */
  77383. physicsProperties?: {
  77384. /**
  77385. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77386. * Note that this requires a physics engine that supports mesh impostors!
  77387. */
  77388. useControllerMesh?: boolean;
  77389. /**
  77390. * The type of impostor to create. Default is sphere
  77391. */
  77392. impostorType?: number;
  77393. /**
  77394. * the size of the impostor. Defaults to 10cm
  77395. */
  77396. impostorSize?: number | {
  77397. width: number;
  77398. height: number;
  77399. depth: number;
  77400. };
  77401. /**
  77402. * Friction definitions
  77403. */
  77404. friction?: number;
  77405. /**
  77406. * Restitution
  77407. */
  77408. restitution?: number;
  77409. };
  77410. /**
  77411. * the xr input to use with this pointer selection
  77412. */
  77413. xrInput: WebXRInput;
  77414. }
  77415. /**
  77416. * Add physics impostor to your webxr controllers,
  77417. * including naive calculation of their linear and angular velocity
  77418. */
  77419. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77420. private readonly _options;
  77421. private _attachController;
  77422. private _controllers;
  77423. private _debugMode;
  77424. private _delta;
  77425. private _headsetImpostor?;
  77426. private _headsetMesh?;
  77427. private _lastTimestamp;
  77428. private _tmpQuaternion;
  77429. private _tmpVector;
  77430. /**
  77431. * The module's name
  77432. */
  77433. static readonly Name: string;
  77434. /**
  77435. * The (Babylon) version of this module.
  77436. * This is an integer representing the implementation version.
  77437. * This number does not correspond to the webxr specs version
  77438. */
  77439. static readonly Version: number;
  77440. /**
  77441. * Construct a new Controller Physics Feature
  77442. * @param _xrSessionManager the corresponding xr session manager
  77443. * @param _options options to create this feature with
  77444. */
  77445. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77446. /**
  77447. * @hidden
  77448. * enable debugging - will show console outputs and the impostor mesh
  77449. */
  77450. _enablePhysicsDebug(): void;
  77451. /**
  77452. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77453. * @param xrController the controller to add
  77454. */
  77455. addController(xrController: WebXRInputSource): void;
  77456. /**
  77457. * attach this feature
  77458. * Will usually be called by the features manager
  77459. *
  77460. * @returns true if successful.
  77461. */
  77462. attach(): boolean;
  77463. /**
  77464. * detach this feature.
  77465. * Will usually be called by the features manager
  77466. *
  77467. * @returns true if successful.
  77468. */
  77469. detach(): boolean;
  77470. /**
  77471. * Get the headset impostor, if enabled
  77472. * @returns the impostor
  77473. */
  77474. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77475. /**
  77476. * Get the physics impostor of a specific controller.
  77477. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77478. * @param controller the controller or the controller id of which to get the impostor
  77479. * @returns the impostor or null
  77480. */
  77481. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77482. /**
  77483. * Update the physics properties provided in the constructor
  77484. * @param newProperties the new properties object
  77485. */
  77486. setPhysicsProperties(newProperties: {
  77487. impostorType?: number;
  77488. impostorSize?: number | {
  77489. width: number;
  77490. height: number;
  77491. depth: number;
  77492. };
  77493. friction?: number;
  77494. restitution?: number;
  77495. }): void;
  77496. protected _onXRFrame(_xrFrame: any): void;
  77497. private _detachController;
  77498. }
  77499. }
  77500. declare module "babylonjs/XR/features/index" {
  77501. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77502. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77503. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77504. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77505. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77506. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77507. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77508. export * from "babylonjs/XR/features/WebXRHitTest";
  77509. }
  77510. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77511. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77513. import { Scene } from "babylonjs/scene";
  77514. /**
  77515. * The motion controller class for all microsoft mixed reality controllers
  77516. */
  77517. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77518. protected readonly _mapping: {
  77519. defaultButton: {
  77520. valueNodeName: string;
  77521. unpressedNodeName: string;
  77522. pressedNodeName: string;
  77523. };
  77524. defaultAxis: {
  77525. valueNodeName: string;
  77526. minNodeName: string;
  77527. maxNodeName: string;
  77528. };
  77529. buttons: {
  77530. "xr-standard-trigger": {
  77531. rootNodeName: string;
  77532. componentProperty: string;
  77533. states: string[];
  77534. };
  77535. "xr-standard-squeeze": {
  77536. rootNodeName: string;
  77537. componentProperty: string;
  77538. states: string[];
  77539. };
  77540. "xr-standard-touchpad": {
  77541. rootNodeName: string;
  77542. labelAnchorNodeName: string;
  77543. touchPointNodeName: string;
  77544. };
  77545. "xr-standard-thumbstick": {
  77546. rootNodeName: string;
  77547. componentProperty: string;
  77548. states: string[];
  77549. };
  77550. };
  77551. axes: {
  77552. "xr-standard-touchpad": {
  77553. "x-axis": {
  77554. rootNodeName: string;
  77555. };
  77556. "y-axis": {
  77557. rootNodeName: string;
  77558. };
  77559. };
  77560. "xr-standard-thumbstick": {
  77561. "x-axis": {
  77562. rootNodeName: string;
  77563. };
  77564. "y-axis": {
  77565. rootNodeName: string;
  77566. };
  77567. };
  77568. };
  77569. };
  77570. /**
  77571. * The base url used to load the left and right controller models
  77572. */
  77573. static MODEL_BASE_URL: string;
  77574. /**
  77575. * The name of the left controller model file
  77576. */
  77577. static MODEL_LEFT_FILENAME: string;
  77578. /**
  77579. * The name of the right controller model file
  77580. */
  77581. static MODEL_RIGHT_FILENAME: string;
  77582. profileId: string;
  77583. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77584. protected _getFilenameAndPath(): {
  77585. filename: string;
  77586. path: string;
  77587. };
  77588. protected _getModelLoadingConstraints(): boolean;
  77589. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77590. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77591. protected _updateModel(): void;
  77592. }
  77593. }
  77594. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77595. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77597. import { Scene } from "babylonjs/scene";
  77598. /**
  77599. * The motion controller class for oculus touch (quest, rift).
  77600. * This class supports legacy mapping as well the standard xr mapping
  77601. */
  77602. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77603. private _forceLegacyControllers;
  77604. private _modelRootNode;
  77605. /**
  77606. * The base url used to load the left and right controller models
  77607. */
  77608. static MODEL_BASE_URL: string;
  77609. /**
  77610. * The name of the left controller model file
  77611. */
  77612. static MODEL_LEFT_FILENAME: string;
  77613. /**
  77614. * The name of the right controller model file
  77615. */
  77616. static MODEL_RIGHT_FILENAME: string;
  77617. /**
  77618. * Base Url for the Quest controller model.
  77619. */
  77620. static QUEST_MODEL_BASE_URL: string;
  77621. profileId: string;
  77622. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77623. protected _getFilenameAndPath(): {
  77624. filename: string;
  77625. path: string;
  77626. };
  77627. protected _getModelLoadingConstraints(): boolean;
  77628. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77629. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77630. protected _updateModel(): void;
  77631. /**
  77632. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77633. * between the touch and touch 2.
  77634. */
  77635. private _isQuest;
  77636. }
  77637. }
  77638. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77639. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77640. import { Scene } from "babylonjs/scene";
  77641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77642. /**
  77643. * The motion controller class for the standard HTC-Vive controllers
  77644. */
  77645. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77646. private _modelRootNode;
  77647. /**
  77648. * The base url used to load the left and right controller models
  77649. */
  77650. static MODEL_BASE_URL: string;
  77651. /**
  77652. * File name for the controller model.
  77653. */
  77654. static MODEL_FILENAME: string;
  77655. profileId: string;
  77656. /**
  77657. * Create a new Vive motion controller object
  77658. * @param scene the scene to use to create this controller
  77659. * @param gamepadObject the corresponding gamepad object
  77660. * @param handedness the handedness of the controller
  77661. */
  77662. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77663. protected _getFilenameAndPath(): {
  77664. filename: string;
  77665. path: string;
  77666. };
  77667. protected _getModelLoadingConstraints(): boolean;
  77668. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77669. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77670. protected _updateModel(): void;
  77671. }
  77672. }
  77673. declare module "babylonjs/XR/motionController/index" {
  77674. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77675. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77676. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77677. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77678. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77679. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77680. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77681. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77682. }
  77683. declare module "babylonjs/XR/index" {
  77684. export * from "babylonjs/XR/webXRCamera";
  77685. export * from "babylonjs/XR/webXREnterExitUI";
  77686. export * from "babylonjs/XR/webXRExperienceHelper";
  77687. export * from "babylonjs/XR/webXRInput";
  77688. export * from "babylonjs/XR/webXRInputSource";
  77689. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77690. export * from "babylonjs/XR/webXRTypes";
  77691. export * from "babylonjs/XR/webXRSessionManager";
  77692. export * from "babylonjs/XR/webXRDefaultExperience";
  77693. export * from "babylonjs/XR/webXRFeaturesManager";
  77694. export * from "babylonjs/XR/features/index";
  77695. export * from "babylonjs/XR/motionController/index";
  77696. }
  77697. declare module "babylonjs/index" {
  77698. export * from "babylonjs/abstractScene";
  77699. export * from "babylonjs/Actions/index";
  77700. export * from "babylonjs/Animations/index";
  77701. export * from "babylonjs/assetContainer";
  77702. export * from "babylonjs/Audio/index";
  77703. export * from "babylonjs/Behaviors/index";
  77704. export * from "babylonjs/Bones/index";
  77705. export * from "babylonjs/Cameras/index";
  77706. export * from "babylonjs/Collisions/index";
  77707. export * from "babylonjs/Culling/index";
  77708. export * from "babylonjs/Debug/index";
  77709. export * from "babylonjs/DeviceInput/index";
  77710. export * from "babylonjs/Engines/index";
  77711. export * from "babylonjs/Events/index";
  77712. export * from "babylonjs/Gamepads/index";
  77713. export * from "babylonjs/Gizmos/index";
  77714. export * from "babylonjs/Helpers/index";
  77715. export * from "babylonjs/Instrumentation/index";
  77716. export * from "babylonjs/Layers/index";
  77717. export * from "babylonjs/LensFlares/index";
  77718. export * from "babylonjs/Lights/index";
  77719. export * from "babylonjs/Loading/index";
  77720. export * from "babylonjs/Materials/index";
  77721. export * from "babylonjs/Maths/index";
  77722. export * from "babylonjs/Meshes/index";
  77723. export * from "babylonjs/Morph/index";
  77724. export * from "babylonjs/Navigation/index";
  77725. export * from "babylonjs/node";
  77726. export * from "babylonjs/Offline/index";
  77727. export * from "babylonjs/Particles/index";
  77728. export * from "babylonjs/Physics/index";
  77729. export * from "babylonjs/PostProcesses/index";
  77730. export * from "babylonjs/Probes/index";
  77731. export * from "babylonjs/Rendering/index";
  77732. export * from "babylonjs/scene";
  77733. export * from "babylonjs/sceneComponent";
  77734. export * from "babylonjs/Sprites/index";
  77735. export * from "babylonjs/States/index";
  77736. export * from "babylonjs/Misc/index";
  77737. export * from "babylonjs/XR/index";
  77738. export * from "babylonjs/types";
  77739. }
  77740. declare module "babylonjs/Animations/pathCursor" {
  77741. import { Vector3 } from "babylonjs/Maths/math.vector";
  77742. import { Path2 } from "babylonjs/Maths/math.path";
  77743. /**
  77744. * A cursor which tracks a point on a path
  77745. */
  77746. export class PathCursor {
  77747. private path;
  77748. /**
  77749. * Stores path cursor callbacks for when an onchange event is triggered
  77750. */
  77751. private _onchange;
  77752. /**
  77753. * The value of the path cursor
  77754. */
  77755. value: number;
  77756. /**
  77757. * The animation array of the path cursor
  77758. */
  77759. animations: Animation[];
  77760. /**
  77761. * Initializes the path cursor
  77762. * @param path The path to track
  77763. */
  77764. constructor(path: Path2);
  77765. /**
  77766. * Gets the cursor point on the path
  77767. * @returns A point on the path cursor at the cursor location
  77768. */
  77769. getPoint(): Vector3;
  77770. /**
  77771. * Moves the cursor ahead by the step amount
  77772. * @param step The amount to move the cursor forward
  77773. * @returns This path cursor
  77774. */
  77775. moveAhead(step?: number): PathCursor;
  77776. /**
  77777. * Moves the cursor behind by the step amount
  77778. * @param step The amount to move the cursor back
  77779. * @returns This path cursor
  77780. */
  77781. moveBack(step?: number): PathCursor;
  77782. /**
  77783. * Moves the cursor by the step amount
  77784. * If the step amount is greater than one, an exception is thrown
  77785. * @param step The amount to move the cursor
  77786. * @returns This path cursor
  77787. */
  77788. move(step: number): PathCursor;
  77789. /**
  77790. * Ensures that the value is limited between zero and one
  77791. * @returns This path cursor
  77792. */
  77793. private ensureLimits;
  77794. /**
  77795. * Runs onchange callbacks on change (used by the animation engine)
  77796. * @returns This path cursor
  77797. */
  77798. private raiseOnChange;
  77799. /**
  77800. * Executes a function on change
  77801. * @param f A path cursor onchange callback
  77802. * @returns This path cursor
  77803. */
  77804. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77805. }
  77806. }
  77807. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77808. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77809. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77810. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77811. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77812. }
  77813. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77814. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77815. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77816. }
  77817. declare module "babylonjs/Engines/Processors/index" {
  77818. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77819. export * from "babylonjs/Engines/Processors/Expressions/index";
  77820. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77821. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77822. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77823. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77824. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77825. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77826. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77827. }
  77828. declare module "babylonjs/Legacy/legacy" {
  77829. import * as Babylon from "babylonjs/index";
  77830. export * from "babylonjs/index";
  77831. }
  77832. declare module "babylonjs/Shaders/blur.fragment" {
  77833. /** @hidden */
  77834. export var blurPixelShader: {
  77835. name: string;
  77836. shader: string;
  77837. };
  77838. }
  77839. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77840. /** @hidden */
  77841. export var pointCloudVertexDeclaration: {
  77842. name: string;
  77843. shader: string;
  77844. };
  77845. }
  77846. declare module "babylonjs" {
  77847. export * from "babylonjs/Legacy/legacy";
  77848. }
  77849. declare module BABYLON {
  77850. /** Alias type for value that can be null */
  77851. export type Nullable<T> = T | null;
  77852. /**
  77853. * Alias type for number that are floats
  77854. * @ignorenaming
  77855. */
  77856. export type float = number;
  77857. /**
  77858. * Alias type for number that are doubles.
  77859. * @ignorenaming
  77860. */
  77861. export type double = number;
  77862. /**
  77863. * Alias type for number that are integer
  77864. * @ignorenaming
  77865. */
  77866. export type int = number;
  77867. /** Alias type for number array or Float32Array */
  77868. export type FloatArray = number[] | Float32Array;
  77869. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77870. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77871. /**
  77872. * Alias for types that can be used by a Buffer or VertexBuffer.
  77873. */
  77874. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77875. /**
  77876. * Alias type for primitive types
  77877. * @ignorenaming
  77878. */
  77879. type Primitive = undefined | null | boolean | string | number | Function;
  77880. /**
  77881. * Type modifier to make all the properties of an object Readonly
  77882. */
  77883. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77884. /**
  77885. * Type modifier to make all the properties of an object Readonly recursively
  77886. */
  77887. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77888. /**
  77889. * Type modifier to make object properties readonly.
  77890. */
  77891. export type DeepImmutableObject<T> = {
  77892. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77893. };
  77894. /** @hidden */
  77895. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77896. }
  77897. }
  77898. declare module BABYLON {
  77899. /**
  77900. * A class serves as a medium between the observable and its observers
  77901. */
  77902. export class EventState {
  77903. /**
  77904. * Create a new EventState
  77905. * @param mask defines the mask associated with this state
  77906. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77907. * @param target defines the original target of the state
  77908. * @param currentTarget defines the current target of the state
  77909. */
  77910. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77911. /**
  77912. * Initialize the current event state
  77913. * @param mask defines the mask associated with this state
  77914. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77915. * @param target defines the original target of the state
  77916. * @param currentTarget defines the current target of the state
  77917. * @returns the current event state
  77918. */
  77919. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77920. /**
  77921. * An Observer can set this property to true to prevent subsequent observers of being notified
  77922. */
  77923. skipNextObservers: boolean;
  77924. /**
  77925. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77926. */
  77927. mask: number;
  77928. /**
  77929. * The object that originally notified the event
  77930. */
  77931. target?: any;
  77932. /**
  77933. * The current object in the bubbling phase
  77934. */
  77935. currentTarget?: any;
  77936. /**
  77937. * This will be populated with the return value of the last function that was executed.
  77938. * If it is the first function in the callback chain it will be the event data.
  77939. */
  77940. lastReturnValue?: any;
  77941. }
  77942. /**
  77943. * Represent an Observer registered to a given Observable object.
  77944. */
  77945. export class Observer<T> {
  77946. /**
  77947. * Defines the callback to call when the observer is notified
  77948. */
  77949. callback: (eventData: T, eventState: EventState) => void;
  77950. /**
  77951. * Defines the mask of the observer (used to filter notifications)
  77952. */
  77953. mask: number;
  77954. /**
  77955. * Defines the current scope used to restore the JS context
  77956. */
  77957. scope: any;
  77958. /** @hidden */
  77959. _willBeUnregistered: boolean;
  77960. /**
  77961. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77962. */
  77963. unregisterOnNextCall: boolean;
  77964. /**
  77965. * Creates a new observer
  77966. * @param callback defines the callback to call when the observer is notified
  77967. * @param mask defines the mask of the observer (used to filter notifications)
  77968. * @param scope defines the current scope used to restore the JS context
  77969. */
  77970. constructor(
  77971. /**
  77972. * Defines the callback to call when the observer is notified
  77973. */
  77974. callback: (eventData: T, eventState: EventState) => void,
  77975. /**
  77976. * Defines the mask of the observer (used to filter notifications)
  77977. */
  77978. mask: number,
  77979. /**
  77980. * Defines the current scope used to restore the JS context
  77981. */
  77982. scope?: any);
  77983. }
  77984. /**
  77985. * Represent a list of observers registered to multiple Observables object.
  77986. */
  77987. export class MultiObserver<T> {
  77988. private _observers;
  77989. private _observables;
  77990. /**
  77991. * Release associated resources
  77992. */
  77993. dispose(): void;
  77994. /**
  77995. * Raise a callback when one of the observable will notify
  77996. * @param observables defines a list of observables to watch
  77997. * @param callback defines the callback to call on notification
  77998. * @param mask defines the mask used to filter notifications
  77999. * @param scope defines the current scope used to restore the JS context
  78000. * @returns the new MultiObserver
  78001. */
  78002. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78003. }
  78004. /**
  78005. * The Observable class is a simple implementation of the Observable pattern.
  78006. *
  78007. * 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.
  78008. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78009. * 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).
  78010. * 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.
  78011. */
  78012. export class Observable<T> {
  78013. private _observers;
  78014. private _eventState;
  78015. private _onObserverAdded;
  78016. /**
  78017. * Gets the list of observers
  78018. */
  78019. get observers(): Array<Observer<T>>;
  78020. /**
  78021. * Creates a new observable
  78022. * @param onObserverAdded defines a callback to call when a new observer is added
  78023. */
  78024. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78025. /**
  78026. * Create a new Observer with the specified callback
  78027. * @param callback the callback that will be executed for that Observer
  78028. * @param mask the mask used to filter observers
  78029. * @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.
  78030. * @param scope optional scope for the callback to be called from
  78031. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78032. * @returns the new observer created for the callback
  78033. */
  78034. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78035. /**
  78036. * Create a new Observer with the specified callback and unregisters after the next notification
  78037. * @param callback the callback that will be executed for that Observer
  78038. * @returns the new observer created for the callback
  78039. */
  78040. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78041. /**
  78042. * Remove an Observer from the Observable object
  78043. * @param observer the instance of the Observer to remove
  78044. * @returns false if it doesn't belong to this Observable
  78045. */
  78046. remove(observer: Nullable<Observer<T>>): boolean;
  78047. /**
  78048. * Remove a callback from the Observable object
  78049. * @param callback the callback to remove
  78050. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78051. * @returns false if it doesn't belong to this Observable
  78052. */
  78053. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78054. private _deferUnregister;
  78055. private _remove;
  78056. /**
  78057. * Moves the observable to the top of the observer list making it get called first when notified
  78058. * @param observer the observer to move
  78059. */
  78060. makeObserverTopPriority(observer: Observer<T>): void;
  78061. /**
  78062. * Moves the observable to the bottom of the observer list making it get called last when notified
  78063. * @param observer the observer to move
  78064. */
  78065. makeObserverBottomPriority(observer: Observer<T>): void;
  78066. /**
  78067. * Notify all Observers by calling their respective callback with the given data
  78068. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78069. * @param eventData defines the data to send to all observers
  78070. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78071. * @param target defines the original target of the state
  78072. * @param currentTarget defines the current target of the state
  78073. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78074. */
  78075. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78076. /**
  78077. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78078. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78079. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78080. * and it is crucial that all callbacks will be executed.
  78081. * The order of the callbacks is kept, callbacks are not executed parallel.
  78082. *
  78083. * @param eventData The data to be sent to each callback
  78084. * @param mask is used to filter observers defaults to -1
  78085. * @param target defines the callback target (see EventState)
  78086. * @param currentTarget defines he current object in the bubbling phase
  78087. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78088. */
  78089. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78090. /**
  78091. * Notify a specific observer
  78092. * @param observer defines the observer to notify
  78093. * @param eventData defines the data to be sent to each callback
  78094. * @param mask is used to filter observers defaults to -1
  78095. */
  78096. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78097. /**
  78098. * Gets a boolean indicating if the observable has at least one observer
  78099. * @returns true is the Observable has at least one Observer registered
  78100. */
  78101. hasObservers(): boolean;
  78102. /**
  78103. * Clear the list of observers
  78104. */
  78105. clear(): void;
  78106. /**
  78107. * Clone the current observable
  78108. * @returns a new observable
  78109. */
  78110. clone(): Observable<T>;
  78111. /**
  78112. * Does this observable handles observer registered with a given mask
  78113. * @param mask defines the mask to be tested
  78114. * @return whether or not one observer registered with the given mask is handeled
  78115. **/
  78116. hasSpecificMask(mask?: number): boolean;
  78117. }
  78118. }
  78119. declare module BABYLON {
  78120. /**
  78121. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78122. * Babylon.js
  78123. */
  78124. export class DomManagement {
  78125. /**
  78126. * Checks if the window object exists
  78127. * @returns true if the window object exists
  78128. */
  78129. static IsWindowObjectExist(): boolean;
  78130. /**
  78131. * Checks if the navigator object exists
  78132. * @returns true if the navigator object exists
  78133. */
  78134. static IsNavigatorAvailable(): boolean;
  78135. /**
  78136. * Check if the document object exists
  78137. * @returns true if the document object exists
  78138. */
  78139. static IsDocumentAvailable(): boolean;
  78140. /**
  78141. * Extracts text content from a DOM element hierarchy
  78142. * @param element defines the root element
  78143. * @returns a string
  78144. */
  78145. static GetDOMTextContent(element: HTMLElement): string;
  78146. }
  78147. }
  78148. declare module BABYLON {
  78149. /**
  78150. * Logger used througouht the application to allow configuration of
  78151. * the log level required for the messages.
  78152. */
  78153. export class Logger {
  78154. /**
  78155. * No log
  78156. */
  78157. static readonly NoneLogLevel: number;
  78158. /**
  78159. * Only message logs
  78160. */
  78161. static readonly MessageLogLevel: number;
  78162. /**
  78163. * Only warning logs
  78164. */
  78165. static readonly WarningLogLevel: number;
  78166. /**
  78167. * Only error logs
  78168. */
  78169. static readonly ErrorLogLevel: number;
  78170. /**
  78171. * All logs
  78172. */
  78173. static readonly AllLogLevel: number;
  78174. private static _LogCache;
  78175. /**
  78176. * Gets a value indicating the number of loading errors
  78177. * @ignorenaming
  78178. */
  78179. static errorsCount: number;
  78180. /**
  78181. * Callback called when a new log is added
  78182. */
  78183. static OnNewCacheEntry: (entry: string) => void;
  78184. private static _AddLogEntry;
  78185. private static _FormatMessage;
  78186. private static _LogDisabled;
  78187. private static _LogEnabled;
  78188. private static _WarnDisabled;
  78189. private static _WarnEnabled;
  78190. private static _ErrorDisabled;
  78191. private static _ErrorEnabled;
  78192. /**
  78193. * Log a message to the console
  78194. */
  78195. static Log: (message: string) => void;
  78196. /**
  78197. * Write a warning message to the console
  78198. */
  78199. static Warn: (message: string) => void;
  78200. /**
  78201. * Write an error message to the console
  78202. */
  78203. static Error: (message: string) => void;
  78204. /**
  78205. * Gets current log cache (list of logs)
  78206. */
  78207. static get LogCache(): string;
  78208. /**
  78209. * Clears the log cache
  78210. */
  78211. static ClearLogCache(): void;
  78212. /**
  78213. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78214. */
  78215. static set LogLevels(level: number);
  78216. }
  78217. }
  78218. declare module BABYLON {
  78219. /** @hidden */
  78220. export class _TypeStore {
  78221. /** @hidden */
  78222. static RegisteredTypes: {
  78223. [key: string]: Object;
  78224. };
  78225. /** @hidden */
  78226. static GetClass(fqdn: string): any;
  78227. }
  78228. }
  78229. declare module BABYLON {
  78230. /**
  78231. * Helper to manipulate strings
  78232. */
  78233. export class StringTools {
  78234. /**
  78235. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78236. * @param str Source string
  78237. * @param suffix Suffix to search for in the source string
  78238. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78239. */
  78240. static EndsWith(str: string, suffix: string): boolean;
  78241. /**
  78242. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78243. * @param str Source string
  78244. * @param suffix Suffix to search for in the source string
  78245. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78246. */
  78247. static StartsWith(str: string, suffix: string): boolean;
  78248. /**
  78249. * Decodes a buffer into a string
  78250. * @param buffer The buffer to decode
  78251. * @returns The decoded string
  78252. */
  78253. static Decode(buffer: Uint8Array | Uint16Array): string;
  78254. /**
  78255. * Encode a buffer to a base64 string
  78256. * @param buffer defines the buffer to encode
  78257. * @returns the encoded string
  78258. */
  78259. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78260. /**
  78261. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78262. * @param num the number to convert and pad
  78263. * @param length the expected length of the string
  78264. * @returns the padded string
  78265. */
  78266. static PadNumber(num: number, length: number): string;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. /**
  78271. * Class containing a set of static utilities functions for deep copy.
  78272. */
  78273. export class DeepCopier {
  78274. /**
  78275. * Tries to copy an object by duplicating every property
  78276. * @param source defines the source object
  78277. * @param destination defines the target object
  78278. * @param doNotCopyList defines a list of properties to avoid
  78279. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78280. */
  78281. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78282. }
  78283. }
  78284. declare module BABYLON {
  78285. /**
  78286. * Class containing a set of static utilities functions for precision date
  78287. */
  78288. export class PrecisionDate {
  78289. /**
  78290. * Gets either window.performance.now() if supported or Date.now() else
  78291. */
  78292. static get Now(): number;
  78293. }
  78294. }
  78295. declare module BABYLON {
  78296. /** @hidden */
  78297. export class _DevTools {
  78298. static WarnImport(name: string): string;
  78299. }
  78300. }
  78301. declare module BABYLON {
  78302. /**
  78303. * Interface used to define the mechanism to get data from the network
  78304. */
  78305. export interface IWebRequest {
  78306. /**
  78307. * Returns client's response url
  78308. */
  78309. responseURL: string;
  78310. /**
  78311. * Returns client's status
  78312. */
  78313. status: number;
  78314. /**
  78315. * Returns client's status as a text
  78316. */
  78317. statusText: string;
  78318. }
  78319. }
  78320. declare module BABYLON {
  78321. /**
  78322. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78323. */
  78324. export class WebRequest implements IWebRequest {
  78325. private _xhr;
  78326. /**
  78327. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78328. * i.e. when loading files, where the server/service expects an Authorization header
  78329. */
  78330. static CustomRequestHeaders: {
  78331. [key: string]: string;
  78332. };
  78333. /**
  78334. * Add callback functions in this array to update all the requests before they get sent to the network
  78335. */
  78336. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78337. private _injectCustomRequestHeaders;
  78338. /**
  78339. * Gets or sets a function to be called when loading progress changes
  78340. */
  78341. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78342. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78343. /**
  78344. * Returns client's state
  78345. */
  78346. get readyState(): number;
  78347. /**
  78348. * Returns client's status
  78349. */
  78350. get status(): number;
  78351. /**
  78352. * Returns client's status as a text
  78353. */
  78354. get statusText(): string;
  78355. /**
  78356. * Returns client's response
  78357. */
  78358. get response(): any;
  78359. /**
  78360. * Returns client's response url
  78361. */
  78362. get responseURL(): string;
  78363. /**
  78364. * Returns client's response as text
  78365. */
  78366. get responseText(): string;
  78367. /**
  78368. * Gets or sets the expected response type
  78369. */
  78370. get responseType(): XMLHttpRequestResponseType;
  78371. set responseType(value: XMLHttpRequestResponseType);
  78372. /** @hidden */
  78373. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78374. /** @hidden */
  78375. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78376. /**
  78377. * Cancels any network activity
  78378. */
  78379. abort(): void;
  78380. /**
  78381. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78382. * @param body defines an optional request body
  78383. */
  78384. send(body?: Document | BodyInit | null): void;
  78385. /**
  78386. * Sets the request method, request URL
  78387. * @param method defines the method to use (GET, POST, etc..)
  78388. * @param url defines the url to connect with
  78389. */
  78390. open(method: string, url: string): void;
  78391. /**
  78392. * Sets the value of a request header.
  78393. * @param name The name of the header whose value is to be set
  78394. * @param value The value to set as the body of the header
  78395. */
  78396. setRequestHeader(name: string, value: string): void;
  78397. /**
  78398. * Get the string containing the text of a particular header's value.
  78399. * @param name The name of the header
  78400. * @returns The string containing the text of the given header name
  78401. */
  78402. getResponseHeader(name: string): Nullable<string>;
  78403. }
  78404. }
  78405. declare module BABYLON {
  78406. /**
  78407. * File request interface
  78408. */
  78409. export interface IFileRequest {
  78410. /**
  78411. * Raised when the request is complete (success or error).
  78412. */
  78413. onCompleteObservable: Observable<IFileRequest>;
  78414. /**
  78415. * Aborts the request for a file.
  78416. */
  78417. abort: () => void;
  78418. }
  78419. }
  78420. declare module BABYLON {
  78421. /**
  78422. * Define options used to create a render target texture
  78423. */
  78424. export class RenderTargetCreationOptions {
  78425. /**
  78426. * Specifies is mipmaps must be generated
  78427. */
  78428. generateMipMaps?: boolean;
  78429. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78430. generateDepthBuffer?: boolean;
  78431. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78432. generateStencilBuffer?: boolean;
  78433. /** Defines texture type (int by default) */
  78434. type?: number;
  78435. /** Defines sampling mode (trilinear by default) */
  78436. samplingMode?: number;
  78437. /** Defines format (RGBA by default) */
  78438. format?: number;
  78439. }
  78440. }
  78441. declare module BABYLON {
  78442. /** Defines the cross module used constants to avoid circular dependncies */
  78443. export class Constants {
  78444. /** Defines that alpha blending is disabled */
  78445. static readonly ALPHA_DISABLE: number;
  78446. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78447. static readonly ALPHA_ADD: number;
  78448. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78449. static readonly ALPHA_COMBINE: number;
  78450. /** Defines that alpha blending is DEST - SRC * DEST */
  78451. static readonly ALPHA_SUBTRACT: number;
  78452. /** Defines that alpha blending is SRC * DEST */
  78453. static readonly ALPHA_MULTIPLY: number;
  78454. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78455. static readonly ALPHA_MAXIMIZED: number;
  78456. /** Defines that alpha blending is SRC + DEST */
  78457. static readonly ALPHA_ONEONE: number;
  78458. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78459. static readonly ALPHA_PREMULTIPLIED: number;
  78460. /**
  78461. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78462. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78463. */
  78464. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78465. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78466. static readonly ALPHA_INTERPOLATE: number;
  78467. /**
  78468. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78469. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78470. */
  78471. static readonly ALPHA_SCREENMODE: number;
  78472. /**
  78473. * Defines that alpha blending is SRC + DST
  78474. * Alpha will be set to SRC ALPHA + DST ALPHA
  78475. */
  78476. static readonly ALPHA_ONEONE_ONEONE: number;
  78477. /**
  78478. * Defines that alpha blending is SRC * DST ALPHA + DST
  78479. * Alpha will be set to 0
  78480. */
  78481. static readonly ALPHA_ALPHATOCOLOR: number;
  78482. /**
  78483. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78484. */
  78485. static readonly ALPHA_REVERSEONEMINUS: number;
  78486. /**
  78487. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78488. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78489. */
  78490. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78491. /**
  78492. * Defines that alpha blending is SRC + DST
  78493. * Alpha will be set to SRC ALPHA
  78494. */
  78495. static readonly ALPHA_ONEONE_ONEZERO: number;
  78496. /**
  78497. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78498. * Alpha will be set to DST ALPHA
  78499. */
  78500. static readonly ALPHA_EXCLUSION: number;
  78501. /** Defines that alpha blending equation a SUM */
  78502. static readonly ALPHA_EQUATION_ADD: number;
  78503. /** Defines that alpha blending equation a SUBSTRACTION */
  78504. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78505. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78506. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78507. /** Defines that alpha blending equation a MAX operation */
  78508. static readonly ALPHA_EQUATION_MAX: number;
  78509. /** Defines that alpha blending equation a MIN operation */
  78510. static readonly ALPHA_EQUATION_MIN: number;
  78511. /**
  78512. * Defines that alpha blending equation a DARKEN operation:
  78513. * It takes the min of the src and sums the alpha channels.
  78514. */
  78515. static readonly ALPHA_EQUATION_DARKEN: number;
  78516. /** Defines that the ressource is not delayed*/
  78517. static readonly DELAYLOADSTATE_NONE: number;
  78518. /** Defines that the ressource was successfully delay loaded */
  78519. static readonly DELAYLOADSTATE_LOADED: number;
  78520. /** Defines that the ressource is currently delay loading */
  78521. static readonly DELAYLOADSTATE_LOADING: number;
  78522. /** Defines that the ressource is delayed and has not started loading */
  78523. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78525. static readonly NEVER: number;
  78526. /** 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 */
  78527. static readonly ALWAYS: number;
  78528. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78529. static readonly LESS: number;
  78530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78531. static readonly EQUAL: number;
  78532. /** 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 */
  78533. static readonly LEQUAL: number;
  78534. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78535. static readonly GREATER: number;
  78536. /** 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 */
  78537. static readonly GEQUAL: number;
  78538. /** 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 */
  78539. static readonly NOTEQUAL: number;
  78540. /** Passed to stencilOperation to specify that stencil value must be kept */
  78541. static readonly KEEP: number;
  78542. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78543. static readonly REPLACE: number;
  78544. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78545. static readonly INCR: number;
  78546. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78547. static readonly DECR: number;
  78548. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78549. static readonly INVERT: number;
  78550. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78551. static readonly INCR_WRAP: number;
  78552. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78553. static readonly DECR_WRAP: number;
  78554. /** Texture is not repeating outside of 0..1 UVs */
  78555. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78556. /** Texture is repeating outside of 0..1 UVs */
  78557. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78558. /** Texture is repeating and mirrored */
  78559. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78560. /** ALPHA */
  78561. static readonly TEXTUREFORMAT_ALPHA: number;
  78562. /** LUMINANCE */
  78563. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78564. /** LUMINANCE_ALPHA */
  78565. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78566. /** RGB */
  78567. static readonly TEXTUREFORMAT_RGB: number;
  78568. /** RGBA */
  78569. static readonly TEXTUREFORMAT_RGBA: number;
  78570. /** RED */
  78571. static readonly TEXTUREFORMAT_RED: number;
  78572. /** RED (2nd reference) */
  78573. static readonly TEXTUREFORMAT_R: number;
  78574. /** RG */
  78575. static readonly TEXTUREFORMAT_RG: number;
  78576. /** RED_INTEGER */
  78577. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78578. /** RED_INTEGER (2nd reference) */
  78579. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78580. /** RG_INTEGER */
  78581. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78582. /** RGB_INTEGER */
  78583. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78584. /** RGBA_INTEGER */
  78585. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78586. /** UNSIGNED_BYTE */
  78587. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78588. /** UNSIGNED_BYTE (2nd reference) */
  78589. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78590. /** FLOAT */
  78591. static readonly TEXTURETYPE_FLOAT: number;
  78592. /** HALF_FLOAT */
  78593. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78594. /** BYTE */
  78595. static readonly TEXTURETYPE_BYTE: number;
  78596. /** SHORT */
  78597. static readonly TEXTURETYPE_SHORT: number;
  78598. /** UNSIGNED_SHORT */
  78599. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78600. /** INT */
  78601. static readonly TEXTURETYPE_INT: number;
  78602. /** UNSIGNED_INT */
  78603. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78604. /** UNSIGNED_SHORT_4_4_4_4 */
  78605. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78606. /** UNSIGNED_SHORT_5_5_5_1 */
  78607. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78608. /** UNSIGNED_SHORT_5_6_5 */
  78609. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78610. /** UNSIGNED_INT_2_10_10_10_REV */
  78611. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78612. /** UNSIGNED_INT_24_8 */
  78613. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78614. /** UNSIGNED_INT_10F_11F_11F_REV */
  78615. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78616. /** UNSIGNED_INT_5_9_9_9_REV */
  78617. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78618. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78619. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78620. /** nearest is mag = nearest and min = nearest and no mip */
  78621. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78622. /** mag = nearest and min = nearest and mip = none */
  78623. static readonly TEXTURE_NEAREST_NEAREST: number;
  78624. /** Bilinear is mag = linear and min = linear and no mip */
  78625. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78626. /** mag = linear and min = linear and mip = none */
  78627. static readonly TEXTURE_LINEAR_LINEAR: number;
  78628. /** Trilinear is mag = linear and min = linear and mip = linear */
  78629. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78630. /** Trilinear is mag = linear and min = linear and mip = linear */
  78631. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78632. /** mag = nearest and min = nearest and mip = nearest */
  78633. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78634. /** mag = nearest and min = linear and mip = nearest */
  78635. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78636. /** mag = nearest and min = linear and mip = linear */
  78637. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78638. /** mag = nearest and min = linear and mip = none */
  78639. static readonly TEXTURE_NEAREST_LINEAR: number;
  78640. /** nearest is mag = nearest and min = nearest and mip = linear */
  78641. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78642. /** mag = linear and min = nearest and mip = nearest */
  78643. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78644. /** mag = linear and min = nearest and mip = linear */
  78645. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78646. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78647. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78648. /** mag = linear and min = nearest and mip = none */
  78649. static readonly TEXTURE_LINEAR_NEAREST: number;
  78650. /** Explicit coordinates mode */
  78651. static readonly TEXTURE_EXPLICIT_MODE: number;
  78652. /** Spherical coordinates mode */
  78653. static readonly TEXTURE_SPHERICAL_MODE: number;
  78654. /** Planar coordinates mode */
  78655. static readonly TEXTURE_PLANAR_MODE: number;
  78656. /** Cubic coordinates mode */
  78657. static readonly TEXTURE_CUBIC_MODE: number;
  78658. /** Projection coordinates mode */
  78659. static readonly TEXTURE_PROJECTION_MODE: number;
  78660. /** Skybox coordinates mode */
  78661. static readonly TEXTURE_SKYBOX_MODE: number;
  78662. /** Inverse Cubic coordinates mode */
  78663. static readonly TEXTURE_INVCUBIC_MODE: number;
  78664. /** Equirectangular coordinates mode */
  78665. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78666. /** Equirectangular Fixed coordinates mode */
  78667. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78668. /** Equirectangular Fixed Mirrored coordinates mode */
  78669. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78670. /** Offline (baking) quality for texture filtering */
  78671. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78672. /** High quality for texture filtering */
  78673. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78674. /** Medium quality for texture filtering */
  78675. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78676. /** Low quality for texture filtering */
  78677. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78678. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78679. static readonly SCALEMODE_FLOOR: number;
  78680. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78681. static readonly SCALEMODE_NEAREST: number;
  78682. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78683. static readonly SCALEMODE_CEILING: number;
  78684. /**
  78685. * The dirty texture flag value
  78686. */
  78687. static readonly MATERIAL_TextureDirtyFlag: number;
  78688. /**
  78689. * The dirty light flag value
  78690. */
  78691. static readonly MATERIAL_LightDirtyFlag: number;
  78692. /**
  78693. * The dirty fresnel flag value
  78694. */
  78695. static readonly MATERIAL_FresnelDirtyFlag: number;
  78696. /**
  78697. * The dirty attribute flag value
  78698. */
  78699. static readonly MATERIAL_AttributesDirtyFlag: number;
  78700. /**
  78701. * The dirty misc flag value
  78702. */
  78703. static readonly MATERIAL_MiscDirtyFlag: number;
  78704. /**
  78705. * The all dirty flag value
  78706. */
  78707. static readonly MATERIAL_AllDirtyFlag: number;
  78708. /**
  78709. * Returns the triangle fill mode
  78710. */
  78711. static readonly MATERIAL_TriangleFillMode: number;
  78712. /**
  78713. * Returns the wireframe mode
  78714. */
  78715. static readonly MATERIAL_WireFrameFillMode: number;
  78716. /**
  78717. * Returns the point fill mode
  78718. */
  78719. static readonly MATERIAL_PointFillMode: number;
  78720. /**
  78721. * Returns the point list draw mode
  78722. */
  78723. static readonly MATERIAL_PointListDrawMode: number;
  78724. /**
  78725. * Returns the line list draw mode
  78726. */
  78727. static readonly MATERIAL_LineListDrawMode: number;
  78728. /**
  78729. * Returns the line loop draw mode
  78730. */
  78731. static readonly MATERIAL_LineLoopDrawMode: number;
  78732. /**
  78733. * Returns the line strip draw mode
  78734. */
  78735. static readonly MATERIAL_LineStripDrawMode: number;
  78736. /**
  78737. * Returns the triangle strip draw mode
  78738. */
  78739. static readonly MATERIAL_TriangleStripDrawMode: number;
  78740. /**
  78741. * Returns the triangle fan draw mode
  78742. */
  78743. static readonly MATERIAL_TriangleFanDrawMode: number;
  78744. /**
  78745. * Stores the clock-wise side orientation
  78746. */
  78747. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78748. /**
  78749. * Stores the counter clock-wise side orientation
  78750. */
  78751. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78752. /**
  78753. * Nothing
  78754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78755. */
  78756. static readonly ACTION_NothingTrigger: number;
  78757. /**
  78758. * On pick
  78759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78760. */
  78761. static readonly ACTION_OnPickTrigger: number;
  78762. /**
  78763. * On left pick
  78764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78765. */
  78766. static readonly ACTION_OnLeftPickTrigger: number;
  78767. /**
  78768. * On right pick
  78769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78770. */
  78771. static readonly ACTION_OnRightPickTrigger: number;
  78772. /**
  78773. * On center pick
  78774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78775. */
  78776. static readonly ACTION_OnCenterPickTrigger: number;
  78777. /**
  78778. * On pick down
  78779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78780. */
  78781. static readonly ACTION_OnPickDownTrigger: number;
  78782. /**
  78783. * On double pick
  78784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78785. */
  78786. static readonly ACTION_OnDoublePickTrigger: number;
  78787. /**
  78788. * On pick up
  78789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78790. */
  78791. static readonly ACTION_OnPickUpTrigger: number;
  78792. /**
  78793. * On pick out.
  78794. * This trigger will only be raised if you also declared a OnPickDown
  78795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78796. */
  78797. static readonly ACTION_OnPickOutTrigger: number;
  78798. /**
  78799. * On long press
  78800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78801. */
  78802. static readonly ACTION_OnLongPressTrigger: number;
  78803. /**
  78804. * On pointer over
  78805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78806. */
  78807. static readonly ACTION_OnPointerOverTrigger: number;
  78808. /**
  78809. * On pointer out
  78810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78811. */
  78812. static readonly ACTION_OnPointerOutTrigger: number;
  78813. /**
  78814. * On every frame
  78815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78816. */
  78817. static readonly ACTION_OnEveryFrameTrigger: number;
  78818. /**
  78819. * On intersection enter
  78820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78821. */
  78822. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78823. /**
  78824. * On intersection exit
  78825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78826. */
  78827. static readonly ACTION_OnIntersectionExitTrigger: number;
  78828. /**
  78829. * On key down
  78830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78831. */
  78832. static readonly ACTION_OnKeyDownTrigger: number;
  78833. /**
  78834. * On key up
  78835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78836. */
  78837. static readonly ACTION_OnKeyUpTrigger: number;
  78838. /**
  78839. * Billboard mode will only apply to Y axis
  78840. */
  78841. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78842. /**
  78843. * Billboard mode will apply to all axes
  78844. */
  78845. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78846. /**
  78847. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78848. */
  78849. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78850. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78851. * Test order :
  78852. * Is the bounding sphere outside the frustum ?
  78853. * If not, are the bounding box vertices outside the frustum ?
  78854. * It not, then the cullable object is in the frustum.
  78855. */
  78856. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78857. /** Culling strategy : Bounding Sphere Only.
  78858. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78859. * It's also less accurate than the standard because some not visible objects can still be selected.
  78860. * Test : is the bounding sphere outside the frustum ?
  78861. * If not, then the cullable object is in the frustum.
  78862. */
  78863. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78864. /** Culling strategy : Optimistic Inclusion.
  78865. * This in an inclusion test first, then the standard exclusion test.
  78866. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78867. * 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.
  78868. * Anyway, it's as accurate as the standard strategy.
  78869. * Test :
  78870. * Is the cullable object bounding sphere center in the frustum ?
  78871. * If not, apply the default culling strategy.
  78872. */
  78873. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78874. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78875. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78876. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78877. * 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.
  78878. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78879. * Test :
  78880. * Is the cullable object bounding sphere center in the frustum ?
  78881. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78882. */
  78883. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78884. /**
  78885. * No logging while loading
  78886. */
  78887. static readonly SCENELOADER_NO_LOGGING: number;
  78888. /**
  78889. * Minimal logging while loading
  78890. */
  78891. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78892. /**
  78893. * Summary logging while loading
  78894. */
  78895. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78896. /**
  78897. * Detailled logging while loading
  78898. */
  78899. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78900. }
  78901. }
  78902. declare module BABYLON {
  78903. /**
  78904. * This represents the required contract to create a new type of texture loader.
  78905. */
  78906. export interface IInternalTextureLoader {
  78907. /**
  78908. * Defines wether the loader supports cascade loading the different faces.
  78909. */
  78910. supportCascades: boolean;
  78911. /**
  78912. * This returns if the loader support the current file information.
  78913. * @param extension defines the file extension of the file being loaded
  78914. * @param mimeType defines the optional mime type of the file being loaded
  78915. * @returns true if the loader can load the specified file
  78916. */
  78917. canLoad(extension: string, mimeType?: string): boolean;
  78918. /**
  78919. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78920. * @param data contains the texture data
  78921. * @param texture defines the BabylonJS internal texture
  78922. * @param createPolynomials will be true if polynomials have been requested
  78923. * @param onLoad defines the callback to trigger once the texture is ready
  78924. * @param onError defines the callback to trigger in case of error
  78925. */
  78926. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78927. /**
  78928. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78929. * @param data contains the texture data
  78930. * @param texture defines the BabylonJS internal texture
  78931. * @param callback defines the method to call once ready to upload
  78932. */
  78933. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78934. }
  78935. }
  78936. declare module BABYLON {
  78937. /**
  78938. * Class used to store and describe the pipeline context associated with an effect
  78939. */
  78940. export interface IPipelineContext {
  78941. /**
  78942. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78943. */
  78944. isAsync: boolean;
  78945. /**
  78946. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78947. */
  78948. isReady: boolean;
  78949. /** @hidden */
  78950. _getVertexShaderCode(): string | null;
  78951. /** @hidden */
  78952. _getFragmentShaderCode(): string | null;
  78953. /** @hidden */
  78954. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78955. }
  78956. }
  78957. declare module BABYLON {
  78958. /**
  78959. * Class used to store gfx data (like WebGLBuffer)
  78960. */
  78961. export class DataBuffer {
  78962. /**
  78963. * Gets or sets the number of objects referencing this buffer
  78964. */
  78965. references: number;
  78966. /** Gets or sets the size of the underlying buffer */
  78967. capacity: number;
  78968. /**
  78969. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78970. */
  78971. is32Bits: boolean;
  78972. /**
  78973. * Gets the underlying buffer
  78974. */
  78975. get underlyingResource(): any;
  78976. }
  78977. }
  78978. declare module BABYLON {
  78979. /** @hidden */
  78980. export interface IShaderProcessor {
  78981. attributeProcessor?: (attribute: string) => string;
  78982. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78983. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78984. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78985. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78986. lineProcessor?: (line: string, isFragment: boolean) => string;
  78987. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78988. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78989. }
  78990. }
  78991. declare module BABYLON {
  78992. /** @hidden */
  78993. export interface ProcessingOptions {
  78994. defines: string[];
  78995. indexParameters: any;
  78996. isFragment: boolean;
  78997. shouldUseHighPrecisionShader: boolean;
  78998. supportsUniformBuffers: boolean;
  78999. shadersRepository: string;
  79000. includesShadersStore: {
  79001. [key: string]: string;
  79002. };
  79003. processor?: IShaderProcessor;
  79004. version: string;
  79005. platformName: string;
  79006. lookForClosingBracketForUniformBuffer?: boolean;
  79007. }
  79008. }
  79009. declare module BABYLON {
  79010. /** @hidden */
  79011. export class ShaderCodeNode {
  79012. line: string;
  79013. children: ShaderCodeNode[];
  79014. additionalDefineKey?: string;
  79015. additionalDefineValue?: string;
  79016. isValid(preprocessors: {
  79017. [key: string]: string;
  79018. }): boolean;
  79019. process(preprocessors: {
  79020. [key: string]: string;
  79021. }, options: ProcessingOptions): string;
  79022. }
  79023. }
  79024. declare module BABYLON {
  79025. /** @hidden */
  79026. export class ShaderCodeCursor {
  79027. private _lines;
  79028. lineIndex: number;
  79029. get currentLine(): string;
  79030. get canRead(): boolean;
  79031. set lines(value: string[]);
  79032. }
  79033. }
  79034. declare module BABYLON {
  79035. /** @hidden */
  79036. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79037. process(preprocessors: {
  79038. [key: string]: string;
  79039. }, options: ProcessingOptions): string;
  79040. }
  79041. }
  79042. declare module BABYLON {
  79043. /** @hidden */
  79044. export class ShaderDefineExpression {
  79045. isTrue(preprocessors: {
  79046. [key: string]: string;
  79047. }): boolean;
  79048. private static _OperatorPriority;
  79049. private static _Stack;
  79050. static postfixToInfix(postfix: string[]): string;
  79051. static infixToPostfix(infix: string): string[];
  79052. }
  79053. }
  79054. declare module BABYLON {
  79055. /** @hidden */
  79056. export class ShaderCodeTestNode extends ShaderCodeNode {
  79057. testExpression: ShaderDefineExpression;
  79058. isValid(preprocessors: {
  79059. [key: string]: string;
  79060. }): boolean;
  79061. }
  79062. }
  79063. declare module BABYLON {
  79064. /** @hidden */
  79065. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79066. define: string;
  79067. not: boolean;
  79068. constructor(define: string, not?: boolean);
  79069. isTrue(preprocessors: {
  79070. [key: string]: string;
  79071. }): boolean;
  79072. }
  79073. }
  79074. declare module BABYLON {
  79075. /** @hidden */
  79076. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79077. leftOperand: ShaderDefineExpression;
  79078. rightOperand: ShaderDefineExpression;
  79079. isTrue(preprocessors: {
  79080. [key: string]: string;
  79081. }): boolean;
  79082. }
  79083. }
  79084. declare module BABYLON {
  79085. /** @hidden */
  79086. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79087. leftOperand: ShaderDefineExpression;
  79088. rightOperand: ShaderDefineExpression;
  79089. isTrue(preprocessors: {
  79090. [key: string]: string;
  79091. }): boolean;
  79092. }
  79093. }
  79094. declare module BABYLON {
  79095. /** @hidden */
  79096. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79097. define: string;
  79098. operand: string;
  79099. testValue: string;
  79100. constructor(define: string, operand: string, testValue: string);
  79101. isTrue(preprocessors: {
  79102. [key: string]: string;
  79103. }): boolean;
  79104. }
  79105. }
  79106. declare module BABYLON {
  79107. /**
  79108. * Class used to enable access to offline support
  79109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79110. */
  79111. export interface IOfflineProvider {
  79112. /**
  79113. * Gets a boolean indicating if scene must be saved in the database
  79114. */
  79115. enableSceneOffline: boolean;
  79116. /**
  79117. * Gets a boolean indicating if textures must be saved in the database
  79118. */
  79119. enableTexturesOffline: boolean;
  79120. /**
  79121. * Open the offline support and make it available
  79122. * @param successCallback defines the callback to call on success
  79123. * @param errorCallback defines the callback to call on error
  79124. */
  79125. open(successCallback: () => void, errorCallback: () => void): void;
  79126. /**
  79127. * Loads an image from the offline support
  79128. * @param url defines the url to load from
  79129. * @param image defines the target DOM image
  79130. */
  79131. loadImage(url: string, image: HTMLImageElement): void;
  79132. /**
  79133. * Loads a file from offline support
  79134. * @param url defines the URL to load from
  79135. * @param sceneLoaded defines a callback to call on success
  79136. * @param progressCallBack defines a callback to call when progress changed
  79137. * @param errorCallback defines a callback to call on error
  79138. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79139. */
  79140. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79141. }
  79142. }
  79143. declare module BABYLON {
  79144. /**
  79145. * Class used to help managing file picking and drag'n'drop
  79146. * File Storage
  79147. */
  79148. export class FilesInputStore {
  79149. /**
  79150. * List of files ready to be loaded
  79151. */
  79152. static FilesToLoad: {
  79153. [key: string]: File;
  79154. };
  79155. }
  79156. }
  79157. declare module BABYLON {
  79158. /**
  79159. * Class used to define a retry strategy when error happens while loading assets
  79160. */
  79161. export class RetryStrategy {
  79162. /**
  79163. * Function used to defines an exponential back off strategy
  79164. * @param maxRetries defines the maximum number of retries (3 by default)
  79165. * @param baseInterval defines the interval between retries
  79166. * @returns the strategy function to use
  79167. */
  79168. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79169. }
  79170. }
  79171. declare module BABYLON {
  79172. /**
  79173. * @ignore
  79174. * Application error to support additional information when loading a file
  79175. */
  79176. export abstract class BaseError extends Error {
  79177. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79178. }
  79179. }
  79180. declare module BABYLON {
  79181. /** @ignore */
  79182. export class LoadFileError extends BaseError {
  79183. request?: WebRequest;
  79184. file?: File;
  79185. /**
  79186. * Creates a new LoadFileError
  79187. * @param message defines the message of the error
  79188. * @param request defines the optional web request
  79189. * @param file defines the optional file
  79190. */
  79191. constructor(message: string, object?: WebRequest | File);
  79192. }
  79193. /** @ignore */
  79194. export class RequestFileError extends BaseError {
  79195. request: WebRequest;
  79196. /**
  79197. * Creates a new LoadFileError
  79198. * @param message defines the message of the error
  79199. * @param request defines the optional web request
  79200. */
  79201. constructor(message: string, request: WebRequest);
  79202. }
  79203. /** @ignore */
  79204. export class ReadFileError extends BaseError {
  79205. file: File;
  79206. /**
  79207. * Creates a new ReadFileError
  79208. * @param message defines the message of the error
  79209. * @param file defines the optional file
  79210. */
  79211. constructor(message: string, file: File);
  79212. }
  79213. /**
  79214. * @hidden
  79215. */
  79216. export class FileTools {
  79217. /**
  79218. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79219. */
  79220. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79221. /**
  79222. * Gets or sets the base URL to use to load assets
  79223. */
  79224. static BaseUrl: string;
  79225. /**
  79226. * Default behaviour for cors in the application.
  79227. * It can be a string if the expected behavior is identical in the entire app.
  79228. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79229. */
  79230. static CorsBehavior: string | ((url: string | string[]) => string);
  79231. /**
  79232. * Gets or sets a function used to pre-process url before using them to load assets
  79233. */
  79234. static PreprocessUrl: (url: string) => string;
  79235. /**
  79236. * Removes unwanted characters from an url
  79237. * @param url defines the url to clean
  79238. * @returns the cleaned url
  79239. */
  79240. private static _CleanUrl;
  79241. /**
  79242. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79243. * @param url define the url we are trying
  79244. * @param element define the dom element where to configure the cors policy
  79245. */
  79246. static SetCorsBehavior(url: string | string[], element: {
  79247. crossOrigin: string | null;
  79248. }): void;
  79249. /**
  79250. * Loads an image as an HTMLImageElement.
  79251. * @param input url string, ArrayBuffer, or Blob to load
  79252. * @param onLoad callback called when the image successfully loads
  79253. * @param onError callback called when the image fails to load
  79254. * @param offlineProvider offline provider for caching
  79255. * @param mimeType optional mime type
  79256. * @returns the HTMLImageElement of the loaded image
  79257. */
  79258. 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>;
  79259. /**
  79260. * Reads a file from a File object
  79261. * @param file defines the file to load
  79262. * @param onSuccess defines the callback to call when data is loaded
  79263. * @param onProgress defines the callback to call during loading process
  79264. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79265. * @param onError defines the callback to call when an error occurs
  79266. * @returns a file request object
  79267. */
  79268. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79269. /**
  79270. * Loads a file from a url
  79271. * @param url url to load
  79272. * @param onSuccess callback called when the file successfully loads
  79273. * @param onProgress callback called while file is loading (if the server supports this mode)
  79274. * @param offlineProvider defines the offline provider for caching
  79275. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79276. * @param onError callback called when the file fails to load
  79277. * @returns a file request object
  79278. */
  79279. 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;
  79280. /**
  79281. * Loads a file
  79282. * @param url url to load
  79283. * @param onSuccess callback called when the file successfully loads
  79284. * @param onProgress callback called while file is loading (if the server supports this mode)
  79285. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79286. * @param onError callback called when the file fails to load
  79287. * @param onOpened callback called when the web request is opened
  79288. * @returns a file request object
  79289. */
  79290. 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;
  79291. /**
  79292. * Checks if the loaded document was accessed via `file:`-Protocol.
  79293. * @returns boolean
  79294. */
  79295. static IsFileURL(): boolean;
  79296. }
  79297. }
  79298. declare module BABYLON {
  79299. /** @hidden */
  79300. export class ShaderProcessor {
  79301. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79302. private static _ProcessPrecision;
  79303. private static _ExtractOperation;
  79304. private static _BuildSubExpression;
  79305. private static _BuildExpression;
  79306. private static _MoveCursorWithinIf;
  79307. private static _MoveCursor;
  79308. private static _EvaluatePreProcessors;
  79309. private static _PreparePreProcessors;
  79310. private static _ProcessShaderConversion;
  79311. private static _ProcessIncludes;
  79312. /**
  79313. * Loads a file from a url
  79314. * @param url url to load
  79315. * @param onSuccess callback called when the file successfully loads
  79316. * @param onProgress callback called while file is loading (if the server supports this mode)
  79317. * @param offlineProvider defines the offline provider for caching
  79318. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79319. * @param onError callback called when the file fails to load
  79320. * @returns a file request object
  79321. * @hidden
  79322. */
  79323. 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;
  79324. }
  79325. }
  79326. declare module BABYLON {
  79327. /**
  79328. * @hidden
  79329. */
  79330. export interface IColor4Like {
  79331. r: float;
  79332. g: float;
  79333. b: float;
  79334. a: float;
  79335. }
  79336. /**
  79337. * @hidden
  79338. */
  79339. export interface IColor3Like {
  79340. r: float;
  79341. g: float;
  79342. b: float;
  79343. }
  79344. /**
  79345. * @hidden
  79346. */
  79347. export interface IVector4Like {
  79348. x: float;
  79349. y: float;
  79350. z: float;
  79351. w: float;
  79352. }
  79353. /**
  79354. * @hidden
  79355. */
  79356. export interface IVector3Like {
  79357. x: float;
  79358. y: float;
  79359. z: float;
  79360. }
  79361. /**
  79362. * @hidden
  79363. */
  79364. export interface IVector2Like {
  79365. x: float;
  79366. y: float;
  79367. }
  79368. /**
  79369. * @hidden
  79370. */
  79371. export interface IMatrixLike {
  79372. toArray(): DeepImmutable<Float32Array>;
  79373. updateFlag: int;
  79374. }
  79375. /**
  79376. * @hidden
  79377. */
  79378. export interface IViewportLike {
  79379. x: float;
  79380. y: float;
  79381. width: float;
  79382. height: float;
  79383. }
  79384. /**
  79385. * @hidden
  79386. */
  79387. export interface IPlaneLike {
  79388. normal: IVector3Like;
  79389. d: float;
  79390. normalize(): void;
  79391. }
  79392. }
  79393. declare module BABYLON {
  79394. /**
  79395. * Interface used to define common properties for effect fallbacks
  79396. */
  79397. export interface IEffectFallbacks {
  79398. /**
  79399. * Removes the defines that should be removed when falling back.
  79400. * @param currentDefines defines the current define statements for the shader.
  79401. * @param effect defines the current effect we try to compile
  79402. * @returns The resulting defines with defines of the current rank removed.
  79403. */
  79404. reduce(currentDefines: string, effect: Effect): string;
  79405. /**
  79406. * Removes the fallback from the bound mesh.
  79407. */
  79408. unBindMesh(): void;
  79409. /**
  79410. * Checks to see if more fallbacks are still availible.
  79411. */
  79412. hasMoreFallbacks: boolean;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * Class used to evalaute queries containing `and` and `or` operators
  79418. */
  79419. export class AndOrNotEvaluator {
  79420. /**
  79421. * Evaluate a query
  79422. * @param query defines the query to evaluate
  79423. * @param evaluateCallback defines the callback used to filter result
  79424. * @returns true if the query matches
  79425. */
  79426. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79427. private static _HandleParenthesisContent;
  79428. private static _SimplifyNegation;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * Class used to store custom tags
  79434. */
  79435. export class Tags {
  79436. /**
  79437. * Adds support for tags on the given object
  79438. * @param obj defines the object to use
  79439. */
  79440. static EnableFor(obj: any): void;
  79441. /**
  79442. * Removes tags support
  79443. * @param obj defines the object to use
  79444. */
  79445. static DisableFor(obj: any): void;
  79446. /**
  79447. * Gets a boolean indicating if the given object has tags
  79448. * @param obj defines the object to use
  79449. * @returns a boolean
  79450. */
  79451. static HasTags(obj: any): boolean;
  79452. /**
  79453. * Gets the tags available on a given object
  79454. * @param obj defines the object to use
  79455. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79456. * @returns the tags
  79457. */
  79458. static GetTags(obj: any, asString?: boolean): any;
  79459. /**
  79460. * Adds tags to an object
  79461. * @param obj defines the object to use
  79462. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79463. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79464. */
  79465. static AddTagsTo(obj: any, tagsString: string): void;
  79466. /**
  79467. * @hidden
  79468. */
  79469. static _AddTagTo(obj: any, tag: string): void;
  79470. /**
  79471. * Removes specific tags from a specific object
  79472. * @param obj defines the object to use
  79473. * @param tagsString defines the tags to remove
  79474. */
  79475. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79476. /**
  79477. * @hidden
  79478. */
  79479. static _RemoveTagFrom(obj: any, tag: string): void;
  79480. /**
  79481. * Defines if tags hosted on an object match a given query
  79482. * @param obj defines the object to use
  79483. * @param tagsQuery defines the tag query
  79484. * @returns a boolean
  79485. */
  79486. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79487. }
  79488. }
  79489. declare module BABYLON {
  79490. /**
  79491. * Scalar computation library
  79492. */
  79493. export class Scalar {
  79494. /**
  79495. * Two pi constants convenient for computation.
  79496. */
  79497. static TwoPi: number;
  79498. /**
  79499. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79500. * @param a number
  79501. * @param b number
  79502. * @param epsilon (default = 1.401298E-45)
  79503. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79504. */
  79505. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79506. /**
  79507. * Returns a string : the upper case translation of the number i to hexadecimal.
  79508. * @param i number
  79509. * @returns the upper case translation of the number i to hexadecimal.
  79510. */
  79511. static ToHex(i: number): string;
  79512. /**
  79513. * Returns -1 if value is negative and +1 is value is positive.
  79514. * @param value the value
  79515. * @returns the value itself if it's equal to zero.
  79516. */
  79517. static Sign(value: number): number;
  79518. /**
  79519. * Returns the value itself if it's between min and max.
  79520. * Returns min if the value is lower than min.
  79521. * Returns max if the value is greater than max.
  79522. * @param value the value to clmap
  79523. * @param min the min value to clamp to (default: 0)
  79524. * @param max the max value to clamp to (default: 1)
  79525. * @returns the clamped value
  79526. */
  79527. static Clamp(value: number, min?: number, max?: number): number;
  79528. /**
  79529. * the log2 of value.
  79530. * @param value the value to compute log2 of
  79531. * @returns the log2 of value.
  79532. */
  79533. static Log2(value: number): number;
  79534. /**
  79535. * Loops the value, so that it is never larger than length and never smaller than 0.
  79536. *
  79537. * This is similar to the modulo operator but it works with floating point numbers.
  79538. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79539. * With t = 5 and length = 2.5, the result would be 0.0.
  79540. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79541. * @param value the value
  79542. * @param length the length
  79543. * @returns the looped value
  79544. */
  79545. static Repeat(value: number, length: number): number;
  79546. /**
  79547. * Normalize the value between 0.0 and 1.0 using min and max values
  79548. * @param value value to normalize
  79549. * @param min max to normalize between
  79550. * @param max min to normalize between
  79551. * @returns the normalized value
  79552. */
  79553. static Normalize(value: number, min: number, max: number): number;
  79554. /**
  79555. * Denormalize the value from 0.0 and 1.0 using min and max values
  79556. * @param normalized value to denormalize
  79557. * @param min max to denormalize between
  79558. * @param max min to denormalize between
  79559. * @returns the denormalized value
  79560. */
  79561. static Denormalize(normalized: number, min: number, max: number): number;
  79562. /**
  79563. * Calculates the shortest difference between two given angles given in degrees.
  79564. * @param current current angle in degrees
  79565. * @param target target angle in degrees
  79566. * @returns the delta
  79567. */
  79568. static DeltaAngle(current: number, target: number): number;
  79569. /**
  79570. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79571. * @param tx value
  79572. * @param length length
  79573. * @returns The returned value will move back and forth between 0 and length
  79574. */
  79575. static PingPong(tx: number, length: number): number;
  79576. /**
  79577. * Interpolates between min and max with smoothing at the limits.
  79578. *
  79579. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79580. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79581. * @param from from
  79582. * @param to to
  79583. * @param tx value
  79584. * @returns the smooth stepped value
  79585. */
  79586. static SmoothStep(from: number, to: number, tx: number): number;
  79587. /**
  79588. * Moves a value current towards target.
  79589. *
  79590. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79591. * Negative values of maxDelta pushes the value away from target.
  79592. * @param current current value
  79593. * @param target target value
  79594. * @param maxDelta max distance to move
  79595. * @returns resulting value
  79596. */
  79597. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79598. /**
  79599. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79600. *
  79601. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79602. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79603. * @param current current value
  79604. * @param target target value
  79605. * @param maxDelta max distance to move
  79606. * @returns resulting angle
  79607. */
  79608. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79609. /**
  79610. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79611. * @param start start value
  79612. * @param end target value
  79613. * @param amount amount to lerp between
  79614. * @returns the lerped value
  79615. */
  79616. static Lerp(start: number, end: number, amount: number): number;
  79617. /**
  79618. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79619. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79620. * @param start start value
  79621. * @param end target value
  79622. * @param amount amount to lerp between
  79623. * @returns the lerped value
  79624. */
  79625. static LerpAngle(start: number, end: number, amount: number): number;
  79626. /**
  79627. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79628. * @param a start value
  79629. * @param b target value
  79630. * @param value value between a and b
  79631. * @returns the inverseLerp value
  79632. */
  79633. static InverseLerp(a: number, b: number, value: number): number;
  79634. /**
  79635. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79636. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79637. * @param value1 spline value
  79638. * @param tangent1 spline value
  79639. * @param value2 spline value
  79640. * @param tangent2 spline value
  79641. * @param amount input value
  79642. * @returns hermite result
  79643. */
  79644. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79645. /**
  79646. * Returns a random float number between and min and max values
  79647. * @param min min value of random
  79648. * @param max max value of random
  79649. * @returns random value
  79650. */
  79651. static RandomRange(min: number, max: number): number;
  79652. /**
  79653. * This function returns percentage of a number in a given range.
  79654. *
  79655. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79656. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79657. * @param number to convert to percentage
  79658. * @param min min range
  79659. * @param max max range
  79660. * @returns the percentage
  79661. */
  79662. static RangeToPercent(number: number, min: number, max: number): number;
  79663. /**
  79664. * This function returns number that corresponds to the percentage in a given range.
  79665. *
  79666. * PercentToRange(0.34,0,100) will return 34.
  79667. * @param percent to convert to number
  79668. * @param min min range
  79669. * @param max max range
  79670. * @returns the number
  79671. */
  79672. static PercentToRange(percent: number, min: number, max: number): number;
  79673. /**
  79674. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79675. * @param angle The angle to normalize in radian.
  79676. * @return The converted angle.
  79677. */
  79678. static NormalizeRadians(angle: number): number;
  79679. }
  79680. }
  79681. declare module BABYLON {
  79682. /**
  79683. * Constant used to convert a value to gamma space
  79684. * @ignorenaming
  79685. */
  79686. export const ToGammaSpace: number;
  79687. /**
  79688. * Constant used to convert a value to linear space
  79689. * @ignorenaming
  79690. */
  79691. export const ToLinearSpace = 2.2;
  79692. /**
  79693. * Constant used to define the minimal number value in Babylon.js
  79694. * @ignorenaming
  79695. */
  79696. let Epsilon: number;
  79697. }
  79698. declare module BABYLON {
  79699. /**
  79700. * Class used to represent a viewport on screen
  79701. */
  79702. export class Viewport {
  79703. /** viewport left coordinate */
  79704. x: number;
  79705. /** viewport top coordinate */
  79706. y: number;
  79707. /**viewport width */
  79708. width: number;
  79709. /** viewport height */
  79710. height: number;
  79711. /**
  79712. * Creates a Viewport object located at (x, y) and sized (width, height)
  79713. * @param x defines viewport left coordinate
  79714. * @param y defines viewport top coordinate
  79715. * @param width defines the viewport width
  79716. * @param height defines the viewport height
  79717. */
  79718. constructor(
  79719. /** viewport left coordinate */
  79720. x: number,
  79721. /** viewport top coordinate */
  79722. y: number,
  79723. /**viewport width */
  79724. width: number,
  79725. /** viewport height */
  79726. height: number);
  79727. /**
  79728. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79729. * @param renderWidth defines the rendering width
  79730. * @param renderHeight defines the rendering height
  79731. * @returns a new Viewport
  79732. */
  79733. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79734. /**
  79735. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79736. * @param renderWidth defines the rendering width
  79737. * @param renderHeight defines the rendering height
  79738. * @param ref defines the target viewport
  79739. * @returns the current viewport
  79740. */
  79741. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79742. /**
  79743. * Returns a new Viewport copied from the current one
  79744. * @returns a new Viewport
  79745. */
  79746. clone(): Viewport;
  79747. }
  79748. }
  79749. declare module BABYLON {
  79750. /**
  79751. * Class containing a set of static utilities functions for arrays.
  79752. */
  79753. export class ArrayTools {
  79754. /**
  79755. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79756. * @param size the number of element to construct and put in the array
  79757. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79758. * @returns a new array filled with new objects
  79759. */
  79760. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79761. }
  79762. }
  79763. declare module BABYLON {
  79764. /**
  79765. * Represents a plane by the equation ax + by + cz + d = 0
  79766. */
  79767. export class Plane {
  79768. private static _TmpMatrix;
  79769. /**
  79770. * Normal of the plane (a,b,c)
  79771. */
  79772. normal: Vector3;
  79773. /**
  79774. * d component of the plane
  79775. */
  79776. d: number;
  79777. /**
  79778. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79779. * @param a a component of the plane
  79780. * @param b b component of the plane
  79781. * @param c c component of the plane
  79782. * @param d d component of the plane
  79783. */
  79784. constructor(a: number, b: number, c: number, d: number);
  79785. /**
  79786. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79787. */
  79788. asArray(): number[];
  79789. /**
  79790. * @returns a new plane copied from the current Plane.
  79791. */
  79792. clone(): Plane;
  79793. /**
  79794. * @returns the string "Plane".
  79795. */
  79796. getClassName(): string;
  79797. /**
  79798. * @returns the Plane hash code.
  79799. */
  79800. getHashCode(): number;
  79801. /**
  79802. * Normalize the current Plane in place.
  79803. * @returns the updated Plane.
  79804. */
  79805. normalize(): Plane;
  79806. /**
  79807. * Applies a transformation the plane and returns the result
  79808. * @param transformation the transformation matrix to be applied to the plane
  79809. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79810. */
  79811. transform(transformation: DeepImmutable<Matrix>): Plane;
  79812. /**
  79813. * Compute the dot product between the point and the plane normal
  79814. * @param point point to calculate the dot product with
  79815. * @returns the dot product (float) of the point coordinates and the plane normal.
  79816. */
  79817. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79818. /**
  79819. * Updates the current Plane from the plane defined by the three given points.
  79820. * @param point1 one of the points used to contruct the plane
  79821. * @param point2 one of the points used to contruct the plane
  79822. * @param point3 one of the points used to contruct the plane
  79823. * @returns the updated Plane.
  79824. */
  79825. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79826. /**
  79827. * Checks if the plane is facing a given direction
  79828. * @param direction the direction to check if the plane is facing
  79829. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79830. * @returns True is the vector "direction" is the same side than the plane normal.
  79831. */
  79832. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79833. /**
  79834. * Calculates the distance to a point
  79835. * @param point point to calculate distance to
  79836. * @returns the signed distance (float) from the given point to the Plane.
  79837. */
  79838. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79839. /**
  79840. * Creates a plane from an array
  79841. * @param array the array to create a plane from
  79842. * @returns a new Plane from the given array.
  79843. */
  79844. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79845. /**
  79846. * Creates a plane from three points
  79847. * @param point1 point used to create the plane
  79848. * @param point2 point used to create the plane
  79849. * @param point3 point used to create the plane
  79850. * @returns a new Plane defined by the three given points.
  79851. */
  79852. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79853. /**
  79854. * Creates a plane from an origin point and a normal
  79855. * @param origin origin of the plane to be constructed
  79856. * @param normal normal of the plane to be constructed
  79857. * @returns a new Plane the normal vector to this plane at the given origin point.
  79858. * Note : the vector "normal" is updated because normalized.
  79859. */
  79860. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  79861. /**
  79862. * Calculates the distance from a plane and a point
  79863. * @param origin origin of the plane to be constructed
  79864. * @param normal normal of the plane to be constructed
  79865. * @param point point to calculate distance to
  79866. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79867. */
  79868. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79869. }
  79870. }
  79871. declare module BABYLON {
  79872. /**
  79873. * Class representing a vector containing 2 coordinates
  79874. */
  79875. export class Vector2 {
  79876. /** defines the first coordinate */
  79877. x: number;
  79878. /** defines the second coordinate */
  79879. y: number;
  79880. /**
  79881. * Creates a new Vector2 from the given x and y coordinates
  79882. * @param x defines the first coordinate
  79883. * @param y defines the second coordinate
  79884. */
  79885. constructor(
  79886. /** defines the first coordinate */
  79887. x?: number,
  79888. /** defines the second coordinate */
  79889. y?: number);
  79890. /**
  79891. * Gets a string with the Vector2 coordinates
  79892. * @returns a string with the Vector2 coordinates
  79893. */
  79894. toString(): string;
  79895. /**
  79896. * Gets class name
  79897. * @returns the string "Vector2"
  79898. */
  79899. getClassName(): string;
  79900. /**
  79901. * Gets current vector hash code
  79902. * @returns the Vector2 hash code as a number
  79903. */
  79904. getHashCode(): number;
  79905. /**
  79906. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79907. * @param array defines the source array
  79908. * @param index defines the offset in source array
  79909. * @returns the current Vector2
  79910. */
  79911. toArray(array: FloatArray, index?: number): Vector2;
  79912. /**
  79913. * Copy the current vector to an array
  79914. * @returns a new array with 2 elements: the Vector2 coordinates.
  79915. */
  79916. asArray(): number[];
  79917. /**
  79918. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79919. * @param source defines the source Vector2
  79920. * @returns the current updated Vector2
  79921. */
  79922. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79923. /**
  79924. * Sets the Vector2 coordinates with the given floats
  79925. * @param x defines the first coordinate
  79926. * @param y defines the second coordinate
  79927. * @returns the current updated Vector2
  79928. */
  79929. copyFromFloats(x: number, y: number): Vector2;
  79930. /**
  79931. * Sets the Vector2 coordinates with the given floats
  79932. * @param x defines the first coordinate
  79933. * @param y defines the second coordinate
  79934. * @returns the current updated Vector2
  79935. */
  79936. set(x: number, y: number): Vector2;
  79937. /**
  79938. * Add another vector with the current one
  79939. * @param otherVector defines the other vector
  79940. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79941. */
  79942. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79943. /**
  79944. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79945. * @param otherVector defines the other vector
  79946. * @param result defines the target vector
  79947. * @returns the unmodified current Vector2
  79948. */
  79949. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79950. /**
  79951. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79952. * @param otherVector defines the other vector
  79953. * @returns the current updated Vector2
  79954. */
  79955. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79956. /**
  79957. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79958. * @param otherVector defines the other vector
  79959. * @returns a new Vector2
  79960. */
  79961. addVector3(otherVector: Vector3): Vector2;
  79962. /**
  79963. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79964. * @param otherVector defines the other vector
  79965. * @returns a new Vector2
  79966. */
  79967. subtract(otherVector: Vector2): Vector2;
  79968. /**
  79969. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79970. * @param otherVector defines the other vector
  79971. * @param result defines the target vector
  79972. * @returns the unmodified current Vector2
  79973. */
  79974. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79975. /**
  79976. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79977. * @param otherVector defines the other vector
  79978. * @returns the current updated Vector2
  79979. */
  79980. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79981. /**
  79982. * Multiplies in place the current Vector2 coordinates by the given ones
  79983. * @param otherVector defines the other vector
  79984. * @returns the current updated Vector2
  79985. */
  79986. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79987. /**
  79988. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79989. * @param otherVector defines the other vector
  79990. * @returns a new Vector2
  79991. */
  79992. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79993. /**
  79994. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79995. * @param otherVector defines the other vector
  79996. * @param result defines the target vector
  79997. * @returns the unmodified current Vector2
  79998. */
  79999. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80000. /**
  80001. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80002. * @param x defines the first coordinate
  80003. * @param y defines the second coordinate
  80004. * @returns a new Vector2
  80005. */
  80006. multiplyByFloats(x: number, y: number): Vector2;
  80007. /**
  80008. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80009. * @param otherVector defines the other vector
  80010. * @returns a new Vector2
  80011. */
  80012. divide(otherVector: Vector2): Vector2;
  80013. /**
  80014. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80015. * @param otherVector defines the other vector
  80016. * @param result defines the target vector
  80017. * @returns the unmodified current Vector2
  80018. */
  80019. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80020. /**
  80021. * Divides the current Vector2 coordinates by the given ones
  80022. * @param otherVector defines the other vector
  80023. * @returns the current updated Vector2
  80024. */
  80025. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80026. /**
  80027. * Gets a new Vector2 with current Vector2 negated coordinates
  80028. * @returns a new Vector2
  80029. */
  80030. negate(): Vector2;
  80031. /**
  80032. * Negate this vector in place
  80033. * @returns this
  80034. */
  80035. negateInPlace(): Vector2;
  80036. /**
  80037. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80038. * @param result defines the Vector3 object where to store the result
  80039. * @returns the current Vector2
  80040. */
  80041. negateToRef(result: Vector2): Vector2;
  80042. /**
  80043. * Multiply the Vector2 coordinates by scale
  80044. * @param scale defines the scaling factor
  80045. * @returns the current updated Vector2
  80046. */
  80047. scaleInPlace(scale: number): Vector2;
  80048. /**
  80049. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80050. * @param scale defines the scaling factor
  80051. * @returns a new Vector2
  80052. */
  80053. scale(scale: number): Vector2;
  80054. /**
  80055. * Scale the current Vector2 values by a factor to a given Vector2
  80056. * @param scale defines the scale factor
  80057. * @param result defines the Vector2 object where to store the result
  80058. * @returns the unmodified current Vector2
  80059. */
  80060. scaleToRef(scale: number, result: Vector2): Vector2;
  80061. /**
  80062. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80063. * @param scale defines the scale factor
  80064. * @param result defines the Vector2 object where to store the result
  80065. * @returns the unmodified current Vector2
  80066. */
  80067. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80068. /**
  80069. * Gets a boolean if two vectors are equals
  80070. * @param otherVector defines the other vector
  80071. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80072. */
  80073. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80074. /**
  80075. * Gets a boolean if two vectors are equals (using an epsilon value)
  80076. * @param otherVector defines the other vector
  80077. * @param epsilon defines the minimal distance to consider equality
  80078. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80079. */
  80080. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80081. /**
  80082. * Gets a new Vector2 from current Vector2 floored values
  80083. * @returns a new Vector2
  80084. */
  80085. floor(): Vector2;
  80086. /**
  80087. * Gets a new Vector2 from current Vector2 floored values
  80088. * @returns a new Vector2
  80089. */
  80090. fract(): Vector2;
  80091. /**
  80092. * Gets the length of the vector
  80093. * @returns the vector length (float)
  80094. */
  80095. length(): number;
  80096. /**
  80097. * Gets the vector squared length
  80098. * @returns the vector squared length (float)
  80099. */
  80100. lengthSquared(): number;
  80101. /**
  80102. * Normalize the vector
  80103. * @returns the current updated Vector2
  80104. */
  80105. normalize(): Vector2;
  80106. /**
  80107. * Gets a new Vector2 copied from the Vector2
  80108. * @returns a new Vector2
  80109. */
  80110. clone(): Vector2;
  80111. /**
  80112. * Gets a new Vector2(0, 0)
  80113. * @returns a new Vector2
  80114. */
  80115. static Zero(): Vector2;
  80116. /**
  80117. * Gets a new Vector2(1, 1)
  80118. * @returns a new Vector2
  80119. */
  80120. static One(): Vector2;
  80121. /**
  80122. * Gets a new Vector2 set from the given index element of the given array
  80123. * @param array defines the data source
  80124. * @param offset defines the offset in the data source
  80125. * @returns a new Vector2
  80126. */
  80127. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80128. /**
  80129. * Sets "result" from the given index element of the given array
  80130. * @param array defines the data source
  80131. * @param offset defines the offset in the data source
  80132. * @param result defines the target vector
  80133. */
  80134. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80135. /**
  80136. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80137. * @param value1 defines 1st point of control
  80138. * @param value2 defines 2nd point of control
  80139. * @param value3 defines 3rd point of control
  80140. * @param value4 defines 4th point of control
  80141. * @param amount defines the interpolation factor
  80142. * @returns a new Vector2
  80143. */
  80144. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80145. /**
  80146. * 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".
  80147. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80148. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80149. * @param value defines the value to clamp
  80150. * @param min defines the lower limit
  80151. * @param max defines the upper limit
  80152. * @returns a new Vector2
  80153. */
  80154. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80155. /**
  80156. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80157. * @param value1 defines the 1st control point
  80158. * @param tangent1 defines the outgoing tangent
  80159. * @param value2 defines the 2nd control point
  80160. * @param tangent2 defines the incoming tangent
  80161. * @param amount defines the interpolation factor
  80162. * @returns a new Vector2
  80163. */
  80164. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80165. /**
  80166. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80167. * @param start defines the start vector
  80168. * @param end defines the end vector
  80169. * @param amount defines the interpolation factor
  80170. * @returns a new Vector2
  80171. */
  80172. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80173. /**
  80174. * Gets the dot product of the vector "left" and the vector "right"
  80175. * @param left defines first vector
  80176. * @param right defines second vector
  80177. * @returns the dot product (float)
  80178. */
  80179. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80180. /**
  80181. * Returns a new Vector2 equal to the normalized given vector
  80182. * @param vector defines the vector to normalize
  80183. * @returns a new Vector2
  80184. */
  80185. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80186. /**
  80187. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80188. * @param left defines 1st vector
  80189. * @param right defines 2nd vector
  80190. * @returns a new Vector2
  80191. */
  80192. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80193. /**
  80194. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80195. * @param left defines 1st vector
  80196. * @param right defines 2nd vector
  80197. * @returns a new Vector2
  80198. */
  80199. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80200. /**
  80201. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80202. * @param vector defines the vector to transform
  80203. * @param transformation defines the matrix to apply
  80204. * @returns a new Vector2
  80205. */
  80206. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80207. /**
  80208. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80209. * @param vector defines the vector to transform
  80210. * @param transformation defines the matrix to apply
  80211. * @param result defines the target vector
  80212. */
  80213. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80214. /**
  80215. * Determines if a given vector is included in a triangle
  80216. * @param p defines the vector to test
  80217. * @param p0 defines 1st triangle point
  80218. * @param p1 defines 2nd triangle point
  80219. * @param p2 defines 3rd triangle point
  80220. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80221. */
  80222. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80223. /**
  80224. * Gets the distance between the vectors "value1" and "value2"
  80225. * @param value1 defines first vector
  80226. * @param value2 defines second vector
  80227. * @returns the distance between vectors
  80228. */
  80229. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80230. /**
  80231. * Returns the squared distance between the vectors "value1" and "value2"
  80232. * @param value1 defines first vector
  80233. * @param value2 defines second vector
  80234. * @returns the squared distance between vectors
  80235. */
  80236. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80237. /**
  80238. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80239. * @param value1 defines first vector
  80240. * @param value2 defines second vector
  80241. * @returns a new Vector2
  80242. */
  80243. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80244. /**
  80245. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80246. * @param p defines the middle point
  80247. * @param segA defines one point of the segment
  80248. * @param segB defines the other point of the segment
  80249. * @returns the shortest distance
  80250. */
  80251. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80252. }
  80253. /**
  80254. * Class used to store (x,y,z) vector representation
  80255. * A Vector3 is the main object used in 3D geometry
  80256. * It can represent etiher the coordinates of a point the space, either a direction
  80257. * Reminder: js uses a left handed forward facing system
  80258. */
  80259. export class Vector3 {
  80260. private static _UpReadOnly;
  80261. private static _ZeroReadOnly;
  80262. /** @hidden */
  80263. _x: number;
  80264. /** @hidden */
  80265. _y: number;
  80266. /** @hidden */
  80267. _z: number;
  80268. /** @hidden */
  80269. _isDirty: boolean;
  80270. /** Gets or sets the x coordinate */
  80271. get x(): number;
  80272. set x(value: number);
  80273. /** Gets or sets the y coordinate */
  80274. get y(): number;
  80275. set y(value: number);
  80276. /** Gets or sets the z coordinate */
  80277. get z(): number;
  80278. set z(value: number);
  80279. /**
  80280. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80281. * @param x defines the first coordinates (on X axis)
  80282. * @param y defines the second coordinates (on Y axis)
  80283. * @param z defines the third coordinates (on Z axis)
  80284. */
  80285. constructor(x?: number, y?: number, z?: number);
  80286. /**
  80287. * Creates a string representation of the Vector3
  80288. * @returns a string with the Vector3 coordinates.
  80289. */
  80290. toString(): string;
  80291. /**
  80292. * Gets the class name
  80293. * @returns the string "Vector3"
  80294. */
  80295. getClassName(): string;
  80296. /**
  80297. * Creates the Vector3 hash code
  80298. * @returns a number which tends to be unique between Vector3 instances
  80299. */
  80300. getHashCode(): number;
  80301. /**
  80302. * Creates an array containing three elements : the coordinates of the Vector3
  80303. * @returns a new array of numbers
  80304. */
  80305. asArray(): number[];
  80306. /**
  80307. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80308. * @param array defines the destination array
  80309. * @param index defines the offset in the destination array
  80310. * @returns the current Vector3
  80311. */
  80312. toArray(array: FloatArray, index?: number): Vector3;
  80313. /**
  80314. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80315. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80316. */
  80317. toQuaternion(): Quaternion;
  80318. /**
  80319. * Adds the given vector to the current Vector3
  80320. * @param otherVector defines the second operand
  80321. * @returns the current updated Vector3
  80322. */
  80323. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80324. /**
  80325. * Adds the given coordinates to the current Vector3
  80326. * @param x defines the x coordinate of the operand
  80327. * @param y defines the y coordinate of the operand
  80328. * @param z defines the z coordinate of the operand
  80329. * @returns the current updated Vector3
  80330. */
  80331. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80332. /**
  80333. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80334. * @param otherVector defines the second operand
  80335. * @returns the resulting Vector3
  80336. */
  80337. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80338. /**
  80339. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80340. * @param otherVector defines the second operand
  80341. * @param result defines the Vector3 object where to store the result
  80342. * @returns the current Vector3
  80343. */
  80344. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80345. /**
  80346. * Subtract the given vector from the current Vector3
  80347. * @param otherVector defines the second operand
  80348. * @returns the current updated Vector3
  80349. */
  80350. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80351. /**
  80352. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80353. * @param otherVector defines the second operand
  80354. * @returns the resulting Vector3
  80355. */
  80356. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80357. /**
  80358. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80359. * @param otherVector defines the second operand
  80360. * @param result defines the Vector3 object where to store the result
  80361. * @returns the current Vector3
  80362. */
  80363. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80364. /**
  80365. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80366. * @param x defines the x coordinate of the operand
  80367. * @param y defines the y coordinate of the operand
  80368. * @param z defines the z coordinate of the operand
  80369. * @returns the resulting Vector3
  80370. */
  80371. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80372. /**
  80373. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80374. * @param x defines the x coordinate of the operand
  80375. * @param y defines the y coordinate of the operand
  80376. * @param z defines the z coordinate of the operand
  80377. * @param result defines the Vector3 object where to store the result
  80378. * @returns the current Vector3
  80379. */
  80380. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80381. /**
  80382. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80383. * @returns a new Vector3
  80384. */
  80385. negate(): Vector3;
  80386. /**
  80387. * Negate this vector in place
  80388. * @returns this
  80389. */
  80390. negateInPlace(): Vector3;
  80391. /**
  80392. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80393. * @param result defines the Vector3 object where to store the result
  80394. * @returns the current Vector3
  80395. */
  80396. negateToRef(result: Vector3): Vector3;
  80397. /**
  80398. * Multiplies the Vector3 coordinates by the float "scale"
  80399. * @param scale defines the multiplier factor
  80400. * @returns the current updated Vector3
  80401. */
  80402. scaleInPlace(scale: number): Vector3;
  80403. /**
  80404. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80405. * @param scale defines the multiplier factor
  80406. * @returns a new Vector3
  80407. */
  80408. scale(scale: number): Vector3;
  80409. /**
  80410. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80411. * @param scale defines the multiplier factor
  80412. * @param result defines the Vector3 object where to store the result
  80413. * @returns the current Vector3
  80414. */
  80415. scaleToRef(scale: number, result: Vector3): Vector3;
  80416. /**
  80417. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80418. * @param scale defines the scale factor
  80419. * @param result defines the Vector3 object where to store the result
  80420. * @returns the unmodified current Vector3
  80421. */
  80422. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80423. /**
  80424. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80425. * @param origin defines the origin of the projection ray
  80426. * @param plane defines the plane to project to
  80427. * @returns the projected vector3
  80428. */
  80429. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80430. /**
  80431. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80432. * @param origin defines the origin of the projection ray
  80433. * @param plane defines the plane to project to
  80434. * @param result defines the Vector3 where to store the result
  80435. */
  80436. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80437. /**
  80438. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80439. * @param otherVector defines the second operand
  80440. * @returns true if both vectors are equals
  80441. */
  80442. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80443. /**
  80444. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80445. * @param otherVector defines the second operand
  80446. * @param epsilon defines the minimal distance to define values as equals
  80447. * @returns true if both vectors are distant less than epsilon
  80448. */
  80449. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80450. /**
  80451. * Returns true if the current Vector3 coordinates equals the given floats
  80452. * @param x defines the x coordinate of the operand
  80453. * @param y defines the y coordinate of the operand
  80454. * @param z defines the z coordinate of the operand
  80455. * @returns true if both vectors are equals
  80456. */
  80457. equalsToFloats(x: number, y: number, z: number): boolean;
  80458. /**
  80459. * Multiplies the current Vector3 coordinates by the given ones
  80460. * @param otherVector defines the second operand
  80461. * @returns the current updated Vector3
  80462. */
  80463. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80464. /**
  80465. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80466. * @param otherVector defines the second operand
  80467. * @returns the new Vector3
  80468. */
  80469. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80470. /**
  80471. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80472. * @param otherVector defines the second operand
  80473. * @param result defines the Vector3 object where to store the result
  80474. * @returns the current Vector3
  80475. */
  80476. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80477. /**
  80478. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80479. * @param x defines the x coordinate of the operand
  80480. * @param y defines the y coordinate of the operand
  80481. * @param z defines the z coordinate of the operand
  80482. * @returns the new Vector3
  80483. */
  80484. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80485. /**
  80486. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80487. * @param otherVector defines the second operand
  80488. * @returns the new Vector3
  80489. */
  80490. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80491. /**
  80492. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80493. * @param otherVector defines the second operand
  80494. * @param result defines the Vector3 object where to store the result
  80495. * @returns the current Vector3
  80496. */
  80497. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80498. /**
  80499. * Divides the current Vector3 coordinates by the given ones.
  80500. * @param otherVector defines the second operand
  80501. * @returns the current updated Vector3
  80502. */
  80503. divideInPlace(otherVector: Vector3): Vector3;
  80504. /**
  80505. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80506. * @param other defines the second operand
  80507. * @returns the current updated Vector3
  80508. */
  80509. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80510. /**
  80511. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80512. * @param other defines the second operand
  80513. * @returns the current updated Vector3
  80514. */
  80515. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80516. /**
  80517. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80518. * @param x defines the x coordinate of the operand
  80519. * @param y defines the y coordinate of the operand
  80520. * @param z defines the z coordinate of the operand
  80521. * @returns the current updated Vector3
  80522. */
  80523. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80524. /**
  80525. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80526. * @param x defines the x coordinate of the operand
  80527. * @param y defines the y coordinate of the operand
  80528. * @param z defines the z coordinate of the operand
  80529. * @returns the current updated Vector3
  80530. */
  80531. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80532. /**
  80533. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80534. * Check if is non uniform within a certain amount of decimal places to account for this
  80535. * @param epsilon the amount the values can differ
  80536. * @returns if the the vector is non uniform to a certain number of decimal places
  80537. */
  80538. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80539. /**
  80540. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80541. */
  80542. get isNonUniform(): boolean;
  80543. /**
  80544. * Gets a new Vector3 from current Vector3 floored values
  80545. * @returns a new Vector3
  80546. */
  80547. floor(): Vector3;
  80548. /**
  80549. * Gets a new Vector3 from current Vector3 floored values
  80550. * @returns a new Vector3
  80551. */
  80552. fract(): Vector3;
  80553. /**
  80554. * Gets the length of the Vector3
  80555. * @returns the length of the Vector3
  80556. */
  80557. length(): number;
  80558. /**
  80559. * Gets the squared length of the Vector3
  80560. * @returns squared length of the Vector3
  80561. */
  80562. lengthSquared(): number;
  80563. /**
  80564. * Normalize the current Vector3.
  80565. * Please note that this is an in place operation.
  80566. * @returns the current updated Vector3
  80567. */
  80568. normalize(): Vector3;
  80569. /**
  80570. * Reorders the x y z properties of the vector in place
  80571. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80572. * @returns the current updated vector
  80573. */
  80574. reorderInPlace(order: string): this;
  80575. /**
  80576. * Rotates the vector around 0,0,0 by a quaternion
  80577. * @param quaternion the rotation quaternion
  80578. * @param result vector to store the result
  80579. * @returns the resulting vector
  80580. */
  80581. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80582. /**
  80583. * Rotates a vector around a given point
  80584. * @param quaternion the rotation quaternion
  80585. * @param point the point to rotate around
  80586. * @param result vector to store the result
  80587. * @returns the resulting vector
  80588. */
  80589. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80590. /**
  80591. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80592. * The cross product is then orthogonal to both current and "other"
  80593. * @param other defines the right operand
  80594. * @returns the cross product
  80595. */
  80596. cross(other: Vector3): Vector3;
  80597. /**
  80598. * Normalize the current Vector3 with the given input length.
  80599. * Please note that this is an in place operation.
  80600. * @param len the length of the vector
  80601. * @returns the current updated Vector3
  80602. */
  80603. normalizeFromLength(len: number): Vector3;
  80604. /**
  80605. * Normalize the current Vector3 to a new vector
  80606. * @returns the new Vector3
  80607. */
  80608. normalizeToNew(): Vector3;
  80609. /**
  80610. * Normalize the current Vector3 to the reference
  80611. * @param reference define the Vector3 to update
  80612. * @returns the updated Vector3
  80613. */
  80614. normalizeToRef(reference: Vector3): Vector3;
  80615. /**
  80616. * Creates a new Vector3 copied from the current Vector3
  80617. * @returns the new Vector3
  80618. */
  80619. clone(): Vector3;
  80620. /**
  80621. * Copies the given vector coordinates to the current Vector3 ones
  80622. * @param source defines the source Vector3
  80623. * @returns the current updated Vector3
  80624. */
  80625. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80626. /**
  80627. * Copies the given floats to the current Vector3 coordinates
  80628. * @param x defines the x coordinate of the operand
  80629. * @param y defines the y coordinate of the operand
  80630. * @param z defines the z coordinate of the operand
  80631. * @returns the current updated Vector3
  80632. */
  80633. copyFromFloats(x: number, y: number, z: number): Vector3;
  80634. /**
  80635. * Copies the given floats to the current Vector3 coordinates
  80636. * @param x defines the x coordinate of the operand
  80637. * @param y defines the y coordinate of the operand
  80638. * @param z defines the z coordinate of the operand
  80639. * @returns the current updated Vector3
  80640. */
  80641. set(x: number, y: number, z: number): Vector3;
  80642. /**
  80643. * Copies the given float to the current Vector3 coordinates
  80644. * @param v defines the x, y and z coordinates of the operand
  80645. * @returns the current updated Vector3
  80646. */
  80647. setAll(v: number): Vector3;
  80648. /**
  80649. * Get the clip factor between two vectors
  80650. * @param vector0 defines the first operand
  80651. * @param vector1 defines the second operand
  80652. * @param axis defines the axis to use
  80653. * @param size defines the size along the axis
  80654. * @returns the clip factor
  80655. */
  80656. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80657. /**
  80658. * Get angle between two vectors
  80659. * @param vector0 angle between vector0 and vector1
  80660. * @param vector1 angle between vector0 and vector1
  80661. * @param normal direction of the normal
  80662. * @return the angle between vector0 and vector1
  80663. */
  80664. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80665. /**
  80666. * Returns a new Vector3 set from the index "offset" of the given array
  80667. * @param array defines the source array
  80668. * @param offset defines the offset in the source array
  80669. * @returns the new Vector3
  80670. */
  80671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80672. /**
  80673. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80674. * @param array defines the source array
  80675. * @param offset defines the offset in the source array
  80676. * @returns the new Vector3
  80677. * @deprecated Please use FromArray instead.
  80678. */
  80679. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80680. /**
  80681. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80682. * @param array defines the source array
  80683. * @param offset defines the offset in the source array
  80684. * @param result defines the Vector3 where to store the result
  80685. */
  80686. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80687. /**
  80688. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80689. * @param array defines the source array
  80690. * @param offset defines the offset in the source array
  80691. * @param result defines the Vector3 where to store the result
  80692. * @deprecated Please use FromArrayToRef instead.
  80693. */
  80694. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80695. /**
  80696. * Sets the given vector "result" with the given floats.
  80697. * @param x defines the x coordinate of the source
  80698. * @param y defines the y coordinate of the source
  80699. * @param z defines the z coordinate of the source
  80700. * @param result defines the Vector3 where to store the result
  80701. */
  80702. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80703. /**
  80704. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80705. * @returns a new empty Vector3
  80706. */
  80707. static Zero(): Vector3;
  80708. /**
  80709. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80710. * @returns a new unit Vector3
  80711. */
  80712. static One(): Vector3;
  80713. /**
  80714. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80715. * @returns a new up Vector3
  80716. */
  80717. static Up(): Vector3;
  80718. /**
  80719. * Gets a up Vector3 that must not be updated
  80720. */
  80721. static get UpReadOnly(): DeepImmutable<Vector3>;
  80722. /**
  80723. * Gets a zero Vector3 that must not be updated
  80724. */
  80725. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80726. /**
  80727. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80728. * @returns a new down Vector3
  80729. */
  80730. static Down(): Vector3;
  80731. /**
  80732. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80733. * @param rightHandedSystem is the scene right-handed (negative z)
  80734. * @returns a new forward Vector3
  80735. */
  80736. static Forward(rightHandedSystem?: boolean): Vector3;
  80737. /**
  80738. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80739. * @param rightHandedSystem is the scene right-handed (negative-z)
  80740. * @returns a new forward Vector3
  80741. */
  80742. static Backward(rightHandedSystem?: boolean): Vector3;
  80743. /**
  80744. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80745. * @returns a new right Vector3
  80746. */
  80747. static Right(): Vector3;
  80748. /**
  80749. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80750. * @returns a new left Vector3
  80751. */
  80752. static Left(): Vector3;
  80753. /**
  80754. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80755. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80756. * @param vector defines the Vector3 to transform
  80757. * @param transformation defines the transformation matrix
  80758. * @returns the transformed Vector3
  80759. */
  80760. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80761. /**
  80762. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80763. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80764. * @param vector defines the Vector3 to transform
  80765. * @param transformation defines the transformation matrix
  80766. * @param result defines the Vector3 where to store the result
  80767. */
  80768. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80769. /**
  80770. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80771. * This method computes tranformed coordinates only, not transformed direction vectors
  80772. * @param x define the x coordinate of the source vector
  80773. * @param y define the y coordinate of the source vector
  80774. * @param z define the z coordinate of the source vector
  80775. * @param transformation defines the transformation matrix
  80776. * @param result defines the Vector3 where to store the result
  80777. */
  80778. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80779. /**
  80780. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80781. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80782. * @param vector defines the Vector3 to transform
  80783. * @param transformation defines the transformation matrix
  80784. * @returns the new Vector3
  80785. */
  80786. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80787. /**
  80788. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80789. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80790. * @param vector defines the Vector3 to transform
  80791. * @param transformation defines the transformation matrix
  80792. * @param result defines the Vector3 where to store the result
  80793. */
  80794. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80795. /**
  80796. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80797. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80798. * @param x define the x coordinate of the source vector
  80799. * @param y define the y coordinate of the source vector
  80800. * @param z define the z coordinate of the source vector
  80801. * @param transformation defines the transformation matrix
  80802. * @param result defines the Vector3 where to store the result
  80803. */
  80804. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80805. /**
  80806. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80807. * @param value1 defines the first control point
  80808. * @param value2 defines the second control point
  80809. * @param value3 defines the third control point
  80810. * @param value4 defines the fourth control point
  80811. * @param amount defines the amount on the spline to use
  80812. * @returns the new Vector3
  80813. */
  80814. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80815. /**
  80816. * 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"
  80817. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80818. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80819. * @param value defines the current value
  80820. * @param min defines the lower range value
  80821. * @param max defines the upper range value
  80822. * @returns the new Vector3
  80823. */
  80824. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80825. /**
  80826. * 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"
  80827. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80828. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80829. * @param value defines the current value
  80830. * @param min defines the lower range value
  80831. * @param max defines the upper range value
  80832. * @param result defines the Vector3 where to store the result
  80833. */
  80834. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80835. /**
  80836. * Checks if a given vector is inside a specific range
  80837. * @param v defines the vector to test
  80838. * @param min defines the minimum range
  80839. * @param max defines the maximum range
  80840. */
  80841. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80842. /**
  80843. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80844. * @param value1 defines the first control point
  80845. * @param tangent1 defines the first tangent vector
  80846. * @param value2 defines the second control point
  80847. * @param tangent2 defines the second tangent vector
  80848. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80849. * @returns the new Vector3
  80850. */
  80851. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80852. /**
  80853. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80854. * @param start defines the start value
  80855. * @param end defines the end value
  80856. * @param amount max defines amount between both (between 0 and 1)
  80857. * @returns the new Vector3
  80858. */
  80859. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80860. /**
  80861. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80862. * @param start defines the start value
  80863. * @param end defines the end value
  80864. * @param amount max defines amount between both (between 0 and 1)
  80865. * @param result defines the Vector3 where to store the result
  80866. */
  80867. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80868. /**
  80869. * Returns the dot product (float) between the vectors "left" and "right"
  80870. * @param left defines the left operand
  80871. * @param right defines the right operand
  80872. * @returns the dot product
  80873. */
  80874. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80875. /**
  80876. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80877. * The cross product is then orthogonal to both "left" and "right"
  80878. * @param left defines the left operand
  80879. * @param right defines the right operand
  80880. * @returns the cross product
  80881. */
  80882. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80883. /**
  80884. * Sets the given vector "result" with the cross product of "left" and "right"
  80885. * The cross product is then orthogonal to both "left" and "right"
  80886. * @param left defines the left operand
  80887. * @param right defines the right operand
  80888. * @param result defines the Vector3 where to store the result
  80889. */
  80890. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  80891. /**
  80892. * Returns a new Vector3 as the normalization of the given vector
  80893. * @param vector defines the Vector3 to normalize
  80894. * @returns the new Vector3
  80895. */
  80896. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80897. /**
  80898. * Sets the given vector "result" with the normalization of the given first vector
  80899. * @param vector defines the Vector3 to normalize
  80900. * @param result defines the Vector3 where to store the result
  80901. */
  80902. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80903. /**
  80904. * Project a Vector3 onto screen space
  80905. * @param vector defines the Vector3 to project
  80906. * @param world defines the world matrix to use
  80907. * @param transform defines the transform (view x projection) matrix to use
  80908. * @param viewport defines the screen viewport to use
  80909. * @returns the new Vector3
  80910. */
  80911. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80912. /** @hidden */
  80913. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80914. /**
  80915. * Unproject from screen space to object space
  80916. * @param source defines the screen space Vector3 to use
  80917. * @param viewportWidth defines the current width of the viewport
  80918. * @param viewportHeight defines the current height of the viewport
  80919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80920. * @param transform defines the transform (view x projection) matrix to use
  80921. * @returns the new Vector3
  80922. */
  80923. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80924. /**
  80925. * Unproject from screen space to object space
  80926. * @param source defines the screen space Vector3 to use
  80927. * @param viewportWidth defines the current width of the viewport
  80928. * @param viewportHeight defines the current height of the viewport
  80929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80930. * @param view defines the view matrix to use
  80931. * @param projection defines the projection matrix to use
  80932. * @returns the new Vector3
  80933. */
  80934. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80935. /**
  80936. * Unproject from screen space to object space
  80937. * @param source defines the screen space Vector3 to use
  80938. * @param viewportWidth defines the current width of the viewport
  80939. * @param viewportHeight defines the current height of the viewport
  80940. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80941. * @param view defines the view matrix to use
  80942. * @param projection defines the projection matrix to use
  80943. * @param result defines the Vector3 where to store the result
  80944. */
  80945. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80946. /**
  80947. * Unproject from screen space to object space
  80948. * @param sourceX defines the screen space x coordinate to use
  80949. * @param sourceY defines the screen space y coordinate to use
  80950. * @param sourceZ defines the screen space z coordinate to use
  80951. * @param viewportWidth defines the current width of the viewport
  80952. * @param viewportHeight defines the current height of the viewport
  80953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80954. * @param view defines the view matrix to use
  80955. * @param projection defines the projection matrix to use
  80956. * @param result defines the Vector3 where to store the result
  80957. */
  80958. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80959. /**
  80960. * Gets the minimal coordinate values between two Vector3
  80961. * @param left defines the first operand
  80962. * @param right defines the second operand
  80963. * @returns the new Vector3
  80964. */
  80965. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80966. /**
  80967. * Gets the maximal coordinate values between two Vector3
  80968. * @param left defines the first operand
  80969. * @param right defines the second operand
  80970. * @returns the new Vector3
  80971. */
  80972. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80973. /**
  80974. * Returns the distance between the vectors "value1" and "value2"
  80975. * @param value1 defines the first operand
  80976. * @param value2 defines the second operand
  80977. * @returns the distance
  80978. */
  80979. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80980. /**
  80981. * Returns the squared distance between the vectors "value1" and "value2"
  80982. * @param value1 defines the first operand
  80983. * @param value2 defines the second operand
  80984. * @returns the squared distance
  80985. */
  80986. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80987. /**
  80988. * Returns a new Vector3 located at the center between "value1" and "value2"
  80989. * @param value1 defines the first operand
  80990. * @param value2 defines the second operand
  80991. * @returns the new Vector3
  80992. */
  80993. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80994. /**
  80995. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80996. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80997. * to something in order to rotate it from its local system to the given target system
  80998. * Note: axis1, axis2 and axis3 are normalized during this operation
  80999. * @param axis1 defines the first axis
  81000. * @param axis2 defines the second axis
  81001. * @param axis3 defines the third axis
  81002. * @returns a new Vector3
  81003. */
  81004. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81005. /**
  81006. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81007. * @param axis1 defines the first axis
  81008. * @param axis2 defines the second axis
  81009. * @param axis3 defines the third axis
  81010. * @param ref defines the Vector3 where to store the result
  81011. */
  81012. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81013. }
  81014. /**
  81015. * Vector4 class created for EulerAngle class conversion to Quaternion
  81016. */
  81017. export class Vector4 {
  81018. /** x value of the vector */
  81019. x: number;
  81020. /** y value of the vector */
  81021. y: number;
  81022. /** z value of the vector */
  81023. z: number;
  81024. /** w value of the vector */
  81025. w: number;
  81026. /**
  81027. * Creates a Vector4 object from the given floats.
  81028. * @param x x value of the vector
  81029. * @param y y value of the vector
  81030. * @param z z value of the vector
  81031. * @param w w value of the vector
  81032. */
  81033. constructor(
  81034. /** x value of the vector */
  81035. x: number,
  81036. /** y value of the vector */
  81037. y: number,
  81038. /** z value of the vector */
  81039. z: number,
  81040. /** w value of the vector */
  81041. w: number);
  81042. /**
  81043. * Returns the string with the Vector4 coordinates.
  81044. * @returns a string containing all the vector values
  81045. */
  81046. toString(): string;
  81047. /**
  81048. * Returns the string "Vector4".
  81049. * @returns "Vector4"
  81050. */
  81051. getClassName(): string;
  81052. /**
  81053. * Returns the Vector4 hash code.
  81054. * @returns a unique hash code
  81055. */
  81056. getHashCode(): number;
  81057. /**
  81058. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81059. * @returns the resulting array
  81060. */
  81061. asArray(): number[];
  81062. /**
  81063. * Populates the given array from the given index with the Vector4 coordinates.
  81064. * @param array array to populate
  81065. * @param index index of the array to start at (default: 0)
  81066. * @returns the Vector4.
  81067. */
  81068. toArray(array: FloatArray, index?: number): Vector4;
  81069. /**
  81070. * Adds the given vector to the current Vector4.
  81071. * @param otherVector the vector to add
  81072. * @returns the updated Vector4.
  81073. */
  81074. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81075. /**
  81076. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81077. * @param otherVector the vector to add
  81078. * @returns the resulting vector
  81079. */
  81080. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81081. /**
  81082. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81083. * @param otherVector the vector to add
  81084. * @param result the vector to store the result
  81085. * @returns the current Vector4.
  81086. */
  81087. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81088. /**
  81089. * Subtract in place the given vector from the current Vector4.
  81090. * @param otherVector the vector to subtract
  81091. * @returns the updated Vector4.
  81092. */
  81093. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81094. /**
  81095. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81096. * @param otherVector the vector to add
  81097. * @returns the new vector with the result
  81098. */
  81099. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81100. /**
  81101. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81102. * @param otherVector the vector to subtract
  81103. * @param result the vector to store the result
  81104. * @returns the current Vector4.
  81105. */
  81106. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81107. /**
  81108. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81109. */
  81110. /**
  81111. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81112. * @param x value to subtract
  81113. * @param y value to subtract
  81114. * @param z value to subtract
  81115. * @param w value to subtract
  81116. * @returns new vector containing the result
  81117. */
  81118. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81119. /**
  81120. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81121. * @param x value to subtract
  81122. * @param y value to subtract
  81123. * @param z value to subtract
  81124. * @param w value to subtract
  81125. * @param result the vector to store the result in
  81126. * @returns the current Vector4.
  81127. */
  81128. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81129. /**
  81130. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81131. * @returns a new vector with the negated values
  81132. */
  81133. negate(): Vector4;
  81134. /**
  81135. * Negate this vector in place
  81136. * @returns this
  81137. */
  81138. negateInPlace(): Vector4;
  81139. /**
  81140. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81141. * @param result defines the Vector3 object where to store the result
  81142. * @returns the current Vector4
  81143. */
  81144. negateToRef(result: Vector4): Vector4;
  81145. /**
  81146. * Multiplies the current Vector4 coordinates by scale (float).
  81147. * @param scale the number to scale with
  81148. * @returns the updated Vector4.
  81149. */
  81150. scaleInPlace(scale: number): Vector4;
  81151. /**
  81152. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81153. * @param scale the number to scale with
  81154. * @returns a new vector with the result
  81155. */
  81156. scale(scale: number): Vector4;
  81157. /**
  81158. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81159. * @param scale the number to scale with
  81160. * @param result a vector to store the result in
  81161. * @returns the current Vector4.
  81162. */
  81163. scaleToRef(scale: number, result: Vector4): Vector4;
  81164. /**
  81165. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81166. * @param scale defines the scale factor
  81167. * @param result defines the Vector4 object where to store the result
  81168. * @returns the unmodified current Vector4
  81169. */
  81170. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81171. /**
  81172. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81173. * @param otherVector the vector to compare against
  81174. * @returns true if they are equal
  81175. */
  81176. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81177. /**
  81178. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81179. * @param otherVector vector to compare against
  81180. * @param epsilon (Default: very small number)
  81181. * @returns true if they are equal
  81182. */
  81183. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81184. /**
  81185. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81186. * @param x x value to compare against
  81187. * @param y y value to compare against
  81188. * @param z z value to compare against
  81189. * @param w w value to compare against
  81190. * @returns true if equal
  81191. */
  81192. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81193. /**
  81194. * Multiplies in place the current Vector4 by the given one.
  81195. * @param otherVector vector to multiple with
  81196. * @returns the updated Vector4.
  81197. */
  81198. multiplyInPlace(otherVector: Vector4): Vector4;
  81199. /**
  81200. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81201. * @param otherVector vector to multiple with
  81202. * @returns resulting new vector
  81203. */
  81204. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81205. /**
  81206. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81207. * @param otherVector vector to multiple with
  81208. * @param result vector to store the result
  81209. * @returns the current Vector4.
  81210. */
  81211. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81212. /**
  81213. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81214. * @param x x value multiply with
  81215. * @param y y value multiply with
  81216. * @param z z value multiply with
  81217. * @param w w value multiply with
  81218. * @returns resulting new vector
  81219. */
  81220. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81221. /**
  81222. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81223. * @param otherVector vector to devide with
  81224. * @returns resulting new vector
  81225. */
  81226. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81227. /**
  81228. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81229. * @param otherVector vector to devide with
  81230. * @param result vector to store the result
  81231. * @returns the current Vector4.
  81232. */
  81233. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81234. /**
  81235. * Divides the current Vector3 coordinates by the given ones.
  81236. * @param otherVector vector to devide with
  81237. * @returns the updated Vector3.
  81238. */
  81239. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81240. /**
  81241. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81242. * @param other defines the second operand
  81243. * @returns the current updated Vector4
  81244. */
  81245. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81246. /**
  81247. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81248. * @param other defines the second operand
  81249. * @returns the current updated Vector4
  81250. */
  81251. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81252. /**
  81253. * Gets a new Vector4 from current Vector4 floored values
  81254. * @returns a new Vector4
  81255. */
  81256. floor(): Vector4;
  81257. /**
  81258. * Gets a new Vector4 from current Vector3 floored values
  81259. * @returns a new Vector4
  81260. */
  81261. fract(): Vector4;
  81262. /**
  81263. * Returns the Vector4 length (float).
  81264. * @returns the length
  81265. */
  81266. length(): number;
  81267. /**
  81268. * Returns the Vector4 squared length (float).
  81269. * @returns the length squared
  81270. */
  81271. lengthSquared(): number;
  81272. /**
  81273. * Normalizes in place the Vector4.
  81274. * @returns the updated Vector4.
  81275. */
  81276. normalize(): Vector4;
  81277. /**
  81278. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81279. * @returns this converted to a new vector3
  81280. */
  81281. toVector3(): Vector3;
  81282. /**
  81283. * Returns a new Vector4 copied from the current one.
  81284. * @returns the new cloned vector
  81285. */
  81286. clone(): Vector4;
  81287. /**
  81288. * Updates the current Vector4 with the given one coordinates.
  81289. * @param source the source vector to copy from
  81290. * @returns the updated Vector4.
  81291. */
  81292. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81293. /**
  81294. * Updates the current Vector4 coordinates with the given floats.
  81295. * @param x float to copy from
  81296. * @param y float to copy from
  81297. * @param z float to copy from
  81298. * @param w float to copy from
  81299. * @returns the updated Vector4.
  81300. */
  81301. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81302. /**
  81303. * Updates the current Vector4 coordinates with the given floats.
  81304. * @param x float to set from
  81305. * @param y float to set from
  81306. * @param z float to set from
  81307. * @param w float to set from
  81308. * @returns the updated Vector4.
  81309. */
  81310. set(x: number, y: number, z: number, w: number): Vector4;
  81311. /**
  81312. * Copies the given float to the current Vector3 coordinates
  81313. * @param v defines the x, y, z and w coordinates of the operand
  81314. * @returns the current updated Vector3
  81315. */
  81316. setAll(v: number): Vector4;
  81317. /**
  81318. * Returns a new Vector4 set from the starting index of the given array.
  81319. * @param array the array to pull values from
  81320. * @param offset the offset into the array to start at
  81321. * @returns the new vector
  81322. */
  81323. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81324. /**
  81325. * Updates the given vector "result" from the starting index of the given array.
  81326. * @param array the array to pull values from
  81327. * @param offset the offset into the array to start at
  81328. * @param result the vector to store the result in
  81329. */
  81330. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81331. /**
  81332. * Updates the given vector "result" from the starting index of the given Float32Array.
  81333. * @param array the array to pull values from
  81334. * @param offset the offset into the array to start at
  81335. * @param result the vector to store the result in
  81336. */
  81337. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81338. /**
  81339. * Updates the given vector "result" coordinates from the given floats.
  81340. * @param x float to set from
  81341. * @param y float to set from
  81342. * @param z float to set from
  81343. * @param w float to set from
  81344. * @param result the vector to the floats in
  81345. */
  81346. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81347. /**
  81348. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81349. * @returns the new vector
  81350. */
  81351. static Zero(): Vector4;
  81352. /**
  81353. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81354. * @returns the new vector
  81355. */
  81356. static One(): Vector4;
  81357. /**
  81358. * Returns a new normalized Vector4 from the given one.
  81359. * @param vector the vector to normalize
  81360. * @returns the vector
  81361. */
  81362. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81363. /**
  81364. * Updates the given vector "result" from the normalization of the given one.
  81365. * @param vector the vector to normalize
  81366. * @param result the vector to store the result in
  81367. */
  81368. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81369. /**
  81370. * Returns a vector with the minimum values from the left and right vectors
  81371. * @param left left vector to minimize
  81372. * @param right right vector to minimize
  81373. * @returns a new vector with the minimum of the left and right vector values
  81374. */
  81375. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81376. /**
  81377. * Returns a vector with the maximum values from the left and right vectors
  81378. * @param left left vector to maximize
  81379. * @param right right vector to maximize
  81380. * @returns a new vector with the maximum of the left and right vector values
  81381. */
  81382. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81383. /**
  81384. * Returns the distance (float) between the vectors "value1" and "value2".
  81385. * @param value1 value to calulate the distance between
  81386. * @param value2 value to calulate the distance between
  81387. * @return the distance between the two vectors
  81388. */
  81389. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81390. /**
  81391. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81392. * @param value1 value to calulate the distance between
  81393. * @param value2 value to calulate the distance between
  81394. * @return the distance between the two vectors squared
  81395. */
  81396. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81397. /**
  81398. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81399. * @param value1 value to calulate the center between
  81400. * @param value2 value to calulate the center between
  81401. * @return the center between the two vectors
  81402. */
  81403. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81404. /**
  81405. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81406. * This methods computes transformed normalized direction vectors only.
  81407. * @param vector the vector to transform
  81408. * @param transformation the transformation matrix to apply
  81409. * @returns the new vector
  81410. */
  81411. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81412. /**
  81413. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81414. * This methods computes transformed normalized direction vectors only.
  81415. * @param vector the vector to transform
  81416. * @param transformation the transformation matrix to apply
  81417. * @param result the vector to store the result in
  81418. */
  81419. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81420. /**
  81421. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81422. * This methods computes transformed normalized direction vectors only.
  81423. * @param x value to transform
  81424. * @param y value to transform
  81425. * @param z value to transform
  81426. * @param w value to transform
  81427. * @param transformation the transformation matrix to apply
  81428. * @param result the vector to store the results in
  81429. */
  81430. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81431. /**
  81432. * Creates a new Vector4 from a Vector3
  81433. * @param source defines the source data
  81434. * @param w defines the 4th component (default is 0)
  81435. * @returns a new Vector4
  81436. */
  81437. static FromVector3(source: Vector3, w?: number): Vector4;
  81438. }
  81439. /**
  81440. * Class used to store quaternion data
  81441. * @see https://en.wikipedia.org/wiki/Quaternion
  81442. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81443. */
  81444. export class Quaternion {
  81445. /** @hidden */
  81446. _x: number;
  81447. /** @hidden */
  81448. _y: number;
  81449. /** @hidden */
  81450. _z: number;
  81451. /** @hidden */
  81452. _w: number;
  81453. /** @hidden */
  81454. _isDirty: boolean;
  81455. /** Gets or sets the x coordinate */
  81456. get x(): number;
  81457. set x(value: number);
  81458. /** Gets or sets the y coordinate */
  81459. get y(): number;
  81460. set y(value: number);
  81461. /** Gets or sets the z coordinate */
  81462. get z(): number;
  81463. set z(value: number);
  81464. /** Gets or sets the w coordinate */
  81465. get w(): number;
  81466. set w(value: number);
  81467. /**
  81468. * Creates a new Quaternion from the given floats
  81469. * @param x defines the first component (0 by default)
  81470. * @param y defines the second component (0 by default)
  81471. * @param z defines the third component (0 by default)
  81472. * @param w defines the fourth component (1.0 by default)
  81473. */
  81474. constructor(x?: number, y?: number, z?: number, w?: number);
  81475. /**
  81476. * Gets a string representation for the current quaternion
  81477. * @returns a string with the Quaternion coordinates
  81478. */
  81479. toString(): string;
  81480. /**
  81481. * Gets the class name of the quaternion
  81482. * @returns the string "Quaternion"
  81483. */
  81484. getClassName(): string;
  81485. /**
  81486. * Gets a hash code for this quaternion
  81487. * @returns the quaternion hash code
  81488. */
  81489. getHashCode(): number;
  81490. /**
  81491. * Copy the quaternion to an array
  81492. * @returns a new array populated with 4 elements from the quaternion coordinates
  81493. */
  81494. asArray(): number[];
  81495. /**
  81496. * Check if two quaternions are equals
  81497. * @param otherQuaternion defines the second operand
  81498. * @return true if the current quaternion and the given one coordinates are strictly equals
  81499. */
  81500. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81501. /**
  81502. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81503. * @param otherQuaternion defines the other quaternion
  81504. * @param epsilon defines the minimal distance to consider equality
  81505. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81506. */
  81507. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81508. /**
  81509. * Clone the current quaternion
  81510. * @returns a new quaternion copied from the current one
  81511. */
  81512. clone(): Quaternion;
  81513. /**
  81514. * Copy a quaternion to the current one
  81515. * @param other defines the other quaternion
  81516. * @returns the updated current quaternion
  81517. */
  81518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81519. /**
  81520. * Updates the current quaternion with the given float coordinates
  81521. * @param x defines the x coordinate
  81522. * @param y defines the y coordinate
  81523. * @param z defines the z coordinate
  81524. * @param w defines the w coordinate
  81525. * @returns the updated current quaternion
  81526. */
  81527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81528. /**
  81529. * Updates the current quaternion from the given float coordinates
  81530. * @param x defines the x coordinate
  81531. * @param y defines the y coordinate
  81532. * @param z defines the z coordinate
  81533. * @param w defines the w coordinate
  81534. * @returns the updated current quaternion
  81535. */
  81536. set(x: number, y: number, z: number, w: number): Quaternion;
  81537. /**
  81538. * Adds two quaternions
  81539. * @param other defines the second operand
  81540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81541. */
  81542. add(other: DeepImmutable<Quaternion>): Quaternion;
  81543. /**
  81544. * Add a quaternion to the current one
  81545. * @param other defines the quaternion to add
  81546. * @returns the current quaternion
  81547. */
  81548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81549. /**
  81550. * Subtract two quaternions
  81551. * @param other defines the second operand
  81552. * @returns a new quaternion as the subtraction result of the given one from the current one
  81553. */
  81554. subtract(other: Quaternion): Quaternion;
  81555. /**
  81556. * Multiplies the current quaternion by a scale factor
  81557. * @param value defines the scale factor
  81558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81559. */
  81560. scale(value: number): Quaternion;
  81561. /**
  81562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81563. * @param scale defines the scale factor
  81564. * @param result defines the Quaternion object where to store the result
  81565. * @returns the unmodified current quaternion
  81566. */
  81567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81568. /**
  81569. * Multiplies in place the current quaternion by a scale factor
  81570. * @param value defines the scale factor
  81571. * @returns the current modified quaternion
  81572. */
  81573. scaleInPlace(value: number): Quaternion;
  81574. /**
  81575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81576. * @param scale defines the scale factor
  81577. * @param result defines the Quaternion object where to store the result
  81578. * @returns the unmodified current quaternion
  81579. */
  81580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81581. /**
  81582. * Multiplies two quaternions
  81583. * @param q1 defines the second operand
  81584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81585. */
  81586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81587. /**
  81588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81589. * @param q1 defines the second operand
  81590. * @param result defines the target quaternion
  81591. * @returns the current quaternion
  81592. */
  81593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81594. /**
  81595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81596. * @param q1 defines the second operand
  81597. * @returns the currentupdated quaternion
  81598. */
  81599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81600. /**
  81601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81602. * @param ref defines the target quaternion
  81603. * @returns the current quaternion
  81604. */
  81605. conjugateToRef(ref: Quaternion): Quaternion;
  81606. /**
  81607. * Conjugates in place (1-q) the current quaternion
  81608. * @returns the current updated quaternion
  81609. */
  81610. conjugateInPlace(): Quaternion;
  81611. /**
  81612. * Conjugates in place (1-q) the current quaternion
  81613. * @returns a new quaternion
  81614. */
  81615. conjugate(): Quaternion;
  81616. /**
  81617. * Gets length of current quaternion
  81618. * @returns the quaternion length (float)
  81619. */
  81620. length(): number;
  81621. /**
  81622. * Normalize in place the current quaternion
  81623. * @returns the current updated quaternion
  81624. */
  81625. normalize(): Quaternion;
  81626. /**
  81627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81628. * @param order is a reserved parameter and is ignore for now
  81629. * @returns a new Vector3 containing the Euler angles
  81630. */
  81631. toEulerAngles(order?: string): Vector3;
  81632. /**
  81633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81634. * @param result defines the vector which will be filled with the Euler angles
  81635. * @param order is a reserved parameter and is ignore for now
  81636. * @returns the current unchanged quaternion
  81637. */
  81638. toEulerAnglesToRef(result: Vector3): Quaternion;
  81639. /**
  81640. * Updates the given rotation matrix with the current quaternion values
  81641. * @param result defines the target matrix
  81642. * @returns the current unchanged quaternion
  81643. */
  81644. toRotationMatrix(result: Matrix): Quaternion;
  81645. /**
  81646. * Updates the current quaternion from the given rotation matrix values
  81647. * @param matrix defines the source matrix
  81648. * @returns the current updated quaternion
  81649. */
  81650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81651. /**
  81652. * Creates a new quaternion from a rotation matrix
  81653. * @param matrix defines the source matrix
  81654. * @returns a new quaternion created from the given rotation matrix values
  81655. */
  81656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81657. /**
  81658. * Updates the given quaternion with the given rotation matrix values
  81659. * @param matrix defines the source matrix
  81660. * @param result defines the target quaternion
  81661. */
  81662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81663. /**
  81664. * Returns the dot product (float) between the quaternions "left" and "right"
  81665. * @param left defines the left operand
  81666. * @param right defines the right operand
  81667. * @returns the dot product
  81668. */
  81669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81670. /**
  81671. * Checks if the two quaternions are close to each other
  81672. * @param quat0 defines the first quaternion to check
  81673. * @param quat1 defines the second quaternion to check
  81674. * @returns true if the two quaternions are close to each other
  81675. */
  81676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81677. /**
  81678. * Creates an empty quaternion
  81679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81680. */
  81681. static Zero(): Quaternion;
  81682. /**
  81683. * Inverse a given quaternion
  81684. * @param q defines the source quaternion
  81685. * @returns a new quaternion as the inverted current quaternion
  81686. */
  81687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81688. /**
  81689. * Inverse a given quaternion
  81690. * @param q defines the source quaternion
  81691. * @param result the quaternion the result will be stored in
  81692. * @returns the result quaternion
  81693. */
  81694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81695. /**
  81696. * Creates an identity quaternion
  81697. * @returns the identity quaternion
  81698. */
  81699. static Identity(): Quaternion;
  81700. /**
  81701. * Gets a boolean indicating if the given quaternion is identity
  81702. * @param quaternion defines the quaternion to check
  81703. * @returns true if the quaternion is identity
  81704. */
  81705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81706. /**
  81707. * Creates a quaternion from a rotation around an axis
  81708. * @param axis defines the axis to use
  81709. * @param angle defines the angle to use
  81710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81711. */
  81712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81713. /**
  81714. * Creates a rotation around an axis and stores it into the given quaternion
  81715. * @param axis defines the axis to use
  81716. * @param angle defines the angle to use
  81717. * @param result defines the target quaternion
  81718. * @returns the target quaternion
  81719. */
  81720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81721. /**
  81722. * Creates a new quaternion from data stored into an array
  81723. * @param array defines the data source
  81724. * @param offset defines the offset in the source array where the data starts
  81725. * @returns a new quaternion
  81726. */
  81727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81728. /**
  81729. * Updates the given quaternion "result" from the starting index of the given array.
  81730. * @param array the array to pull values from
  81731. * @param offset the offset into the array to start at
  81732. * @param result the quaternion to store the result in
  81733. */
  81734. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81735. /**
  81736. * Create a quaternion from Euler rotation angles
  81737. * @param x Pitch
  81738. * @param y Yaw
  81739. * @param z Roll
  81740. * @returns the new Quaternion
  81741. */
  81742. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81743. /**
  81744. * Updates a quaternion from Euler rotation angles
  81745. * @param x Pitch
  81746. * @param y Yaw
  81747. * @param z Roll
  81748. * @param result the quaternion to store the result
  81749. * @returns the updated quaternion
  81750. */
  81751. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81752. /**
  81753. * Create a quaternion from Euler rotation vector
  81754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81755. * @returns the new Quaternion
  81756. */
  81757. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81758. /**
  81759. * Updates a quaternion from Euler rotation vector
  81760. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81761. * @param result the quaternion to store the result
  81762. * @returns the updated quaternion
  81763. */
  81764. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81765. /**
  81766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81767. * @param yaw defines the rotation around Y axis
  81768. * @param pitch defines the rotation around X axis
  81769. * @param roll defines the rotation around Z axis
  81770. * @returns the new quaternion
  81771. */
  81772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81773. /**
  81774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81775. * @param yaw defines the rotation around Y axis
  81776. * @param pitch defines the rotation around X axis
  81777. * @param roll defines the rotation around Z axis
  81778. * @param result defines the target quaternion
  81779. */
  81780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81781. /**
  81782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81783. * @param alpha defines the rotation around first axis
  81784. * @param beta defines the rotation around second axis
  81785. * @param gamma defines the rotation around third axis
  81786. * @returns the new quaternion
  81787. */
  81788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81789. /**
  81790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81791. * @param alpha defines the rotation around first axis
  81792. * @param beta defines the rotation around second axis
  81793. * @param gamma defines the rotation around third axis
  81794. * @param result defines the target quaternion
  81795. */
  81796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81797. /**
  81798. * 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)
  81799. * @param axis1 defines the first axis
  81800. * @param axis2 defines the second axis
  81801. * @param axis3 defines the third axis
  81802. * @returns the new quaternion
  81803. */
  81804. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81805. /**
  81806. * 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
  81807. * @param axis1 defines the first axis
  81808. * @param axis2 defines the second axis
  81809. * @param axis3 defines the third axis
  81810. * @param ref defines the target quaternion
  81811. */
  81812. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81813. /**
  81814. * Interpolates between two quaternions
  81815. * @param left defines first quaternion
  81816. * @param right defines second quaternion
  81817. * @param amount defines the gradient to use
  81818. * @returns the new interpolated quaternion
  81819. */
  81820. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81821. /**
  81822. * Interpolates between two quaternions and stores it into a target quaternion
  81823. * @param left defines first quaternion
  81824. * @param right defines second quaternion
  81825. * @param amount defines the gradient to use
  81826. * @param result defines the target quaternion
  81827. */
  81828. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81829. /**
  81830. * Interpolate between two quaternions using Hermite interpolation
  81831. * @param value1 defines first quaternion
  81832. * @param tangent1 defines the incoming tangent
  81833. * @param value2 defines second quaternion
  81834. * @param tangent2 defines the outgoing tangent
  81835. * @param amount defines the target quaternion
  81836. * @returns the new interpolated quaternion
  81837. */
  81838. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81839. }
  81840. /**
  81841. * Class used to store matrix data (4x4)
  81842. */
  81843. export class Matrix {
  81844. private static _updateFlagSeed;
  81845. private static _identityReadOnly;
  81846. private _isIdentity;
  81847. private _isIdentityDirty;
  81848. private _isIdentity3x2;
  81849. private _isIdentity3x2Dirty;
  81850. /**
  81851. * Gets the update flag of the matrix which is an unique number for the matrix.
  81852. * It will be incremented every time the matrix data change.
  81853. * You can use it to speed the comparison between two versions of the same matrix.
  81854. */
  81855. updateFlag: number;
  81856. private readonly _m;
  81857. /**
  81858. * Gets the internal data of the matrix
  81859. */
  81860. get m(): DeepImmutable<Float32Array>;
  81861. /** @hidden */
  81862. _markAsUpdated(): void;
  81863. /** @hidden */
  81864. private _updateIdentityStatus;
  81865. /**
  81866. * Creates an empty matrix (filled with zeros)
  81867. */
  81868. constructor();
  81869. /**
  81870. * Check if the current matrix is identity
  81871. * @returns true is the matrix is the identity matrix
  81872. */
  81873. isIdentity(): boolean;
  81874. /**
  81875. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81876. * @returns true is the matrix is the identity matrix
  81877. */
  81878. isIdentityAs3x2(): boolean;
  81879. /**
  81880. * Gets the determinant of the matrix
  81881. * @returns the matrix determinant
  81882. */
  81883. determinant(): number;
  81884. /**
  81885. * Returns the matrix as a Float32Array
  81886. * @returns the matrix underlying array
  81887. */
  81888. toArray(): DeepImmutable<Float32Array>;
  81889. /**
  81890. * Returns the matrix as a Float32Array
  81891. * @returns the matrix underlying array.
  81892. */
  81893. asArray(): DeepImmutable<Float32Array>;
  81894. /**
  81895. * Inverts the current matrix in place
  81896. * @returns the current inverted matrix
  81897. */
  81898. invert(): Matrix;
  81899. /**
  81900. * Sets all the matrix elements to zero
  81901. * @returns the current matrix
  81902. */
  81903. reset(): Matrix;
  81904. /**
  81905. * Adds the current matrix with a second one
  81906. * @param other defines the matrix to add
  81907. * @returns a new matrix as the addition of the current matrix and the given one
  81908. */
  81909. add(other: DeepImmutable<Matrix>): Matrix;
  81910. /**
  81911. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81912. * @param other defines the matrix to add
  81913. * @param result defines the target matrix
  81914. * @returns the current matrix
  81915. */
  81916. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81917. /**
  81918. * Adds in place the given matrix to the current matrix
  81919. * @param other defines the second operand
  81920. * @returns the current updated matrix
  81921. */
  81922. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81923. /**
  81924. * Sets the given matrix to the current inverted Matrix
  81925. * @param other defines the target matrix
  81926. * @returns the unmodified current matrix
  81927. */
  81928. invertToRef(other: Matrix): Matrix;
  81929. /**
  81930. * add a value at the specified position in the current Matrix
  81931. * @param index the index of the value within the matrix. between 0 and 15.
  81932. * @param value the value to be added
  81933. * @returns the current updated matrix
  81934. */
  81935. addAtIndex(index: number, value: number): Matrix;
  81936. /**
  81937. * mutiply the specified position in the current Matrix by a value
  81938. * @param index the index of the value within the matrix. between 0 and 15.
  81939. * @param value the value to be added
  81940. * @returns the current updated matrix
  81941. */
  81942. multiplyAtIndex(index: number, value: number): Matrix;
  81943. /**
  81944. * Inserts the translation vector (using 3 floats) in the current matrix
  81945. * @param x defines the 1st component of the translation
  81946. * @param y defines the 2nd component of the translation
  81947. * @param z defines the 3rd component of the translation
  81948. * @returns the current updated matrix
  81949. */
  81950. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81951. /**
  81952. * Adds the translation vector (using 3 floats) in the current matrix
  81953. * @param x defines the 1st component of the translation
  81954. * @param y defines the 2nd component of the translation
  81955. * @param z defines the 3rd component of the translation
  81956. * @returns the current updated matrix
  81957. */
  81958. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81959. /**
  81960. * Inserts the translation vector in the current matrix
  81961. * @param vector3 defines the translation to insert
  81962. * @returns the current updated matrix
  81963. */
  81964. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81965. /**
  81966. * Gets the translation value of the current matrix
  81967. * @returns a new Vector3 as the extracted translation from the matrix
  81968. */
  81969. getTranslation(): Vector3;
  81970. /**
  81971. * Fill a Vector3 with the extracted translation from the matrix
  81972. * @param result defines the Vector3 where to store the translation
  81973. * @returns the current matrix
  81974. */
  81975. getTranslationToRef(result: Vector3): Matrix;
  81976. /**
  81977. * Remove rotation and scaling part from the matrix
  81978. * @returns the updated matrix
  81979. */
  81980. removeRotationAndScaling(): Matrix;
  81981. /**
  81982. * Multiply two matrices
  81983. * @param other defines the second operand
  81984. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81985. */
  81986. multiply(other: DeepImmutable<Matrix>): Matrix;
  81987. /**
  81988. * Copy the current matrix from the given one
  81989. * @param other defines the source matrix
  81990. * @returns the current updated matrix
  81991. */
  81992. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81993. /**
  81994. * Populates the given array from the starting index with the current matrix values
  81995. * @param array defines the target array
  81996. * @param offset defines the offset in the target array where to start storing values
  81997. * @returns the current matrix
  81998. */
  81999. copyToArray(array: Float32Array, offset?: number): Matrix;
  82000. /**
  82001. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82002. * @param other defines the second operand
  82003. * @param result defines the matrix where to store the multiplication
  82004. * @returns the current matrix
  82005. */
  82006. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82007. /**
  82008. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82009. * @param other defines the second operand
  82010. * @param result defines the array where to store the multiplication
  82011. * @param offset defines the offset in the target array where to start storing values
  82012. * @returns the current matrix
  82013. */
  82014. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82015. /**
  82016. * Check equality between this matrix and a second one
  82017. * @param value defines the second matrix to compare
  82018. * @returns true is the current matrix and the given one values are strictly equal
  82019. */
  82020. equals(value: DeepImmutable<Matrix>): boolean;
  82021. /**
  82022. * Clone the current matrix
  82023. * @returns a new matrix from the current matrix
  82024. */
  82025. clone(): Matrix;
  82026. /**
  82027. * Returns the name of the current matrix class
  82028. * @returns the string "Matrix"
  82029. */
  82030. getClassName(): string;
  82031. /**
  82032. * Gets the hash code of the current matrix
  82033. * @returns the hash code
  82034. */
  82035. getHashCode(): number;
  82036. /**
  82037. * Decomposes the current Matrix into a translation, rotation and scaling components
  82038. * @param scale defines the scale vector3 given as a reference to update
  82039. * @param rotation defines the rotation quaternion given as a reference to update
  82040. * @param translation defines the translation vector3 given as a reference to update
  82041. * @returns true if operation was successful
  82042. */
  82043. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82044. /**
  82045. * Gets specific row of the matrix
  82046. * @param index defines the number of the row to get
  82047. * @returns the index-th row of the current matrix as a new Vector4
  82048. */
  82049. getRow(index: number): Nullable<Vector4>;
  82050. /**
  82051. * Sets the index-th row of the current matrix to the vector4 values
  82052. * @param index defines the number of the row to set
  82053. * @param row defines the target vector4
  82054. * @returns the updated current matrix
  82055. */
  82056. setRow(index: number, row: Vector4): Matrix;
  82057. /**
  82058. * Compute the transpose of the matrix
  82059. * @returns the new transposed matrix
  82060. */
  82061. transpose(): Matrix;
  82062. /**
  82063. * Compute the transpose of the matrix and store it in a given matrix
  82064. * @param result defines the target matrix
  82065. * @returns the current matrix
  82066. */
  82067. transposeToRef(result: Matrix): Matrix;
  82068. /**
  82069. * Sets the index-th row of the current matrix with the given 4 x float values
  82070. * @param index defines the row index
  82071. * @param x defines the x component to set
  82072. * @param y defines the y component to set
  82073. * @param z defines the z component to set
  82074. * @param w defines the w component to set
  82075. * @returns the updated current matrix
  82076. */
  82077. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82078. /**
  82079. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82080. * @param scale defines the scale factor
  82081. * @returns a new matrix
  82082. */
  82083. scale(scale: number): Matrix;
  82084. /**
  82085. * Scale the current matrix values by a factor to a given result matrix
  82086. * @param scale defines the scale factor
  82087. * @param result defines the matrix to store the result
  82088. * @returns the current matrix
  82089. */
  82090. scaleToRef(scale: number, result: Matrix): Matrix;
  82091. /**
  82092. * Scale the current matrix values by a factor and add the result to a given matrix
  82093. * @param scale defines the scale factor
  82094. * @param result defines the Matrix to store the result
  82095. * @returns the current matrix
  82096. */
  82097. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82098. /**
  82099. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82100. * @param ref matrix to store the result
  82101. */
  82102. toNormalMatrix(ref: Matrix): void;
  82103. /**
  82104. * Gets only rotation part of the current matrix
  82105. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82106. */
  82107. getRotationMatrix(): Matrix;
  82108. /**
  82109. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82110. * @param result defines the target matrix to store data to
  82111. * @returns the current matrix
  82112. */
  82113. getRotationMatrixToRef(result: Matrix): Matrix;
  82114. /**
  82115. * Toggles model matrix from being right handed to left handed in place and vice versa
  82116. */
  82117. toggleModelMatrixHandInPlace(): void;
  82118. /**
  82119. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82120. */
  82121. toggleProjectionMatrixHandInPlace(): void;
  82122. /**
  82123. * Creates a matrix from an array
  82124. * @param array defines the source array
  82125. * @param offset defines an offset in the source array
  82126. * @returns a new Matrix set from the starting index of the given array
  82127. */
  82128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82129. /**
  82130. * Copy the content of an array into a given matrix
  82131. * @param array defines the source array
  82132. * @param offset defines an offset in the source array
  82133. * @param result defines the target matrix
  82134. */
  82135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82136. /**
  82137. * Stores an array into a matrix after having multiplied each component by a given factor
  82138. * @param array defines the source array
  82139. * @param offset defines the offset in the source array
  82140. * @param scale defines the scaling factor
  82141. * @param result defines the target matrix
  82142. */
  82143. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82144. /**
  82145. * Gets an identity matrix that must not be updated
  82146. */
  82147. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82148. /**
  82149. * Stores a list of values (16) inside a given matrix
  82150. * @param initialM11 defines 1st value of 1st row
  82151. * @param initialM12 defines 2nd value of 1st row
  82152. * @param initialM13 defines 3rd value of 1st row
  82153. * @param initialM14 defines 4th value of 1st row
  82154. * @param initialM21 defines 1st value of 2nd row
  82155. * @param initialM22 defines 2nd value of 2nd row
  82156. * @param initialM23 defines 3rd value of 2nd row
  82157. * @param initialM24 defines 4th value of 2nd row
  82158. * @param initialM31 defines 1st value of 3rd row
  82159. * @param initialM32 defines 2nd value of 3rd row
  82160. * @param initialM33 defines 3rd value of 3rd row
  82161. * @param initialM34 defines 4th value of 3rd row
  82162. * @param initialM41 defines 1st value of 4th row
  82163. * @param initialM42 defines 2nd value of 4th row
  82164. * @param initialM43 defines 3rd value of 4th row
  82165. * @param initialM44 defines 4th value of 4th row
  82166. * @param result defines the target matrix
  82167. */
  82168. 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;
  82169. /**
  82170. * Creates new matrix from a list of values (16)
  82171. * @param initialM11 defines 1st value of 1st row
  82172. * @param initialM12 defines 2nd value of 1st row
  82173. * @param initialM13 defines 3rd value of 1st row
  82174. * @param initialM14 defines 4th value of 1st row
  82175. * @param initialM21 defines 1st value of 2nd row
  82176. * @param initialM22 defines 2nd value of 2nd row
  82177. * @param initialM23 defines 3rd value of 2nd row
  82178. * @param initialM24 defines 4th value of 2nd row
  82179. * @param initialM31 defines 1st value of 3rd row
  82180. * @param initialM32 defines 2nd value of 3rd row
  82181. * @param initialM33 defines 3rd value of 3rd row
  82182. * @param initialM34 defines 4th value of 3rd row
  82183. * @param initialM41 defines 1st value of 4th row
  82184. * @param initialM42 defines 2nd value of 4th row
  82185. * @param initialM43 defines 3rd value of 4th row
  82186. * @param initialM44 defines 4th value of 4th row
  82187. * @returns the new matrix
  82188. */
  82189. 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;
  82190. /**
  82191. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82192. * @param scale defines the scale vector3
  82193. * @param rotation defines the rotation quaternion
  82194. * @param translation defines the translation vector3
  82195. * @returns a new matrix
  82196. */
  82197. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82198. /**
  82199. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82200. * @param scale defines the scale vector3
  82201. * @param rotation defines the rotation quaternion
  82202. * @param translation defines the translation vector3
  82203. * @param result defines the target matrix
  82204. */
  82205. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82206. /**
  82207. * Creates a new identity matrix
  82208. * @returns a new identity matrix
  82209. */
  82210. static Identity(): Matrix;
  82211. /**
  82212. * Creates a new identity matrix and stores the result in a given matrix
  82213. * @param result defines the target matrix
  82214. */
  82215. static IdentityToRef(result: Matrix): void;
  82216. /**
  82217. * Creates a new zero matrix
  82218. * @returns a new zero matrix
  82219. */
  82220. static Zero(): Matrix;
  82221. /**
  82222. * Creates a new rotation matrix for "angle" radians around the X axis
  82223. * @param angle defines the angle (in radians) to use
  82224. * @return the new matrix
  82225. */
  82226. static RotationX(angle: number): Matrix;
  82227. /**
  82228. * Creates a new matrix as the invert of a given matrix
  82229. * @param source defines the source matrix
  82230. * @returns the new matrix
  82231. */
  82232. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82233. /**
  82234. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82235. * @param angle defines the angle (in radians) to use
  82236. * @param result defines the target matrix
  82237. */
  82238. static RotationXToRef(angle: number, result: Matrix): void;
  82239. /**
  82240. * Creates a new rotation matrix for "angle" radians around the Y axis
  82241. * @param angle defines the angle (in radians) to use
  82242. * @return the new matrix
  82243. */
  82244. static RotationY(angle: number): Matrix;
  82245. /**
  82246. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82247. * @param angle defines the angle (in radians) to use
  82248. * @param result defines the target matrix
  82249. */
  82250. static RotationYToRef(angle: number, result: Matrix): void;
  82251. /**
  82252. * Creates a new rotation matrix for "angle" radians around the Z axis
  82253. * @param angle defines the angle (in radians) to use
  82254. * @return the new matrix
  82255. */
  82256. static RotationZ(angle: number): Matrix;
  82257. /**
  82258. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82259. * @param angle defines the angle (in radians) to use
  82260. * @param result defines the target matrix
  82261. */
  82262. static RotationZToRef(angle: number, result: Matrix): void;
  82263. /**
  82264. * Creates a new rotation matrix for "angle" radians around the given axis
  82265. * @param axis defines the axis to use
  82266. * @param angle defines the angle (in radians) to use
  82267. * @return the new matrix
  82268. */
  82269. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82270. /**
  82271. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82272. * @param axis defines the axis to use
  82273. * @param angle defines the angle (in radians) to use
  82274. * @param result defines the target matrix
  82275. */
  82276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82277. /**
  82278. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82279. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82280. * @param from defines the vector to align
  82281. * @param to defines the vector to align to
  82282. * @param result defines the target matrix
  82283. */
  82284. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82285. /**
  82286. * Creates a rotation matrix
  82287. * @param yaw defines the yaw angle in radians (Y axis)
  82288. * @param pitch defines the pitch angle in radians (X axis)
  82289. * @param roll defines the roll angle in radians (X axis)
  82290. * @returns the new rotation matrix
  82291. */
  82292. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82293. /**
  82294. * Creates a rotation matrix and stores it in a given matrix
  82295. * @param yaw defines the yaw angle in radians (Y axis)
  82296. * @param pitch defines the pitch angle in radians (X axis)
  82297. * @param roll defines the roll angle in radians (X axis)
  82298. * @param result defines the target matrix
  82299. */
  82300. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82301. /**
  82302. * Creates a scaling matrix
  82303. * @param x defines the scale factor on X axis
  82304. * @param y defines the scale factor on Y axis
  82305. * @param z defines the scale factor on Z axis
  82306. * @returns the new matrix
  82307. */
  82308. static Scaling(x: number, y: number, z: number): Matrix;
  82309. /**
  82310. * Creates a scaling matrix and stores it in a given matrix
  82311. * @param x defines the scale factor on X axis
  82312. * @param y defines the scale factor on Y axis
  82313. * @param z defines the scale factor on Z axis
  82314. * @param result defines the target matrix
  82315. */
  82316. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82317. /**
  82318. * Creates a translation matrix
  82319. * @param x defines the translation on X axis
  82320. * @param y defines the translation on Y axis
  82321. * @param z defines the translationon Z axis
  82322. * @returns the new matrix
  82323. */
  82324. static Translation(x: number, y: number, z: number): Matrix;
  82325. /**
  82326. * Creates a translation matrix and stores it in a given matrix
  82327. * @param x defines the translation on X axis
  82328. * @param y defines the translation on Y axis
  82329. * @param z defines the translationon Z axis
  82330. * @param result defines the target matrix
  82331. */
  82332. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82333. /**
  82334. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82335. * @param startValue defines the start value
  82336. * @param endValue defines the end value
  82337. * @param gradient defines the gradient factor
  82338. * @returns the new matrix
  82339. */
  82340. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82341. /**
  82342. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82343. * @param startValue defines the start value
  82344. * @param endValue defines the end value
  82345. * @param gradient defines the gradient factor
  82346. * @param result defines the Matrix object where to store data
  82347. */
  82348. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82349. /**
  82350. * Builds a new matrix whose values are computed by:
  82351. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82352. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82353. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82354. * @param startValue defines the first matrix
  82355. * @param endValue defines the second matrix
  82356. * @param gradient defines the gradient between the two matrices
  82357. * @returns the new matrix
  82358. */
  82359. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82360. /**
  82361. * Update a matrix to values which are computed by:
  82362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82365. * @param startValue defines the first matrix
  82366. * @param endValue defines the second matrix
  82367. * @param gradient defines the gradient between the two matrices
  82368. * @param result defines the target matrix
  82369. */
  82370. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82371. /**
  82372. * 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"
  82373. * This function works in left handed mode
  82374. * @param eye defines the final position of the entity
  82375. * @param target defines where the entity should look at
  82376. * @param up defines the up vector for the entity
  82377. * @returns the new matrix
  82378. */
  82379. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82380. /**
  82381. * 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".
  82382. * This function works in left handed mode
  82383. * @param eye defines the final position of the entity
  82384. * @param target defines where the entity should look at
  82385. * @param up defines the up vector for the entity
  82386. * @param result defines the target matrix
  82387. */
  82388. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82389. /**
  82390. * 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"
  82391. * This function works in right handed mode
  82392. * @param eye defines the final position of the entity
  82393. * @param target defines where the entity should look at
  82394. * @param up defines the up vector for the entity
  82395. * @returns the new matrix
  82396. */
  82397. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82398. /**
  82399. * 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".
  82400. * This function works in right handed mode
  82401. * @param eye defines the final position of the entity
  82402. * @param target defines where the entity should look at
  82403. * @param up defines the up vector for the entity
  82404. * @param result defines the target matrix
  82405. */
  82406. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82407. /**
  82408. * Create a left-handed orthographic projection matrix
  82409. * @param width defines the viewport width
  82410. * @param height defines the viewport height
  82411. * @param znear defines the near clip plane
  82412. * @param zfar defines the far clip plane
  82413. * @returns a new matrix as a left-handed orthographic projection matrix
  82414. */
  82415. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82416. /**
  82417. * Store a left-handed orthographic projection to a given matrix
  82418. * @param width defines the viewport width
  82419. * @param height defines the viewport height
  82420. * @param znear defines the near clip plane
  82421. * @param zfar defines the far clip plane
  82422. * @param result defines the target matrix
  82423. */
  82424. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82425. /**
  82426. * Create a left-handed orthographic projection matrix
  82427. * @param left defines the viewport left coordinate
  82428. * @param right defines the viewport right coordinate
  82429. * @param bottom defines the viewport bottom coordinate
  82430. * @param top defines the viewport top coordinate
  82431. * @param znear defines the near clip plane
  82432. * @param zfar defines the far clip plane
  82433. * @returns a new matrix as a left-handed orthographic projection matrix
  82434. */
  82435. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82436. /**
  82437. * Stores a left-handed orthographic projection into a given matrix
  82438. * @param left defines the viewport left coordinate
  82439. * @param right defines the viewport right coordinate
  82440. * @param bottom defines the viewport bottom coordinate
  82441. * @param top defines the viewport top coordinate
  82442. * @param znear defines the near clip plane
  82443. * @param zfar defines the far clip plane
  82444. * @param result defines the target matrix
  82445. */
  82446. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82447. /**
  82448. * Creates a right-handed orthographic projection matrix
  82449. * @param left defines the viewport left coordinate
  82450. * @param right defines the viewport right coordinate
  82451. * @param bottom defines the viewport bottom coordinate
  82452. * @param top defines the viewport top coordinate
  82453. * @param znear defines the near clip plane
  82454. * @param zfar defines the far clip plane
  82455. * @returns a new matrix as a right-handed orthographic projection matrix
  82456. */
  82457. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82458. /**
  82459. * Stores a right-handed orthographic projection into a given matrix
  82460. * @param left defines the viewport left coordinate
  82461. * @param right defines the viewport right coordinate
  82462. * @param bottom defines the viewport bottom coordinate
  82463. * @param top defines the viewport top coordinate
  82464. * @param znear defines the near clip plane
  82465. * @param zfar defines the far clip plane
  82466. * @param result defines the target matrix
  82467. */
  82468. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82469. /**
  82470. * Creates a left-handed perspective projection matrix
  82471. * @param width defines the viewport width
  82472. * @param height defines the viewport height
  82473. * @param znear defines the near clip plane
  82474. * @param zfar defines the far clip plane
  82475. * @returns a new matrix as a left-handed perspective projection matrix
  82476. */
  82477. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82478. /**
  82479. * Creates a left-handed perspective projection matrix
  82480. * @param fov defines the horizontal field of view
  82481. * @param aspect defines the aspect ratio
  82482. * @param znear defines the near clip plane
  82483. * @param zfar defines the far clip plane
  82484. * @returns a new matrix as a left-handed perspective projection matrix
  82485. */
  82486. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82487. /**
  82488. * Stores a left-handed perspective projection into a given matrix
  82489. * @param fov defines the horizontal field of view
  82490. * @param aspect defines the aspect ratio
  82491. * @param znear defines the near clip plane
  82492. * @param zfar defines the far clip plane
  82493. * @param result defines the target matrix
  82494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82495. */
  82496. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82497. /**
  82498. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82499. * @param fov defines the horizontal field of view
  82500. * @param aspect defines the aspect ratio
  82501. * @param znear defines the near clip plane
  82502. * @param zfar not used as infinity is used as far clip
  82503. * @param result defines the target matrix
  82504. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82505. */
  82506. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82507. /**
  82508. * Creates a right-handed perspective projection matrix
  82509. * @param fov defines the horizontal field of view
  82510. * @param aspect defines the aspect ratio
  82511. * @param znear defines the near clip plane
  82512. * @param zfar defines the far clip plane
  82513. * @returns a new matrix as a right-handed perspective projection matrix
  82514. */
  82515. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82516. /**
  82517. * Stores a right-handed perspective projection into a given matrix
  82518. * @param fov defines the horizontal field of view
  82519. * @param aspect defines the aspect ratio
  82520. * @param znear defines the near clip plane
  82521. * @param zfar defines the far clip plane
  82522. * @param result defines the target matrix
  82523. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82524. */
  82525. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82526. /**
  82527. * Stores a right-handed perspective projection into a given matrix
  82528. * @param fov defines the horizontal field of view
  82529. * @param aspect defines the aspect ratio
  82530. * @param znear defines the near clip plane
  82531. * @param zfar not used as infinity is used as far clip
  82532. * @param result defines the target matrix
  82533. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82534. */
  82535. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82536. /**
  82537. * Stores a perspective projection for WebVR info a given matrix
  82538. * @param fov defines the field of view
  82539. * @param znear defines the near clip plane
  82540. * @param zfar defines the far clip plane
  82541. * @param result defines the target matrix
  82542. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82543. */
  82544. static PerspectiveFovWebVRToRef(fov: {
  82545. upDegrees: number;
  82546. downDegrees: number;
  82547. leftDegrees: number;
  82548. rightDegrees: number;
  82549. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82550. /**
  82551. * Computes a complete transformation matrix
  82552. * @param viewport defines the viewport to use
  82553. * @param world defines the world matrix
  82554. * @param view defines the view matrix
  82555. * @param projection defines the projection matrix
  82556. * @param zmin defines the near clip plane
  82557. * @param zmax defines the far clip plane
  82558. * @returns the transformation matrix
  82559. */
  82560. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82561. /**
  82562. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82563. * @param matrix defines the matrix to use
  82564. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82565. */
  82566. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82567. /**
  82568. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82569. * @param matrix defines the matrix to use
  82570. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82571. */
  82572. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82573. /**
  82574. * Compute the transpose of a given matrix
  82575. * @param matrix defines the matrix to transpose
  82576. * @returns the new matrix
  82577. */
  82578. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82579. /**
  82580. * Compute the transpose of a matrix and store it in a target matrix
  82581. * @param matrix defines the matrix to transpose
  82582. * @param result defines the target matrix
  82583. */
  82584. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82585. /**
  82586. * Computes a reflection matrix from a plane
  82587. * @param plane defines the reflection plane
  82588. * @returns a new matrix
  82589. */
  82590. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82591. /**
  82592. * Computes a reflection matrix from a plane
  82593. * @param plane defines the reflection plane
  82594. * @param result defines the target matrix
  82595. */
  82596. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82597. /**
  82598. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82599. * @param xaxis defines the value of the 1st axis
  82600. * @param yaxis defines the value of the 2nd axis
  82601. * @param zaxis defines the value of the 3rd axis
  82602. * @param result defines the target matrix
  82603. */
  82604. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82605. /**
  82606. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82607. * @param quat defines the quaternion to use
  82608. * @param result defines the target matrix
  82609. */
  82610. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82611. }
  82612. /**
  82613. * @hidden
  82614. */
  82615. export class TmpVectors {
  82616. static Vector2: Vector2[];
  82617. static Vector3: Vector3[];
  82618. static Vector4: Vector4[];
  82619. static Quaternion: Quaternion[];
  82620. static Matrix: Matrix[];
  82621. }
  82622. }
  82623. declare module BABYLON {
  82624. /**
  82625. * Defines potential orientation for back face culling
  82626. */
  82627. export enum Orientation {
  82628. /**
  82629. * Clockwise
  82630. */
  82631. CW = 0,
  82632. /** Counter clockwise */
  82633. CCW = 1
  82634. }
  82635. /** Class used to represent a Bezier curve */
  82636. export class BezierCurve {
  82637. /**
  82638. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82639. * @param t defines the time
  82640. * @param x1 defines the left coordinate on X axis
  82641. * @param y1 defines the left coordinate on Y axis
  82642. * @param x2 defines the right coordinate on X axis
  82643. * @param y2 defines the right coordinate on Y axis
  82644. * @returns the interpolated value
  82645. */
  82646. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82647. }
  82648. /**
  82649. * Defines angle representation
  82650. */
  82651. export class Angle {
  82652. private _radians;
  82653. /**
  82654. * Creates an Angle object of "radians" radians (float).
  82655. * @param radians the angle in radians
  82656. */
  82657. constructor(radians: number);
  82658. /**
  82659. * Get value in degrees
  82660. * @returns the Angle value in degrees (float)
  82661. */
  82662. degrees(): number;
  82663. /**
  82664. * Get value in radians
  82665. * @returns the Angle value in radians (float)
  82666. */
  82667. radians(): number;
  82668. /**
  82669. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82670. * @param a defines first vector
  82671. * @param b defines second vector
  82672. * @returns a new Angle
  82673. */
  82674. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82675. /**
  82676. * Gets a new Angle object from the given float in radians
  82677. * @param radians defines the angle value in radians
  82678. * @returns a new Angle
  82679. */
  82680. static FromRadians(radians: number): Angle;
  82681. /**
  82682. * Gets a new Angle object from the given float in degrees
  82683. * @param degrees defines the angle value in degrees
  82684. * @returns a new Angle
  82685. */
  82686. static FromDegrees(degrees: number): Angle;
  82687. }
  82688. /**
  82689. * This represents an arc in a 2d space.
  82690. */
  82691. export class Arc2 {
  82692. /** Defines the start point of the arc */
  82693. startPoint: Vector2;
  82694. /** Defines the mid point of the arc */
  82695. midPoint: Vector2;
  82696. /** Defines the end point of the arc */
  82697. endPoint: Vector2;
  82698. /**
  82699. * Defines the center point of the arc.
  82700. */
  82701. centerPoint: Vector2;
  82702. /**
  82703. * Defines the radius of the arc.
  82704. */
  82705. radius: number;
  82706. /**
  82707. * Defines the angle of the arc (from mid point to end point).
  82708. */
  82709. angle: Angle;
  82710. /**
  82711. * Defines the start angle of the arc (from start point to middle point).
  82712. */
  82713. startAngle: Angle;
  82714. /**
  82715. * Defines the orientation of the arc (clock wise/counter clock wise).
  82716. */
  82717. orientation: Orientation;
  82718. /**
  82719. * Creates an Arc object from the three given points : start, middle and end.
  82720. * @param startPoint Defines the start point of the arc
  82721. * @param midPoint Defines the midlle point of the arc
  82722. * @param endPoint Defines the end point of the arc
  82723. */
  82724. constructor(
  82725. /** Defines the start point of the arc */
  82726. startPoint: Vector2,
  82727. /** Defines the mid point of the arc */
  82728. midPoint: Vector2,
  82729. /** Defines the end point of the arc */
  82730. endPoint: Vector2);
  82731. }
  82732. /**
  82733. * Represents a 2D path made up of multiple 2D points
  82734. */
  82735. export class Path2 {
  82736. private _points;
  82737. private _length;
  82738. /**
  82739. * If the path start and end point are the same
  82740. */
  82741. closed: boolean;
  82742. /**
  82743. * Creates a Path2 object from the starting 2D coordinates x and y.
  82744. * @param x the starting points x value
  82745. * @param y the starting points y value
  82746. */
  82747. constructor(x: number, y: number);
  82748. /**
  82749. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82750. * @param x the added points x value
  82751. * @param y the added points y value
  82752. * @returns the updated Path2.
  82753. */
  82754. addLineTo(x: number, y: number): Path2;
  82755. /**
  82756. * 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.
  82757. * @param midX middle point x value
  82758. * @param midY middle point y value
  82759. * @param endX end point x value
  82760. * @param endY end point y value
  82761. * @param numberOfSegments (default: 36)
  82762. * @returns the updated Path2.
  82763. */
  82764. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82765. /**
  82766. * Closes the Path2.
  82767. * @returns the Path2.
  82768. */
  82769. close(): Path2;
  82770. /**
  82771. * Gets the sum of the distance between each sequential point in the path
  82772. * @returns the Path2 total length (float).
  82773. */
  82774. length(): number;
  82775. /**
  82776. * Gets the points which construct the path
  82777. * @returns the Path2 internal array of points.
  82778. */
  82779. getPoints(): Vector2[];
  82780. /**
  82781. * Retreives the point at the distance aways from the starting point
  82782. * @param normalizedLengthPosition the length along the path to retreive the point from
  82783. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82784. */
  82785. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82786. /**
  82787. * Creates a new path starting from an x and y position
  82788. * @param x starting x value
  82789. * @param y starting y value
  82790. * @returns a new Path2 starting at the coordinates (x, y).
  82791. */
  82792. static StartingAt(x: number, y: number): Path2;
  82793. }
  82794. /**
  82795. * Represents a 3D path made up of multiple 3D points
  82796. */
  82797. export class Path3D {
  82798. /**
  82799. * an array of Vector3, the curve axis of the Path3D
  82800. */
  82801. path: Vector3[];
  82802. private _curve;
  82803. private _distances;
  82804. private _tangents;
  82805. private _normals;
  82806. private _binormals;
  82807. private _raw;
  82808. private _alignTangentsWithPath;
  82809. private readonly _pointAtData;
  82810. /**
  82811. * new Path3D(path, normal, raw)
  82812. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82813. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82814. * @param path an array of Vector3, the curve axis of the Path3D
  82815. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82816. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82817. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82818. */
  82819. constructor(
  82820. /**
  82821. * an array of Vector3, the curve axis of the Path3D
  82822. */
  82823. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82824. /**
  82825. * Returns the Path3D array of successive Vector3 designing its curve.
  82826. * @returns the Path3D array of successive Vector3 designing its curve.
  82827. */
  82828. getCurve(): Vector3[];
  82829. /**
  82830. * Returns the Path3D array of successive Vector3 designing its curve.
  82831. * @returns the Path3D array of successive Vector3 designing its curve.
  82832. */
  82833. getPoints(): Vector3[];
  82834. /**
  82835. * @returns the computed length (float) of the path.
  82836. */
  82837. length(): number;
  82838. /**
  82839. * Returns an array populated with tangent vectors on each Path3D curve point.
  82840. * @returns an array populated with tangent vectors on each Path3D curve point.
  82841. */
  82842. getTangents(): Vector3[];
  82843. /**
  82844. * Returns an array populated with normal vectors on each Path3D curve point.
  82845. * @returns an array populated with normal vectors on each Path3D curve point.
  82846. */
  82847. getNormals(): Vector3[];
  82848. /**
  82849. * Returns an array populated with binormal vectors on each Path3D curve point.
  82850. * @returns an array populated with binormal vectors on each Path3D curve point.
  82851. */
  82852. getBinormals(): Vector3[];
  82853. /**
  82854. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82855. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82856. */
  82857. getDistances(): number[];
  82858. /**
  82859. * Returns an interpolated point along this path
  82860. * @param position the position of the point along this path, from 0.0 to 1.0
  82861. * @returns a new Vector3 as the point
  82862. */
  82863. getPointAt(position: number): Vector3;
  82864. /**
  82865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82866. * @param position the position of the point along this path, from 0.0 to 1.0
  82867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82868. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82869. */
  82870. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82871. /**
  82872. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82873. * @param position the position of the point along this path, from 0.0 to 1.0
  82874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82875. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82876. */
  82877. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82878. /**
  82879. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82880. * @param position the position of the point along this path, from 0.0 to 1.0
  82881. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82882. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82883. */
  82884. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82885. /**
  82886. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82887. * @param position the position of the point along this path, from 0.0 to 1.0
  82888. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82889. */
  82890. getDistanceAt(position: number): number;
  82891. /**
  82892. * Returns the array index of the previous point of an interpolated point along this path
  82893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82894. * @returns the array index
  82895. */
  82896. getPreviousPointIndexAt(position: number): number;
  82897. /**
  82898. * 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)
  82899. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82900. * @returns the sub position
  82901. */
  82902. getSubPositionAt(position: number): number;
  82903. /**
  82904. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82905. * @param target the vector of which to get the closest position to
  82906. * @returns the position of the closest virtual point on this path to the target vector
  82907. */
  82908. getClosestPositionTo(target: Vector3): number;
  82909. /**
  82910. * Returns a sub path (slice) of this path
  82911. * @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
  82912. * @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
  82913. * @returns a sub path (slice) of this path
  82914. */
  82915. slice(start?: number, end?: number): Path3D;
  82916. /**
  82917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82918. * @param path path which all values are copied into the curves points
  82919. * @param firstNormal which should be projected onto the curve
  82920. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82921. * @returns the same object updated.
  82922. */
  82923. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82924. private _compute;
  82925. private _getFirstNonNullVector;
  82926. private _getLastNonNullVector;
  82927. private _normalVector;
  82928. /**
  82929. * Updates the point at data for an interpolated point along this curve
  82930. * @param position the position of the point along this curve, from 0.0 to 1.0
  82931. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82932. * @returns the (updated) point at data
  82933. */
  82934. private _updatePointAtData;
  82935. /**
  82936. * Updates the point at data from the specified parameters
  82937. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82938. * @param point the interpolated point
  82939. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82940. */
  82941. private _setPointAtData;
  82942. /**
  82943. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82944. */
  82945. private _updateInterpolationMatrix;
  82946. }
  82947. /**
  82948. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82949. * A Curve3 is designed from a series of successive Vector3.
  82950. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82951. */
  82952. export class Curve3 {
  82953. private _points;
  82954. private _length;
  82955. /**
  82956. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82957. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82958. * @param v1 (Vector3) the control point
  82959. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82960. * @param nbPoints (integer) the wanted number of points in the curve
  82961. * @returns the created Curve3
  82962. */
  82963. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82964. /**
  82965. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82966. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82967. * @param v1 (Vector3) the first control point
  82968. * @param v2 (Vector3) the second control point
  82969. * @param v3 (Vector3) the end point of the Cubic Bezier
  82970. * @param nbPoints (integer) the wanted number of points in the curve
  82971. * @returns the created Curve3
  82972. */
  82973. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82974. /**
  82975. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82976. * @param p1 (Vector3) the origin point of the Hermite Spline
  82977. * @param t1 (Vector3) the tangent vector at the origin point
  82978. * @param p2 (Vector3) the end point of the Hermite Spline
  82979. * @param t2 (Vector3) the tangent vector at the end point
  82980. * @param nbPoints (integer) the wanted number of points in the curve
  82981. * @returns the created Curve3
  82982. */
  82983. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82984. /**
  82985. * Returns a Curve3 object along a CatmullRom Spline curve :
  82986. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82987. * @param nbPoints (integer) the wanted number of points between each curve control points
  82988. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82989. * @returns the created Curve3
  82990. */
  82991. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82992. /**
  82993. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82994. * A Curve3 is designed from a series of successive Vector3.
  82995. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82996. * @param points points which make up the curve
  82997. */
  82998. constructor(points: Vector3[]);
  82999. /**
  83000. * @returns the Curve3 stored array of successive Vector3
  83001. */
  83002. getPoints(): Vector3[];
  83003. /**
  83004. * @returns the computed length (float) of the curve.
  83005. */
  83006. length(): number;
  83007. /**
  83008. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83009. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83010. * curveA and curveB keep unchanged.
  83011. * @param curve the curve to continue from this curve
  83012. * @returns the newly constructed curve
  83013. */
  83014. continue(curve: DeepImmutable<Curve3>): Curve3;
  83015. private _computeLength;
  83016. }
  83017. }
  83018. declare module BABYLON {
  83019. /**
  83020. * This represents the main contract an easing function should follow.
  83021. * Easing functions are used throughout the animation system.
  83022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83023. */
  83024. export interface IEasingFunction {
  83025. /**
  83026. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83027. * of the easing function.
  83028. * The link below provides some of the most common examples of easing functions.
  83029. * @see https://easings.net/
  83030. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83031. * @returns the corresponding value on the curve defined by the easing function
  83032. */
  83033. ease(gradient: number): number;
  83034. }
  83035. /**
  83036. * Base class used for every default easing function.
  83037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83038. */
  83039. export class EasingFunction implements IEasingFunction {
  83040. /**
  83041. * Interpolation follows the mathematical formula associated with the easing function.
  83042. */
  83043. static readonly EASINGMODE_EASEIN: number;
  83044. /**
  83045. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83046. */
  83047. static readonly EASINGMODE_EASEOUT: number;
  83048. /**
  83049. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83050. */
  83051. static readonly EASINGMODE_EASEINOUT: number;
  83052. private _easingMode;
  83053. /**
  83054. * Sets the easing mode of the current function.
  83055. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83056. */
  83057. setEasingMode(easingMode: number): void;
  83058. /**
  83059. * Gets the current easing mode.
  83060. * @returns the easing mode
  83061. */
  83062. getEasingMode(): number;
  83063. /**
  83064. * @hidden
  83065. */
  83066. easeInCore(gradient: number): number;
  83067. /**
  83068. * Given an input gradient between 0 and 1, this returns the corresponding value
  83069. * of the easing function.
  83070. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83071. * @returns the corresponding value on the curve defined by the easing function
  83072. */
  83073. ease(gradient: number): number;
  83074. }
  83075. /**
  83076. * Easing function with a circle shape (see link below).
  83077. * @see https://easings.net/#easeInCirc
  83078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83079. */
  83080. export class CircleEase extends EasingFunction implements IEasingFunction {
  83081. /** @hidden */
  83082. easeInCore(gradient: number): number;
  83083. }
  83084. /**
  83085. * Easing function with a ease back shape (see link below).
  83086. * @see https://easings.net/#easeInBack
  83087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83088. */
  83089. export class BackEase extends EasingFunction implements IEasingFunction {
  83090. /** Defines the amplitude of the function */
  83091. amplitude: number;
  83092. /**
  83093. * Instantiates a back ease easing
  83094. * @see https://easings.net/#easeInBack
  83095. * @param amplitude Defines the amplitude of the function
  83096. */
  83097. constructor(
  83098. /** Defines the amplitude of the function */
  83099. amplitude?: number);
  83100. /** @hidden */
  83101. easeInCore(gradient: number): number;
  83102. }
  83103. /**
  83104. * Easing function with a bouncing shape (see link below).
  83105. * @see https://easings.net/#easeInBounce
  83106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83107. */
  83108. export class BounceEase extends EasingFunction implements IEasingFunction {
  83109. /** Defines the number of bounces */
  83110. bounces: number;
  83111. /** Defines the amplitude of the bounce */
  83112. bounciness: number;
  83113. /**
  83114. * Instantiates a bounce easing
  83115. * @see https://easings.net/#easeInBounce
  83116. * @param bounces Defines the number of bounces
  83117. * @param bounciness Defines the amplitude of the bounce
  83118. */
  83119. constructor(
  83120. /** Defines the number of bounces */
  83121. bounces?: number,
  83122. /** Defines the amplitude of the bounce */
  83123. bounciness?: number);
  83124. /** @hidden */
  83125. easeInCore(gradient: number): number;
  83126. }
  83127. /**
  83128. * Easing function with a power of 3 shape (see link below).
  83129. * @see https://easings.net/#easeInCubic
  83130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83131. */
  83132. export class CubicEase extends EasingFunction implements IEasingFunction {
  83133. /** @hidden */
  83134. easeInCore(gradient: number): number;
  83135. }
  83136. /**
  83137. * Easing function with an elastic shape (see link below).
  83138. * @see https://easings.net/#easeInElastic
  83139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83140. */
  83141. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83142. /** Defines the number of oscillations*/
  83143. oscillations: number;
  83144. /** Defines the amplitude of the oscillations*/
  83145. springiness: number;
  83146. /**
  83147. * Instantiates an elastic easing function
  83148. * @see https://easings.net/#easeInElastic
  83149. * @param oscillations Defines the number of oscillations
  83150. * @param springiness Defines the amplitude of the oscillations
  83151. */
  83152. constructor(
  83153. /** Defines the number of oscillations*/
  83154. oscillations?: number,
  83155. /** Defines the amplitude of the oscillations*/
  83156. springiness?: number);
  83157. /** @hidden */
  83158. easeInCore(gradient: number): number;
  83159. }
  83160. /**
  83161. * Easing function with an exponential shape (see link below).
  83162. * @see https://easings.net/#easeInExpo
  83163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83164. */
  83165. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83166. /** Defines the exponent of the function */
  83167. exponent: number;
  83168. /**
  83169. * Instantiates an exponential easing function
  83170. * @see https://easings.net/#easeInExpo
  83171. * @param exponent Defines the exponent of the function
  83172. */
  83173. constructor(
  83174. /** Defines the exponent of the function */
  83175. exponent?: number);
  83176. /** @hidden */
  83177. easeInCore(gradient: number): number;
  83178. }
  83179. /**
  83180. * Easing function with a power shape (see link below).
  83181. * @see https://easings.net/#easeInQuad
  83182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83183. */
  83184. export class PowerEase extends EasingFunction implements IEasingFunction {
  83185. /** Defines the power of the function */
  83186. power: number;
  83187. /**
  83188. * Instantiates an power base easing function
  83189. * @see https://easings.net/#easeInQuad
  83190. * @param power Defines the power of the function
  83191. */
  83192. constructor(
  83193. /** Defines the power of the function */
  83194. power?: number);
  83195. /** @hidden */
  83196. easeInCore(gradient: number): number;
  83197. }
  83198. /**
  83199. * Easing function with a power of 2 shape (see link below).
  83200. * @see https://easings.net/#easeInQuad
  83201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83202. */
  83203. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83204. /** @hidden */
  83205. easeInCore(gradient: number): number;
  83206. }
  83207. /**
  83208. * Easing function with a power of 4 shape (see link below).
  83209. * @see https://easings.net/#easeInQuart
  83210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83211. */
  83212. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83213. /** @hidden */
  83214. easeInCore(gradient: number): number;
  83215. }
  83216. /**
  83217. * Easing function with a power of 5 shape (see link below).
  83218. * @see https://easings.net/#easeInQuint
  83219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83220. */
  83221. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83222. /** @hidden */
  83223. easeInCore(gradient: number): number;
  83224. }
  83225. /**
  83226. * Easing function with a sin shape (see link below).
  83227. * @see https://easings.net/#easeInSine
  83228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83229. */
  83230. export class SineEase extends EasingFunction implements IEasingFunction {
  83231. /** @hidden */
  83232. easeInCore(gradient: number): number;
  83233. }
  83234. /**
  83235. * Easing function with a bezier shape (see link below).
  83236. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83238. */
  83239. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83240. /** Defines the x component of the start tangent in the bezier curve */
  83241. x1: number;
  83242. /** Defines the y component of the start tangent in the bezier curve */
  83243. y1: number;
  83244. /** Defines the x component of the end tangent in the bezier curve */
  83245. x2: number;
  83246. /** Defines the y component of the end tangent in the bezier curve */
  83247. y2: number;
  83248. /**
  83249. * Instantiates a bezier function
  83250. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83251. * @param x1 Defines the x component of the start tangent in the bezier curve
  83252. * @param y1 Defines the y component of the start tangent in the bezier curve
  83253. * @param x2 Defines the x component of the end tangent in the bezier curve
  83254. * @param y2 Defines the y component of the end tangent in the bezier curve
  83255. */
  83256. constructor(
  83257. /** Defines the x component of the start tangent in the bezier curve */
  83258. x1?: number,
  83259. /** Defines the y component of the start tangent in the bezier curve */
  83260. y1?: number,
  83261. /** Defines the x component of the end tangent in the bezier curve */
  83262. x2?: number,
  83263. /** Defines the y component of the end tangent in the bezier curve */
  83264. y2?: number);
  83265. /** @hidden */
  83266. easeInCore(gradient: number): number;
  83267. }
  83268. }
  83269. declare module BABYLON {
  83270. /**
  83271. * Class used to hold a RBG color
  83272. */
  83273. export class Color3 {
  83274. /**
  83275. * Defines the red component (between 0 and 1, default is 0)
  83276. */
  83277. r: number;
  83278. /**
  83279. * Defines the green component (between 0 and 1, default is 0)
  83280. */
  83281. g: number;
  83282. /**
  83283. * Defines the blue component (between 0 and 1, default is 0)
  83284. */
  83285. b: number;
  83286. /**
  83287. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83288. * @param r defines the red component (between 0 and 1, default is 0)
  83289. * @param g defines the green component (between 0 and 1, default is 0)
  83290. * @param b defines the blue component (between 0 and 1, default is 0)
  83291. */
  83292. constructor(
  83293. /**
  83294. * Defines the red component (between 0 and 1, default is 0)
  83295. */
  83296. r?: number,
  83297. /**
  83298. * Defines the green component (between 0 and 1, default is 0)
  83299. */
  83300. g?: number,
  83301. /**
  83302. * Defines the blue component (between 0 and 1, default is 0)
  83303. */
  83304. b?: number);
  83305. /**
  83306. * Creates a string with the Color3 current values
  83307. * @returns the string representation of the Color3 object
  83308. */
  83309. toString(): string;
  83310. /**
  83311. * Returns the string "Color3"
  83312. * @returns "Color3"
  83313. */
  83314. getClassName(): string;
  83315. /**
  83316. * Compute the Color3 hash code
  83317. * @returns an unique number that can be used to hash Color3 objects
  83318. */
  83319. getHashCode(): number;
  83320. /**
  83321. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83322. * @param array defines the array where to store the r,g,b components
  83323. * @param index defines an optional index in the target array to define where to start storing values
  83324. * @returns the current Color3 object
  83325. */
  83326. toArray(array: FloatArray, index?: number): Color3;
  83327. /**
  83328. * Returns a new Color4 object from the current Color3 and the given alpha
  83329. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83330. * @returns a new Color4 object
  83331. */
  83332. toColor4(alpha?: number): Color4;
  83333. /**
  83334. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83335. * @returns the new array
  83336. */
  83337. asArray(): number[];
  83338. /**
  83339. * Returns the luminance value
  83340. * @returns a float value
  83341. */
  83342. toLuminance(): number;
  83343. /**
  83344. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83345. * @param otherColor defines the second operand
  83346. * @returns the new Color3 object
  83347. */
  83348. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83349. /**
  83350. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83351. * @param otherColor defines the second operand
  83352. * @param result defines the Color3 object where to store the result
  83353. * @returns the current Color3
  83354. */
  83355. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83356. /**
  83357. * Determines equality between Color3 objects
  83358. * @param otherColor defines the second operand
  83359. * @returns true if the rgb values are equal to the given ones
  83360. */
  83361. equals(otherColor: DeepImmutable<Color3>): boolean;
  83362. /**
  83363. * Determines equality between the current Color3 object and a set of r,b,g values
  83364. * @param r defines the red component to check
  83365. * @param g defines the green component to check
  83366. * @param b defines the blue component to check
  83367. * @returns true if the rgb values are equal to the given ones
  83368. */
  83369. equalsFloats(r: number, g: number, b: number): boolean;
  83370. /**
  83371. * Multiplies in place each rgb value by scale
  83372. * @param scale defines the scaling factor
  83373. * @returns the updated Color3
  83374. */
  83375. scale(scale: number): Color3;
  83376. /**
  83377. * Multiplies the rgb values by scale and stores the result into "result"
  83378. * @param scale defines the scaling factor
  83379. * @param result defines the Color3 object where to store the result
  83380. * @returns the unmodified current Color3
  83381. */
  83382. scaleToRef(scale: number, result: Color3): Color3;
  83383. /**
  83384. * Scale the current Color3 values by a factor and add the result to a given Color3
  83385. * @param scale defines the scale factor
  83386. * @param result defines color to store the result into
  83387. * @returns the unmodified current Color3
  83388. */
  83389. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83390. /**
  83391. * Clamps the rgb values by the min and max values and stores the result into "result"
  83392. * @param min defines minimum clamping value (default is 0)
  83393. * @param max defines maximum clamping value (default is 1)
  83394. * @param result defines color to store the result into
  83395. * @returns the original Color3
  83396. */
  83397. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83398. /**
  83399. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83400. * @param otherColor defines the second operand
  83401. * @returns the new Color3
  83402. */
  83403. add(otherColor: DeepImmutable<Color3>): Color3;
  83404. /**
  83405. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83406. * @param otherColor defines the second operand
  83407. * @param result defines Color3 object to store the result into
  83408. * @returns the unmodified current Color3
  83409. */
  83410. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83411. /**
  83412. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83413. * @param otherColor defines the second operand
  83414. * @returns the new Color3
  83415. */
  83416. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83417. /**
  83418. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83419. * @param otherColor defines the second operand
  83420. * @param result defines Color3 object to store the result into
  83421. * @returns the unmodified current Color3
  83422. */
  83423. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83424. /**
  83425. * Copy the current object
  83426. * @returns a new Color3 copied the current one
  83427. */
  83428. clone(): Color3;
  83429. /**
  83430. * Copies the rgb values from the source in the current Color3
  83431. * @param source defines the source Color3 object
  83432. * @returns the updated Color3 object
  83433. */
  83434. copyFrom(source: DeepImmutable<Color3>): Color3;
  83435. /**
  83436. * Updates the Color3 rgb values from the given floats
  83437. * @param r defines the red component to read from
  83438. * @param g defines the green component to read from
  83439. * @param b defines the blue component to read from
  83440. * @returns the current Color3 object
  83441. */
  83442. copyFromFloats(r: number, g: number, b: number): Color3;
  83443. /**
  83444. * Updates the Color3 rgb values from the given floats
  83445. * @param r defines the red component to read from
  83446. * @param g defines the green component to read from
  83447. * @param b defines the blue component to read from
  83448. * @returns the current Color3 object
  83449. */
  83450. set(r: number, g: number, b: number): Color3;
  83451. /**
  83452. * Compute the Color3 hexadecimal code as a string
  83453. * @returns a string containing the hexadecimal representation of the Color3 object
  83454. */
  83455. toHexString(): string;
  83456. /**
  83457. * Computes a new Color3 converted from the current one to linear space
  83458. * @returns a new Color3 object
  83459. */
  83460. toLinearSpace(): Color3;
  83461. /**
  83462. * Converts current color in rgb space to HSV values
  83463. * @returns a new color3 representing the HSV values
  83464. */
  83465. toHSV(): Color3;
  83466. /**
  83467. * Converts current color in rgb space to HSV values
  83468. * @param result defines the Color3 where to store the HSV values
  83469. */
  83470. toHSVToRef(result: Color3): void;
  83471. /**
  83472. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83473. * @param convertedColor defines the Color3 object where to store the linear space version
  83474. * @returns the unmodified Color3
  83475. */
  83476. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83477. /**
  83478. * Computes a new Color3 converted from the current one to gamma space
  83479. * @returns a new Color3 object
  83480. */
  83481. toGammaSpace(): Color3;
  83482. /**
  83483. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83484. * @param convertedColor defines the Color3 object where to store the gamma space version
  83485. * @returns the unmodified Color3
  83486. */
  83487. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83488. private static _BlackReadOnly;
  83489. /**
  83490. * Convert Hue, saturation and value to a Color3 (RGB)
  83491. * @param hue defines the hue
  83492. * @param saturation defines the saturation
  83493. * @param value defines the value
  83494. * @param result defines the Color3 where to store the RGB values
  83495. */
  83496. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83497. /**
  83498. * Creates a new Color3 from the string containing valid hexadecimal values
  83499. * @param hex defines a string containing valid hexadecimal values
  83500. * @returns a new Color3 object
  83501. */
  83502. static FromHexString(hex: string): Color3;
  83503. /**
  83504. * Creates a new Color3 from the starting index of the given array
  83505. * @param array defines the source array
  83506. * @param offset defines an offset in the source array
  83507. * @returns a new Color3 object
  83508. */
  83509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83510. /**
  83511. * Creates a new Color3 from integer values (< 256)
  83512. * @param r defines the red component to read from (value between 0 and 255)
  83513. * @param g defines the green component to read from (value between 0 and 255)
  83514. * @param b defines the blue component to read from (value between 0 and 255)
  83515. * @returns a new Color3 object
  83516. */
  83517. static FromInts(r: number, g: number, b: number): Color3;
  83518. /**
  83519. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83520. * @param start defines the start Color3 value
  83521. * @param end defines the end Color3 value
  83522. * @param amount defines the gradient value between start and end
  83523. * @returns a new Color3 object
  83524. */
  83525. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83526. /**
  83527. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83528. * @param left defines the start value
  83529. * @param right defines the end value
  83530. * @param amount defines the gradient factor
  83531. * @param result defines the Color3 object where to store the result
  83532. */
  83533. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83534. /**
  83535. * Returns a Color3 value containing a red color
  83536. * @returns a new Color3 object
  83537. */
  83538. static Red(): Color3;
  83539. /**
  83540. * Returns a Color3 value containing a green color
  83541. * @returns a new Color3 object
  83542. */
  83543. static Green(): Color3;
  83544. /**
  83545. * Returns a Color3 value containing a blue color
  83546. * @returns a new Color3 object
  83547. */
  83548. static Blue(): Color3;
  83549. /**
  83550. * Returns a Color3 value containing a black color
  83551. * @returns a new Color3 object
  83552. */
  83553. static Black(): Color3;
  83554. /**
  83555. * Gets a Color3 value containing a black color that must not be updated
  83556. */
  83557. static get BlackReadOnly(): DeepImmutable<Color3>;
  83558. /**
  83559. * Returns a Color3 value containing a white color
  83560. * @returns a new Color3 object
  83561. */
  83562. static White(): Color3;
  83563. /**
  83564. * Returns a Color3 value containing a purple color
  83565. * @returns a new Color3 object
  83566. */
  83567. static Purple(): Color3;
  83568. /**
  83569. * Returns a Color3 value containing a magenta color
  83570. * @returns a new Color3 object
  83571. */
  83572. static Magenta(): Color3;
  83573. /**
  83574. * Returns a Color3 value containing a yellow color
  83575. * @returns a new Color3 object
  83576. */
  83577. static Yellow(): Color3;
  83578. /**
  83579. * Returns a Color3 value containing a gray color
  83580. * @returns a new Color3 object
  83581. */
  83582. static Gray(): Color3;
  83583. /**
  83584. * Returns a Color3 value containing a teal color
  83585. * @returns a new Color3 object
  83586. */
  83587. static Teal(): Color3;
  83588. /**
  83589. * Returns a Color3 value containing a random color
  83590. * @returns a new Color3 object
  83591. */
  83592. static Random(): Color3;
  83593. }
  83594. /**
  83595. * Class used to hold a RBGA color
  83596. */
  83597. export class Color4 {
  83598. /**
  83599. * Defines the red component (between 0 and 1, default is 0)
  83600. */
  83601. r: number;
  83602. /**
  83603. * Defines the green component (between 0 and 1, default is 0)
  83604. */
  83605. g: number;
  83606. /**
  83607. * Defines the blue component (between 0 and 1, default is 0)
  83608. */
  83609. b: number;
  83610. /**
  83611. * Defines the alpha component (between 0 and 1, default is 1)
  83612. */
  83613. a: number;
  83614. /**
  83615. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83616. * @param r defines the red component (between 0 and 1, default is 0)
  83617. * @param g defines the green component (between 0 and 1, default is 0)
  83618. * @param b defines the blue component (between 0 and 1, default is 0)
  83619. * @param a defines the alpha component (between 0 and 1, default is 1)
  83620. */
  83621. constructor(
  83622. /**
  83623. * Defines the red component (between 0 and 1, default is 0)
  83624. */
  83625. r?: number,
  83626. /**
  83627. * Defines the green component (between 0 and 1, default is 0)
  83628. */
  83629. g?: number,
  83630. /**
  83631. * Defines the blue component (between 0 and 1, default is 0)
  83632. */
  83633. b?: number,
  83634. /**
  83635. * Defines the alpha component (between 0 and 1, default is 1)
  83636. */
  83637. a?: number);
  83638. /**
  83639. * Adds in place the given Color4 values to the current Color4 object
  83640. * @param right defines the second operand
  83641. * @returns the current updated Color4 object
  83642. */
  83643. addInPlace(right: DeepImmutable<Color4>): Color4;
  83644. /**
  83645. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83646. * @returns the new array
  83647. */
  83648. asArray(): number[];
  83649. /**
  83650. * Stores from the starting index in the given array the Color4 successive values
  83651. * @param array defines the array where to store the r,g,b components
  83652. * @param index defines an optional index in the target array to define where to start storing values
  83653. * @returns the current Color4 object
  83654. */
  83655. toArray(array: number[], index?: number): Color4;
  83656. /**
  83657. * Determines equality between Color4 objects
  83658. * @param otherColor defines the second operand
  83659. * @returns true if the rgba values are equal to the given ones
  83660. */
  83661. equals(otherColor: DeepImmutable<Color4>): boolean;
  83662. /**
  83663. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83664. * @param right defines the second operand
  83665. * @returns a new Color4 object
  83666. */
  83667. add(right: DeepImmutable<Color4>): Color4;
  83668. /**
  83669. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83670. * @param right defines the second operand
  83671. * @returns a new Color4 object
  83672. */
  83673. subtract(right: DeepImmutable<Color4>): Color4;
  83674. /**
  83675. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83676. * @param right defines the second operand
  83677. * @param result defines the Color4 object where to store the result
  83678. * @returns the current Color4 object
  83679. */
  83680. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83681. /**
  83682. * Creates a new Color4 with the current Color4 values multiplied by scale
  83683. * @param scale defines the scaling factor to apply
  83684. * @returns a new Color4 object
  83685. */
  83686. scale(scale: number): Color4;
  83687. /**
  83688. * Multiplies the current Color4 values by scale and stores the result in "result"
  83689. * @param scale defines the scaling factor to apply
  83690. * @param result defines the Color4 object where to store the result
  83691. * @returns the current unmodified Color4
  83692. */
  83693. scaleToRef(scale: number, result: Color4): Color4;
  83694. /**
  83695. * Scale the current Color4 values by a factor and add the result to a given Color4
  83696. * @param scale defines the scale factor
  83697. * @param result defines the Color4 object where to store the result
  83698. * @returns the unmodified current Color4
  83699. */
  83700. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83701. /**
  83702. * Clamps the rgb values by the min and max values and stores the result into "result"
  83703. * @param min defines minimum clamping value (default is 0)
  83704. * @param max defines maximum clamping value (default is 1)
  83705. * @param result defines color to store the result into.
  83706. * @returns the cuurent Color4
  83707. */
  83708. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83709. /**
  83710. * Multipy an Color4 value by another and return a new Color4 object
  83711. * @param color defines the Color4 value to multiply by
  83712. * @returns a new Color4 object
  83713. */
  83714. multiply(color: Color4): Color4;
  83715. /**
  83716. * Multipy a Color4 value by another and push the result in a reference value
  83717. * @param color defines the Color4 value to multiply by
  83718. * @param result defines the Color4 to fill the result in
  83719. * @returns the result Color4
  83720. */
  83721. multiplyToRef(color: Color4, result: Color4): Color4;
  83722. /**
  83723. * Creates a string with the Color4 current values
  83724. * @returns the string representation of the Color4 object
  83725. */
  83726. toString(): string;
  83727. /**
  83728. * Returns the string "Color4"
  83729. * @returns "Color4"
  83730. */
  83731. getClassName(): string;
  83732. /**
  83733. * Compute the Color4 hash code
  83734. * @returns an unique number that can be used to hash Color4 objects
  83735. */
  83736. getHashCode(): number;
  83737. /**
  83738. * Creates a new Color4 copied from the current one
  83739. * @returns a new Color4 object
  83740. */
  83741. clone(): Color4;
  83742. /**
  83743. * Copies the given Color4 values into the current one
  83744. * @param source defines the source Color4 object
  83745. * @returns the current updated Color4 object
  83746. */
  83747. copyFrom(source: Color4): Color4;
  83748. /**
  83749. * Copies the given float values into the current one
  83750. * @param r defines the red component to read from
  83751. * @param g defines the green component to read from
  83752. * @param b defines the blue component to read from
  83753. * @param a defines the alpha component to read from
  83754. * @returns the current updated Color4 object
  83755. */
  83756. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83757. /**
  83758. * Copies the given float values into the current one
  83759. * @param r defines the red component to read from
  83760. * @param g defines the green component to read from
  83761. * @param b defines the blue component to read from
  83762. * @param a defines the alpha component to read from
  83763. * @returns the current updated Color4 object
  83764. */
  83765. set(r: number, g: number, b: number, a: number): Color4;
  83766. /**
  83767. * Compute the Color4 hexadecimal code as a string
  83768. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83769. * @returns a string containing the hexadecimal representation of the Color4 object
  83770. */
  83771. toHexString(returnAsColor3?: boolean): string;
  83772. /**
  83773. * Computes a new Color4 converted from the current one to linear space
  83774. * @returns a new Color4 object
  83775. */
  83776. toLinearSpace(): Color4;
  83777. /**
  83778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83779. * @param convertedColor defines the Color4 object where to store the linear space version
  83780. * @returns the unmodified Color4
  83781. */
  83782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83783. /**
  83784. * Computes a new Color4 converted from the current one to gamma space
  83785. * @returns a new Color4 object
  83786. */
  83787. toGammaSpace(): Color4;
  83788. /**
  83789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83790. * @param convertedColor defines the Color4 object where to store the gamma space version
  83791. * @returns the unmodified Color4
  83792. */
  83793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83794. /**
  83795. * Creates a new Color4 from the string containing valid hexadecimal values
  83796. * @param hex defines a string containing valid hexadecimal values
  83797. * @returns a new Color4 object
  83798. */
  83799. static FromHexString(hex: string): Color4;
  83800. /**
  83801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83802. * @param left defines the start value
  83803. * @param right defines the end value
  83804. * @param amount defines the gradient factor
  83805. * @returns a new Color4 object
  83806. */
  83807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83808. /**
  83809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83810. * @param left defines the start value
  83811. * @param right defines the end value
  83812. * @param amount defines the gradient factor
  83813. * @param result defines the Color4 object where to store data
  83814. */
  83815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83816. /**
  83817. * Creates a new Color4 from a Color3 and an alpha value
  83818. * @param color3 defines the source Color3 to read from
  83819. * @param alpha defines the alpha component (1.0 by default)
  83820. * @returns a new Color4 object
  83821. */
  83822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83823. /**
  83824. * Creates a new Color4 from the starting index element of the given array
  83825. * @param array defines the source array to read from
  83826. * @param offset defines the offset in the source array
  83827. * @returns a new Color4 object
  83828. */
  83829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83830. /**
  83831. * Creates a new Color3 from integer values (< 256)
  83832. * @param r defines the red component to read from (value between 0 and 255)
  83833. * @param g defines the green component to read from (value between 0 and 255)
  83834. * @param b defines the blue component to read from (value between 0 and 255)
  83835. * @param a defines the alpha component to read from (value between 0 and 255)
  83836. * @returns a new Color3 object
  83837. */
  83838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83839. /**
  83840. * Check the content of a given array and convert it to an array containing RGBA data
  83841. * If the original array was already containing count * 4 values then it is returned directly
  83842. * @param colors defines the array to check
  83843. * @param count defines the number of RGBA data to expect
  83844. * @returns an array containing count * 4 values (RGBA)
  83845. */
  83846. static CheckColors4(colors: number[], count: number): number[];
  83847. }
  83848. /**
  83849. * @hidden
  83850. */
  83851. export class TmpColors {
  83852. static Color3: Color3[];
  83853. static Color4: Color4[];
  83854. }
  83855. }
  83856. declare module BABYLON {
  83857. /**
  83858. * Defines an interface which represents an animation key frame
  83859. */
  83860. export interface IAnimationKey {
  83861. /**
  83862. * Frame of the key frame
  83863. */
  83864. frame: number;
  83865. /**
  83866. * Value at the specifies key frame
  83867. */
  83868. value: any;
  83869. /**
  83870. * The input tangent for the cubic hermite spline
  83871. */
  83872. inTangent?: any;
  83873. /**
  83874. * The output tangent for the cubic hermite spline
  83875. */
  83876. outTangent?: any;
  83877. /**
  83878. * The animation interpolation type
  83879. */
  83880. interpolation?: AnimationKeyInterpolation;
  83881. }
  83882. /**
  83883. * Enum for the animation key frame interpolation type
  83884. */
  83885. export enum AnimationKeyInterpolation {
  83886. /**
  83887. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83888. */
  83889. STEP = 1
  83890. }
  83891. }
  83892. declare module BABYLON {
  83893. /**
  83894. * Represents the range of an animation
  83895. */
  83896. export class AnimationRange {
  83897. /**The name of the animation range**/
  83898. name: string;
  83899. /**The starting frame of the animation */
  83900. from: number;
  83901. /**The ending frame of the animation*/
  83902. to: number;
  83903. /**
  83904. * Initializes the range of an animation
  83905. * @param name The name of the animation range
  83906. * @param from The starting frame of the animation
  83907. * @param to The ending frame of the animation
  83908. */
  83909. constructor(
  83910. /**The name of the animation range**/
  83911. name: string,
  83912. /**The starting frame of the animation */
  83913. from: number,
  83914. /**The ending frame of the animation*/
  83915. to: number);
  83916. /**
  83917. * Makes a copy of the animation range
  83918. * @returns A copy of the animation range
  83919. */
  83920. clone(): AnimationRange;
  83921. }
  83922. }
  83923. declare module BABYLON {
  83924. /**
  83925. * Composed of a frame, and an action function
  83926. */
  83927. export class AnimationEvent {
  83928. /** The frame for which the event is triggered **/
  83929. frame: number;
  83930. /** The event to perform when triggered **/
  83931. action: (currentFrame: number) => void;
  83932. /** Specifies if the event should be triggered only once**/
  83933. onlyOnce?: boolean | undefined;
  83934. /**
  83935. * Specifies if the animation event is done
  83936. */
  83937. isDone: boolean;
  83938. /**
  83939. * Initializes the animation event
  83940. * @param frame The frame for which the event is triggered
  83941. * @param action The event to perform when triggered
  83942. * @param onlyOnce Specifies if the event should be triggered only once
  83943. */
  83944. constructor(
  83945. /** The frame for which the event is triggered **/
  83946. frame: number,
  83947. /** The event to perform when triggered **/
  83948. action: (currentFrame: number) => void,
  83949. /** Specifies if the event should be triggered only once**/
  83950. onlyOnce?: boolean | undefined);
  83951. /** @hidden */
  83952. _clone(): AnimationEvent;
  83953. }
  83954. }
  83955. declare module BABYLON {
  83956. /**
  83957. * Interface used to define a behavior
  83958. */
  83959. export interface Behavior<T> {
  83960. /** gets or sets behavior's name */
  83961. name: string;
  83962. /**
  83963. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83964. */
  83965. init(): void;
  83966. /**
  83967. * Called when the behavior is attached to a target
  83968. * @param target defines the target where the behavior is attached to
  83969. */
  83970. attach(target: T): void;
  83971. /**
  83972. * Called when the behavior is detached from its target
  83973. */
  83974. detach(): void;
  83975. }
  83976. /**
  83977. * Interface implemented by classes supporting behaviors
  83978. */
  83979. export interface IBehaviorAware<T> {
  83980. /**
  83981. * Attach a behavior
  83982. * @param behavior defines the behavior to attach
  83983. * @returns the current host
  83984. */
  83985. addBehavior(behavior: Behavior<T>): T;
  83986. /**
  83987. * Remove a behavior from the current object
  83988. * @param behavior defines the behavior to detach
  83989. * @returns the current host
  83990. */
  83991. removeBehavior(behavior: Behavior<T>): T;
  83992. /**
  83993. * Gets a behavior using its name to search
  83994. * @param name defines the name to search
  83995. * @returns the behavior or null if not found
  83996. */
  83997. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83998. }
  83999. }
  84000. declare module BABYLON {
  84001. /**
  84002. * Defines an array and its length.
  84003. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84004. */
  84005. export interface ISmartArrayLike<T> {
  84006. /**
  84007. * The data of the array.
  84008. */
  84009. data: Array<T>;
  84010. /**
  84011. * The active length of the array.
  84012. */
  84013. length: number;
  84014. }
  84015. /**
  84016. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84017. */
  84018. export class SmartArray<T> implements ISmartArrayLike<T> {
  84019. /**
  84020. * The full set of data from the array.
  84021. */
  84022. data: Array<T>;
  84023. /**
  84024. * The active length of the array.
  84025. */
  84026. length: number;
  84027. protected _id: number;
  84028. /**
  84029. * Instantiates a Smart Array.
  84030. * @param capacity defines the default capacity of the array.
  84031. */
  84032. constructor(capacity: number);
  84033. /**
  84034. * Pushes a value at the end of the active data.
  84035. * @param value defines the object to push in the array.
  84036. */
  84037. push(value: T): void;
  84038. /**
  84039. * Iterates over the active data and apply the lambda to them.
  84040. * @param func defines the action to apply on each value.
  84041. */
  84042. forEach(func: (content: T) => void): void;
  84043. /**
  84044. * Sorts the full sets of data.
  84045. * @param compareFn defines the comparison function to apply.
  84046. */
  84047. sort(compareFn: (a: T, b: T) => number): void;
  84048. /**
  84049. * Resets the active data to an empty array.
  84050. */
  84051. reset(): void;
  84052. /**
  84053. * Releases all the data from the array as well as the array.
  84054. */
  84055. dispose(): void;
  84056. /**
  84057. * Concats the active data with a given array.
  84058. * @param array defines the data to concatenate with.
  84059. */
  84060. concat(array: any): void;
  84061. /**
  84062. * Returns the position of a value in the active data.
  84063. * @param value defines the value to find the index for
  84064. * @returns the index if found in the active data otherwise -1
  84065. */
  84066. indexOf(value: T): number;
  84067. /**
  84068. * Returns whether an element is part of the active data.
  84069. * @param value defines the value to look for
  84070. * @returns true if found in the active data otherwise false
  84071. */
  84072. contains(value: T): boolean;
  84073. private static _GlobalId;
  84074. }
  84075. /**
  84076. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84077. * The data in this array can only be present once
  84078. */
  84079. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84080. private _duplicateId;
  84081. /**
  84082. * Pushes a value at the end of the active data.
  84083. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84084. * @param value defines the object to push in the array.
  84085. */
  84086. push(value: T): void;
  84087. /**
  84088. * Pushes a value at the end of the active data.
  84089. * If the data is already present, it won t be added again
  84090. * @param value defines the object to push in the array.
  84091. * @returns true if added false if it was already present
  84092. */
  84093. pushNoDuplicate(value: T): boolean;
  84094. /**
  84095. * Resets the active data to an empty array.
  84096. */
  84097. reset(): void;
  84098. /**
  84099. * Concats the active data with a given array.
  84100. * This ensures no dupplicate will be present in the result.
  84101. * @param array defines the data to concatenate with.
  84102. */
  84103. concatWithNoDuplicate(array: any): void;
  84104. }
  84105. }
  84106. declare module BABYLON {
  84107. /**
  84108. * @ignore
  84109. * This is a list of all the different input types that are available in the application.
  84110. * Fo instance: ArcRotateCameraGamepadInput...
  84111. */
  84112. export var CameraInputTypes: {};
  84113. /**
  84114. * This is the contract to implement in order to create a new input class.
  84115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84116. */
  84117. export interface ICameraInput<TCamera extends Camera> {
  84118. /**
  84119. * Defines the camera the input is attached to.
  84120. */
  84121. camera: Nullable<TCamera>;
  84122. /**
  84123. * Gets the class name of the current intput.
  84124. * @returns the class name
  84125. */
  84126. getClassName(): string;
  84127. /**
  84128. * Get the friendly name associated with the input class.
  84129. * @returns the input friendly name
  84130. */
  84131. getSimpleName(): string;
  84132. /**
  84133. * Attach the input controls to a specific dom element to get the input from.
  84134. * @param element Defines the element the controls should be listened from
  84135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84136. */
  84137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84138. /**
  84139. * Detach the current controls from the specified dom element.
  84140. * @param element Defines the element to stop listening the inputs from
  84141. */
  84142. detachControl(element: Nullable<HTMLElement>): void;
  84143. /**
  84144. * Update the current camera state depending on the inputs that have been used this frame.
  84145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84146. */
  84147. checkInputs?: () => void;
  84148. }
  84149. /**
  84150. * Represents a map of input types to input instance or input index to input instance.
  84151. */
  84152. export interface CameraInputsMap<TCamera extends Camera> {
  84153. /**
  84154. * Accessor to the input by input type.
  84155. */
  84156. [name: string]: ICameraInput<TCamera>;
  84157. /**
  84158. * Accessor to the input by input index.
  84159. */
  84160. [idx: number]: ICameraInput<TCamera>;
  84161. }
  84162. /**
  84163. * This represents the input manager used within a camera.
  84164. * It helps dealing with all the different kind of input attached to a camera.
  84165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84166. */
  84167. export class CameraInputsManager<TCamera extends Camera> {
  84168. /**
  84169. * Defines the list of inputs attahed to the camera.
  84170. */
  84171. attached: CameraInputsMap<TCamera>;
  84172. /**
  84173. * Defines the dom element the camera is collecting inputs from.
  84174. * This is null if the controls have not been attached.
  84175. */
  84176. attachedElement: Nullable<HTMLElement>;
  84177. /**
  84178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84179. */
  84180. noPreventDefault: boolean;
  84181. /**
  84182. * Defined the camera the input manager belongs to.
  84183. */
  84184. camera: TCamera;
  84185. /**
  84186. * Update the current camera state depending on the inputs that have been used this frame.
  84187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84188. */
  84189. checkInputs: () => void;
  84190. /**
  84191. * Instantiate a new Camera Input Manager.
  84192. * @param camera Defines the camera the input manager blongs to
  84193. */
  84194. constructor(camera: TCamera);
  84195. /**
  84196. * Add an input method to a camera
  84197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84198. * @param input camera input method
  84199. */
  84200. add(input: ICameraInput<TCamera>): void;
  84201. /**
  84202. * Remove a specific input method from a camera
  84203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84204. * @param inputToRemove camera input method
  84205. */
  84206. remove(inputToRemove: ICameraInput<TCamera>): void;
  84207. /**
  84208. * Remove a specific input type from a camera
  84209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84210. * @param inputType the type of the input to remove
  84211. */
  84212. removeByType(inputType: string): void;
  84213. private _addCheckInputs;
  84214. /**
  84215. * Attach the input controls to the currently attached dom element to listen the events from.
  84216. * @param input Defines the input to attach
  84217. */
  84218. attachInput(input: ICameraInput<TCamera>): void;
  84219. /**
  84220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84221. * @param element Defines the dom element to collect the events from
  84222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84223. */
  84224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84225. /**
  84226. * Detach the current manager inputs controls from a specific dom element.
  84227. * @param element Defines the dom element to collect the events from
  84228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84229. */
  84230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84231. /**
  84232. * Rebuild the dynamic inputCheck function from the current list of
  84233. * defined inputs in the manager.
  84234. */
  84235. rebuildInputCheck(): void;
  84236. /**
  84237. * Remove all attached input methods from a camera
  84238. */
  84239. clear(): void;
  84240. /**
  84241. * Serialize the current input manager attached to a camera.
  84242. * This ensures than once parsed,
  84243. * the input associated to the camera will be identical to the current ones
  84244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84245. */
  84246. serialize(serializedCamera: any): void;
  84247. /**
  84248. * Parses an input manager serialized JSON to restore the previous list of inputs
  84249. * and states associated to a camera.
  84250. * @param parsedCamera Defines the JSON to parse
  84251. */
  84252. parse(parsedCamera: any): void;
  84253. }
  84254. }
  84255. declare module BABYLON {
  84256. /**
  84257. * Class used to store data that will be store in GPU memory
  84258. */
  84259. export class Buffer {
  84260. private _engine;
  84261. private _buffer;
  84262. /** @hidden */
  84263. _data: Nullable<DataArray>;
  84264. private _updatable;
  84265. private _instanced;
  84266. private _divisor;
  84267. /**
  84268. * Gets the byte stride.
  84269. */
  84270. readonly byteStride: number;
  84271. /**
  84272. * Constructor
  84273. * @param engine the engine
  84274. * @param data the data to use for this buffer
  84275. * @param updatable whether the data is updatable
  84276. * @param stride the stride (optional)
  84277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84278. * @param instanced whether the buffer is instanced (optional)
  84279. * @param useBytes set to true if the stride in in bytes (optional)
  84280. * @param divisor sets an optional divisor for instances (1 by default)
  84281. */
  84282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84283. /**
  84284. * Create a new VertexBuffer based on the current buffer
  84285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84286. * @param offset defines offset in the buffer (0 by default)
  84287. * @param size defines the size in floats of attributes (position is 3 for instance)
  84288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84289. * @param instanced defines if the vertex buffer contains indexed data
  84290. * @param useBytes defines if the offset and stride are in bytes *
  84291. * @param divisor sets an optional divisor for instances (1 by default)
  84292. * @returns the new vertex buffer
  84293. */
  84294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84295. /**
  84296. * Gets a boolean indicating if the Buffer is updatable?
  84297. * @returns true if the buffer is updatable
  84298. */
  84299. isUpdatable(): boolean;
  84300. /**
  84301. * Gets current buffer's data
  84302. * @returns a DataArray or null
  84303. */
  84304. getData(): Nullable<DataArray>;
  84305. /**
  84306. * Gets underlying native buffer
  84307. * @returns underlying native buffer
  84308. */
  84309. getBuffer(): Nullable<DataBuffer>;
  84310. /**
  84311. * Gets the stride in float32 units (i.e. byte stride / 4).
  84312. * May not be an integer if the byte stride is not divisible by 4.
  84313. * @returns the stride in float32 units
  84314. * @deprecated Please use byteStride instead.
  84315. */
  84316. getStrideSize(): number;
  84317. /**
  84318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84319. * @param data defines the data to store
  84320. */
  84321. create(data?: Nullable<DataArray>): void;
  84322. /** @hidden */
  84323. _rebuild(): void;
  84324. /**
  84325. * Update current buffer data
  84326. * @param data defines the data to store
  84327. */
  84328. update(data: DataArray): void;
  84329. /**
  84330. * Updates the data directly.
  84331. * @param data the new data
  84332. * @param offset the new offset
  84333. * @param vertexCount the vertex count (optional)
  84334. * @param useBytes set to true if the offset is in bytes
  84335. */
  84336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84337. /**
  84338. * Release all resources
  84339. */
  84340. dispose(): void;
  84341. }
  84342. /**
  84343. * Specialized buffer used to store vertex data
  84344. */
  84345. export class VertexBuffer {
  84346. /** @hidden */
  84347. _buffer: Buffer;
  84348. private _kind;
  84349. private _size;
  84350. private _ownsBuffer;
  84351. private _instanced;
  84352. private _instanceDivisor;
  84353. /**
  84354. * The byte type.
  84355. */
  84356. static readonly BYTE: number;
  84357. /**
  84358. * The unsigned byte type.
  84359. */
  84360. static readonly UNSIGNED_BYTE: number;
  84361. /**
  84362. * The short type.
  84363. */
  84364. static readonly SHORT: number;
  84365. /**
  84366. * The unsigned short type.
  84367. */
  84368. static readonly UNSIGNED_SHORT: number;
  84369. /**
  84370. * The integer type.
  84371. */
  84372. static readonly INT: number;
  84373. /**
  84374. * The unsigned integer type.
  84375. */
  84376. static readonly UNSIGNED_INT: number;
  84377. /**
  84378. * The float type.
  84379. */
  84380. static readonly FLOAT: number;
  84381. /**
  84382. * Gets or sets the instance divisor when in instanced mode
  84383. */
  84384. get instanceDivisor(): number;
  84385. set instanceDivisor(value: number);
  84386. /**
  84387. * Gets the byte stride.
  84388. */
  84389. readonly byteStride: number;
  84390. /**
  84391. * Gets the byte offset.
  84392. */
  84393. readonly byteOffset: number;
  84394. /**
  84395. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84396. */
  84397. readonly normalized: boolean;
  84398. /**
  84399. * Gets the data type of each component in the array.
  84400. */
  84401. readonly type: number;
  84402. /**
  84403. * Constructor
  84404. * @param engine the engine
  84405. * @param data the data to use for this vertex buffer
  84406. * @param kind the vertex buffer kind
  84407. * @param updatable whether the data is updatable
  84408. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84409. * @param stride the stride (optional)
  84410. * @param instanced whether the buffer is instanced (optional)
  84411. * @param offset the offset of the data (optional)
  84412. * @param size the number of components (optional)
  84413. * @param type the type of the component (optional)
  84414. * @param normalized whether the data contains normalized data (optional)
  84415. * @param useBytes set to true if stride and offset are in bytes (optional)
  84416. * @param divisor defines the instance divisor to use (1 by default)
  84417. */
  84418. 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);
  84419. /** @hidden */
  84420. _rebuild(): void;
  84421. /**
  84422. * Returns the kind of the VertexBuffer (string)
  84423. * @returns a string
  84424. */
  84425. getKind(): string;
  84426. /**
  84427. * Gets a boolean indicating if the VertexBuffer is updatable?
  84428. * @returns true if the buffer is updatable
  84429. */
  84430. isUpdatable(): boolean;
  84431. /**
  84432. * Gets current buffer's data
  84433. * @returns a DataArray or null
  84434. */
  84435. getData(): Nullable<DataArray>;
  84436. /**
  84437. * Gets underlying native buffer
  84438. * @returns underlying native buffer
  84439. */
  84440. getBuffer(): Nullable<DataBuffer>;
  84441. /**
  84442. * Gets the stride in float32 units (i.e. byte stride / 4).
  84443. * May not be an integer if the byte stride is not divisible by 4.
  84444. * @returns the stride in float32 units
  84445. * @deprecated Please use byteStride instead.
  84446. */
  84447. getStrideSize(): number;
  84448. /**
  84449. * Returns the offset as a multiple of the type byte length.
  84450. * @returns the offset in bytes
  84451. * @deprecated Please use byteOffset instead.
  84452. */
  84453. getOffset(): number;
  84454. /**
  84455. * Returns the number of components per vertex attribute (integer)
  84456. * @returns the size in float
  84457. */
  84458. getSize(): number;
  84459. /**
  84460. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84461. * @returns true if this buffer is instanced
  84462. */
  84463. getIsInstanced(): boolean;
  84464. /**
  84465. * Returns the instancing divisor, zero for non-instanced (integer).
  84466. * @returns a number
  84467. */
  84468. getInstanceDivisor(): number;
  84469. /**
  84470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84471. * @param data defines the data to store
  84472. */
  84473. create(data?: DataArray): void;
  84474. /**
  84475. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84476. * This function will create a new buffer if the current one is not updatable
  84477. * @param data defines the data to store
  84478. */
  84479. update(data: DataArray): void;
  84480. /**
  84481. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84482. * Returns the directly updated WebGLBuffer.
  84483. * @param data the new data
  84484. * @param offset the new offset
  84485. * @param useBytes set to true if the offset is in bytes
  84486. */
  84487. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84488. /**
  84489. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84490. */
  84491. dispose(): void;
  84492. /**
  84493. * Enumerates each value of this vertex buffer as numbers.
  84494. * @param count the number of values to enumerate
  84495. * @param callback the callback function called for each value
  84496. */
  84497. forEach(count: number, callback: (value: number, index: number) => void): void;
  84498. /**
  84499. * Positions
  84500. */
  84501. static readonly PositionKind: string;
  84502. /**
  84503. * Normals
  84504. */
  84505. static readonly NormalKind: string;
  84506. /**
  84507. * Tangents
  84508. */
  84509. static readonly TangentKind: string;
  84510. /**
  84511. * Texture coordinates
  84512. */
  84513. static readonly UVKind: string;
  84514. /**
  84515. * Texture coordinates 2
  84516. */
  84517. static readonly UV2Kind: string;
  84518. /**
  84519. * Texture coordinates 3
  84520. */
  84521. static readonly UV3Kind: string;
  84522. /**
  84523. * Texture coordinates 4
  84524. */
  84525. static readonly UV4Kind: string;
  84526. /**
  84527. * Texture coordinates 5
  84528. */
  84529. static readonly UV5Kind: string;
  84530. /**
  84531. * Texture coordinates 6
  84532. */
  84533. static readonly UV6Kind: string;
  84534. /**
  84535. * Colors
  84536. */
  84537. static readonly ColorKind: string;
  84538. /**
  84539. * Matrix indices (for bones)
  84540. */
  84541. static readonly MatricesIndicesKind: string;
  84542. /**
  84543. * Matrix weights (for bones)
  84544. */
  84545. static readonly MatricesWeightsKind: string;
  84546. /**
  84547. * Additional matrix indices (for bones)
  84548. */
  84549. static readonly MatricesIndicesExtraKind: string;
  84550. /**
  84551. * Additional matrix weights (for bones)
  84552. */
  84553. static readonly MatricesWeightsExtraKind: string;
  84554. /**
  84555. * Deduces the stride given a kind.
  84556. * @param kind The kind string to deduce
  84557. * @returns The deduced stride
  84558. */
  84559. static DeduceStride(kind: string): number;
  84560. /**
  84561. * Gets the byte length of the given type.
  84562. * @param type the type
  84563. * @returns the number of bytes
  84564. */
  84565. static GetTypeByteLength(type: number): number;
  84566. /**
  84567. * Enumerates each value of the given parameters as numbers.
  84568. * @param data the data to enumerate
  84569. * @param byteOffset the byte offset of the data
  84570. * @param byteStride the byte stride of the data
  84571. * @param componentCount the number of components per element
  84572. * @param componentType the type of the component
  84573. * @param count the number of values to enumerate
  84574. * @param normalized whether the data is normalized
  84575. * @param callback the callback function called for each value
  84576. */
  84577. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84578. private static _GetFloatValue;
  84579. }
  84580. }
  84581. declare module BABYLON {
  84582. /**
  84583. * @hidden
  84584. */
  84585. export class IntersectionInfo {
  84586. bu: Nullable<number>;
  84587. bv: Nullable<number>;
  84588. distance: number;
  84589. faceId: number;
  84590. subMeshId: number;
  84591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84592. }
  84593. }
  84594. declare module BABYLON {
  84595. /**
  84596. * Class used to store bounding sphere information
  84597. */
  84598. export class BoundingSphere {
  84599. /**
  84600. * Gets the center of the bounding sphere in local space
  84601. */
  84602. readonly center: Vector3;
  84603. /**
  84604. * Radius of the bounding sphere in local space
  84605. */
  84606. radius: number;
  84607. /**
  84608. * Gets the center of the bounding sphere in world space
  84609. */
  84610. readonly centerWorld: Vector3;
  84611. /**
  84612. * Radius of the bounding sphere in world space
  84613. */
  84614. radiusWorld: number;
  84615. /**
  84616. * Gets the minimum vector in local space
  84617. */
  84618. readonly minimum: Vector3;
  84619. /**
  84620. * Gets the maximum vector in local space
  84621. */
  84622. readonly maximum: Vector3;
  84623. private _worldMatrix;
  84624. private static readonly TmpVector3;
  84625. /**
  84626. * Creates a new bounding sphere
  84627. * @param min defines the minimum vector (in local space)
  84628. * @param max defines the maximum vector (in local space)
  84629. * @param worldMatrix defines the new world matrix
  84630. */
  84631. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84632. /**
  84633. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84634. * @param min defines the new minimum vector (in local space)
  84635. * @param max defines the new maximum vector (in local space)
  84636. * @param worldMatrix defines the new world matrix
  84637. */
  84638. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84639. /**
  84640. * Scale the current bounding sphere by applying a scale factor
  84641. * @param factor defines the scale factor to apply
  84642. * @returns the current bounding box
  84643. */
  84644. scale(factor: number): BoundingSphere;
  84645. /**
  84646. * Gets the world matrix of the bounding box
  84647. * @returns a matrix
  84648. */
  84649. getWorldMatrix(): DeepImmutable<Matrix>;
  84650. /** @hidden */
  84651. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84652. /**
  84653. * Tests if the bounding sphere is intersecting the frustum planes
  84654. * @param frustumPlanes defines the frustum planes to test
  84655. * @returns true if there is an intersection
  84656. */
  84657. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84658. /**
  84659. * Tests if the bounding sphere center is in between the frustum planes.
  84660. * Used for optimistic fast inclusion.
  84661. * @param frustumPlanes defines the frustum planes to test
  84662. * @returns true if the sphere center is in between the frustum planes
  84663. */
  84664. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84665. /**
  84666. * Tests if a point is inside the bounding sphere
  84667. * @param point defines the point to test
  84668. * @returns true if the point is inside the bounding sphere
  84669. */
  84670. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84671. /**
  84672. * Checks if two sphere intersct
  84673. * @param sphere0 sphere 0
  84674. * @param sphere1 sphere 1
  84675. * @returns true if the speres intersect
  84676. */
  84677. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84678. }
  84679. }
  84680. declare module BABYLON {
  84681. /**
  84682. * Class used to store bounding box information
  84683. */
  84684. export class BoundingBox implements ICullable {
  84685. /**
  84686. * Gets the 8 vectors representing the bounding box in local space
  84687. */
  84688. readonly vectors: Vector3[];
  84689. /**
  84690. * Gets the center of the bounding box in local space
  84691. */
  84692. readonly center: Vector3;
  84693. /**
  84694. * Gets the center of the bounding box in world space
  84695. */
  84696. readonly centerWorld: Vector3;
  84697. /**
  84698. * Gets the extend size in local space
  84699. */
  84700. readonly extendSize: Vector3;
  84701. /**
  84702. * Gets the extend size in world space
  84703. */
  84704. readonly extendSizeWorld: Vector3;
  84705. /**
  84706. * Gets the OBB (object bounding box) directions
  84707. */
  84708. readonly directions: Vector3[];
  84709. /**
  84710. * Gets the 8 vectors representing the bounding box in world space
  84711. */
  84712. readonly vectorsWorld: Vector3[];
  84713. /**
  84714. * Gets the minimum vector in world space
  84715. */
  84716. readonly minimumWorld: Vector3;
  84717. /**
  84718. * Gets the maximum vector in world space
  84719. */
  84720. readonly maximumWorld: Vector3;
  84721. /**
  84722. * Gets the minimum vector in local space
  84723. */
  84724. readonly minimum: Vector3;
  84725. /**
  84726. * Gets the maximum vector in local space
  84727. */
  84728. readonly maximum: Vector3;
  84729. private _worldMatrix;
  84730. private static readonly TmpVector3;
  84731. /**
  84732. * @hidden
  84733. */
  84734. _tag: number;
  84735. /**
  84736. * Creates a new bounding box
  84737. * @param min defines the minimum vector (in local space)
  84738. * @param max defines the maximum vector (in local space)
  84739. * @param worldMatrix defines the new world matrix
  84740. */
  84741. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84742. /**
  84743. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84744. * @param min defines the new minimum vector (in local space)
  84745. * @param max defines the new maximum vector (in local space)
  84746. * @param worldMatrix defines the new world matrix
  84747. */
  84748. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84749. /**
  84750. * Scale the current bounding box by applying a scale factor
  84751. * @param factor defines the scale factor to apply
  84752. * @returns the current bounding box
  84753. */
  84754. scale(factor: number): BoundingBox;
  84755. /**
  84756. * Gets the world matrix of the bounding box
  84757. * @returns a matrix
  84758. */
  84759. getWorldMatrix(): DeepImmutable<Matrix>;
  84760. /** @hidden */
  84761. _update(world: DeepImmutable<Matrix>): void;
  84762. /**
  84763. * Tests if the bounding box is intersecting the frustum planes
  84764. * @param frustumPlanes defines the frustum planes to test
  84765. * @returns true if there is an intersection
  84766. */
  84767. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84768. /**
  84769. * Tests if the bounding box is entirely inside the frustum planes
  84770. * @param frustumPlanes defines the frustum planes to test
  84771. * @returns true if there is an inclusion
  84772. */
  84773. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84774. /**
  84775. * Tests if a point is inside the bounding box
  84776. * @param point defines the point to test
  84777. * @returns true if the point is inside the bounding box
  84778. */
  84779. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84780. /**
  84781. * Tests if the bounding box intersects with a bounding sphere
  84782. * @param sphere defines the sphere to test
  84783. * @returns true if there is an intersection
  84784. */
  84785. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84786. /**
  84787. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84788. * @param min defines the min vector to use
  84789. * @param max defines the max vector to use
  84790. * @returns true if there is an intersection
  84791. */
  84792. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84793. /**
  84794. * Tests if two bounding boxes are intersections
  84795. * @param box0 defines the first box to test
  84796. * @param box1 defines the second box to test
  84797. * @returns true if there is an intersection
  84798. */
  84799. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84800. /**
  84801. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84802. * @param minPoint defines the minimum vector of the bounding box
  84803. * @param maxPoint defines the maximum vector of the bounding box
  84804. * @param sphereCenter defines the sphere center
  84805. * @param sphereRadius defines the sphere radius
  84806. * @returns true if there is an intersection
  84807. */
  84808. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84809. /**
  84810. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84811. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84812. * @param frustumPlanes defines the frustum planes to test
  84813. * @return true if there is an inclusion
  84814. */
  84815. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84816. /**
  84817. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84818. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84819. * @param frustumPlanes defines the frustum planes to test
  84820. * @return true if there is an intersection
  84821. */
  84822. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84823. }
  84824. }
  84825. declare module BABYLON {
  84826. /** @hidden */
  84827. export class Collider {
  84828. /** Define if a collision was found */
  84829. collisionFound: boolean;
  84830. /**
  84831. * Define last intersection point in local space
  84832. */
  84833. intersectionPoint: Vector3;
  84834. /**
  84835. * Define last collided mesh
  84836. */
  84837. collidedMesh: Nullable<AbstractMesh>;
  84838. private _collisionPoint;
  84839. private _planeIntersectionPoint;
  84840. private _tempVector;
  84841. private _tempVector2;
  84842. private _tempVector3;
  84843. private _tempVector4;
  84844. private _edge;
  84845. private _baseToVertex;
  84846. private _destinationPoint;
  84847. private _slidePlaneNormal;
  84848. private _displacementVector;
  84849. /** @hidden */
  84850. _radius: Vector3;
  84851. /** @hidden */
  84852. _retry: number;
  84853. private _velocity;
  84854. private _basePoint;
  84855. private _epsilon;
  84856. /** @hidden */
  84857. _velocityWorldLength: number;
  84858. /** @hidden */
  84859. _basePointWorld: Vector3;
  84860. private _velocityWorld;
  84861. private _normalizedVelocity;
  84862. /** @hidden */
  84863. _initialVelocity: Vector3;
  84864. /** @hidden */
  84865. _initialPosition: Vector3;
  84866. private _nearestDistance;
  84867. private _collisionMask;
  84868. get collisionMask(): number;
  84869. set collisionMask(mask: number);
  84870. /**
  84871. * Gets the plane normal used to compute the sliding response (in local space)
  84872. */
  84873. get slidePlaneNormal(): Vector3;
  84874. /** @hidden */
  84875. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84876. /** @hidden */
  84877. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84878. /** @hidden */
  84879. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84880. /** @hidden */
  84881. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84882. /** @hidden */
  84883. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84884. /** @hidden */
  84885. _getResponse(pos: Vector3, vel: Vector3): void;
  84886. }
  84887. }
  84888. declare module BABYLON {
  84889. /**
  84890. * Interface for cullable objects
  84891. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84892. */
  84893. export interface ICullable {
  84894. /**
  84895. * Checks if the object or part of the object is in the frustum
  84896. * @param frustumPlanes Camera near/planes
  84897. * @returns true if the object is in frustum otherwise false
  84898. */
  84899. isInFrustum(frustumPlanes: Plane[]): boolean;
  84900. /**
  84901. * Checks if a cullable object (mesh...) is in the camera frustum
  84902. * Unlike isInFrustum this cheks the full bounding box
  84903. * @param frustumPlanes Camera near/planes
  84904. * @returns true if the object is in frustum otherwise false
  84905. */
  84906. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84907. }
  84908. /**
  84909. * Info for a bounding data of a mesh
  84910. */
  84911. export class BoundingInfo implements ICullable {
  84912. /**
  84913. * Bounding box for the mesh
  84914. */
  84915. readonly boundingBox: BoundingBox;
  84916. /**
  84917. * Bounding sphere for the mesh
  84918. */
  84919. readonly boundingSphere: BoundingSphere;
  84920. private _isLocked;
  84921. private static readonly TmpVector3;
  84922. /**
  84923. * Constructs bounding info
  84924. * @param minimum min vector of the bounding box/sphere
  84925. * @param maximum max vector of the bounding box/sphere
  84926. * @param worldMatrix defines the new world matrix
  84927. */
  84928. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84929. /**
  84930. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84931. * @param min defines the new minimum vector (in local space)
  84932. * @param max defines the new maximum vector (in local space)
  84933. * @param worldMatrix defines the new world matrix
  84934. */
  84935. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84936. /**
  84937. * min vector of the bounding box/sphere
  84938. */
  84939. get minimum(): Vector3;
  84940. /**
  84941. * max vector of the bounding box/sphere
  84942. */
  84943. get maximum(): Vector3;
  84944. /**
  84945. * If the info is locked and won't be updated to avoid perf overhead
  84946. */
  84947. get isLocked(): boolean;
  84948. set isLocked(value: boolean);
  84949. /**
  84950. * Updates the bounding sphere and box
  84951. * @param world world matrix to be used to update
  84952. */
  84953. update(world: DeepImmutable<Matrix>): void;
  84954. /**
  84955. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84956. * @param center New center of the bounding info
  84957. * @param extend New extend of the bounding info
  84958. * @returns the current bounding info
  84959. */
  84960. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84961. /**
  84962. * Scale the current bounding info by applying a scale factor
  84963. * @param factor defines the scale factor to apply
  84964. * @returns the current bounding info
  84965. */
  84966. scale(factor: number): BoundingInfo;
  84967. /**
  84968. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84969. * @param frustumPlanes defines the frustum to test
  84970. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84971. * @returns true if the bounding info is in the frustum planes
  84972. */
  84973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84974. /**
  84975. * Gets the world distance between the min and max points of the bounding box
  84976. */
  84977. get diagonalLength(): number;
  84978. /**
  84979. * Checks if a cullable object (mesh...) is in the camera frustum
  84980. * Unlike isInFrustum this cheks the full bounding box
  84981. * @param frustumPlanes Camera near/planes
  84982. * @returns true if the object is in frustum otherwise false
  84983. */
  84984. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84985. /** @hidden */
  84986. _checkCollision(collider: Collider): boolean;
  84987. /**
  84988. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84989. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84990. * @param point the point to check intersection with
  84991. * @returns if the point intersects
  84992. */
  84993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84994. /**
  84995. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84996. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84997. * @param boundingInfo the bounding info to check intersection with
  84998. * @param precise if the intersection should be done using OBB
  84999. * @returns if the bounding info intersects
  85000. */
  85001. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85002. }
  85003. }
  85004. declare module BABYLON {
  85005. /**
  85006. * Extracts minimum and maximum values from a list of indexed positions
  85007. * @param positions defines the positions to use
  85008. * @param indices defines the indices to the positions
  85009. * @param indexStart defines the start index
  85010. * @param indexCount defines the end index
  85011. * @param bias defines bias value to add to the result
  85012. * @return minimum and maximum values
  85013. */
  85014. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85015. minimum: Vector3;
  85016. maximum: Vector3;
  85017. };
  85018. /**
  85019. * Extracts minimum and maximum values from a list of positions
  85020. * @param positions defines the positions to use
  85021. * @param start defines the start index in the positions array
  85022. * @param count defines the number of positions to handle
  85023. * @param bias defines bias value to add to the result
  85024. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85025. * @return minimum and maximum values
  85026. */
  85027. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85028. minimum: Vector3;
  85029. maximum: Vector3;
  85030. };
  85031. }
  85032. declare module BABYLON {
  85033. /** @hidden */
  85034. export class WebGLDataBuffer extends DataBuffer {
  85035. private _buffer;
  85036. constructor(resource: WebGLBuffer);
  85037. get underlyingResource(): any;
  85038. }
  85039. }
  85040. declare module BABYLON {
  85041. /** @hidden */
  85042. export class WebGLPipelineContext implements IPipelineContext {
  85043. engine: ThinEngine;
  85044. program: Nullable<WebGLProgram>;
  85045. context?: WebGLRenderingContext;
  85046. vertexShader?: WebGLShader;
  85047. fragmentShader?: WebGLShader;
  85048. isParallelCompiled: boolean;
  85049. onCompiled?: () => void;
  85050. transformFeedback?: WebGLTransformFeedback | null;
  85051. vertexCompilationError: Nullable<string>;
  85052. fragmentCompilationError: Nullable<string>;
  85053. programLinkError: Nullable<string>;
  85054. programValidationError: Nullable<string>;
  85055. get isAsync(): boolean;
  85056. get isReady(): boolean;
  85057. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85058. _getVertexShaderCode(): string | null;
  85059. _getFragmentShaderCode(): string | null;
  85060. }
  85061. }
  85062. declare module BABYLON {
  85063. interface ThinEngine {
  85064. /**
  85065. * Create an uniform buffer
  85066. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85067. * @param elements defines the content of the uniform buffer
  85068. * @returns the webGL uniform buffer
  85069. */
  85070. createUniformBuffer(elements: FloatArray): DataBuffer;
  85071. /**
  85072. * Create a dynamic uniform buffer
  85073. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85074. * @param elements defines the content of the uniform buffer
  85075. * @returns the webGL uniform buffer
  85076. */
  85077. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85078. /**
  85079. * Update an existing uniform buffer
  85080. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85081. * @param uniformBuffer defines the target uniform buffer
  85082. * @param elements defines the content to update
  85083. * @param offset defines the offset in the uniform buffer where update should start
  85084. * @param count defines the size of the data to update
  85085. */
  85086. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85087. /**
  85088. * Bind an uniform buffer to the current webGL context
  85089. * @param buffer defines the buffer to bind
  85090. */
  85091. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85092. /**
  85093. * Bind a buffer to the current webGL context at a given location
  85094. * @param buffer defines the buffer to bind
  85095. * @param location defines the index where to bind the buffer
  85096. */
  85097. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85098. /**
  85099. * Bind a specific block at a given index in a specific shader program
  85100. * @param pipelineContext defines the pipeline context to use
  85101. * @param blockName defines the block name
  85102. * @param index defines the index where to bind the block
  85103. */
  85104. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85105. }
  85106. }
  85107. declare module BABYLON {
  85108. /**
  85109. * Uniform buffer objects.
  85110. *
  85111. * Handles blocks of uniform on the GPU.
  85112. *
  85113. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85114. *
  85115. * For more information, please refer to :
  85116. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85117. */
  85118. export class UniformBuffer {
  85119. private _engine;
  85120. private _buffer;
  85121. private _data;
  85122. private _bufferData;
  85123. private _dynamic?;
  85124. private _uniformLocations;
  85125. private _uniformSizes;
  85126. private _uniformLocationPointer;
  85127. private _needSync;
  85128. private _noUBO;
  85129. private _currentEffect;
  85130. /** @hidden */
  85131. _alreadyBound: boolean;
  85132. private static _MAX_UNIFORM_SIZE;
  85133. private static _tempBuffer;
  85134. /**
  85135. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85136. * This is dynamic to allow compat with webgl 1 and 2.
  85137. * You will need to pass the name of the uniform as well as the value.
  85138. */
  85139. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85140. /**
  85141. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85142. * This is dynamic to allow compat with webgl 1 and 2.
  85143. * You will need to pass the name of the uniform as well as the value.
  85144. */
  85145. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85146. /**
  85147. * Lambda to Update a single float in a uniform buffer.
  85148. * This is dynamic to allow compat with webgl 1 and 2.
  85149. * You will need to pass the name of the uniform as well as the value.
  85150. */
  85151. updateFloat: (name: string, x: number) => void;
  85152. /**
  85153. * Lambda to Update a vec2 of float in a uniform buffer.
  85154. * This is dynamic to allow compat with webgl 1 and 2.
  85155. * You will need to pass the name of the uniform as well as the value.
  85156. */
  85157. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85158. /**
  85159. * Lambda to Update a vec3 of float in a uniform buffer.
  85160. * This is dynamic to allow compat with webgl 1 and 2.
  85161. * You will need to pass the name of the uniform as well as the value.
  85162. */
  85163. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85164. /**
  85165. * Lambda to Update a vec4 of float in a uniform buffer.
  85166. * This is dynamic to allow compat with webgl 1 and 2.
  85167. * You will need to pass the name of the uniform as well as the value.
  85168. */
  85169. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85170. /**
  85171. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85172. * This is dynamic to allow compat with webgl 1 and 2.
  85173. * You will need to pass the name of the uniform as well as the value.
  85174. */
  85175. updateMatrix: (name: string, mat: Matrix) => void;
  85176. /**
  85177. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85178. * This is dynamic to allow compat with webgl 1 and 2.
  85179. * You will need to pass the name of the uniform as well as the value.
  85180. */
  85181. updateVector3: (name: string, vector: Vector3) => void;
  85182. /**
  85183. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85184. * This is dynamic to allow compat with webgl 1 and 2.
  85185. * You will need to pass the name of the uniform as well as the value.
  85186. */
  85187. updateVector4: (name: string, vector: Vector4) => void;
  85188. /**
  85189. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85190. * This is dynamic to allow compat with webgl 1 and 2.
  85191. * You will need to pass the name of the uniform as well as the value.
  85192. */
  85193. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85194. /**
  85195. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85196. * This is dynamic to allow compat with webgl 1 and 2.
  85197. * You will need to pass the name of the uniform as well as the value.
  85198. */
  85199. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85200. /**
  85201. * Instantiates a new Uniform buffer objects.
  85202. *
  85203. * Handles blocks of uniform on the GPU.
  85204. *
  85205. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85206. *
  85207. * For more information, please refer to :
  85208. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85209. * @param engine Define the engine the buffer is associated with
  85210. * @param data Define the data contained in the buffer
  85211. * @param dynamic Define if the buffer is updatable
  85212. */
  85213. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85214. /**
  85215. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85216. * or just falling back on setUniformXXX calls.
  85217. */
  85218. get useUbo(): boolean;
  85219. /**
  85220. * Indicates if the WebGL underlying uniform buffer is in sync
  85221. * with the javascript cache data.
  85222. */
  85223. get isSync(): boolean;
  85224. /**
  85225. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85226. * Also, a dynamic UniformBuffer will disable cache verification and always
  85227. * update the underlying WebGL uniform buffer to the GPU.
  85228. * @returns if Dynamic, otherwise false
  85229. */
  85230. isDynamic(): boolean;
  85231. /**
  85232. * The data cache on JS side.
  85233. * @returns the underlying data as a float array
  85234. */
  85235. getData(): Float32Array;
  85236. /**
  85237. * The underlying WebGL Uniform buffer.
  85238. * @returns the webgl buffer
  85239. */
  85240. getBuffer(): Nullable<DataBuffer>;
  85241. /**
  85242. * std140 layout specifies how to align data within an UBO structure.
  85243. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85244. * for specs.
  85245. */
  85246. private _fillAlignment;
  85247. /**
  85248. * Adds an uniform in the buffer.
  85249. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85250. * for the layout to be correct !
  85251. * @param name Name of the uniform, as used in the uniform block in the shader.
  85252. * @param size Data size, or data directly.
  85253. */
  85254. addUniform(name: string, size: number | number[]): void;
  85255. /**
  85256. * Adds a Matrix 4x4 to the uniform buffer.
  85257. * @param name Name of the uniform, as used in the uniform block in the shader.
  85258. * @param mat A 4x4 matrix.
  85259. */
  85260. addMatrix(name: string, mat: Matrix): void;
  85261. /**
  85262. * Adds a vec2 to the uniform buffer.
  85263. * @param name Name of the uniform, as used in the uniform block in the shader.
  85264. * @param x Define the x component value of the vec2
  85265. * @param y Define the y component value of the vec2
  85266. */
  85267. addFloat2(name: string, x: number, y: number): void;
  85268. /**
  85269. * Adds a vec3 to the uniform buffer.
  85270. * @param name Name of the uniform, as used in the uniform block in the shader.
  85271. * @param x Define the x component value of the vec3
  85272. * @param y Define the y component value of the vec3
  85273. * @param z Define the z component value of the vec3
  85274. */
  85275. addFloat3(name: string, x: number, y: number, z: number): void;
  85276. /**
  85277. * Adds a vec3 to the uniform buffer.
  85278. * @param name Name of the uniform, as used in the uniform block in the shader.
  85279. * @param color Define the vec3 from a Color
  85280. */
  85281. addColor3(name: string, color: Color3): void;
  85282. /**
  85283. * Adds a vec4 to the uniform buffer.
  85284. * @param name Name of the uniform, as used in the uniform block in the shader.
  85285. * @param color Define the rgb components from a Color
  85286. * @param alpha Define the a component of the vec4
  85287. */
  85288. addColor4(name: string, color: Color3, alpha: number): void;
  85289. /**
  85290. * Adds a vec3 to the uniform buffer.
  85291. * @param name Name of the uniform, as used in the uniform block in the shader.
  85292. * @param vector Define the vec3 components from a Vector
  85293. */
  85294. addVector3(name: string, vector: Vector3): void;
  85295. /**
  85296. * Adds a Matrix 3x3 to the uniform buffer.
  85297. * @param name Name of the uniform, as used in the uniform block in the shader.
  85298. */
  85299. addMatrix3x3(name: string): void;
  85300. /**
  85301. * Adds a Matrix 2x2 to the uniform buffer.
  85302. * @param name Name of the uniform, as used in the uniform block in the shader.
  85303. */
  85304. addMatrix2x2(name: string): void;
  85305. /**
  85306. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85307. */
  85308. create(): void;
  85309. /** @hidden */
  85310. _rebuild(): void;
  85311. /**
  85312. * Updates the WebGL Uniform Buffer on the GPU.
  85313. * If the `dynamic` flag is set to true, no cache comparison is done.
  85314. * Otherwise, the buffer will be updated only if the cache differs.
  85315. */
  85316. update(): void;
  85317. /**
  85318. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85319. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85320. * @param data Define the flattened data
  85321. * @param size Define the size of the data.
  85322. */
  85323. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85324. private _valueCache;
  85325. private _cacheMatrix;
  85326. private _updateMatrix3x3ForUniform;
  85327. private _updateMatrix3x3ForEffect;
  85328. private _updateMatrix2x2ForEffect;
  85329. private _updateMatrix2x2ForUniform;
  85330. private _updateFloatForEffect;
  85331. private _updateFloatForUniform;
  85332. private _updateFloat2ForEffect;
  85333. private _updateFloat2ForUniform;
  85334. private _updateFloat3ForEffect;
  85335. private _updateFloat3ForUniform;
  85336. private _updateFloat4ForEffect;
  85337. private _updateFloat4ForUniform;
  85338. private _updateMatrixForEffect;
  85339. private _updateMatrixForUniform;
  85340. private _updateVector3ForEffect;
  85341. private _updateVector3ForUniform;
  85342. private _updateVector4ForEffect;
  85343. private _updateVector4ForUniform;
  85344. private _updateColor3ForEffect;
  85345. private _updateColor3ForUniform;
  85346. private _updateColor4ForEffect;
  85347. private _updateColor4ForUniform;
  85348. /**
  85349. * Sets a sampler uniform on the effect.
  85350. * @param name Define the name of the sampler.
  85351. * @param texture Define the texture to set in the sampler
  85352. */
  85353. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85354. /**
  85355. * Directly updates the value of the uniform in the cache AND on the GPU.
  85356. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85357. * @param data Define the flattened data
  85358. */
  85359. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85360. /**
  85361. * Binds this uniform buffer to an effect.
  85362. * @param effect Define the effect to bind the buffer to
  85363. * @param name Name of the uniform block in the shader.
  85364. */
  85365. bindToEffect(effect: Effect, name: string): void;
  85366. /**
  85367. * Disposes the uniform buffer.
  85368. */
  85369. dispose(): void;
  85370. }
  85371. }
  85372. declare module BABYLON {
  85373. /**
  85374. * Enum that determines the text-wrapping mode to use.
  85375. */
  85376. export enum InspectableType {
  85377. /**
  85378. * Checkbox for booleans
  85379. */
  85380. Checkbox = 0,
  85381. /**
  85382. * Sliders for numbers
  85383. */
  85384. Slider = 1,
  85385. /**
  85386. * Vector3
  85387. */
  85388. Vector3 = 2,
  85389. /**
  85390. * Quaternions
  85391. */
  85392. Quaternion = 3,
  85393. /**
  85394. * Color3
  85395. */
  85396. Color3 = 4,
  85397. /**
  85398. * String
  85399. */
  85400. String = 5
  85401. }
  85402. /**
  85403. * Interface used to define custom inspectable properties.
  85404. * This interface is used by the inspector to display custom property grids
  85405. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85406. */
  85407. export interface IInspectable {
  85408. /**
  85409. * Gets the label to display
  85410. */
  85411. label: string;
  85412. /**
  85413. * Gets the name of the property to edit
  85414. */
  85415. propertyName: string;
  85416. /**
  85417. * Gets the type of the editor to use
  85418. */
  85419. type: InspectableType;
  85420. /**
  85421. * Gets the minimum value of the property when using in "slider" mode
  85422. */
  85423. min?: number;
  85424. /**
  85425. * Gets the maximum value of the property when using in "slider" mode
  85426. */
  85427. max?: number;
  85428. /**
  85429. * Gets the setp to use when using in "slider" mode
  85430. */
  85431. step?: number;
  85432. }
  85433. }
  85434. declare module BABYLON {
  85435. /**
  85436. * Class used to provide helper for timing
  85437. */
  85438. export class TimingTools {
  85439. /**
  85440. * Polyfill for setImmediate
  85441. * @param action defines the action to execute after the current execution block
  85442. */
  85443. static SetImmediate(action: () => void): void;
  85444. }
  85445. }
  85446. declare module BABYLON {
  85447. /**
  85448. * Class used to enable instatition of objects by class name
  85449. */
  85450. export class InstantiationTools {
  85451. /**
  85452. * Use this object to register external classes like custom textures or material
  85453. * to allow the laoders to instantiate them
  85454. */
  85455. static RegisteredExternalClasses: {
  85456. [key: string]: Object;
  85457. };
  85458. /**
  85459. * Tries to instantiate a new object from a given class name
  85460. * @param className defines the class name to instantiate
  85461. * @returns the new object or null if the system was not able to do the instantiation
  85462. */
  85463. static Instantiate(className: string): any;
  85464. }
  85465. }
  85466. declare module BABYLON {
  85467. /**
  85468. * Define options used to create a depth texture
  85469. */
  85470. export class DepthTextureCreationOptions {
  85471. /** Specifies whether or not a stencil should be allocated in the texture */
  85472. generateStencil?: boolean;
  85473. /** Specifies whether or not bilinear filtering is enable on the texture */
  85474. bilinearFiltering?: boolean;
  85475. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85476. comparisonFunction?: number;
  85477. /** Specifies if the created texture is a cube texture */
  85478. isCube?: boolean;
  85479. }
  85480. }
  85481. declare module BABYLON {
  85482. interface ThinEngine {
  85483. /**
  85484. * Creates a depth stencil cube texture.
  85485. * This is only available in WebGL 2.
  85486. * @param size The size of face edge in the cube texture.
  85487. * @param options The options defining the cube texture.
  85488. * @returns The cube texture
  85489. */
  85490. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85491. /**
  85492. * Creates a cube texture
  85493. * @param rootUrl defines the url where the files to load is located
  85494. * @param scene defines the current scene
  85495. * @param files defines the list of files to load (1 per face)
  85496. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85497. * @param onLoad defines an optional callback raised when the texture is loaded
  85498. * @param onError defines an optional callback raised if there is an issue to load the texture
  85499. * @param format defines the format of the data
  85500. * @param forcedExtension defines the extension to use to pick the right loader
  85501. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85502. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85503. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85504. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85505. * @returns the cube texture as an InternalTexture
  85506. */
  85507. 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;
  85508. /**
  85509. * Creates a cube texture
  85510. * @param rootUrl defines the url where the files to load is located
  85511. * @param scene defines the current scene
  85512. * @param files defines the list of files to load (1 per face)
  85513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85514. * @param onLoad defines an optional callback raised when the texture is loaded
  85515. * @param onError defines an optional callback raised if there is an issue to load the texture
  85516. * @param format defines the format of the data
  85517. * @param forcedExtension defines the extension to use to pick the right loader
  85518. * @returns the cube texture as an InternalTexture
  85519. */
  85520. 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;
  85521. /**
  85522. * Creates a cube texture
  85523. * @param rootUrl defines the url where the files to load is located
  85524. * @param scene defines the current scene
  85525. * @param files defines the list of files to load (1 per face)
  85526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85527. * @param onLoad defines an optional callback raised when the texture is loaded
  85528. * @param onError defines an optional callback raised if there is an issue to load the texture
  85529. * @param format defines the format of the data
  85530. * @param forcedExtension defines the extension to use to pick the right loader
  85531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85534. * @returns the cube texture as an InternalTexture
  85535. */
  85536. 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;
  85537. /** @hidden */
  85538. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85539. /** @hidden */
  85540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85541. /** @hidden */
  85542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85543. /** @hidden */
  85544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85545. /**
  85546. * @hidden
  85547. */
  85548. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85549. }
  85550. }
  85551. declare module BABYLON {
  85552. /**
  85553. * Class for creating a cube texture
  85554. */
  85555. export class CubeTexture extends BaseTexture {
  85556. private _delayedOnLoad;
  85557. /**
  85558. * Observable triggered once the texture has been loaded.
  85559. */
  85560. onLoadObservable: Observable<CubeTexture>;
  85561. /**
  85562. * The url of the texture
  85563. */
  85564. url: string;
  85565. /**
  85566. * Gets or sets the center of the bounding box associated with the cube texture.
  85567. * It must define where the camera used to render the texture was set
  85568. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85569. */
  85570. boundingBoxPosition: Vector3;
  85571. private _boundingBoxSize;
  85572. /**
  85573. * Gets or sets the size of the bounding box associated with the cube texture
  85574. * When defined, the cubemap will switch to local mode
  85575. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85576. * @example https://www.babylonjs-playground.com/#RNASML
  85577. */
  85578. set boundingBoxSize(value: Vector3);
  85579. /**
  85580. * Returns the bounding box size
  85581. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85582. */
  85583. get boundingBoxSize(): Vector3;
  85584. protected _rotationY: number;
  85585. /**
  85586. * Sets texture matrix rotation angle around Y axis in radians.
  85587. */
  85588. set rotationY(value: number);
  85589. /**
  85590. * Gets texture matrix rotation angle around Y axis radians.
  85591. */
  85592. get rotationY(): number;
  85593. /**
  85594. * Are mip maps generated for this texture or not.
  85595. */
  85596. get noMipmap(): boolean;
  85597. private _noMipmap;
  85598. private _files;
  85599. protected _forcedExtension: Nullable<string>;
  85600. private _extensions;
  85601. private _textureMatrix;
  85602. private _format;
  85603. private _createPolynomials;
  85604. /**
  85605. * Creates a cube texture from an array of image urls
  85606. * @param files defines an array of image urls
  85607. * @param scene defines the hosting scene
  85608. * @param noMipmap specifies if mip maps are not used
  85609. * @returns a cube texture
  85610. */
  85611. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85612. /**
  85613. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85614. * @param url defines the url of the prefiltered texture
  85615. * @param scene defines the scene the texture is attached to
  85616. * @param forcedExtension defines the extension of the file if different from the url
  85617. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85618. * @return the prefiltered texture
  85619. */
  85620. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85621. /**
  85622. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85623. * as prefiltered data.
  85624. * @param rootUrl defines the url of the texture or the root name of the six images
  85625. * @param null defines the scene or engine the texture is attached to
  85626. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85627. * @param noMipmap defines if mipmaps should be created or not
  85628. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85629. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85630. * @param onError defines a callback triggered in case of error during load
  85631. * @param format defines the internal format to use for the texture once loaded
  85632. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85633. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85634. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85635. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85636. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85637. * @return the cube texture
  85638. */
  85639. 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);
  85640. /**
  85641. * Get the current class name of the texture useful for serialization or dynamic coding.
  85642. * @returns "CubeTexture"
  85643. */
  85644. getClassName(): string;
  85645. /**
  85646. * Update the url (and optional buffer) of this texture if url was null during construction.
  85647. * @param url the url of the texture
  85648. * @param forcedExtension defines the extension to use
  85649. * @param onLoad callback called when the texture is loaded (defaults to null)
  85650. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85651. */
  85652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85653. /**
  85654. * Delays loading of the cube texture
  85655. * @param forcedExtension defines the extension to use
  85656. */
  85657. delayLoad(forcedExtension?: string): void;
  85658. /**
  85659. * Returns the reflection texture matrix
  85660. * @returns the reflection texture matrix
  85661. */
  85662. getReflectionTextureMatrix(): Matrix;
  85663. /**
  85664. * Sets the reflection texture matrix
  85665. * @param value Reflection texture matrix
  85666. */
  85667. setReflectionTextureMatrix(value: Matrix): void;
  85668. /**
  85669. * Parses text to create a cube texture
  85670. * @param parsedTexture define the serialized text to read from
  85671. * @param scene defines the hosting scene
  85672. * @param rootUrl defines the root url of the cube texture
  85673. * @returns a cube texture
  85674. */
  85675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85676. /**
  85677. * Makes a clone, or deep copy, of the cube texture
  85678. * @returns a new cube texture
  85679. */
  85680. clone(): CubeTexture;
  85681. }
  85682. }
  85683. declare module BABYLON {
  85684. /**
  85685. * Manages the defines for the Material
  85686. */
  85687. export class MaterialDefines {
  85688. /** @hidden */
  85689. protected _keys: string[];
  85690. private _isDirty;
  85691. /** @hidden */
  85692. _renderId: number;
  85693. /** @hidden */
  85694. _areLightsDirty: boolean;
  85695. /** @hidden */
  85696. _areLightsDisposed: boolean;
  85697. /** @hidden */
  85698. _areAttributesDirty: boolean;
  85699. /** @hidden */
  85700. _areTexturesDirty: boolean;
  85701. /** @hidden */
  85702. _areFresnelDirty: boolean;
  85703. /** @hidden */
  85704. _areMiscDirty: boolean;
  85705. /** @hidden */
  85706. _areImageProcessingDirty: boolean;
  85707. /** @hidden */
  85708. _normals: boolean;
  85709. /** @hidden */
  85710. _uvs: boolean;
  85711. /** @hidden */
  85712. _needNormals: boolean;
  85713. /** @hidden */
  85714. _needUVs: boolean;
  85715. [id: string]: any;
  85716. /**
  85717. * Specifies if the material needs to be re-calculated
  85718. */
  85719. get isDirty(): boolean;
  85720. /**
  85721. * Marks the material to indicate that it has been re-calculated
  85722. */
  85723. markAsProcessed(): void;
  85724. /**
  85725. * Marks the material to indicate that it needs to be re-calculated
  85726. */
  85727. markAsUnprocessed(): void;
  85728. /**
  85729. * Marks the material to indicate all of its defines need to be re-calculated
  85730. */
  85731. markAllAsDirty(): void;
  85732. /**
  85733. * Marks the material to indicate that image processing needs to be re-calculated
  85734. */
  85735. markAsImageProcessingDirty(): void;
  85736. /**
  85737. * Marks the material to indicate the lights need to be re-calculated
  85738. * @param disposed Defines whether the light is dirty due to dispose or not
  85739. */
  85740. markAsLightDirty(disposed?: boolean): void;
  85741. /**
  85742. * Marks the attribute state as changed
  85743. */
  85744. markAsAttributesDirty(): void;
  85745. /**
  85746. * Marks the texture state as changed
  85747. */
  85748. markAsTexturesDirty(): void;
  85749. /**
  85750. * Marks the fresnel state as changed
  85751. */
  85752. markAsFresnelDirty(): void;
  85753. /**
  85754. * Marks the misc state as changed
  85755. */
  85756. markAsMiscDirty(): void;
  85757. /**
  85758. * Rebuilds the material defines
  85759. */
  85760. rebuild(): void;
  85761. /**
  85762. * Specifies if two material defines are equal
  85763. * @param other - A material define instance to compare to
  85764. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85765. */
  85766. isEqual(other: MaterialDefines): boolean;
  85767. /**
  85768. * Clones this instance's defines to another instance
  85769. * @param other - material defines to clone values to
  85770. */
  85771. cloneTo(other: MaterialDefines): void;
  85772. /**
  85773. * Resets the material define values
  85774. */
  85775. reset(): void;
  85776. /**
  85777. * Converts the material define values to a string
  85778. * @returns - String of material define information
  85779. */
  85780. toString(): string;
  85781. }
  85782. }
  85783. declare module BABYLON {
  85784. /**
  85785. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85786. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85787. * 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;
  85788. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85789. */
  85790. export class ColorCurves {
  85791. private _dirty;
  85792. private _tempColor;
  85793. private _globalCurve;
  85794. private _highlightsCurve;
  85795. private _midtonesCurve;
  85796. private _shadowsCurve;
  85797. private _positiveCurve;
  85798. private _negativeCurve;
  85799. private _globalHue;
  85800. private _globalDensity;
  85801. private _globalSaturation;
  85802. private _globalExposure;
  85803. /**
  85804. * Gets the global Hue value.
  85805. * 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).
  85806. */
  85807. get globalHue(): number;
  85808. /**
  85809. * Sets the global Hue value.
  85810. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  85811. */
  85812. set globalHue(value: number);
  85813. /**
  85814. * Gets the global Density value.
  85815. * 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.
  85816. * Values less than zero provide a filter of opposite hue.
  85817. */
  85818. get globalDensity(): number;
  85819. /**
  85820. * Sets the global Density value.
  85821. * 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.
  85822. * Values less than zero provide a filter of opposite hue.
  85823. */
  85824. set globalDensity(value: number);
  85825. /**
  85826. * Gets the global Saturation value.
  85827. * 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.
  85828. */
  85829. get globalSaturation(): number;
  85830. /**
  85831. * Sets the global Saturation value.
  85832. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  85833. */
  85834. set globalSaturation(value: number);
  85835. /**
  85836. * Gets the global Exposure value.
  85837. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  85838. */
  85839. get globalExposure(): number;
  85840. /**
  85841. * Sets the global Exposure value.
  85842. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  85843. */
  85844. set globalExposure(value: number);
  85845. private _highlightsHue;
  85846. private _highlightsDensity;
  85847. private _highlightsSaturation;
  85848. private _highlightsExposure;
  85849. /**
  85850. * Gets the highlights Hue value.
  85851. * 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).
  85852. */
  85853. get highlightsHue(): number;
  85854. /**
  85855. * Sets the highlights Hue value.
  85856. * 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).
  85857. */
  85858. set highlightsHue(value: number);
  85859. /**
  85860. * Gets the highlights Density value.
  85861. * 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.
  85862. * Values less than zero provide a filter of opposite hue.
  85863. */
  85864. get highlightsDensity(): number;
  85865. /**
  85866. * Sets the highlights Density value.
  85867. * 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.
  85868. * Values less than zero provide a filter of opposite hue.
  85869. */
  85870. set highlightsDensity(value: number);
  85871. /**
  85872. * Gets the highlights Saturation value.
  85873. * 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.
  85874. */
  85875. get highlightsSaturation(): number;
  85876. /**
  85877. * Sets the highlights Saturation value.
  85878. * 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.
  85879. */
  85880. set highlightsSaturation(value: number);
  85881. /**
  85882. * Gets the highlights Exposure value.
  85883. * 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.
  85884. */
  85885. get highlightsExposure(): number;
  85886. /**
  85887. * Sets the highlights Exposure value.
  85888. * 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.
  85889. */
  85890. set highlightsExposure(value: number);
  85891. private _midtonesHue;
  85892. private _midtonesDensity;
  85893. private _midtonesSaturation;
  85894. private _midtonesExposure;
  85895. /**
  85896. * Gets the midtones Hue value.
  85897. * 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).
  85898. */
  85899. get midtonesHue(): number;
  85900. /**
  85901. * Sets the midtones Hue value.
  85902. * 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).
  85903. */
  85904. set midtonesHue(value: number);
  85905. /**
  85906. * Gets the midtones Density value.
  85907. * 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.
  85908. * Values less than zero provide a filter of opposite hue.
  85909. */
  85910. get midtonesDensity(): number;
  85911. /**
  85912. * Sets the midtones Density value.
  85913. * 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.
  85914. * Values less than zero provide a filter of opposite hue.
  85915. */
  85916. set midtonesDensity(value: number);
  85917. /**
  85918. * Gets the midtones Saturation value.
  85919. * 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.
  85920. */
  85921. get midtonesSaturation(): number;
  85922. /**
  85923. * Sets the midtones Saturation value.
  85924. * 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.
  85925. */
  85926. set midtonesSaturation(value: number);
  85927. /**
  85928. * Gets the midtones Exposure value.
  85929. * 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.
  85930. */
  85931. get midtonesExposure(): number;
  85932. /**
  85933. * Sets the midtones Exposure value.
  85934. * 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.
  85935. */
  85936. set midtonesExposure(value: number);
  85937. private _shadowsHue;
  85938. private _shadowsDensity;
  85939. private _shadowsSaturation;
  85940. private _shadowsExposure;
  85941. /**
  85942. * Gets the shadows Hue value.
  85943. * 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).
  85944. */
  85945. get shadowsHue(): number;
  85946. /**
  85947. * Sets the shadows Hue value.
  85948. * 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).
  85949. */
  85950. set shadowsHue(value: number);
  85951. /**
  85952. * Gets the shadows Density value.
  85953. * 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.
  85954. * Values less than zero provide a filter of opposite hue.
  85955. */
  85956. get shadowsDensity(): number;
  85957. /**
  85958. * Sets the shadows Density value.
  85959. * 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.
  85960. * Values less than zero provide a filter of opposite hue.
  85961. */
  85962. set shadowsDensity(value: number);
  85963. /**
  85964. * Gets the shadows Saturation value.
  85965. * 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.
  85966. */
  85967. get shadowsSaturation(): number;
  85968. /**
  85969. * Sets the shadows Saturation value.
  85970. * 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.
  85971. */
  85972. set shadowsSaturation(value: number);
  85973. /**
  85974. * Gets the shadows Exposure value.
  85975. * 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.
  85976. */
  85977. get shadowsExposure(): number;
  85978. /**
  85979. * Sets the shadows Exposure value.
  85980. * 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.
  85981. */
  85982. set shadowsExposure(value: number);
  85983. /**
  85984. * Returns the class name
  85985. * @returns The class name
  85986. */
  85987. getClassName(): string;
  85988. /**
  85989. * Binds the color curves to the shader.
  85990. * @param colorCurves The color curve to bind
  85991. * @param effect The effect to bind to
  85992. * @param positiveUniform The positive uniform shader parameter
  85993. * @param neutralUniform The neutral uniform shader parameter
  85994. * @param negativeUniform The negative uniform shader parameter
  85995. */
  85996. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85997. /**
  85998. * Prepare the list of uniforms associated with the ColorCurves effects.
  85999. * @param uniformsList The list of uniforms used in the effect
  86000. */
  86001. static PrepareUniforms(uniformsList: string[]): void;
  86002. /**
  86003. * Returns color grading data based on a hue, density, saturation and exposure value.
  86004. * @param filterHue The hue of the color filter.
  86005. * @param filterDensity The density of the color filter.
  86006. * @param saturation The saturation.
  86007. * @param exposure The exposure.
  86008. * @param result The result data container.
  86009. */
  86010. private getColorGradingDataToRef;
  86011. /**
  86012. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86013. * @param value The input slider value in range [-100,100].
  86014. * @returns Adjusted value.
  86015. */
  86016. private static applyColorGradingSliderNonlinear;
  86017. /**
  86018. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86019. * @param hue The hue (H) input.
  86020. * @param saturation The saturation (S) input.
  86021. * @param brightness The brightness (B) input.
  86022. * @result An RGBA color represented as Vector4.
  86023. */
  86024. private static fromHSBToRef;
  86025. /**
  86026. * Returns a value clamped between min and max
  86027. * @param value The value to clamp
  86028. * @param min The minimum of value
  86029. * @param max The maximum of value
  86030. * @returns The clamped value.
  86031. */
  86032. private static clamp;
  86033. /**
  86034. * Clones the current color curve instance.
  86035. * @return The cloned curves
  86036. */
  86037. clone(): ColorCurves;
  86038. /**
  86039. * Serializes the current color curve instance to a json representation.
  86040. * @return a JSON representation
  86041. */
  86042. serialize(): any;
  86043. /**
  86044. * Parses the color curve from a json representation.
  86045. * @param source the JSON source to parse
  86046. * @return The parsed curves
  86047. */
  86048. static Parse(source: any): ColorCurves;
  86049. }
  86050. }
  86051. declare module BABYLON {
  86052. /**
  86053. * Interface to follow in your material defines to integrate easily the
  86054. * Image proccessing functions.
  86055. * @hidden
  86056. */
  86057. export interface IImageProcessingConfigurationDefines {
  86058. IMAGEPROCESSING: boolean;
  86059. VIGNETTE: boolean;
  86060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86061. VIGNETTEBLENDMODEOPAQUE: boolean;
  86062. TONEMAPPING: boolean;
  86063. TONEMAPPING_ACES: boolean;
  86064. CONTRAST: boolean;
  86065. EXPOSURE: boolean;
  86066. COLORCURVES: boolean;
  86067. COLORGRADING: boolean;
  86068. COLORGRADING3D: boolean;
  86069. SAMPLER3DGREENDEPTH: boolean;
  86070. SAMPLER3DBGRMAP: boolean;
  86071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86072. }
  86073. /**
  86074. * @hidden
  86075. */
  86076. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86077. IMAGEPROCESSING: boolean;
  86078. VIGNETTE: boolean;
  86079. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86080. VIGNETTEBLENDMODEOPAQUE: boolean;
  86081. TONEMAPPING: boolean;
  86082. TONEMAPPING_ACES: boolean;
  86083. CONTRAST: boolean;
  86084. COLORCURVES: boolean;
  86085. COLORGRADING: boolean;
  86086. COLORGRADING3D: boolean;
  86087. SAMPLER3DGREENDEPTH: boolean;
  86088. SAMPLER3DBGRMAP: boolean;
  86089. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86090. EXPOSURE: boolean;
  86091. constructor();
  86092. }
  86093. /**
  86094. * This groups together the common properties used for image processing either in direct forward pass
  86095. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86096. * or not.
  86097. */
  86098. export class ImageProcessingConfiguration {
  86099. /**
  86100. * Default tone mapping applied in BabylonJS.
  86101. */
  86102. static readonly TONEMAPPING_STANDARD: number;
  86103. /**
  86104. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86105. * to other engines rendering to increase portability.
  86106. */
  86107. static readonly TONEMAPPING_ACES: number;
  86108. /**
  86109. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86110. */
  86111. colorCurves: Nullable<ColorCurves>;
  86112. private _colorCurvesEnabled;
  86113. /**
  86114. * Gets wether the color curves effect is enabled.
  86115. */
  86116. get colorCurvesEnabled(): boolean;
  86117. /**
  86118. * Sets wether the color curves effect is enabled.
  86119. */
  86120. set colorCurvesEnabled(value: boolean);
  86121. private _colorGradingTexture;
  86122. /**
  86123. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86124. */
  86125. get colorGradingTexture(): Nullable<BaseTexture>;
  86126. /**
  86127. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86128. */
  86129. set colorGradingTexture(value: Nullable<BaseTexture>);
  86130. private _colorGradingEnabled;
  86131. /**
  86132. * Gets wether the color grading effect is enabled.
  86133. */
  86134. get colorGradingEnabled(): boolean;
  86135. /**
  86136. * Sets wether the color grading effect is enabled.
  86137. */
  86138. set colorGradingEnabled(value: boolean);
  86139. private _colorGradingWithGreenDepth;
  86140. /**
  86141. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86142. */
  86143. get colorGradingWithGreenDepth(): boolean;
  86144. /**
  86145. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86146. */
  86147. set colorGradingWithGreenDepth(value: boolean);
  86148. private _colorGradingBGR;
  86149. /**
  86150. * Gets wether the color grading texture contains BGR values.
  86151. */
  86152. get colorGradingBGR(): boolean;
  86153. /**
  86154. * Sets wether the color grading texture contains BGR values.
  86155. */
  86156. set colorGradingBGR(value: boolean);
  86157. /** @hidden */
  86158. _exposure: number;
  86159. /**
  86160. * Gets the Exposure used in the effect.
  86161. */
  86162. get exposure(): number;
  86163. /**
  86164. * Sets the Exposure used in the effect.
  86165. */
  86166. set exposure(value: number);
  86167. private _toneMappingEnabled;
  86168. /**
  86169. * Gets wether the tone mapping effect is enabled.
  86170. */
  86171. get toneMappingEnabled(): boolean;
  86172. /**
  86173. * Sets wether the tone mapping effect is enabled.
  86174. */
  86175. set toneMappingEnabled(value: boolean);
  86176. private _toneMappingType;
  86177. /**
  86178. * Gets the type of tone mapping effect.
  86179. */
  86180. get toneMappingType(): number;
  86181. /**
  86182. * Sets the type of tone mapping effect used in BabylonJS.
  86183. */
  86184. set toneMappingType(value: number);
  86185. protected _contrast: number;
  86186. /**
  86187. * Gets the contrast used in the effect.
  86188. */
  86189. get contrast(): number;
  86190. /**
  86191. * Sets the contrast used in the effect.
  86192. */
  86193. set contrast(value: number);
  86194. /**
  86195. * Vignette stretch size.
  86196. */
  86197. vignetteStretch: number;
  86198. /**
  86199. * Vignette centre X Offset.
  86200. */
  86201. vignetteCentreX: number;
  86202. /**
  86203. * Vignette centre Y Offset.
  86204. */
  86205. vignetteCentreY: number;
  86206. /**
  86207. * Vignette weight or intensity of the vignette effect.
  86208. */
  86209. vignetteWeight: number;
  86210. /**
  86211. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86212. * if vignetteEnabled is set to true.
  86213. */
  86214. vignetteColor: Color4;
  86215. /**
  86216. * Camera field of view used by the Vignette effect.
  86217. */
  86218. vignetteCameraFov: number;
  86219. private _vignetteBlendMode;
  86220. /**
  86221. * Gets the vignette blend mode allowing different kind of effect.
  86222. */
  86223. get vignetteBlendMode(): number;
  86224. /**
  86225. * Sets the vignette blend mode allowing different kind of effect.
  86226. */
  86227. set vignetteBlendMode(value: number);
  86228. private _vignetteEnabled;
  86229. /**
  86230. * Gets wether the vignette effect is enabled.
  86231. */
  86232. get vignetteEnabled(): boolean;
  86233. /**
  86234. * Sets wether the vignette effect is enabled.
  86235. */
  86236. set vignetteEnabled(value: boolean);
  86237. private _applyByPostProcess;
  86238. /**
  86239. * Gets wether the image processing is applied through a post process or not.
  86240. */
  86241. get applyByPostProcess(): boolean;
  86242. /**
  86243. * Sets wether the image processing is applied through a post process or not.
  86244. */
  86245. set applyByPostProcess(value: boolean);
  86246. private _isEnabled;
  86247. /**
  86248. * Gets wether the image processing is enabled or not.
  86249. */
  86250. get isEnabled(): boolean;
  86251. /**
  86252. * Sets wether the image processing is enabled or not.
  86253. */
  86254. set isEnabled(value: boolean);
  86255. /**
  86256. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86257. */
  86258. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86259. /**
  86260. * Method called each time the image processing information changes requires to recompile the effect.
  86261. */
  86262. protected _updateParameters(): void;
  86263. /**
  86264. * Gets the current class name.
  86265. * @return "ImageProcessingConfiguration"
  86266. */
  86267. getClassName(): string;
  86268. /**
  86269. * Prepare the list of uniforms associated with the Image Processing effects.
  86270. * @param uniforms The list of uniforms used in the effect
  86271. * @param defines the list of defines currently in use
  86272. */
  86273. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86274. /**
  86275. * Prepare the list of samplers associated with the Image Processing effects.
  86276. * @param samplersList The list of uniforms used in the effect
  86277. * @param defines the list of defines currently in use
  86278. */
  86279. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86280. /**
  86281. * Prepare the list of defines associated to the shader.
  86282. * @param defines the list of defines to complete
  86283. * @param forPostProcess Define if we are currently in post process mode or not
  86284. */
  86285. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86286. /**
  86287. * Returns true if all the image processing information are ready.
  86288. * @returns True if ready, otherwise, false
  86289. */
  86290. isReady(): boolean;
  86291. /**
  86292. * Binds the image processing to the shader.
  86293. * @param effect The effect to bind to
  86294. * @param overrideAspectRatio Override the aspect ratio of the effect
  86295. */
  86296. bind(effect: Effect, overrideAspectRatio?: number): void;
  86297. /**
  86298. * Clones the current image processing instance.
  86299. * @return The cloned image processing
  86300. */
  86301. clone(): ImageProcessingConfiguration;
  86302. /**
  86303. * Serializes the current image processing instance to a json representation.
  86304. * @return a JSON representation
  86305. */
  86306. serialize(): any;
  86307. /**
  86308. * Parses the image processing from a json representation.
  86309. * @param source the JSON source to parse
  86310. * @return The parsed image processing
  86311. */
  86312. static Parse(source: any): ImageProcessingConfiguration;
  86313. private static _VIGNETTEMODE_MULTIPLY;
  86314. private static _VIGNETTEMODE_OPAQUE;
  86315. /**
  86316. * Used to apply the vignette as a mix with the pixel color.
  86317. */
  86318. static get VIGNETTEMODE_MULTIPLY(): number;
  86319. /**
  86320. * Used to apply the vignette as a replacement of the pixel color.
  86321. */
  86322. static get VIGNETTEMODE_OPAQUE(): number;
  86323. }
  86324. }
  86325. declare module BABYLON {
  86326. /** @hidden */
  86327. export var postprocessVertexShader: {
  86328. name: string;
  86329. shader: string;
  86330. };
  86331. }
  86332. declare module BABYLON {
  86333. interface ThinEngine {
  86334. /**
  86335. * Creates a new render target texture
  86336. * @param size defines the size of the texture
  86337. * @param options defines the options used to create the texture
  86338. * @returns a new render target texture stored in an InternalTexture
  86339. */
  86340. createRenderTargetTexture(size: number | {
  86341. width: number;
  86342. height: number;
  86343. layers?: number;
  86344. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86345. /**
  86346. * Creates a depth stencil texture.
  86347. * This is only available in WebGL 2 or with the depth texture extension available.
  86348. * @param size The size of face edge in the texture.
  86349. * @param options The options defining the texture.
  86350. * @returns The texture
  86351. */
  86352. createDepthStencilTexture(size: number | {
  86353. width: number;
  86354. height: number;
  86355. layers?: number;
  86356. }, options: DepthTextureCreationOptions): InternalTexture;
  86357. /** @hidden */
  86358. _createDepthStencilTexture(size: number | {
  86359. width: number;
  86360. height: number;
  86361. layers?: number;
  86362. }, options: DepthTextureCreationOptions): InternalTexture;
  86363. }
  86364. }
  86365. declare module BABYLON {
  86366. /**
  86367. * Defines the kind of connection point for node based material
  86368. */
  86369. export enum NodeMaterialBlockConnectionPointTypes {
  86370. /** Float */
  86371. Float = 1,
  86372. /** Int */
  86373. Int = 2,
  86374. /** Vector2 */
  86375. Vector2 = 4,
  86376. /** Vector3 */
  86377. Vector3 = 8,
  86378. /** Vector4 */
  86379. Vector4 = 16,
  86380. /** Color3 */
  86381. Color3 = 32,
  86382. /** Color4 */
  86383. Color4 = 64,
  86384. /** Matrix */
  86385. Matrix = 128,
  86386. /** Custom object */
  86387. Object = 256,
  86388. /** Detect type based on connection */
  86389. AutoDetect = 1024,
  86390. /** Output type that will be defined by input type */
  86391. BasedOnInput = 2048
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. /**
  86396. * Enum used to define the target of a block
  86397. */
  86398. export enum NodeMaterialBlockTargets {
  86399. /** Vertex shader */
  86400. Vertex = 1,
  86401. /** Fragment shader */
  86402. Fragment = 2,
  86403. /** Neutral */
  86404. Neutral = 4,
  86405. /** Vertex and Fragment */
  86406. VertexAndFragment = 3
  86407. }
  86408. }
  86409. declare module BABYLON {
  86410. /**
  86411. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86412. */
  86413. export enum NodeMaterialBlockConnectionPointMode {
  86414. /** Value is an uniform */
  86415. Uniform = 0,
  86416. /** Value is a mesh attribute */
  86417. Attribute = 1,
  86418. /** Value is a varying between vertex and fragment shaders */
  86419. Varying = 2,
  86420. /** Mode is undefined */
  86421. Undefined = 3
  86422. }
  86423. }
  86424. declare module BABYLON {
  86425. /**
  86426. * Enum used to define system values e.g. values automatically provided by the system
  86427. */
  86428. export enum NodeMaterialSystemValues {
  86429. /** World */
  86430. World = 1,
  86431. /** View */
  86432. View = 2,
  86433. /** Projection */
  86434. Projection = 3,
  86435. /** ViewProjection */
  86436. ViewProjection = 4,
  86437. /** WorldView */
  86438. WorldView = 5,
  86439. /** WorldViewProjection */
  86440. WorldViewProjection = 6,
  86441. /** CameraPosition */
  86442. CameraPosition = 7,
  86443. /** Fog Color */
  86444. FogColor = 8,
  86445. /** Delta time */
  86446. DeltaTime = 9
  86447. }
  86448. }
  86449. declare module BABYLON {
  86450. /** Defines supported spaces */
  86451. export enum Space {
  86452. /** Local (object) space */
  86453. LOCAL = 0,
  86454. /** World space */
  86455. WORLD = 1,
  86456. /** Bone space */
  86457. BONE = 2
  86458. }
  86459. /** Defines the 3 main axes */
  86460. export class Axis {
  86461. /** X axis */
  86462. static X: Vector3;
  86463. /** Y axis */
  86464. static Y: Vector3;
  86465. /** Z axis */
  86466. static Z: Vector3;
  86467. }
  86468. }
  86469. declare module BABYLON {
  86470. /**
  86471. * Represents a camera frustum
  86472. */
  86473. export class Frustum {
  86474. /**
  86475. * Gets the planes representing the frustum
  86476. * @param transform matrix to be applied to the returned planes
  86477. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86478. */
  86479. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86480. /**
  86481. * Gets the near frustum plane transformed by the transform matrix
  86482. * @param transform transformation matrix to be applied to the resulting frustum plane
  86483. * @param frustumPlane the resuling frustum plane
  86484. */
  86485. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86486. /**
  86487. * Gets the far frustum plane transformed by the transform matrix
  86488. * @param transform transformation matrix to be applied to the resulting frustum plane
  86489. * @param frustumPlane the resuling frustum plane
  86490. */
  86491. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86492. /**
  86493. * Gets the left frustum plane transformed by the transform matrix
  86494. * @param transform transformation matrix to be applied to the resulting frustum plane
  86495. * @param frustumPlane the resuling frustum plane
  86496. */
  86497. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86498. /**
  86499. * Gets the right frustum plane transformed by the transform matrix
  86500. * @param transform transformation matrix to be applied to the resulting frustum plane
  86501. * @param frustumPlane the resuling frustum plane
  86502. */
  86503. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86504. /**
  86505. * Gets the top frustum plane transformed by the transform matrix
  86506. * @param transform transformation matrix to be applied to the resulting frustum plane
  86507. * @param frustumPlane the resuling frustum plane
  86508. */
  86509. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86510. /**
  86511. * Gets the bottom frustum plane transformed by the transform matrix
  86512. * @param transform transformation matrix to be applied to the resulting frustum plane
  86513. * @param frustumPlane the resuling frustum plane
  86514. */
  86515. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86516. /**
  86517. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86518. * @param transform transformation matrix to be applied to the resulting frustum planes
  86519. * @param frustumPlanes the resuling frustum planes
  86520. */
  86521. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86522. }
  86523. }
  86524. declare module BABYLON {
  86525. /**
  86526. * Interface for the size containing width and height
  86527. */
  86528. export interface ISize {
  86529. /**
  86530. * Width
  86531. */
  86532. width: number;
  86533. /**
  86534. * Heighht
  86535. */
  86536. height: number;
  86537. }
  86538. /**
  86539. * Size containing widht and height
  86540. */
  86541. export class Size implements ISize {
  86542. /**
  86543. * Width
  86544. */
  86545. width: number;
  86546. /**
  86547. * Height
  86548. */
  86549. height: number;
  86550. /**
  86551. * Creates a Size object from the given width and height (floats).
  86552. * @param width width of the new size
  86553. * @param height height of the new size
  86554. */
  86555. constructor(width: number, height: number);
  86556. /**
  86557. * Returns a string with the Size width and height
  86558. * @returns a string with the Size width and height
  86559. */
  86560. toString(): string;
  86561. /**
  86562. * "Size"
  86563. * @returns the string "Size"
  86564. */
  86565. getClassName(): string;
  86566. /**
  86567. * Returns the Size hash code.
  86568. * @returns a hash code for a unique width and height
  86569. */
  86570. getHashCode(): number;
  86571. /**
  86572. * Updates the current size from the given one.
  86573. * @param src the given size
  86574. */
  86575. copyFrom(src: Size): void;
  86576. /**
  86577. * Updates in place the current Size from the given floats.
  86578. * @param width width of the new size
  86579. * @param height height of the new size
  86580. * @returns the updated Size.
  86581. */
  86582. copyFromFloats(width: number, height: number): Size;
  86583. /**
  86584. * Updates in place the current Size from the given floats.
  86585. * @param width width to set
  86586. * @param height height to set
  86587. * @returns the updated Size.
  86588. */
  86589. set(width: number, height: number): Size;
  86590. /**
  86591. * Multiplies the width and height by numbers
  86592. * @param w factor to multiple the width by
  86593. * @param h factor to multiple the height by
  86594. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86595. */
  86596. multiplyByFloats(w: number, h: number): Size;
  86597. /**
  86598. * Clones the size
  86599. * @returns a new Size copied from the given one.
  86600. */
  86601. clone(): Size;
  86602. /**
  86603. * True if the current Size and the given one width and height are strictly equal.
  86604. * @param other the other size to compare against
  86605. * @returns True if the current Size and the given one width and height are strictly equal.
  86606. */
  86607. equals(other: Size): boolean;
  86608. /**
  86609. * The surface of the Size : width * height (float).
  86610. */
  86611. get surface(): number;
  86612. /**
  86613. * Create a new size of zero
  86614. * @returns a new Size set to (0.0, 0.0)
  86615. */
  86616. static Zero(): Size;
  86617. /**
  86618. * Sums the width and height of two sizes
  86619. * @param otherSize size to add to this size
  86620. * @returns a new Size set as the addition result of the current Size and the given one.
  86621. */
  86622. add(otherSize: Size): Size;
  86623. /**
  86624. * Subtracts the width and height of two
  86625. * @param otherSize size to subtract to this size
  86626. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86627. */
  86628. subtract(otherSize: Size): Size;
  86629. /**
  86630. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86631. * @param start starting size to lerp between
  86632. * @param end end size to lerp between
  86633. * @param amount amount to lerp between the start and end values
  86634. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86635. */
  86636. static Lerp(start: Size, end: Size, amount: number): Size;
  86637. }
  86638. }
  86639. declare module BABYLON {
  86640. /**
  86641. * Contains position and normal vectors for a vertex
  86642. */
  86643. export class PositionNormalVertex {
  86644. /** the position of the vertex (defaut: 0,0,0) */
  86645. position: Vector3;
  86646. /** the normal of the vertex (defaut: 0,1,0) */
  86647. normal: Vector3;
  86648. /**
  86649. * Creates a PositionNormalVertex
  86650. * @param position the position of the vertex (defaut: 0,0,0)
  86651. * @param normal the normal of the vertex (defaut: 0,1,0)
  86652. */
  86653. constructor(
  86654. /** the position of the vertex (defaut: 0,0,0) */
  86655. position?: Vector3,
  86656. /** the normal of the vertex (defaut: 0,1,0) */
  86657. normal?: Vector3);
  86658. /**
  86659. * Clones the PositionNormalVertex
  86660. * @returns the cloned PositionNormalVertex
  86661. */
  86662. clone(): PositionNormalVertex;
  86663. }
  86664. /**
  86665. * Contains position, normal and uv vectors for a vertex
  86666. */
  86667. export class PositionNormalTextureVertex {
  86668. /** the position of the vertex (defaut: 0,0,0) */
  86669. position: Vector3;
  86670. /** the normal of the vertex (defaut: 0,1,0) */
  86671. normal: Vector3;
  86672. /** the uv of the vertex (default: 0,0) */
  86673. uv: Vector2;
  86674. /**
  86675. * Creates a PositionNormalTextureVertex
  86676. * @param position the position of the vertex (defaut: 0,0,0)
  86677. * @param normal the normal of the vertex (defaut: 0,1,0)
  86678. * @param uv the uv of the vertex (default: 0,0)
  86679. */
  86680. constructor(
  86681. /** the position of the vertex (defaut: 0,0,0) */
  86682. position?: Vector3,
  86683. /** the normal of the vertex (defaut: 0,1,0) */
  86684. normal?: Vector3,
  86685. /** the uv of the vertex (default: 0,0) */
  86686. uv?: Vector2);
  86687. /**
  86688. * Clones the PositionNormalTextureVertex
  86689. * @returns the cloned PositionNormalTextureVertex
  86690. */
  86691. clone(): PositionNormalTextureVertex;
  86692. }
  86693. }
  86694. declare module BABYLON {
  86695. /**
  86696. * Enum defining the type of animations supported by InputBlock
  86697. */
  86698. export enum AnimatedInputBlockTypes {
  86699. /** No animation */
  86700. None = 0,
  86701. /** Time based animation. Will only work for floats */
  86702. Time = 1
  86703. }
  86704. }
  86705. declare module BABYLON {
  86706. /**
  86707. * Interface describing all the common properties and methods a shadow light needs to implement.
  86708. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86709. * as well as binding the different shadow properties to the effects.
  86710. */
  86711. export interface IShadowLight extends Light {
  86712. /**
  86713. * The light id in the scene (used in scene.findLighById for instance)
  86714. */
  86715. id: string;
  86716. /**
  86717. * The position the shdow will be casted from.
  86718. */
  86719. position: Vector3;
  86720. /**
  86721. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86722. */
  86723. direction: Vector3;
  86724. /**
  86725. * The transformed position. Position of the light in world space taking parenting in account.
  86726. */
  86727. transformedPosition: Vector3;
  86728. /**
  86729. * The transformed direction. Direction of the light in world space taking parenting in account.
  86730. */
  86731. transformedDirection: Vector3;
  86732. /**
  86733. * The friendly name of the light in the scene.
  86734. */
  86735. name: string;
  86736. /**
  86737. * Defines the shadow projection clipping minimum z value.
  86738. */
  86739. shadowMinZ: number;
  86740. /**
  86741. * Defines the shadow projection clipping maximum z value.
  86742. */
  86743. shadowMaxZ: number;
  86744. /**
  86745. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86746. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86747. */
  86748. computeTransformedInformation(): boolean;
  86749. /**
  86750. * Gets the scene the light belongs to.
  86751. * @returns The scene
  86752. */
  86753. getScene(): Scene;
  86754. /**
  86755. * Callback defining a custom Projection Matrix Builder.
  86756. * This can be used to override the default projection matrix computation.
  86757. */
  86758. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86759. /**
  86760. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86761. * @param matrix The materix to updated with the projection information
  86762. * @param viewMatrix The transform matrix of the light
  86763. * @param renderList The list of mesh to render in the map
  86764. * @returns The current light
  86765. */
  86766. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86767. /**
  86768. * Gets the current depth scale used in ESM.
  86769. * @returns The scale
  86770. */
  86771. getDepthScale(): number;
  86772. /**
  86773. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86774. * @returns true if a cube texture needs to be use
  86775. */
  86776. needCube(): boolean;
  86777. /**
  86778. * Detects if the projection matrix requires to be recomputed this frame.
  86779. * @returns true if it requires to be recomputed otherwise, false.
  86780. */
  86781. needProjectionMatrixCompute(): boolean;
  86782. /**
  86783. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86784. */
  86785. forceProjectionMatrixCompute(): void;
  86786. /**
  86787. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86788. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86789. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86790. */
  86791. getShadowDirection(faceIndex?: number): Vector3;
  86792. /**
  86793. * Gets the minZ used for shadow according to both the scene and the light.
  86794. * @param activeCamera The camera we are returning the min for
  86795. * @returns the depth min z
  86796. */
  86797. getDepthMinZ(activeCamera: Camera): number;
  86798. /**
  86799. * Gets the maxZ used for shadow according to both the scene and the light.
  86800. * @param activeCamera The camera we are returning the max for
  86801. * @returns the depth max z
  86802. */
  86803. getDepthMaxZ(activeCamera: Camera): number;
  86804. }
  86805. /**
  86806. * Base implementation IShadowLight
  86807. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86808. */
  86809. export abstract class ShadowLight extends Light implements IShadowLight {
  86810. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86811. protected _position: Vector3;
  86812. protected _setPosition(value: Vector3): void;
  86813. /**
  86814. * Sets the position the shadow will be casted from. Also use as the light position for both
  86815. * point and spot lights.
  86816. */
  86817. get position(): Vector3;
  86818. /**
  86819. * Sets the position the shadow will be casted from. Also use as the light position for both
  86820. * point and spot lights.
  86821. */
  86822. set position(value: Vector3);
  86823. protected _direction: Vector3;
  86824. protected _setDirection(value: Vector3): void;
  86825. /**
  86826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86827. * Also use as the light direction on spot and directional lights.
  86828. */
  86829. get direction(): Vector3;
  86830. /**
  86831. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86832. * Also use as the light direction on spot and directional lights.
  86833. */
  86834. set direction(value: Vector3);
  86835. protected _shadowMinZ: number;
  86836. /**
  86837. * Gets the shadow projection clipping minimum z value.
  86838. */
  86839. get shadowMinZ(): number;
  86840. /**
  86841. * Sets the shadow projection clipping minimum z value.
  86842. */
  86843. set shadowMinZ(value: number);
  86844. protected _shadowMaxZ: number;
  86845. /**
  86846. * Sets the shadow projection clipping maximum z value.
  86847. */
  86848. get shadowMaxZ(): number;
  86849. /**
  86850. * Gets the shadow projection clipping maximum z value.
  86851. */
  86852. set shadowMaxZ(value: number);
  86853. /**
  86854. * Callback defining a custom Projection Matrix Builder.
  86855. * This can be used to override the default projection matrix computation.
  86856. */
  86857. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86858. /**
  86859. * The transformed position. Position of the light in world space taking parenting in account.
  86860. */
  86861. transformedPosition: Vector3;
  86862. /**
  86863. * The transformed direction. Direction of the light in world space taking parenting in account.
  86864. */
  86865. transformedDirection: Vector3;
  86866. private _needProjectionMatrixCompute;
  86867. /**
  86868. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86869. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86870. */
  86871. computeTransformedInformation(): boolean;
  86872. /**
  86873. * Return the depth scale used for the shadow map.
  86874. * @returns the depth scale.
  86875. */
  86876. getDepthScale(): number;
  86877. /**
  86878. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86879. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86880. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86881. */
  86882. getShadowDirection(faceIndex?: number): Vector3;
  86883. /**
  86884. * Returns the ShadowLight absolute position in the World.
  86885. * @returns the position vector in world space
  86886. */
  86887. getAbsolutePosition(): Vector3;
  86888. /**
  86889. * Sets the ShadowLight direction toward the passed target.
  86890. * @param target The point to target in local space
  86891. * @returns the updated ShadowLight direction
  86892. */
  86893. setDirectionToTarget(target: Vector3): Vector3;
  86894. /**
  86895. * Returns the light rotation in euler definition.
  86896. * @returns the x y z rotation in local space.
  86897. */
  86898. getRotation(): Vector3;
  86899. /**
  86900. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86901. * @returns true if a cube texture needs to be use
  86902. */
  86903. needCube(): boolean;
  86904. /**
  86905. * Detects if the projection matrix requires to be recomputed this frame.
  86906. * @returns true if it requires to be recomputed otherwise, false.
  86907. */
  86908. needProjectionMatrixCompute(): boolean;
  86909. /**
  86910. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86911. */
  86912. forceProjectionMatrixCompute(): void;
  86913. /** @hidden */
  86914. _initCache(): void;
  86915. /** @hidden */
  86916. _isSynchronized(): boolean;
  86917. /**
  86918. * Computes the world matrix of the node
  86919. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86920. * @returns the world matrix
  86921. */
  86922. computeWorldMatrix(force?: boolean): Matrix;
  86923. /**
  86924. * Gets the minZ used for shadow according to both the scene and the light.
  86925. * @param activeCamera The camera we are returning the min for
  86926. * @returns the depth min z
  86927. */
  86928. getDepthMinZ(activeCamera: Camera): number;
  86929. /**
  86930. * Gets the maxZ used for shadow according to both the scene and the light.
  86931. * @param activeCamera The camera we are returning the max for
  86932. * @returns the depth max z
  86933. */
  86934. getDepthMaxZ(activeCamera: Camera): number;
  86935. /**
  86936. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86937. * @param matrix The materix to updated with the projection information
  86938. * @param viewMatrix The transform matrix of the light
  86939. * @param renderList The list of mesh to render in the map
  86940. * @returns The current light
  86941. */
  86942. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86943. }
  86944. }
  86945. declare module BABYLON {
  86946. /** @hidden */
  86947. export var packingFunctions: {
  86948. name: string;
  86949. shader: string;
  86950. };
  86951. }
  86952. declare module BABYLON {
  86953. /** @hidden */
  86954. export var bayerDitherFunctions: {
  86955. name: string;
  86956. shader: string;
  86957. };
  86958. }
  86959. declare module BABYLON {
  86960. /** @hidden */
  86961. export var shadowMapFragmentDeclaration: {
  86962. name: string;
  86963. shader: string;
  86964. };
  86965. }
  86966. declare module BABYLON {
  86967. /** @hidden */
  86968. export var clipPlaneFragmentDeclaration: {
  86969. name: string;
  86970. shader: string;
  86971. };
  86972. }
  86973. declare module BABYLON {
  86974. /** @hidden */
  86975. export var clipPlaneFragment: {
  86976. name: string;
  86977. shader: string;
  86978. };
  86979. }
  86980. declare module BABYLON {
  86981. /** @hidden */
  86982. export var shadowMapFragment: {
  86983. name: string;
  86984. shader: string;
  86985. };
  86986. }
  86987. declare module BABYLON {
  86988. /** @hidden */
  86989. export var shadowMapPixelShader: {
  86990. name: string;
  86991. shader: string;
  86992. };
  86993. }
  86994. declare module BABYLON {
  86995. /** @hidden */
  86996. export var bonesDeclaration: {
  86997. name: string;
  86998. shader: string;
  86999. };
  87000. }
  87001. declare module BABYLON {
  87002. /** @hidden */
  87003. export var morphTargetsVertexGlobalDeclaration: {
  87004. name: string;
  87005. shader: string;
  87006. };
  87007. }
  87008. declare module BABYLON {
  87009. /** @hidden */
  87010. export var morphTargetsVertexDeclaration: {
  87011. name: string;
  87012. shader: string;
  87013. };
  87014. }
  87015. declare module BABYLON {
  87016. /** @hidden */
  87017. export var instancesDeclaration: {
  87018. name: string;
  87019. shader: string;
  87020. };
  87021. }
  87022. declare module BABYLON {
  87023. /** @hidden */
  87024. export var helperFunctions: {
  87025. name: string;
  87026. shader: string;
  87027. };
  87028. }
  87029. declare module BABYLON {
  87030. /** @hidden */
  87031. export var shadowMapVertexDeclaration: {
  87032. name: string;
  87033. shader: string;
  87034. };
  87035. }
  87036. declare module BABYLON {
  87037. /** @hidden */
  87038. export var clipPlaneVertexDeclaration: {
  87039. name: string;
  87040. shader: string;
  87041. };
  87042. }
  87043. declare module BABYLON {
  87044. /** @hidden */
  87045. export var morphTargetsVertex: {
  87046. name: string;
  87047. shader: string;
  87048. };
  87049. }
  87050. declare module BABYLON {
  87051. /** @hidden */
  87052. export var instancesVertex: {
  87053. name: string;
  87054. shader: string;
  87055. };
  87056. }
  87057. declare module BABYLON {
  87058. /** @hidden */
  87059. export var bonesVertex: {
  87060. name: string;
  87061. shader: string;
  87062. };
  87063. }
  87064. declare module BABYLON {
  87065. /** @hidden */
  87066. export var shadowMapVertexNormalBias: {
  87067. name: string;
  87068. shader: string;
  87069. };
  87070. }
  87071. declare module BABYLON {
  87072. /** @hidden */
  87073. export var shadowMapVertexMetric: {
  87074. name: string;
  87075. shader: string;
  87076. };
  87077. }
  87078. declare module BABYLON {
  87079. /** @hidden */
  87080. export var clipPlaneVertex: {
  87081. name: string;
  87082. shader: string;
  87083. };
  87084. }
  87085. declare module BABYLON {
  87086. /** @hidden */
  87087. export var shadowMapVertexShader: {
  87088. name: string;
  87089. shader: string;
  87090. };
  87091. }
  87092. declare module BABYLON {
  87093. /** @hidden */
  87094. export var depthBoxBlurPixelShader: {
  87095. name: string;
  87096. shader: string;
  87097. };
  87098. }
  87099. declare module BABYLON {
  87100. /** @hidden */
  87101. export var shadowMapFragmentSoftTransparentShadow: {
  87102. name: string;
  87103. shader: string;
  87104. };
  87105. }
  87106. declare module BABYLON {
  87107. /**
  87108. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87109. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87110. */
  87111. export class EffectFallbacks implements IEffectFallbacks {
  87112. private _defines;
  87113. private _currentRank;
  87114. private _maxRank;
  87115. private _mesh;
  87116. /**
  87117. * Removes the fallback from the bound mesh.
  87118. */
  87119. unBindMesh(): void;
  87120. /**
  87121. * Adds a fallback on the specified property.
  87122. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87123. * @param define The name of the define in the shader
  87124. */
  87125. addFallback(rank: number, define: string): void;
  87126. /**
  87127. * Sets the mesh to use CPU skinning when needing to fallback.
  87128. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87129. * @param mesh The mesh to use the fallbacks.
  87130. */
  87131. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87132. /**
  87133. * Checks to see if more fallbacks are still availible.
  87134. */
  87135. get hasMoreFallbacks(): boolean;
  87136. /**
  87137. * Removes the defines that should be removed when falling back.
  87138. * @param currentDefines defines the current define statements for the shader.
  87139. * @param effect defines the current effect we try to compile
  87140. * @returns The resulting defines with defines of the current rank removed.
  87141. */
  87142. reduce(currentDefines: string, effect: Effect): string;
  87143. }
  87144. }
  87145. declare module BABYLON {
  87146. /**
  87147. * Interface used to define Action
  87148. */
  87149. export interface IAction {
  87150. /**
  87151. * Trigger for the action
  87152. */
  87153. trigger: number;
  87154. /** Options of the trigger */
  87155. triggerOptions: any;
  87156. /**
  87157. * Gets the trigger parameters
  87158. * @returns the trigger parameters
  87159. */
  87160. getTriggerParameter(): any;
  87161. /**
  87162. * Internal only - executes current action event
  87163. * @hidden
  87164. */
  87165. _executeCurrent(evt?: ActionEvent): void;
  87166. /**
  87167. * Serialize placeholder for child classes
  87168. * @param parent of child
  87169. * @returns the serialized object
  87170. */
  87171. serialize(parent: any): any;
  87172. /**
  87173. * Internal only
  87174. * @hidden
  87175. */
  87176. _prepare(): void;
  87177. /**
  87178. * Internal only - manager for action
  87179. * @hidden
  87180. */
  87181. _actionManager: AbstractActionManager;
  87182. /**
  87183. * Adds action to chain of actions, may be a DoNothingAction
  87184. * @param action defines the next action to execute
  87185. * @returns The action passed in
  87186. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87187. */
  87188. then(action: IAction): IAction;
  87189. }
  87190. /**
  87191. * The action to be carried out following a trigger
  87192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87193. */
  87194. export class Action implements IAction {
  87195. /** the trigger, with or without parameters, for the action */
  87196. triggerOptions: any;
  87197. /**
  87198. * Trigger for the action
  87199. */
  87200. trigger: number;
  87201. /**
  87202. * Internal only - manager for action
  87203. * @hidden
  87204. */
  87205. _actionManager: ActionManager;
  87206. private _nextActiveAction;
  87207. private _child;
  87208. private _condition?;
  87209. private _triggerParameter;
  87210. /**
  87211. * An event triggered prior to action being executed.
  87212. */
  87213. onBeforeExecuteObservable: Observable<Action>;
  87214. /**
  87215. * Creates a new Action
  87216. * @param triggerOptions the trigger, with or without parameters, for the action
  87217. * @param condition an optional determinant of action
  87218. */
  87219. constructor(
  87220. /** the trigger, with or without parameters, for the action */
  87221. triggerOptions: any, condition?: Condition);
  87222. /**
  87223. * Internal only
  87224. * @hidden
  87225. */
  87226. _prepare(): void;
  87227. /**
  87228. * Gets the trigger parameters
  87229. * @returns the trigger parameters
  87230. */
  87231. getTriggerParameter(): any;
  87232. /**
  87233. * Internal only - executes current action event
  87234. * @hidden
  87235. */
  87236. _executeCurrent(evt?: ActionEvent): void;
  87237. /**
  87238. * Execute placeholder for child classes
  87239. * @param evt optional action event
  87240. */
  87241. execute(evt?: ActionEvent): void;
  87242. /**
  87243. * Skips to next active action
  87244. */
  87245. skipToNextActiveAction(): void;
  87246. /**
  87247. * Adds action to chain of actions, may be a DoNothingAction
  87248. * @param action defines the next action to execute
  87249. * @returns The action passed in
  87250. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87251. */
  87252. then(action: Action): Action;
  87253. /**
  87254. * Internal only
  87255. * @hidden
  87256. */
  87257. _getProperty(propertyPath: string): string;
  87258. /**
  87259. * Internal only
  87260. * @hidden
  87261. */
  87262. _getEffectiveTarget(target: any, propertyPath: string): any;
  87263. /**
  87264. * Serialize placeholder for child classes
  87265. * @param parent of child
  87266. * @returns the serialized object
  87267. */
  87268. serialize(parent: any): any;
  87269. /**
  87270. * Internal only called by serialize
  87271. * @hidden
  87272. */
  87273. protected _serialize(serializedAction: any, parent?: any): any;
  87274. /**
  87275. * Internal only
  87276. * @hidden
  87277. */
  87278. static _SerializeValueAsString: (value: any) => string;
  87279. /**
  87280. * Internal only
  87281. * @hidden
  87282. */
  87283. static _GetTargetProperty: (target: Node | Scene) => {
  87284. name: string;
  87285. targetType: string;
  87286. value: string;
  87287. };
  87288. }
  87289. }
  87290. declare module BABYLON {
  87291. /**
  87292. * A Condition applied to an Action
  87293. */
  87294. export class Condition {
  87295. /**
  87296. * Internal only - manager for action
  87297. * @hidden
  87298. */
  87299. _actionManager: ActionManager;
  87300. /**
  87301. * Internal only
  87302. * @hidden
  87303. */
  87304. _evaluationId: number;
  87305. /**
  87306. * Internal only
  87307. * @hidden
  87308. */
  87309. _currentResult: boolean;
  87310. /**
  87311. * Creates a new Condition
  87312. * @param actionManager the manager of the action the condition is applied to
  87313. */
  87314. constructor(actionManager: ActionManager);
  87315. /**
  87316. * Check if the current condition is valid
  87317. * @returns a boolean
  87318. */
  87319. isValid(): boolean;
  87320. /**
  87321. * Internal only
  87322. * @hidden
  87323. */
  87324. _getProperty(propertyPath: string): string;
  87325. /**
  87326. * Internal only
  87327. * @hidden
  87328. */
  87329. _getEffectiveTarget(target: any, propertyPath: string): any;
  87330. /**
  87331. * Serialize placeholder for child classes
  87332. * @returns the serialized object
  87333. */
  87334. serialize(): any;
  87335. /**
  87336. * Internal only
  87337. * @hidden
  87338. */
  87339. protected _serialize(serializedCondition: any): any;
  87340. }
  87341. /**
  87342. * Defines specific conditional operators as extensions of Condition
  87343. */
  87344. export class ValueCondition extends Condition {
  87345. /** path to specify the property of the target the conditional operator uses */
  87346. propertyPath: string;
  87347. /** the value compared by the conditional operator against the current value of the property */
  87348. value: any;
  87349. /** the conditional operator, default ValueCondition.IsEqual */
  87350. operator: number;
  87351. /**
  87352. * Internal only
  87353. * @hidden
  87354. */
  87355. private static _IsEqual;
  87356. /**
  87357. * Internal only
  87358. * @hidden
  87359. */
  87360. private static _IsDifferent;
  87361. /**
  87362. * Internal only
  87363. * @hidden
  87364. */
  87365. private static _IsGreater;
  87366. /**
  87367. * Internal only
  87368. * @hidden
  87369. */
  87370. private static _IsLesser;
  87371. /**
  87372. * returns the number for IsEqual
  87373. */
  87374. static get IsEqual(): number;
  87375. /**
  87376. * Returns the number for IsDifferent
  87377. */
  87378. static get IsDifferent(): number;
  87379. /**
  87380. * Returns the number for IsGreater
  87381. */
  87382. static get IsGreater(): number;
  87383. /**
  87384. * Returns the number for IsLesser
  87385. */
  87386. static get IsLesser(): number;
  87387. /**
  87388. * Internal only The action manager for the condition
  87389. * @hidden
  87390. */
  87391. _actionManager: ActionManager;
  87392. /**
  87393. * Internal only
  87394. * @hidden
  87395. */
  87396. private _target;
  87397. /**
  87398. * Internal only
  87399. * @hidden
  87400. */
  87401. private _effectiveTarget;
  87402. /**
  87403. * Internal only
  87404. * @hidden
  87405. */
  87406. private _property;
  87407. /**
  87408. * Creates a new ValueCondition
  87409. * @param actionManager manager for the action the condition applies to
  87410. * @param target for the action
  87411. * @param propertyPath path to specify the property of the target the conditional operator uses
  87412. * @param value the value compared by the conditional operator against the current value of the property
  87413. * @param operator the conditional operator, default ValueCondition.IsEqual
  87414. */
  87415. constructor(actionManager: ActionManager, target: any,
  87416. /** path to specify the property of the target the conditional operator uses */
  87417. propertyPath: string,
  87418. /** the value compared by the conditional operator against the current value of the property */
  87419. value: any,
  87420. /** the conditional operator, default ValueCondition.IsEqual */
  87421. operator?: number);
  87422. /**
  87423. * Compares the given value with the property value for the specified conditional operator
  87424. * @returns the result of the comparison
  87425. */
  87426. isValid(): boolean;
  87427. /**
  87428. * Serialize the ValueCondition into a JSON compatible object
  87429. * @returns serialization object
  87430. */
  87431. serialize(): any;
  87432. /**
  87433. * Gets the name of the conditional operator for the ValueCondition
  87434. * @param operator the conditional operator
  87435. * @returns the name
  87436. */
  87437. static GetOperatorName(operator: number): string;
  87438. }
  87439. /**
  87440. * Defines a predicate condition as an extension of Condition
  87441. */
  87442. export class PredicateCondition extends Condition {
  87443. /** defines the predicate function used to validate the condition */
  87444. predicate: () => boolean;
  87445. /**
  87446. * Internal only - manager for action
  87447. * @hidden
  87448. */
  87449. _actionManager: ActionManager;
  87450. /**
  87451. * Creates a new PredicateCondition
  87452. * @param actionManager manager for the action the condition applies to
  87453. * @param predicate defines the predicate function used to validate the condition
  87454. */
  87455. constructor(actionManager: ActionManager,
  87456. /** defines the predicate function used to validate the condition */
  87457. predicate: () => boolean);
  87458. /**
  87459. * @returns the validity of the predicate condition
  87460. */
  87461. isValid(): boolean;
  87462. }
  87463. /**
  87464. * Defines a state condition as an extension of Condition
  87465. */
  87466. export class StateCondition extends Condition {
  87467. /** Value to compare with target state */
  87468. value: string;
  87469. /**
  87470. * Internal only - manager for action
  87471. * @hidden
  87472. */
  87473. _actionManager: ActionManager;
  87474. /**
  87475. * Internal only
  87476. * @hidden
  87477. */
  87478. private _target;
  87479. /**
  87480. * Creates a new StateCondition
  87481. * @param actionManager manager for the action the condition applies to
  87482. * @param target of the condition
  87483. * @param value to compare with target state
  87484. */
  87485. constructor(actionManager: ActionManager, target: any,
  87486. /** Value to compare with target state */
  87487. value: string);
  87488. /**
  87489. * Gets a boolean indicating if the current condition is met
  87490. * @returns the validity of the state
  87491. */
  87492. isValid(): boolean;
  87493. /**
  87494. * Serialize the StateCondition into a JSON compatible object
  87495. * @returns serialization object
  87496. */
  87497. serialize(): any;
  87498. }
  87499. }
  87500. declare module BABYLON {
  87501. /**
  87502. * This defines an action responsible to toggle a boolean once triggered.
  87503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87504. */
  87505. export class SwitchBooleanAction extends Action {
  87506. /**
  87507. * The path to the boolean property in the target object
  87508. */
  87509. propertyPath: string;
  87510. private _target;
  87511. private _effectiveTarget;
  87512. private _property;
  87513. /**
  87514. * Instantiate the action
  87515. * @param triggerOptions defines the trigger options
  87516. * @param target defines the object containing the boolean
  87517. * @param propertyPath defines the path to the boolean property in the target object
  87518. * @param condition defines the trigger related conditions
  87519. */
  87520. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87521. /** @hidden */
  87522. _prepare(): void;
  87523. /**
  87524. * Execute the action toggle the boolean value.
  87525. */
  87526. execute(): void;
  87527. /**
  87528. * Serializes the actions and its related information.
  87529. * @param parent defines the object to serialize in
  87530. * @returns the serialized object
  87531. */
  87532. serialize(parent: any): any;
  87533. }
  87534. /**
  87535. * This defines an action responsible to set a the state field of the target
  87536. * to a desired value once triggered.
  87537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87538. */
  87539. export class SetStateAction extends Action {
  87540. /**
  87541. * The value to store in the state field.
  87542. */
  87543. value: string;
  87544. private _target;
  87545. /**
  87546. * Instantiate the action
  87547. * @param triggerOptions defines the trigger options
  87548. * @param target defines the object containing the state property
  87549. * @param value defines the value to store in the state field
  87550. * @param condition defines the trigger related conditions
  87551. */
  87552. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87553. /**
  87554. * Execute the action and store the value on the target state property.
  87555. */
  87556. execute(): void;
  87557. /**
  87558. * Serializes the actions and its related information.
  87559. * @param parent defines the object to serialize in
  87560. * @returns the serialized object
  87561. */
  87562. serialize(parent: any): any;
  87563. }
  87564. /**
  87565. * This defines an action responsible to set a property of the target
  87566. * to a desired value once triggered.
  87567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87568. */
  87569. export class SetValueAction extends Action {
  87570. /**
  87571. * The path of the property to set in the target.
  87572. */
  87573. propertyPath: string;
  87574. /**
  87575. * The value to set in the property
  87576. */
  87577. value: any;
  87578. private _target;
  87579. private _effectiveTarget;
  87580. private _property;
  87581. /**
  87582. * Instantiate the action
  87583. * @param triggerOptions defines the trigger options
  87584. * @param target defines the object containing the property
  87585. * @param propertyPath defines the path of the property to set in the target
  87586. * @param value defines the value to set in the property
  87587. * @param condition defines the trigger related conditions
  87588. */
  87589. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87590. /** @hidden */
  87591. _prepare(): void;
  87592. /**
  87593. * Execute the action and set the targetted property to the desired value.
  87594. */
  87595. execute(): void;
  87596. /**
  87597. * Serializes the actions and its related information.
  87598. * @param parent defines the object to serialize in
  87599. * @returns the serialized object
  87600. */
  87601. serialize(parent: any): any;
  87602. }
  87603. /**
  87604. * This defines an action responsible to increment the target value
  87605. * to a desired value once triggered.
  87606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87607. */
  87608. export class IncrementValueAction extends Action {
  87609. /**
  87610. * The path of the property to increment in the target.
  87611. */
  87612. propertyPath: string;
  87613. /**
  87614. * The value we should increment the property by.
  87615. */
  87616. value: any;
  87617. private _target;
  87618. private _effectiveTarget;
  87619. private _property;
  87620. /**
  87621. * Instantiate the action
  87622. * @param triggerOptions defines the trigger options
  87623. * @param target defines the object containing the property
  87624. * @param propertyPath defines the path of the property to increment in the target
  87625. * @param value defines the value value we should increment the property by
  87626. * @param condition defines the trigger related conditions
  87627. */
  87628. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87629. /** @hidden */
  87630. _prepare(): void;
  87631. /**
  87632. * Execute the action and increment the target of the value amount.
  87633. */
  87634. execute(): void;
  87635. /**
  87636. * Serializes the actions and its related information.
  87637. * @param parent defines the object to serialize in
  87638. * @returns the serialized object
  87639. */
  87640. serialize(parent: any): any;
  87641. }
  87642. /**
  87643. * This defines an action responsible to start an animation once triggered.
  87644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87645. */
  87646. export class PlayAnimationAction extends Action {
  87647. /**
  87648. * Where the animation should start (animation frame)
  87649. */
  87650. from: number;
  87651. /**
  87652. * Where the animation should stop (animation frame)
  87653. */
  87654. to: number;
  87655. /**
  87656. * Define if the animation should loop or stop after the first play.
  87657. */
  87658. loop?: boolean;
  87659. private _target;
  87660. /**
  87661. * Instantiate the action
  87662. * @param triggerOptions defines the trigger options
  87663. * @param target defines the target animation or animation name
  87664. * @param from defines from where the animation should start (animation frame)
  87665. * @param end defines where the animation should stop (animation frame)
  87666. * @param loop defines if the animation should loop or stop after the first play
  87667. * @param condition defines the trigger related conditions
  87668. */
  87669. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87670. /** @hidden */
  87671. _prepare(): void;
  87672. /**
  87673. * Execute the action and play the animation.
  87674. */
  87675. execute(): void;
  87676. /**
  87677. * Serializes the actions and its related information.
  87678. * @param parent defines the object to serialize in
  87679. * @returns the serialized object
  87680. */
  87681. serialize(parent: any): any;
  87682. }
  87683. /**
  87684. * This defines an action responsible to stop an animation once triggered.
  87685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87686. */
  87687. export class StopAnimationAction extends Action {
  87688. private _target;
  87689. /**
  87690. * Instantiate the action
  87691. * @param triggerOptions defines the trigger options
  87692. * @param target defines the target animation or animation name
  87693. * @param condition defines the trigger related conditions
  87694. */
  87695. constructor(triggerOptions: any, target: any, condition?: Condition);
  87696. /** @hidden */
  87697. _prepare(): void;
  87698. /**
  87699. * Execute the action and stop the animation.
  87700. */
  87701. execute(): void;
  87702. /**
  87703. * Serializes the actions and its related information.
  87704. * @param parent defines the object to serialize in
  87705. * @returns the serialized object
  87706. */
  87707. serialize(parent: any): any;
  87708. }
  87709. /**
  87710. * This defines an action responsible that does nothing once triggered.
  87711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87712. */
  87713. export class DoNothingAction extends Action {
  87714. /**
  87715. * Instantiate the action
  87716. * @param triggerOptions defines the trigger options
  87717. * @param condition defines the trigger related conditions
  87718. */
  87719. constructor(triggerOptions?: any, condition?: Condition);
  87720. /**
  87721. * Execute the action and do nothing.
  87722. */
  87723. execute(): void;
  87724. /**
  87725. * Serializes the actions and its related information.
  87726. * @param parent defines the object to serialize in
  87727. * @returns the serialized object
  87728. */
  87729. serialize(parent: any): any;
  87730. }
  87731. /**
  87732. * This defines an action responsible to trigger several actions once triggered.
  87733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87734. */
  87735. export class CombineAction extends Action {
  87736. /**
  87737. * The list of aggregated animations to run.
  87738. */
  87739. children: Action[];
  87740. /**
  87741. * Instantiate the action
  87742. * @param triggerOptions defines the trigger options
  87743. * @param children defines the list of aggregated animations to run
  87744. * @param condition defines the trigger related conditions
  87745. */
  87746. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87747. /** @hidden */
  87748. _prepare(): void;
  87749. /**
  87750. * Execute the action and executes all the aggregated actions.
  87751. */
  87752. execute(evt: ActionEvent): void;
  87753. /**
  87754. * Serializes the actions and its related information.
  87755. * @param parent defines the object to serialize in
  87756. * @returns the serialized object
  87757. */
  87758. serialize(parent: any): any;
  87759. }
  87760. /**
  87761. * This defines an action responsible to run code (external event) once triggered.
  87762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87763. */
  87764. export class ExecuteCodeAction extends Action {
  87765. /**
  87766. * The callback function to run.
  87767. */
  87768. func: (evt: ActionEvent) => void;
  87769. /**
  87770. * Instantiate the action
  87771. * @param triggerOptions defines the trigger options
  87772. * @param func defines the callback function to run
  87773. * @param condition defines the trigger related conditions
  87774. */
  87775. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87776. /**
  87777. * Execute the action and run the attached code.
  87778. */
  87779. execute(evt: ActionEvent): void;
  87780. }
  87781. /**
  87782. * This defines an action responsible to set the parent property of the target once triggered.
  87783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87784. */
  87785. export class SetParentAction extends Action {
  87786. private _parent;
  87787. private _target;
  87788. /**
  87789. * Instantiate the action
  87790. * @param triggerOptions defines the trigger options
  87791. * @param target defines the target containing the parent property
  87792. * @param parent defines from where the animation should start (animation frame)
  87793. * @param condition defines the trigger related conditions
  87794. */
  87795. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87796. /** @hidden */
  87797. _prepare(): void;
  87798. /**
  87799. * Execute the action and set the parent property.
  87800. */
  87801. execute(): void;
  87802. /**
  87803. * Serializes the actions and its related information.
  87804. * @param parent defines the object to serialize in
  87805. * @returns the serialized object
  87806. */
  87807. serialize(parent: any): any;
  87808. }
  87809. }
  87810. declare module BABYLON {
  87811. /**
  87812. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87813. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87815. */
  87816. export class ActionManager extends AbstractActionManager {
  87817. /**
  87818. * Nothing
  87819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87820. */
  87821. static readonly NothingTrigger: number;
  87822. /**
  87823. * On pick
  87824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87825. */
  87826. static readonly OnPickTrigger: number;
  87827. /**
  87828. * On left pick
  87829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87830. */
  87831. static readonly OnLeftPickTrigger: number;
  87832. /**
  87833. * On right pick
  87834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87835. */
  87836. static readonly OnRightPickTrigger: number;
  87837. /**
  87838. * On center pick
  87839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87840. */
  87841. static readonly OnCenterPickTrigger: number;
  87842. /**
  87843. * On pick down
  87844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87845. */
  87846. static readonly OnPickDownTrigger: number;
  87847. /**
  87848. * On double pick
  87849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87850. */
  87851. static readonly OnDoublePickTrigger: number;
  87852. /**
  87853. * On pick up
  87854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87855. */
  87856. static readonly OnPickUpTrigger: number;
  87857. /**
  87858. * On pick out.
  87859. * This trigger will only be raised if you also declared a OnPickDown
  87860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87861. */
  87862. static readonly OnPickOutTrigger: number;
  87863. /**
  87864. * On long press
  87865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87866. */
  87867. static readonly OnLongPressTrigger: number;
  87868. /**
  87869. * On pointer over
  87870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87871. */
  87872. static readonly OnPointerOverTrigger: number;
  87873. /**
  87874. * On pointer out
  87875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87876. */
  87877. static readonly OnPointerOutTrigger: number;
  87878. /**
  87879. * On every frame
  87880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87881. */
  87882. static readonly OnEveryFrameTrigger: number;
  87883. /**
  87884. * On intersection enter
  87885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87886. */
  87887. static readonly OnIntersectionEnterTrigger: number;
  87888. /**
  87889. * On intersection exit
  87890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87891. */
  87892. static readonly OnIntersectionExitTrigger: number;
  87893. /**
  87894. * On key down
  87895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87896. */
  87897. static readonly OnKeyDownTrigger: number;
  87898. /**
  87899. * On key up
  87900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87901. */
  87902. static readonly OnKeyUpTrigger: number;
  87903. private _scene;
  87904. /**
  87905. * Creates a new action manager
  87906. * @param scene defines the hosting scene
  87907. */
  87908. constructor(scene: Scene);
  87909. /**
  87910. * Releases all associated resources
  87911. */
  87912. dispose(): void;
  87913. /**
  87914. * Gets hosting scene
  87915. * @returns the hosting scene
  87916. */
  87917. getScene(): Scene;
  87918. /**
  87919. * Does this action manager handles actions of any of the given triggers
  87920. * @param triggers defines the triggers to be tested
  87921. * @return a boolean indicating whether one (or more) of the triggers is handled
  87922. */
  87923. hasSpecificTriggers(triggers: number[]): boolean;
  87924. /**
  87925. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87926. * speed.
  87927. * @param triggerA defines the trigger to be tested
  87928. * @param triggerB defines the trigger to be tested
  87929. * @return a boolean indicating whether one (or more) of the triggers is handled
  87930. */
  87931. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87932. /**
  87933. * Does this action manager handles actions of a given trigger
  87934. * @param trigger defines the trigger to be tested
  87935. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87936. * @return whether the trigger is handled
  87937. */
  87938. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87939. /**
  87940. * Does this action manager has pointer triggers
  87941. */
  87942. get hasPointerTriggers(): boolean;
  87943. /**
  87944. * Does this action manager has pick triggers
  87945. */
  87946. get hasPickTriggers(): boolean;
  87947. /**
  87948. * Registers an action to this action manager
  87949. * @param action defines the action to be registered
  87950. * @return the action amended (prepared) after registration
  87951. */
  87952. registerAction(action: IAction): Nullable<IAction>;
  87953. /**
  87954. * Unregisters an action to this action manager
  87955. * @param action defines the action to be unregistered
  87956. * @return a boolean indicating whether the action has been unregistered
  87957. */
  87958. unregisterAction(action: IAction): Boolean;
  87959. /**
  87960. * Process a specific trigger
  87961. * @param trigger defines the trigger to process
  87962. * @param evt defines the event details to be processed
  87963. */
  87964. processTrigger(trigger: number, evt?: IActionEvent): void;
  87965. /** @hidden */
  87966. _getEffectiveTarget(target: any, propertyPath: string): any;
  87967. /** @hidden */
  87968. _getProperty(propertyPath: string): string;
  87969. /**
  87970. * Serialize this manager to a JSON object
  87971. * @param name defines the property name to store this manager
  87972. * @returns a JSON representation of this manager
  87973. */
  87974. serialize(name: string): any;
  87975. /**
  87976. * Creates a new ActionManager from a JSON data
  87977. * @param parsedActions defines the JSON data to read from
  87978. * @param object defines the hosting mesh
  87979. * @param scene defines the hosting scene
  87980. */
  87981. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87982. /**
  87983. * Get a trigger name by index
  87984. * @param trigger defines the trigger index
  87985. * @returns a trigger name
  87986. */
  87987. static GetTriggerName(trigger: number): string;
  87988. }
  87989. }
  87990. declare module BABYLON {
  87991. /**
  87992. * Class used to represent a sprite
  87993. * @see http://doc.babylonjs.com/babylon101/sprites
  87994. */
  87995. export class Sprite implements IAnimatable {
  87996. /** defines the name */
  87997. name: string;
  87998. /** Gets or sets the current world position */
  87999. position: Vector3;
  88000. /** Gets or sets the main color */
  88001. color: Color4;
  88002. /** Gets or sets the width */
  88003. width: number;
  88004. /** Gets or sets the height */
  88005. height: number;
  88006. /** Gets or sets rotation angle */
  88007. angle: number;
  88008. /** Gets or sets the cell index in the sprite sheet */
  88009. cellIndex: number;
  88010. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88011. cellRef: string;
  88012. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88013. invertU: boolean;
  88014. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88015. invertV: boolean;
  88016. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88017. disposeWhenFinishedAnimating: boolean;
  88018. /** Gets the list of attached animations */
  88019. animations: Nullable<Array<Animation>>;
  88020. /** Gets or sets a boolean indicating if the sprite can be picked */
  88021. isPickable: boolean;
  88022. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88023. useAlphaForPicking: boolean;
  88024. /** @hidden */
  88025. _xOffset: number;
  88026. /** @hidden */
  88027. _yOffset: number;
  88028. /** @hidden */
  88029. _xSize: number;
  88030. /** @hidden */
  88031. _ySize: number;
  88032. /**
  88033. * Gets or sets the associated action manager
  88034. */
  88035. actionManager: Nullable<ActionManager>;
  88036. /**
  88037. * An event triggered when the control has been disposed
  88038. */
  88039. onDisposeObservable: Observable<Sprite>;
  88040. private _animationStarted;
  88041. private _loopAnimation;
  88042. private _fromIndex;
  88043. private _toIndex;
  88044. private _delay;
  88045. private _direction;
  88046. private _manager;
  88047. private _time;
  88048. private _onAnimationEnd;
  88049. /**
  88050. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88051. */
  88052. isVisible: boolean;
  88053. /**
  88054. * Gets or sets the sprite size
  88055. */
  88056. get size(): number;
  88057. set size(value: number);
  88058. /**
  88059. * Returns a boolean indicating if the animation is started
  88060. */
  88061. get animationStarted(): boolean;
  88062. /**
  88063. * Gets or sets the unique id of the sprite
  88064. */
  88065. uniqueId: number;
  88066. /**
  88067. * Gets the manager of this sprite
  88068. */
  88069. get manager(): ISpriteManager;
  88070. /**
  88071. * Creates a new Sprite
  88072. * @param name defines the name
  88073. * @param manager defines the manager
  88074. */
  88075. constructor(
  88076. /** defines the name */
  88077. name: string, manager: ISpriteManager);
  88078. /**
  88079. * Returns the string "Sprite"
  88080. * @returns "Sprite"
  88081. */
  88082. getClassName(): string;
  88083. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88084. get fromIndex(): number;
  88085. set fromIndex(value: number);
  88086. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88087. get toIndex(): number;
  88088. set toIndex(value: number);
  88089. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88090. get loopAnimation(): boolean;
  88091. set loopAnimation(value: boolean);
  88092. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88093. get delay(): number;
  88094. set delay(value: number);
  88095. /**
  88096. * Starts an animation
  88097. * @param from defines the initial key
  88098. * @param to defines the end key
  88099. * @param loop defines if the animation must loop
  88100. * @param delay defines the start delay (in ms)
  88101. * @param onAnimationEnd defines a callback to call when animation ends
  88102. */
  88103. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88104. /** Stops current animation (if any) */
  88105. stopAnimation(): void;
  88106. /** @hidden */
  88107. _animate(deltaTime: number): void;
  88108. /** Release associated resources */
  88109. dispose(): void;
  88110. /**
  88111. * Serializes the sprite to a JSON object
  88112. * @returns the JSON object
  88113. */
  88114. serialize(): any;
  88115. /**
  88116. * Parses a JSON object to create a new sprite
  88117. * @param parsedSprite The JSON object to parse
  88118. * @param manager defines the hosting manager
  88119. * @returns the new sprite
  88120. */
  88121. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88122. }
  88123. }
  88124. declare module BABYLON {
  88125. /**
  88126. * Information about the result of picking within a scene
  88127. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88128. */
  88129. export class PickingInfo {
  88130. /** @hidden */
  88131. _pickingUnavailable: boolean;
  88132. /**
  88133. * If the pick collided with an object
  88134. */
  88135. hit: boolean;
  88136. /**
  88137. * Distance away where the pick collided
  88138. */
  88139. distance: number;
  88140. /**
  88141. * The location of pick collision
  88142. */
  88143. pickedPoint: Nullable<Vector3>;
  88144. /**
  88145. * The mesh corresponding the the pick collision
  88146. */
  88147. pickedMesh: Nullable<AbstractMesh>;
  88148. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88149. bu: number;
  88150. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88151. bv: number;
  88152. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88153. faceId: number;
  88154. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88155. subMeshFaceId: number;
  88156. /** Id of the the submesh that was picked */
  88157. subMeshId: number;
  88158. /** If a sprite was picked, this will be the sprite the pick collided with */
  88159. pickedSprite: Nullable<Sprite>;
  88160. /**
  88161. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88162. */
  88163. originMesh: Nullable<AbstractMesh>;
  88164. /**
  88165. * The ray that was used to perform the picking.
  88166. */
  88167. ray: Nullable<Ray>;
  88168. /**
  88169. * Gets the normal correspodning to the face the pick collided with
  88170. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88171. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88172. * @returns The normal correspodning to the face the pick collided with
  88173. */
  88174. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88175. /**
  88176. * Gets the texture coordinates of where the pick occured
  88177. * @returns the vector containing the coordnates of the texture
  88178. */
  88179. getTextureCoordinates(): Nullable<Vector2>;
  88180. }
  88181. }
  88182. declare module BABYLON {
  88183. /**
  88184. * Class representing a ray with position and direction
  88185. */
  88186. export class Ray {
  88187. /** origin point */
  88188. origin: Vector3;
  88189. /** direction */
  88190. direction: Vector3;
  88191. /** length of the ray */
  88192. length: number;
  88193. private static readonly TmpVector3;
  88194. private _tmpRay;
  88195. /**
  88196. * Creates a new ray
  88197. * @param origin origin point
  88198. * @param direction direction
  88199. * @param length length of the ray
  88200. */
  88201. constructor(
  88202. /** origin point */
  88203. origin: Vector3,
  88204. /** direction */
  88205. direction: Vector3,
  88206. /** length of the ray */
  88207. length?: number);
  88208. /**
  88209. * Checks if the ray intersects a box
  88210. * This does not account for the ray lenght by design to improve perfs.
  88211. * @param minimum bound of the box
  88212. * @param maximum bound of the box
  88213. * @param intersectionTreshold extra extend to be added to the box in all direction
  88214. * @returns if the box was hit
  88215. */
  88216. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88217. /**
  88218. * Checks if the ray intersects a box
  88219. * This does not account for the ray lenght by design to improve perfs.
  88220. * @param box the bounding box to check
  88221. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88222. * @returns if the box was hit
  88223. */
  88224. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88225. /**
  88226. * If the ray hits a sphere
  88227. * @param sphere the bounding sphere to check
  88228. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88229. * @returns true if it hits the sphere
  88230. */
  88231. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88232. /**
  88233. * If the ray hits a triange
  88234. * @param vertex0 triangle vertex
  88235. * @param vertex1 triangle vertex
  88236. * @param vertex2 triangle vertex
  88237. * @returns intersection information if hit
  88238. */
  88239. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88240. /**
  88241. * Checks if ray intersects a plane
  88242. * @param plane the plane to check
  88243. * @returns the distance away it was hit
  88244. */
  88245. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88246. /**
  88247. * Calculate the intercept of a ray on a given axis
  88248. * @param axis to check 'x' | 'y' | 'z'
  88249. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88250. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88251. */
  88252. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88253. /**
  88254. * Checks if ray intersects a mesh
  88255. * @param mesh the mesh to check
  88256. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88257. * @returns picking info of the intersecton
  88258. */
  88259. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88260. /**
  88261. * Checks if ray intersects a mesh
  88262. * @param meshes the meshes to check
  88263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88264. * @param results array to store result in
  88265. * @returns Array of picking infos
  88266. */
  88267. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88268. private _comparePickingInfo;
  88269. private static smallnum;
  88270. private static rayl;
  88271. /**
  88272. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88273. * @param sega the first point of the segment to test the intersection against
  88274. * @param segb the second point of the segment to test the intersection against
  88275. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88276. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88277. */
  88278. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88279. /**
  88280. * Update the ray from viewport position
  88281. * @param x position
  88282. * @param y y position
  88283. * @param viewportWidth viewport width
  88284. * @param viewportHeight viewport height
  88285. * @param world world matrix
  88286. * @param view view matrix
  88287. * @param projection projection matrix
  88288. * @returns this ray updated
  88289. */
  88290. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88291. /**
  88292. * Creates a ray with origin and direction of 0,0,0
  88293. * @returns the new ray
  88294. */
  88295. static Zero(): Ray;
  88296. /**
  88297. * Creates a new ray from screen space and viewport
  88298. * @param x position
  88299. * @param y y position
  88300. * @param viewportWidth viewport width
  88301. * @param viewportHeight viewport height
  88302. * @param world world matrix
  88303. * @param view view matrix
  88304. * @param projection projection matrix
  88305. * @returns new ray
  88306. */
  88307. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88308. /**
  88309. * 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
  88310. * transformed to the given world matrix.
  88311. * @param origin The origin point
  88312. * @param end The end point
  88313. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88314. * @returns the new ray
  88315. */
  88316. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88317. /**
  88318. * Transforms a ray by a matrix
  88319. * @param ray ray to transform
  88320. * @param matrix matrix to apply
  88321. * @returns the resulting new ray
  88322. */
  88323. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88324. /**
  88325. * Transforms a ray by a matrix
  88326. * @param ray ray to transform
  88327. * @param matrix matrix to apply
  88328. * @param result ray to store result in
  88329. */
  88330. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88331. /**
  88332. * Unproject a ray from screen space to object space
  88333. * @param sourceX defines the screen space x coordinate to use
  88334. * @param sourceY defines the screen space y coordinate to use
  88335. * @param viewportWidth defines the current width of the viewport
  88336. * @param viewportHeight defines the current height of the viewport
  88337. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88338. * @param view defines the view matrix to use
  88339. * @param projection defines the projection matrix to use
  88340. */
  88341. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88342. }
  88343. /**
  88344. * Type used to define predicate used to select faces when a mesh intersection is detected
  88345. */
  88346. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88347. interface Scene {
  88348. /** @hidden */
  88349. _tempPickingRay: Nullable<Ray>;
  88350. /** @hidden */
  88351. _cachedRayForTransform: Ray;
  88352. /** @hidden */
  88353. _pickWithRayInverseMatrix: Matrix;
  88354. /** @hidden */
  88355. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88356. /** @hidden */
  88357. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88358. }
  88359. }
  88360. declare module BABYLON {
  88361. /**
  88362. * Groups all the scene component constants in one place to ease maintenance.
  88363. * @hidden
  88364. */
  88365. export class SceneComponentConstants {
  88366. static readonly NAME_EFFECTLAYER: string;
  88367. static readonly NAME_LAYER: string;
  88368. static readonly NAME_LENSFLARESYSTEM: string;
  88369. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88370. static readonly NAME_PARTICLESYSTEM: string;
  88371. static readonly NAME_GAMEPAD: string;
  88372. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88373. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88374. static readonly NAME_DEPTHRENDERER: string;
  88375. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88376. static readonly NAME_SPRITE: string;
  88377. static readonly NAME_OUTLINERENDERER: string;
  88378. static readonly NAME_PROCEDURALTEXTURE: string;
  88379. static readonly NAME_SHADOWGENERATOR: string;
  88380. static readonly NAME_OCTREE: string;
  88381. static readonly NAME_PHYSICSENGINE: string;
  88382. static readonly NAME_AUDIO: string;
  88383. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88384. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88385. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88386. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88387. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88388. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88389. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88390. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88391. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88392. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88393. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88394. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88395. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88396. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88397. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88398. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88399. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88400. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88401. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88402. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88403. static readonly STEP_AFTERRENDER_AUDIO: number;
  88404. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88405. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88406. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88407. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88408. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88409. static readonly STEP_POINTERMOVE_SPRITE: number;
  88410. static readonly STEP_POINTERDOWN_SPRITE: number;
  88411. static readonly STEP_POINTERUP_SPRITE: number;
  88412. }
  88413. /**
  88414. * This represents a scene component.
  88415. *
  88416. * This is used to decouple the dependency the scene is having on the different workloads like
  88417. * layers, post processes...
  88418. */
  88419. export interface ISceneComponent {
  88420. /**
  88421. * The name of the component. Each component must have a unique name.
  88422. */
  88423. name: string;
  88424. /**
  88425. * The scene the component belongs to.
  88426. */
  88427. scene: Scene;
  88428. /**
  88429. * Register the component to one instance of a scene.
  88430. */
  88431. register(): void;
  88432. /**
  88433. * Rebuilds the elements related to this component in case of
  88434. * context lost for instance.
  88435. */
  88436. rebuild(): void;
  88437. /**
  88438. * Disposes the component and the associated ressources.
  88439. */
  88440. dispose(): void;
  88441. }
  88442. /**
  88443. * This represents a SERIALIZABLE scene component.
  88444. *
  88445. * This extends Scene Component to add Serialization methods on top.
  88446. */
  88447. export interface ISceneSerializableComponent extends ISceneComponent {
  88448. /**
  88449. * Adds all the elements from the container to the scene
  88450. * @param container the container holding the elements
  88451. */
  88452. addFromContainer(container: AbstractScene): void;
  88453. /**
  88454. * Removes all the elements in the container from the scene
  88455. * @param container contains the elements to remove
  88456. * @param dispose if the removed element should be disposed (default: false)
  88457. */
  88458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88459. /**
  88460. * Serializes the component data to the specified json object
  88461. * @param serializationObject The object to serialize to
  88462. */
  88463. serialize(serializationObject: any): void;
  88464. }
  88465. /**
  88466. * Strong typing of a Mesh related stage step action
  88467. */
  88468. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88469. /**
  88470. * Strong typing of a Evaluate Sub Mesh related stage step action
  88471. */
  88472. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88473. /**
  88474. * Strong typing of a Active Mesh related stage step action
  88475. */
  88476. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88477. /**
  88478. * Strong typing of a Camera related stage step action
  88479. */
  88480. export type CameraStageAction = (camera: Camera) => void;
  88481. /**
  88482. * Strong typing of a Camera Frame buffer related stage step action
  88483. */
  88484. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88485. /**
  88486. * Strong typing of a Render Target related stage step action
  88487. */
  88488. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88489. /**
  88490. * Strong typing of a RenderingGroup related stage step action
  88491. */
  88492. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88493. /**
  88494. * Strong typing of a Mesh Render related stage step action
  88495. */
  88496. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88497. /**
  88498. * Strong typing of a simple stage step action
  88499. */
  88500. export type SimpleStageAction = () => void;
  88501. /**
  88502. * Strong typing of a render target action.
  88503. */
  88504. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88505. /**
  88506. * Strong typing of a pointer move action.
  88507. */
  88508. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88509. /**
  88510. * Strong typing of a pointer up/down action.
  88511. */
  88512. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88513. /**
  88514. * Representation of a stage in the scene (Basically a list of ordered steps)
  88515. * @hidden
  88516. */
  88517. export class Stage<T extends Function> extends Array<{
  88518. index: number;
  88519. component: ISceneComponent;
  88520. action: T;
  88521. }> {
  88522. /**
  88523. * Hide ctor from the rest of the world.
  88524. * @param items The items to add.
  88525. */
  88526. private constructor();
  88527. /**
  88528. * Creates a new Stage.
  88529. * @returns A new instance of a Stage
  88530. */
  88531. static Create<T extends Function>(): Stage<T>;
  88532. /**
  88533. * Registers a step in an ordered way in the targeted stage.
  88534. * @param index Defines the position to register the step in
  88535. * @param component Defines the component attached to the step
  88536. * @param action Defines the action to launch during the step
  88537. */
  88538. registerStep(index: number, component: ISceneComponent, action: T): void;
  88539. /**
  88540. * Clears all the steps from the stage.
  88541. */
  88542. clear(): void;
  88543. }
  88544. }
  88545. declare module BABYLON {
  88546. interface Scene {
  88547. /** @hidden */
  88548. _pointerOverSprite: Nullable<Sprite>;
  88549. /** @hidden */
  88550. _pickedDownSprite: Nullable<Sprite>;
  88551. /** @hidden */
  88552. _tempSpritePickingRay: Nullable<Ray>;
  88553. /**
  88554. * All of the sprite managers added to this scene
  88555. * @see http://doc.babylonjs.com/babylon101/sprites
  88556. */
  88557. spriteManagers: Array<ISpriteManager>;
  88558. /**
  88559. * An event triggered when sprites rendering is about to start
  88560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88561. */
  88562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88563. /**
  88564. * An event triggered when sprites rendering is done
  88565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88566. */
  88567. onAfterSpritesRenderingObservable: Observable<Scene>;
  88568. /** @hidden */
  88569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88570. /** Launch a ray to try to pick a sprite in the scene
  88571. * @param x position on screen
  88572. * @param y position on screen
  88573. * @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
  88574. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88576. * @returns a PickingInfo
  88577. */
  88578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88579. /** Use the given ray to pick a sprite in the scene
  88580. * @param ray The ray (in world space) to use to pick meshes
  88581. * @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
  88582. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88584. * @returns a PickingInfo
  88585. */
  88586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88587. /** @hidden */
  88588. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88589. /** Launch a ray to try to pick sprites in the scene
  88590. * @param x position on screen
  88591. * @param y position on screen
  88592. * @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
  88593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88594. * @returns a PickingInfo array
  88595. */
  88596. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88597. /** Use the given ray to pick sprites in the scene
  88598. * @param ray The ray (in world space) to use to pick meshes
  88599. * @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
  88600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88601. * @returns a PickingInfo array
  88602. */
  88603. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88604. /**
  88605. * Force the sprite under the pointer
  88606. * @param sprite defines the sprite to use
  88607. */
  88608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88609. /**
  88610. * Gets the sprite under the pointer
  88611. * @returns a Sprite or null if no sprite is under the pointer
  88612. */
  88613. getPointerOverSprite(): Nullable<Sprite>;
  88614. }
  88615. /**
  88616. * Defines the sprite scene component responsible to manage sprites
  88617. * in a given scene.
  88618. */
  88619. export class SpriteSceneComponent implements ISceneComponent {
  88620. /**
  88621. * The component name helpfull to identify the component in the list of scene components.
  88622. */
  88623. readonly name: string;
  88624. /**
  88625. * The scene the component belongs to.
  88626. */
  88627. scene: Scene;
  88628. /** @hidden */
  88629. private _spritePredicate;
  88630. /**
  88631. * Creates a new instance of the component for the given scene
  88632. * @param scene Defines the scene to register the component in
  88633. */
  88634. constructor(scene: Scene);
  88635. /**
  88636. * Registers the component in a given scene
  88637. */
  88638. register(): void;
  88639. /**
  88640. * Rebuilds the elements related to this component in case of
  88641. * context lost for instance.
  88642. */
  88643. rebuild(): void;
  88644. /**
  88645. * Disposes the component and the associated ressources.
  88646. */
  88647. dispose(): void;
  88648. private _pickSpriteButKeepRay;
  88649. private _pointerMove;
  88650. private _pointerDown;
  88651. private _pointerUp;
  88652. }
  88653. }
  88654. declare module BABYLON {
  88655. /** @hidden */
  88656. export var fogFragmentDeclaration: {
  88657. name: string;
  88658. shader: string;
  88659. };
  88660. }
  88661. declare module BABYLON {
  88662. /** @hidden */
  88663. export var fogFragment: {
  88664. name: string;
  88665. shader: string;
  88666. };
  88667. }
  88668. declare module BABYLON {
  88669. /** @hidden */
  88670. export var spritesPixelShader: {
  88671. name: string;
  88672. shader: string;
  88673. };
  88674. }
  88675. declare module BABYLON {
  88676. /** @hidden */
  88677. export var fogVertexDeclaration: {
  88678. name: string;
  88679. shader: string;
  88680. };
  88681. }
  88682. declare module BABYLON {
  88683. /** @hidden */
  88684. export var spritesVertexShader: {
  88685. name: string;
  88686. shader: string;
  88687. };
  88688. }
  88689. declare module BABYLON {
  88690. /**
  88691. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88692. */
  88693. export interface ISpriteManager extends IDisposable {
  88694. /**
  88695. * Gets manager's name
  88696. */
  88697. name: string;
  88698. /**
  88699. * Restricts the camera to viewing objects with the same layerMask.
  88700. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88701. */
  88702. layerMask: number;
  88703. /**
  88704. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88705. */
  88706. isPickable: boolean;
  88707. /**
  88708. * Gets the hosting scene
  88709. */
  88710. scene: Scene;
  88711. /**
  88712. * Specifies the rendering group id for this mesh (0 by default)
  88713. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88714. */
  88715. renderingGroupId: number;
  88716. /**
  88717. * Defines the list of sprites managed by the manager.
  88718. */
  88719. sprites: Array<Sprite>;
  88720. /**
  88721. * Gets or sets the spritesheet texture
  88722. */
  88723. texture: Texture;
  88724. /** Defines the default width of a cell in the spritesheet */
  88725. cellWidth: number;
  88726. /** Defines the default height of a cell in the spritesheet */
  88727. cellHeight: number;
  88728. /**
  88729. * Tests the intersection of a sprite with a specific ray.
  88730. * @param ray The ray we are sending to test the collision
  88731. * @param camera The camera space we are sending rays in
  88732. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88733. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88734. * @returns picking info or null.
  88735. */
  88736. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88737. /**
  88738. * Intersects the sprites with a ray
  88739. * @param ray defines the ray to intersect with
  88740. * @param camera defines the current active camera
  88741. * @param predicate defines a predicate used to select candidate sprites
  88742. * @returns null if no hit or a PickingInfo array
  88743. */
  88744. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88745. /**
  88746. * Renders the list of sprites on screen.
  88747. */
  88748. render(): void;
  88749. }
  88750. /**
  88751. * Class used to manage multiple sprites on the same spritesheet
  88752. * @see http://doc.babylonjs.com/babylon101/sprites
  88753. */
  88754. export class SpriteManager implements ISpriteManager {
  88755. /** defines the manager's name */
  88756. name: string;
  88757. /** Define the Url to load snippets */
  88758. static SnippetUrl: string;
  88759. /** Snippet ID if the manager was created from the snippet server */
  88760. snippetId: string;
  88761. /** Gets the list of sprites */
  88762. sprites: Sprite[];
  88763. /** Gets or sets the rendering group id (0 by default) */
  88764. renderingGroupId: number;
  88765. /** Gets or sets camera layer mask */
  88766. layerMask: number;
  88767. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88768. fogEnabled: boolean;
  88769. /** Gets or sets a boolean indicating if the sprites are pickable */
  88770. isPickable: boolean;
  88771. /** Defines the default width of a cell in the spritesheet */
  88772. cellWidth: number;
  88773. /** Defines the default height of a cell in the spritesheet */
  88774. cellHeight: number;
  88775. /** Associative array from JSON sprite data file */
  88776. private _cellData;
  88777. /** Array of sprite names from JSON sprite data file */
  88778. private _spriteMap;
  88779. /** True when packed cell data from JSON file is ready*/
  88780. private _packedAndReady;
  88781. private _textureContent;
  88782. /**
  88783. * An event triggered when the manager is disposed.
  88784. */
  88785. onDisposeObservable: Observable<SpriteManager>;
  88786. private _onDisposeObserver;
  88787. /**
  88788. * Callback called when the manager is disposed
  88789. */
  88790. set onDispose(callback: () => void);
  88791. private _capacity;
  88792. private _fromPacked;
  88793. private _spriteTexture;
  88794. private _epsilon;
  88795. private _scene;
  88796. private _vertexData;
  88797. private _buffer;
  88798. private _vertexBuffers;
  88799. private _indexBuffer;
  88800. private _effectBase;
  88801. private _effectFog;
  88802. /**
  88803. * Gets or sets the unique id of the sprite
  88804. */
  88805. uniqueId: number;
  88806. /**
  88807. * Gets the array of sprites
  88808. */
  88809. get children(): Sprite[];
  88810. /**
  88811. * Gets the hosting scene
  88812. */
  88813. get scene(): Scene;
  88814. /**
  88815. * Gets the capacity of the manager
  88816. */
  88817. get capacity(): number;
  88818. /**
  88819. * Gets or sets the spritesheet texture
  88820. */
  88821. get texture(): Texture;
  88822. set texture(value: Texture);
  88823. private _blendMode;
  88824. /**
  88825. * Blend mode use to render the particle, it can be any of
  88826. * the static Constants.ALPHA_x properties provided in this class.
  88827. * Default value is Constants.ALPHA_COMBINE
  88828. */
  88829. get blendMode(): number;
  88830. set blendMode(blendMode: number);
  88831. /** Disables writing to the depth buffer when rendering the sprites.
  88832. * It can be handy to disable depth writing when using textures without alpha channel
  88833. * and setting some specific blend modes.
  88834. */
  88835. disableDepthWrite: boolean;
  88836. /**
  88837. * Creates a new sprite manager
  88838. * @param name defines the manager's name
  88839. * @param imgUrl defines the sprite sheet url
  88840. * @param capacity defines the maximum allowed number of sprites
  88841. * @param cellSize defines the size of a sprite cell
  88842. * @param scene defines the hosting scene
  88843. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88844. * @param samplingMode defines the smapling mode to use with spritesheet
  88845. * @param fromPacked set to false; do not alter
  88846. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88847. */
  88848. constructor(
  88849. /** defines the manager's name */
  88850. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88851. /**
  88852. * Returns the string "SpriteManager"
  88853. * @returns "SpriteManager"
  88854. */
  88855. getClassName(): string;
  88856. private _makePacked;
  88857. private _appendSpriteVertex;
  88858. private _checkTextureAlpha;
  88859. /**
  88860. * Intersects the sprites with a ray
  88861. * @param ray defines the ray to intersect with
  88862. * @param camera defines the current active camera
  88863. * @param predicate defines a predicate used to select candidate sprites
  88864. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88865. * @returns null if no hit or a PickingInfo
  88866. */
  88867. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88868. /**
  88869. * Intersects the sprites with a ray
  88870. * @param ray defines the ray to intersect with
  88871. * @param camera defines the current active camera
  88872. * @param predicate defines a predicate used to select candidate sprites
  88873. * @returns null if no hit or a PickingInfo array
  88874. */
  88875. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88876. /**
  88877. * Render all child sprites
  88878. */
  88879. render(): void;
  88880. /**
  88881. * Release associated resources
  88882. */
  88883. dispose(): void;
  88884. /**
  88885. * Serializes the sprite manager to a JSON object
  88886. * @param serializeTexture defines if the texture must be serialized as well
  88887. * @returns the JSON object
  88888. */
  88889. serialize(serializeTexture?: boolean): any;
  88890. /**
  88891. * Parses a JSON object to create a new sprite manager.
  88892. * @param parsedManager The JSON object to parse
  88893. * @param scene The scene to create the sprite managerin
  88894. * @param rootUrl The root url to use to load external dependencies like texture
  88895. * @returns the new sprite manager
  88896. */
  88897. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88898. /**
  88899. * Creates a sprite manager from a snippet saved in a remote file
  88900. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88901. * @param url defines the url to load from
  88902. * @param scene defines the hosting scene
  88903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88904. * @returns a promise that will resolve to the new sprite manager
  88905. */
  88906. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88907. /**
  88908. * Creates a sprite manager from a snippet saved by the sprite editor
  88909. * @param snippetId defines the snippet to load
  88910. * @param scene defines the hosting scene
  88911. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88912. * @returns a promise that will resolve to the new sprite manager
  88913. */
  88914. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88915. }
  88916. }
  88917. declare module BABYLON {
  88918. /** Interface used by value gradients (color, factor, ...) */
  88919. export interface IValueGradient {
  88920. /**
  88921. * Gets or sets the gradient value (between 0 and 1)
  88922. */
  88923. gradient: number;
  88924. }
  88925. /** Class used to store color4 gradient */
  88926. export class ColorGradient implements IValueGradient {
  88927. /**
  88928. * Gets or sets the gradient value (between 0 and 1)
  88929. */
  88930. gradient: number;
  88931. /**
  88932. * Gets or sets first associated color
  88933. */
  88934. color1: Color4;
  88935. /**
  88936. * Gets or sets second associated color
  88937. */
  88938. color2?: Color4 | undefined;
  88939. /**
  88940. * Creates a new color4 gradient
  88941. * @param gradient gets or sets the gradient value (between 0 and 1)
  88942. * @param color1 gets or sets first associated color
  88943. * @param color2 gets or sets first second color
  88944. */
  88945. constructor(
  88946. /**
  88947. * Gets or sets the gradient value (between 0 and 1)
  88948. */
  88949. gradient: number,
  88950. /**
  88951. * Gets or sets first associated color
  88952. */
  88953. color1: Color4,
  88954. /**
  88955. * Gets or sets second associated color
  88956. */
  88957. color2?: Color4 | undefined);
  88958. /**
  88959. * Will get a color picked randomly between color1 and color2.
  88960. * If color2 is undefined then color1 will be used
  88961. * @param result defines the target Color4 to store the result in
  88962. */
  88963. getColorToRef(result: Color4): void;
  88964. }
  88965. /** Class used to store color 3 gradient */
  88966. export class Color3Gradient implements IValueGradient {
  88967. /**
  88968. * Gets or sets the gradient value (between 0 and 1)
  88969. */
  88970. gradient: number;
  88971. /**
  88972. * Gets or sets the associated color
  88973. */
  88974. color: Color3;
  88975. /**
  88976. * Creates a new color3 gradient
  88977. * @param gradient gets or sets the gradient value (between 0 and 1)
  88978. * @param color gets or sets associated color
  88979. */
  88980. constructor(
  88981. /**
  88982. * Gets or sets the gradient value (between 0 and 1)
  88983. */
  88984. gradient: number,
  88985. /**
  88986. * Gets or sets the associated color
  88987. */
  88988. color: Color3);
  88989. }
  88990. /** Class used to store factor gradient */
  88991. export class FactorGradient implements IValueGradient {
  88992. /**
  88993. * Gets or sets the gradient value (between 0 and 1)
  88994. */
  88995. gradient: number;
  88996. /**
  88997. * Gets or sets first associated factor
  88998. */
  88999. factor1: number;
  89000. /**
  89001. * Gets or sets second associated factor
  89002. */
  89003. factor2?: number | undefined;
  89004. /**
  89005. * Creates a new factor gradient
  89006. * @param gradient gets or sets the gradient value (between 0 and 1)
  89007. * @param factor1 gets or sets first associated factor
  89008. * @param factor2 gets or sets second associated factor
  89009. */
  89010. constructor(
  89011. /**
  89012. * Gets or sets the gradient value (between 0 and 1)
  89013. */
  89014. gradient: number,
  89015. /**
  89016. * Gets or sets first associated factor
  89017. */
  89018. factor1: number,
  89019. /**
  89020. * Gets or sets second associated factor
  89021. */
  89022. factor2?: number | undefined);
  89023. /**
  89024. * Will get a number picked randomly between factor1 and factor2.
  89025. * If factor2 is undefined then factor1 will be used
  89026. * @returns the picked number
  89027. */
  89028. getFactor(): number;
  89029. }
  89030. /**
  89031. * Helper used to simplify some generic gradient tasks
  89032. */
  89033. export class GradientHelper {
  89034. /**
  89035. * Gets the current gradient from an array of IValueGradient
  89036. * @param ratio defines the current ratio to get
  89037. * @param gradients defines the array of IValueGradient
  89038. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89039. */
  89040. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89041. }
  89042. }
  89043. declare module BABYLON {
  89044. interface ThinEngine {
  89045. /**
  89046. * Creates a raw texture
  89047. * @param data defines the data to store in the texture
  89048. * @param width defines the width of the texture
  89049. * @param height defines the height of the texture
  89050. * @param format defines the format of the data
  89051. * @param generateMipMaps defines if the engine should generate the mip levels
  89052. * @param invertY defines if data must be stored with Y axis inverted
  89053. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89054. * @param compression defines the compression used (null by default)
  89055. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89056. * @returns the raw texture inside an InternalTexture
  89057. */
  89058. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89059. /**
  89060. * Update a raw texture
  89061. * @param texture defines the texture to update
  89062. * @param data defines the data to store in the texture
  89063. * @param format defines the format of the data
  89064. * @param invertY defines if data must be stored with Y axis inverted
  89065. */
  89066. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89067. /**
  89068. * Update a raw texture
  89069. * @param texture defines the texture to update
  89070. * @param data defines the data to store in the texture
  89071. * @param format defines the format of the data
  89072. * @param invertY defines if data must be stored with Y axis inverted
  89073. * @param compression defines the compression used (null by default)
  89074. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89075. */
  89076. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89077. /**
  89078. * Creates a new raw cube texture
  89079. * @param data defines the array of data to use to create each face
  89080. * @param size defines the size of the textures
  89081. * @param format defines the format of the data
  89082. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89083. * @param generateMipMaps defines if the engine should generate the mip levels
  89084. * @param invertY defines if data must be stored with Y axis inverted
  89085. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89086. * @param compression defines the compression used (null by default)
  89087. * @returns the cube texture as an InternalTexture
  89088. */
  89089. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89090. /**
  89091. * Update a raw cube texture
  89092. * @param texture defines the texture to udpdate
  89093. * @param data defines the data to store
  89094. * @param format defines the data format
  89095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89096. * @param invertY defines if data must be stored with Y axis inverted
  89097. */
  89098. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89099. /**
  89100. * Update a raw cube texture
  89101. * @param texture defines the texture to udpdate
  89102. * @param data defines the data to store
  89103. * @param format defines the data format
  89104. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89105. * @param invertY defines if data must be stored with Y axis inverted
  89106. * @param compression defines the compression used (null by default)
  89107. */
  89108. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89109. /**
  89110. * Update a raw cube texture
  89111. * @param texture defines the texture to udpdate
  89112. * @param data defines the data to store
  89113. * @param format defines the data format
  89114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89115. * @param invertY defines if data must be stored with Y axis inverted
  89116. * @param compression defines the compression used (null by default)
  89117. * @param level defines which level of the texture to update
  89118. */
  89119. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89120. /**
  89121. * Creates a new raw cube texture from a specified url
  89122. * @param url defines the url where the data is located
  89123. * @param scene defines the current scene
  89124. * @param size defines the size of the textures
  89125. * @param format defines the format of the data
  89126. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89127. * @param noMipmap defines if the engine should avoid generating the mip levels
  89128. * @param callback defines a callback used to extract texture data from loaded data
  89129. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89130. * @param onLoad defines a callback called when texture is loaded
  89131. * @param onError defines a callback called if there is an error
  89132. * @returns the cube texture as an InternalTexture
  89133. */
  89134. 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;
  89135. /**
  89136. * Creates a new raw cube texture from a specified url
  89137. * @param url defines the url where the data is located
  89138. * @param scene defines the current scene
  89139. * @param size defines the size of the textures
  89140. * @param format defines the format of the data
  89141. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89142. * @param noMipmap defines if the engine should avoid generating the mip levels
  89143. * @param callback defines a callback used to extract texture data from loaded data
  89144. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89145. * @param onLoad defines a callback called when texture is loaded
  89146. * @param onError defines a callback called if there is an error
  89147. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89148. * @param invertY defines if data must be stored with Y axis inverted
  89149. * @returns the cube texture as an InternalTexture
  89150. */
  89151. 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;
  89152. /**
  89153. * Creates a new raw 3D texture
  89154. * @param data defines the data used to create the texture
  89155. * @param width defines the width of the texture
  89156. * @param height defines the height of the texture
  89157. * @param depth defines the depth of the texture
  89158. * @param format defines the format of the texture
  89159. * @param generateMipMaps defines if the engine must generate mip levels
  89160. * @param invertY defines if data must be stored with Y axis inverted
  89161. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89162. * @param compression defines the compressed used (can be null)
  89163. * @param textureType defines the compressed used (can be null)
  89164. * @returns a new raw 3D texture (stored in an InternalTexture)
  89165. */
  89166. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89167. /**
  89168. * Update a raw 3D texture
  89169. * @param texture defines the texture to update
  89170. * @param data defines the data to store
  89171. * @param format defines the data format
  89172. * @param invertY defines if data must be stored with Y axis inverted
  89173. */
  89174. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89175. /**
  89176. * Update a raw 3D texture
  89177. * @param texture defines the texture to update
  89178. * @param data defines the data to store
  89179. * @param format defines the data format
  89180. * @param invertY defines if data must be stored with Y axis inverted
  89181. * @param compression defines the used compression (can be null)
  89182. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89183. */
  89184. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89185. /**
  89186. * Creates a new raw 2D array texture
  89187. * @param data defines the data used to create the texture
  89188. * @param width defines the width of the texture
  89189. * @param height defines the height of the texture
  89190. * @param depth defines the number of layers of the texture
  89191. * @param format defines the format of the texture
  89192. * @param generateMipMaps defines if the engine must generate mip levels
  89193. * @param invertY defines if data must be stored with Y axis inverted
  89194. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89195. * @param compression defines the compressed used (can be null)
  89196. * @param textureType defines the compressed used (can be null)
  89197. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89198. */
  89199. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89200. /**
  89201. * Update a raw 2D array texture
  89202. * @param texture defines the texture to update
  89203. * @param data defines the data to store
  89204. * @param format defines the data format
  89205. * @param invertY defines if data must be stored with Y axis inverted
  89206. */
  89207. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89208. /**
  89209. * Update a raw 2D array texture
  89210. * @param texture defines the texture to update
  89211. * @param data defines the data to store
  89212. * @param format defines the data format
  89213. * @param invertY defines if data must be stored with Y axis inverted
  89214. * @param compression defines the used compression (can be null)
  89215. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89216. */
  89217. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89218. }
  89219. }
  89220. declare module BABYLON {
  89221. /**
  89222. * Raw texture can help creating a texture directly from an array of data.
  89223. * This can be super useful if you either get the data from an uncompressed source or
  89224. * if you wish to create your texture pixel by pixel.
  89225. */
  89226. export class RawTexture extends Texture {
  89227. /**
  89228. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89229. */
  89230. format: number;
  89231. /**
  89232. * Instantiates a new RawTexture.
  89233. * Raw texture can help creating a texture directly from an array of data.
  89234. * This can be super useful if you either get the data from an uncompressed source or
  89235. * if you wish to create your texture pixel by pixel.
  89236. * @param data define the array of data to use to create the texture
  89237. * @param width define the width of the texture
  89238. * @param height define the height of the texture
  89239. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89240. * @param scene define the scene the texture belongs to
  89241. * @param generateMipMaps define whether mip maps should be generated or not
  89242. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89243. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89244. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89245. */
  89246. constructor(data: ArrayBufferView, width: number, height: number,
  89247. /**
  89248. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89249. */
  89250. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89251. /**
  89252. * Updates the texture underlying data.
  89253. * @param data Define the new data of the texture
  89254. */
  89255. update(data: ArrayBufferView): void;
  89256. /**
  89257. * Creates a luminance texture from some data.
  89258. * @param data Define the texture data
  89259. * @param width Define the width of the texture
  89260. * @param height Define the height of the texture
  89261. * @param scene Define the scene the texture belongs to
  89262. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89263. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89264. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89265. * @returns the luminance texture
  89266. */
  89267. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89268. /**
  89269. * Creates a luminance alpha texture from some data.
  89270. * @param data Define the texture data
  89271. * @param width Define the width of the texture
  89272. * @param height Define the height of the texture
  89273. * @param scene Define the scene the texture belongs to
  89274. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89275. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89276. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89277. * @returns the luminance alpha texture
  89278. */
  89279. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89280. /**
  89281. * Creates an alpha texture from some data.
  89282. * @param data Define the texture data
  89283. * @param width Define the width of the texture
  89284. * @param height Define the height of the texture
  89285. * @param scene Define the scene the texture belongs to
  89286. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89287. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89288. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89289. * @returns the alpha texture
  89290. */
  89291. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89292. /**
  89293. * Creates a RGB texture from some data.
  89294. * @param data Define the texture data
  89295. * @param width Define the width of the texture
  89296. * @param height Define the height of the texture
  89297. * @param scene Define the scene the texture belongs to
  89298. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89299. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89300. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89301. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89302. * @returns the RGB alpha texture
  89303. */
  89304. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89305. /**
  89306. * Creates a RGBA texture from some data.
  89307. * @param data Define the texture data
  89308. * @param width Define the width of the texture
  89309. * @param height Define the height of the texture
  89310. * @param scene Define the scene the texture belongs to
  89311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89314. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89315. * @returns the RGBA texture
  89316. */
  89317. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89318. /**
  89319. * Creates a R texture from some data.
  89320. * @param data Define the texture data
  89321. * @param width Define the width of the texture
  89322. * @param height Define the height of the texture
  89323. * @param scene Define the scene the texture belongs to
  89324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89327. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89328. * @returns the R texture
  89329. */
  89330. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89331. }
  89332. }
  89333. declare module BABYLON {
  89334. interface AbstractScene {
  89335. /**
  89336. * The list of procedural textures added to the scene
  89337. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89338. */
  89339. proceduralTextures: Array<ProceduralTexture>;
  89340. }
  89341. /**
  89342. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89343. * in a given scene.
  89344. */
  89345. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89346. /**
  89347. * The component name helpfull to identify the component in the list of scene components.
  89348. */
  89349. readonly name: string;
  89350. /**
  89351. * The scene the component belongs to.
  89352. */
  89353. scene: Scene;
  89354. /**
  89355. * Creates a new instance of the component for the given scene
  89356. * @param scene Defines the scene to register the component in
  89357. */
  89358. constructor(scene: Scene);
  89359. /**
  89360. * Registers the component in a given scene
  89361. */
  89362. register(): void;
  89363. /**
  89364. * Rebuilds the elements related to this component in case of
  89365. * context lost for instance.
  89366. */
  89367. rebuild(): void;
  89368. /**
  89369. * Disposes the component and the associated ressources.
  89370. */
  89371. dispose(): void;
  89372. private _beforeClear;
  89373. }
  89374. }
  89375. declare module BABYLON {
  89376. interface ThinEngine {
  89377. /**
  89378. * Creates a new render target cube texture
  89379. * @param size defines the size of the texture
  89380. * @param options defines the options used to create the texture
  89381. * @returns a new render target cube texture stored in an InternalTexture
  89382. */
  89383. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89384. }
  89385. }
  89386. declare module BABYLON {
  89387. /** @hidden */
  89388. export var proceduralVertexShader: {
  89389. name: string;
  89390. shader: string;
  89391. };
  89392. }
  89393. declare module BABYLON {
  89394. /**
  89395. * 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.
  89396. * This is the base class of any Procedural texture and contains most of the shareable code.
  89397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89398. */
  89399. export class ProceduralTexture extends Texture {
  89400. isCube: boolean;
  89401. /**
  89402. * Define if the texture is enabled or not (disabled texture will not render)
  89403. */
  89404. isEnabled: boolean;
  89405. /**
  89406. * Define if the texture must be cleared before rendering (default is true)
  89407. */
  89408. autoClear: boolean;
  89409. /**
  89410. * Callback called when the texture is generated
  89411. */
  89412. onGenerated: () => void;
  89413. /**
  89414. * Event raised when the texture is generated
  89415. */
  89416. onGeneratedObservable: Observable<ProceduralTexture>;
  89417. /** @hidden */
  89418. _generateMipMaps: boolean;
  89419. /** @hidden **/
  89420. _effect: Effect;
  89421. /** @hidden */
  89422. _textures: {
  89423. [key: string]: Texture;
  89424. };
  89425. /** @hidden */
  89426. protected _fallbackTexture: Nullable<Texture>;
  89427. private _size;
  89428. private _currentRefreshId;
  89429. private _frameId;
  89430. private _refreshRate;
  89431. private _vertexBuffers;
  89432. private _indexBuffer;
  89433. private _uniforms;
  89434. private _samplers;
  89435. private _fragment;
  89436. private _floats;
  89437. private _ints;
  89438. private _floatsArrays;
  89439. private _colors3;
  89440. private _colors4;
  89441. private _vectors2;
  89442. private _vectors3;
  89443. private _matrices;
  89444. private _fallbackTextureUsed;
  89445. private _fullEngine;
  89446. private _cachedDefines;
  89447. private _contentUpdateId;
  89448. private _contentData;
  89449. /**
  89450. * Instantiates a new procedural texture.
  89451. * 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.
  89452. * This is the base class of any Procedural texture and contains most of the shareable code.
  89453. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89454. * @param name Define the name of the texture
  89455. * @param size Define the size of the texture to create
  89456. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89457. * @param scene Define the scene the texture belongs to
  89458. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89459. * @param generateMipMaps Define if the texture should creates mip maps or not
  89460. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89461. */
  89462. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89463. /**
  89464. * The effect that is created when initializing the post process.
  89465. * @returns The created effect corresponding the the postprocess.
  89466. */
  89467. getEffect(): Effect;
  89468. /**
  89469. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89470. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89471. */
  89472. getContent(): Nullable<ArrayBufferView>;
  89473. private _createIndexBuffer;
  89474. /** @hidden */
  89475. _rebuild(): void;
  89476. /**
  89477. * Resets the texture in order to recreate its associated resources.
  89478. * This can be called in case of context loss
  89479. */
  89480. reset(): void;
  89481. protected _getDefines(): string;
  89482. /**
  89483. * Is the texture ready to be used ? (rendered at least once)
  89484. * @returns true if ready, otherwise, false.
  89485. */
  89486. isReady(): boolean;
  89487. /**
  89488. * Resets the refresh counter of the texture and start bak from scratch.
  89489. * Could be useful to regenerate the texture if it is setup to render only once.
  89490. */
  89491. resetRefreshCounter(): void;
  89492. /**
  89493. * Set the fragment shader to use in order to render the texture.
  89494. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89495. */
  89496. setFragment(fragment: any): void;
  89497. /**
  89498. * Define the refresh rate of the texture or the rendering frequency.
  89499. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89500. */
  89501. get refreshRate(): number;
  89502. set refreshRate(value: number);
  89503. /** @hidden */
  89504. _shouldRender(): boolean;
  89505. /**
  89506. * Get the size the texture is rendering at.
  89507. * @returns the size (texture is always squared)
  89508. */
  89509. getRenderSize(): number;
  89510. /**
  89511. * Resize the texture to new value.
  89512. * @param size Define the new size the texture should have
  89513. * @param generateMipMaps Define whether the new texture should create mip maps
  89514. */
  89515. resize(size: number, generateMipMaps: boolean): void;
  89516. private _checkUniform;
  89517. /**
  89518. * Set a texture in the shader program used to render.
  89519. * @param name Define the name of the uniform samplers as defined in the shader
  89520. * @param texture Define the texture to bind to this sampler
  89521. * @return the texture itself allowing "fluent" like uniform updates
  89522. */
  89523. setTexture(name: string, texture: Texture): ProceduralTexture;
  89524. /**
  89525. * Set a float in the shader.
  89526. * @param name Define the name of the uniform as defined in the shader
  89527. * @param value Define the value to give to the uniform
  89528. * @return the texture itself allowing "fluent" like uniform updates
  89529. */
  89530. setFloat(name: string, value: number): ProceduralTexture;
  89531. /**
  89532. * Set a int in the shader.
  89533. * @param name Define the name of the uniform as defined in the shader
  89534. * @param value Define the value to give to the uniform
  89535. * @return the texture itself allowing "fluent" like uniform updates
  89536. */
  89537. setInt(name: string, value: number): ProceduralTexture;
  89538. /**
  89539. * Set an array of floats in the shader.
  89540. * @param name Define the name of the uniform as defined in the shader
  89541. * @param value Define the value to give to the uniform
  89542. * @return the texture itself allowing "fluent" like uniform updates
  89543. */
  89544. setFloats(name: string, value: number[]): ProceduralTexture;
  89545. /**
  89546. * Set a vec3 in the shader from a Color3.
  89547. * @param name Define the name of the uniform as defined in the shader
  89548. * @param value Define the value to give to the uniform
  89549. * @return the texture itself allowing "fluent" like uniform updates
  89550. */
  89551. setColor3(name: string, value: Color3): ProceduralTexture;
  89552. /**
  89553. * Set a vec4 in the shader from a Color4.
  89554. * @param name Define the name of the uniform as defined in the shader
  89555. * @param value Define the value to give to the uniform
  89556. * @return the texture itself allowing "fluent" like uniform updates
  89557. */
  89558. setColor4(name: string, value: Color4): ProceduralTexture;
  89559. /**
  89560. * Set a vec2 in the shader from a Vector2.
  89561. * @param name Define the name of the uniform as defined in the shader
  89562. * @param value Define the value to give to the uniform
  89563. * @return the texture itself allowing "fluent" like uniform updates
  89564. */
  89565. setVector2(name: string, value: Vector2): ProceduralTexture;
  89566. /**
  89567. * Set a vec3 in the shader from a Vector3.
  89568. * @param name Define the name of the uniform as defined in the shader
  89569. * @param value Define the value to give to the uniform
  89570. * @return the texture itself allowing "fluent" like uniform updates
  89571. */
  89572. setVector3(name: string, value: Vector3): ProceduralTexture;
  89573. /**
  89574. * Set a mat4 in the shader from a MAtrix.
  89575. * @param name Define the name of the uniform as defined in the shader
  89576. * @param value Define the value to give to the uniform
  89577. * @return the texture itself allowing "fluent" like uniform updates
  89578. */
  89579. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89580. /**
  89581. * Render the texture to its associated render target.
  89582. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89583. */
  89584. render(useCameraPostProcess?: boolean): void;
  89585. /**
  89586. * Clone the texture.
  89587. * @returns the cloned texture
  89588. */
  89589. clone(): ProceduralTexture;
  89590. /**
  89591. * Dispose the texture and release its asoociated resources.
  89592. */
  89593. dispose(): void;
  89594. }
  89595. }
  89596. declare module BABYLON {
  89597. /**
  89598. * This represents the base class for particle system in Babylon.
  89599. * 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.
  89600. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89601. * @example https://doc.babylonjs.com/babylon101/particles
  89602. */
  89603. export class BaseParticleSystem {
  89604. /**
  89605. * Source color is added to the destination color without alpha affecting the result
  89606. */
  89607. static BLENDMODE_ONEONE: number;
  89608. /**
  89609. * Blend current color and particle color using particle’s alpha
  89610. */
  89611. static BLENDMODE_STANDARD: number;
  89612. /**
  89613. * Add current color and particle color multiplied by particle’s alpha
  89614. */
  89615. static BLENDMODE_ADD: number;
  89616. /**
  89617. * Multiply current color with particle color
  89618. */
  89619. static BLENDMODE_MULTIPLY: number;
  89620. /**
  89621. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89622. */
  89623. static BLENDMODE_MULTIPLYADD: number;
  89624. /**
  89625. * List of animations used by the particle system.
  89626. */
  89627. animations: Animation[];
  89628. /**
  89629. * Gets or sets the unique id of the particle system
  89630. */
  89631. uniqueId: number;
  89632. /**
  89633. * The id of the Particle system.
  89634. */
  89635. id: string;
  89636. /**
  89637. * The friendly name of the Particle system.
  89638. */
  89639. name: string;
  89640. /**
  89641. * Snippet ID if the particle system was created from the snippet server
  89642. */
  89643. snippetId: string;
  89644. /**
  89645. * The rendering group used by the Particle system to chose when to render.
  89646. */
  89647. renderingGroupId: number;
  89648. /**
  89649. * The emitter represents the Mesh or position we are attaching the particle system to.
  89650. */
  89651. emitter: Nullable<AbstractMesh | Vector3>;
  89652. /**
  89653. * The maximum number of particles to emit per frame
  89654. */
  89655. emitRate: number;
  89656. /**
  89657. * If you want to launch only a few particles at once, that can be done, as well.
  89658. */
  89659. manualEmitCount: number;
  89660. /**
  89661. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89662. */
  89663. updateSpeed: number;
  89664. /**
  89665. * The amount of time the particle system is running (depends of the overall update speed).
  89666. */
  89667. targetStopDuration: number;
  89668. /**
  89669. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89670. */
  89671. disposeOnStop: boolean;
  89672. /**
  89673. * Minimum power of emitting particles.
  89674. */
  89675. minEmitPower: number;
  89676. /**
  89677. * Maximum power of emitting particles.
  89678. */
  89679. maxEmitPower: number;
  89680. /**
  89681. * Minimum life time of emitting particles.
  89682. */
  89683. minLifeTime: number;
  89684. /**
  89685. * Maximum life time of emitting particles.
  89686. */
  89687. maxLifeTime: number;
  89688. /**
  89689. * Minimum Size of emitting particles.
  89690. */
  89691. minSize: number;
  89692. /**
  89693. * Maximum Size of emitting particles.
  89694. */
  89695. maxSize: number;
  89696. /**
  89697. * Minimum scale of emitting particles on X axis.
  89698. */
  89699. minScaleX: number;
  89700. /**
  89701. * Maximum scale of emitting particles on X axis.
  89702. */
  89703. maxScaleX: number;
  89704. /**
  89705. * Minimum scale of emitting particles on Y axis.
  89706. */
  89707. minScaleY: number;
  89708. /**
  89709. * Maximum scale of emitting particles on Y axis.
  89710. */
  89711. maxScaleY: number;
  89712. /**
  89713. * Gets or sets the minimal initial rotation in radians.
  89714. */
  89715. minInitialRotation: number;
  89716. /**
  89717. * Gets or sets the maximal initial rotation in radians.
  89718. */
  89719. maxInitialRotation: number;
  89720. /**
  89721. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89722. */
  89723. minAngularSpeed: number;
  89724. /**
  89725. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89726. */
  89727. maxAngularSpeed: number;
  89728. /**
  89729. * The texture used to render each particle. (this can be a spritesheet)
  89730. */
  89731. particleTexture: Nullable<Texture>;
  89732. /**
  89733. * The layer mask we are rendering the particles through.
  89734. */
  89735. layerMask: number;
  89736. /**
  89737. * This can help using your own shader to render the particle system.
  89738. * The according effect will be created
  89739. */
  89740. customShader: any;
  89741. /**
  89742. * By default particle system starts as soon as they are created. This prevents the
  89743. * automatic start to happen and let you decide when to start emitting particles.
  89744. */
  89745. preventAutoStart: boolean;
  89746. private _noiseTexture;
  89747. /**
  89748. * Gets or sets a texture used to add random noise to particle positions
  89749. */
  89750. get noiseTexture(): Nullable<ProceduralTexture>;
  89751. set noiseTexture(value: Nullable<ProceduralTexture>);
  89752. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89753. noiseStrength: Vector3;
  89754. /**
  89755. * Callback triggered when the particle animation is ending.
  89756. */
  89757. onAnimationEnd: Nullable<() => void>;
  89758. /**
  89759. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89760. */
  89761. blendMode: number;
  89762. /**
  89763. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89764. * to override the particles.
  89765. */
  89766. forceDepthWrite: boolean;
  89767. /** 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 */
  89768. preWarmCycles: number;
  89769. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89770. preWarmStepOffset: number;
  89771. /**
  89772. * 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)
  89773. */
  89774. spriteCellChangeSpeed: number;
  89775. /**
  89776. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89777. */
  89778. startSpriteCellID: number;
  89779. /**
  89780. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89781. */
  89782. endSpriteCellID: number;
  89783. /**
  89784. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89785. */
  89786. spriteCellWidth: number;
  89787. /**
  89788. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89789. */
  89790. spriteCellHeight: number;
  89791. /**
  89792. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89793. */
  89794. spriteRandomStartCell: boolean;
  89795. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89796. translationPivot: Vector2;
  89797. /** @hidden */
  89798. protected _isAnimationSheetEnabled: boolean;
  89799. /**
  89800. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89801. */
  89802. beginAnimationOnStart: boolean;
  89803. /**
  89804. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89805. */
  89806. beginAnimationFrom: number;
  89807. /**
  89808. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89809. */
  89810. beginAnimationTo: number;
  89811. /**
  89812. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89813. */
  89814. beginAnimationLoop: boolean;
  89815. /**
  89816. * Gets or sets a world offset applied to all particles
  89817. */
  89818. worldOffset: Vector3;
  89819. /**
  89820. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89821. */
  89822. get isAnimationSheetEnabled(): boolean;
  89823. set isAnimationSheetEnabled(value: boolean);
  89824. /**
  89825. * Get hosting scene
  89826. * @returns the scene
  89827. */
  89828. getScene(): Scene;
  89829. /**
  89830. * You can use gravity if you want to give an orientation to your particles.
  89831. */
  89832. gravity: Vector3;
  89833. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89834. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89835. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89836. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89837. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89838. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89839. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89840. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89841. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89842. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89843. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89844. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89845. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89846. /**
  89847. * Defines the delay in milliseconds before starting the system (0 by default)
  89848. */
  89849. startDelay: number;
  89850. /**
  89851. * Gets the current list of drag gradients.
  89852. * You must use addDragGradient and removeDragGradient to udpate this list
  89853. * @returns the list of drag gradients
  89854. */
  89855. getDragGradients(): Nullable<Array<FactorGradient>>;
  89856. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89857. limitVelocityDamping: number;
  89858. /**
  89859. * Gets the current list of limit velocity gradients.
  89860. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89861. * @returns the list of limit velocity gradients
  89862. */
  89863. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89864. /**
  89865. * Gets the current list of color gradients.
  89866. * You must use addColorGradient and removeColorGradient to udpate this list
  89867. * @returns the list of color gradients
  89868. */
  89869. getColorGradients(): Nullable<Array<ColorGradient>>;
  89870. /**
  89871. * Gets the current list of size gradients.
  89872. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89873. * @returns the list of size gradients
  89874. */
  89875. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89876. /**
  89877. * Gets the current list of color remap gradients.
  89878. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89879. * @returns the list of color remap gradients
  89880. */
  89881. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89882. /**
  89883. * Gets the current list of alpha remap gradients.
  89884. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89885. * @returns the list of alpha remap gradients
  89886. */
  89887. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89888. /**
  89889. * Gets the current list of life time gradients.
  89890. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89891. * @returns the list of life time gradients
  89892. */
  89893. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89894. /**
  89895. * Gets the current list of angular speed gradients.
  89896. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89897. * @returns the list of angular speed gradients
  89898. */
  89899. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89900. /**
  89901. * Gets the current list of velocity gradients.
  89902. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89903. * @returns the list of velocity gradients
  89904. */
  89905. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89906. /**
  89907. * Gets the current list of start size gradients.
  89908. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89909. * @returns the list of start size gradients
  89910. */
  89911. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89912. /**
  89913. * Gets the current list of emit rate gradients.
  89914. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89915. * @returns the list of emit rate gradients
  89916. */
  89917. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89918. /**
  89919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89920. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89921. */
  89922. get direction1(): Vector3;
  89923. set direction1(value: Vector3);
  89924. /**
  89925. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89926. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89927. */
  89928. get direction2(): Vector3;
  89929. set direction2(value: Vector3);
  89930. /**
  89931. * 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.
  89932. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89933. */
  89934. get minEmitBox(): Vector3;
  89935. set minEmitBox(value: Vector3);
  89936. /**
  89937. * 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.
  89938. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89939. */
  89940. get maxEmitBox(): Vector3;
  89941. set maxEmitBox(value: Vector3);
  89942. /**
  89943. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89944. */
  89945. color1: Color4;
  89946. /**
  89947. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89948. */
  89949. color2: Color4;
  89950. /**
  89951. * Color the particle will have at the end of its lifetime
  89952. */
  89953. colorDead: Color4;
  89954. /**
  89955. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89956. */
  89957. textureMask: Color4;
  89958. /**
  89959. * The particle emitter type defines the emitter used by the particle system.
  89960. * It can be for example box, sphere, or cone...
  89961. */
  89962. particleEmitterType: IParticleEmitterType;
  89963. /** @hidden */
  89964. _isSubEmitter: boolean;
  89965. /**
  89966. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89967. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89968. */
  89969. billboardMode: number;
  89970. protected _isBillboardBased: boolean;
  89971. /**
  89972. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89973. */
  89974. get isBillboardBased(): boolean;
  89975. set isBillboardBased(value: boolean);
  89976. /**
  89977. * The scene the particle system belongs to.
  89978. */
  89979. protected _scene: Scene;
  89980. /**
  89981. * Local cache of defines for image processing.
  89982. */
  89983. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89984. /**
  89985. * Default configuration related to image processing available in the standard Material.
  89986. */
  89987. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89988. /**
  89989. * Gets the image processing configuration used either in this material.
  89990. */
  89991. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89992. /**
  89993. * Sets the Default image processing configuration used either in the this material.
  89994. *
  89995. * If sets to null, the scene one is in use.
  89996. */
  89997. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89998. /**
  89999. * Attaches a new image processing configuration to the Standard Material.
  90000. * @param configuration
  90001. */
  90002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90003. /** @hidden */
  90004. protected _reset(): void;
  90005. /** @hidden */
  90006. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90007. /**
  90008. * Instantiates a particle system.
  90009. * 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.
  90010. * @param name The name of the particle system
  90011. */
  90012. constructor(name: string);
  90013. /**
  90014. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90017. * @returns the emitter
  90018. */
  90019. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90020. /**
  90021. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90022. * @param radius The radius of the hemisphere to emit from
  90023. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90024. * @returns the emitter
  90025. */
  90026. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90027. /**
  90028. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90029. * @param radius The radius of the sphere to emit from
  90030. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90031. * @returns the emitter
  90032. */
  90033. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90034. /**
  90035. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90036. * @param radius The radius of the sphere to emit from
  90037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90039. * @returns the emitter
  90040. */
  90041. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90042. /**
  90043. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90044. * @param radius The radius of the emission cylinder
  90045. * @param height The height of the emission cylinder
  90046. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90047. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90048. * @returns the emitter
  90049. */
  90050. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90051. /**
  90052. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90053. * @param radius The radius of the cylinder to emit from
  90054. * @param height The height of the emission cylinder
  90055. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90058. * @returns the emitter
  90059. */
  90060. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90061. /**
  90062. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90063. * @param radius The radius of the cone to emit from
  90064. * @param angle The base angle of the cone
  90065. * @returns the emitter
  90066. */
  90067. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90068. /**
  90069. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90072. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90073. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90074. * @returns the emitter
  90075. */
  90076. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90077. }
  90078. }
  90079. declare module BABYLON {
  90080. /**
  90081. * Type of sub emitter
  90082. */
  90083. export enum SubEmitterType {
  90084. /**
  90085. * Attached to the particle over it's lifetime
  90086. */
  90087. ATTACHED = 0,
  90088. /**
  90089. * Created when the particle dies
  90090. */
  90091. END = 1
  90092. }
  90093. /**
  90094. * Sub emitter class used to emit particles from an existing particle
  90095. */
  90096. export class SubEmitter {
  90097. /**
  90098. * the particle system to be used by the sub emitter
  90099. */
  90100. particleSystem: ParticleSystem;
  90101. /**
  90102. * Type of the submitter (Default: END)
  90103. */
  90104. type: SubEmitterType;
  90105. /**
  90106. * 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)
  90107. * Note: This only is supported when using an emitter of type Mesh
  90108. */
  90109. inheritDirection: boolean;
  90110. /**
  90111. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90112. */
  90113. inheritedVelocityAmount: number;
  90114. /**
  90115. * Creates a sub emitter
  90116. * @param particleSystem the particle system to be used by the sub emitter
  90117. */
  90118. constructor(
  90119. /**
  90120. * the particle system to be used by the sub emitter
  90121. */
  90122. particleSystem: ParticleSystem);
  90123. /**
  90124. * Clones the sub emitter
  90125. * @returns the cloned sub emitter
  90126. */
  90127. clone(): SubEmitter;
  90128. /**
  90129. * Serialize current object to a JSON object
  90130. * @returns the serialized object
  90131. */
  90132. serialize(): any;
  90133. /** @hidden */
  90134. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90135. /**
  90136. * Creates a new SubEmitter from a serialized JSON version
  90137. * @param serializationObject defines the JSON object to read from
  90138. * @param scene defines the hosting scene
  90139. * @param rootUrl defines the rootUrl for data loading
  90140. * @returns a new SubEmitter
  90141. */
  90142. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90143. /** Release associated resources */
  90144. dispose(): void;
  90145. }
  90146. }
  90147. declare module BABYLON {
  90148. /** @hidden */
  90149. export var imageProcessingDeclaration: {
  90150. name: string;
  90151. shader: string;
  90152. };
  90153. }
  90154. declare module BABYLON {
  90155. /** @hidden */
  90156. export var imageProcessingFunctions: {
  90157. name: string;
  90158. shader: string;
  90159. };
  90160. }
  90161. declare module BABYLON {
  90162. /** @hidden */
  90163. export var particlesPixelShader: {
  90164. name: string;
  90165. shader: string;
  90166. };
  90167. }
  90168. declare module BABYLON {
  90169. /** @hidden */
  90170. export var particlesVertexShader: {
  90171. name: string;
  90172. shader: string;
  90173. };
  90174. }
  90175. declare module BABYLON {
  90176. /**
  90177. * This represents a particle system in Babylon.
  90178. * 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.
  90179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90180. * @example https://doc.babylonjs.com/babylon101/particles
  90181. */
  90182. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90183. /**
  90184. * Billboard mode will only apply to Y axis
  90185. */
  90186. static readonly BILLBOARDMODE_Y: number;
  90187. /**
  90188. * Billboard mode will apply to all axes
  90189. */
  90190. static readonly BILLBOARDMODE_ALL: number;
  90191. /**
  90192. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90193. */
  90194. static readonly BILLBOARDMODE_STRETCHED: number;
  90195. /**
  90196. * This function can be defined to provide custom update for active particles.
  90197. * This function will be called instead of regular update (age, position, color, etc.).
  90198. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90199. */
  90200. updateFunction: (particles: Particle[]) => void;
  90201. private _emitterWorldMatrix;
  90202. /**
  90203. * This function can be defined to specify initial direction for every new particle.
  90204. * It by default use the emitterType defined function
  90205. */
  90206. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90207. /**
  90208. * This function can be defined to specify initial position for every new particle.
  90209. * It by default use the emitterType defined function
  90210. */
  90211. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90212. /**
  90213. * @hidden
  90214. */
  90215. _inheritedVelocityOffset: Vector3;
  90216. /**
  90217. * An event triggered when the system is disposed
  90218. */
  90219. onDisposeObservable: Observable<IParticleSystem>;
  90220. private _onDisposeObserver;
  90221. /**
  90222. * Sets a callback that will be triggered when the system is disposed
  90223. */
  90224. set onDispose(callback: () => void);
  90225. private _particles;
  90226. private _epsilon;
  90227. private _capacity;
  90228. private _stockParticles;
  90229. private _newPartsExcess;
  90230. private _vertexData;
  90231. private _vertexBuffer;
  90232. private _vertexBuffers;
  90233. private _spriteBuffer;
  90234. private _indexBuffer;
  90235. private _effect;
  90236. private _customEffect;
  90237. private _cachedDefines;
  90238. private _scaledColorStep;
  90239. private _colorDiff;
  90240. private _scaledDirection;
  90241. private _scaledGravity;
  90242. private _currentRenderId;
  90243. private _alive;
  90244. private _useInstancing;
  90245. private _started;
  90246. private _stopped;
  90247. private _actualFrame;
  90248. private _scaledUpdateSpeed;
  90249. private _vertexBufferSize;
  90250. /** @hidden */
  90251. _currentEmitRateGradient: Nullable<FactorGradient>;
  90252. /** @hidden */
  90253. _currentEmitRate1: number;
  90254. /** @hidden */
  90255. _currentEmitRate2: number;
  90256. /** @hidden */
  90257. _currentStartSizeGradient: Nullable<FactorGradient>;
  90258. /** @hidden */
  90259. _currentStartSize1: number;
  90260. /** @hidden */
  90261. _currentStartSize2: number;
  90262. private readonly _rawTextureWidth;
  90263. private _rampGradientsTexture;
  90264. private _useRampGradients;
  90265. /** Gets or sets a boolean indicating that ramp gradients must be used
  90266. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90267. */
  90268. get useRampGradients(): boolean;
  90269. set useRampGradients(value: boolean);
  90270. /**
  90271. * 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.
  90272. * 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: [])
  90273. */
  90274. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90275. private _subEmitters;
  90276. /**
  90277. * @hidden
  90278. * If the particle systems emitter should be disposed when the particle system is disposed
  90279. */
  90280. _disposeEmitterOnDispose: boolean;
  90281. /**
  90282. * The current active Sub-systems, this property is used by the root particle system only.
  90283. */
  90284. activeSubSystems: Array<ParticleSystem>;
  90285. /**
  90286. * Specifies if the particles are updated in emitter local space or world space
  90287. */
  90288. isLocal: boolean;
  90289. private _rootParticleSystem;
  90290. /**
  90291. * Gets the current list of active particles
  90292. */
  90293. get particles(): Particle[];
  90294. /**
  90295. * Gets the number of particles active at the same time.
  90296. * @returns The number of active particles.
  90297. */
  90298. getActiveCount(): number;
  90299. /**
  90300. * Returns the string "ParticleSystem"
  90301. * @returns a string containing the class name
  90302. */
  90303. getClassName(): string;
  90304. /**
  90305. * Gets a boolean indicating that the system is stopping
  90306. * @returns true if the system is currently stopping
  90307. */
  90308. isStopping(): boolean;
  90309. /**
  90310. * Gets the custom effect used to render the particles
  90311. * @param blendMode Blend mode for which the effect should be retrieved
  90312. * @returns The effect
  90313. */
  90314. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90315. /**
  90316. * Sets the custom effect used to render the particles
  90317. * @param effect The effect to set
  90318. * @param blendMode Blend mode for which the effect should be set
  90319. */
  90320. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90321. /** @hidden */
  90322. private _onBeforeDrawParticlesObservable;
  90323. /**
  90324. * Observable that will be called just before the particles are drawn
  90325. */
  90326. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90327. /**
  90328. * Gets the name of the particle vertex shader
  90329. */
  90330. get vertexShaderName(): string;
  90331. /**
  90332. * Instantiates a particle system.
  90333. * 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.
  90334. * @param name The name of the particle system
  90335. * @param capacity The max number of particles alive at the same time
  90336. * @param scene The scene the particle system belongs to
  90337. * @param customEffect a custom effect used to change the way particles are rendered by default
  90338. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90339. * @param epsilon Offset used to render the particles
  90340. */
  90341. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90342. private _addFactorGradient;
  90343. private _removeFactorGradient;
  90344. /**
  90345. * Adds a new life time gradient
  90346. * @param gradient defines the gradient to use (between 0 and 1)
  90347. * @param factor defines the life time factor to affect to the specified gradient
  90348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90349. * @returns the current particle system
  90350. */
  90351. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90352. /**
  90353. * Remove a specific life time gradient
  90354. * @param gradient defines the gradient to remove
  90355. * @returns the current particle system
  90356. */
  90357. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90358. /**
  90359. * Adds a new size gradient
  90360. * @param gradient defines the gradient to use (between 0 and 1)
  90361. * @param factor defines the size factor to affect to the specified gradient
  90362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90363. * @returns the current particle system
  90364. */
  90365. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90366. /**
  90367. * Remove a specific size gradient
  90368. * @param gradient defines the gradient to remove
  90369. * @returns the current particle system
  90370. */
  90371. removeSizeGradient(gradient: number): IParticleSystem;
  90372. /**
  90373. * Adds a new color remap gradient
  90374. * @param gradient defines the gradient to use (between 0 and 1)
  90375. * @param min defines the color remap minimal range
  90376. * @param max defines the color remap maximal range
  90377. * @returns the current particle system
  90378. */
  90379. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90380. /**
  90381. * Remove a specific color remap gradient
  90382. * @param gradient defines the gradient to remove
  90383. * @returns the current particle system
  90384. */
  90385. removeColorRemapGradient(gradient: number): IParticleSystem;
  90386. /**
  90387. * Adds a new alpha remap gradient
  90388. * @param gradient defines the gradient to use (between 0 and 1)
  90389. * @param min defines the alpha remap minimal range
  90390. * @param max defines the alpha remap maximal range
  90391. * @returns the current particle system
  90392. */
  90393. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90394. /**
  90395. * Remove a specific alpha remap gradient
  90396. * @param gradient defines the gradient to remove
  90397. * @returns the current particle system
  90398. */
  90399. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90400. /**
  90401. * Adds a new angular speed gradient
  90402. * @param gradient defines the gradient to use (between 0 and 1)
  90403. * @param factor defines the angular speed to affect to the specified gradient
  90404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90405. * @returns the current particle system
  90406. */
  90407. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90408. /**
  90409. * Remove a specific angular speed gradient
  90410. * @param gradient defines the gradient to remove
  90411. * @returns the current particle system
  90412. */
  90413. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90414. /**
  90415. * Adds a new velocity gradient
  90416. * @param gradient defines the gradient to use (between 0 and 1)
  90417. * @param factor defines the velocity to affect to the specified gradient
  90418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90419. * @returns the current particle system
  90420. */
  90421. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90422. /**
  90423. * Remove a specific velocity gradient
  90424. * @param gradient defines the gradient to remove
  90425. * @returns the current particle system
  90426. */
  90427. removeVelocityGradient(gradient: number): IParticleSystem;
  90428. /**
  90429. * Adds a new limit velocity gradient
  90430. * @param gradient defines the gradient to use (between 0 and 1)
  90431. * @param factor defines the limit velocity value to affect to the specified gradient
  90432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90433. * @returns the current particle system
  90434. */
  90435. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90436. /**
  90437. * Remove a specific limit velocity gradient
  90438. * @param gradient defines the gradient to remove
  90439. * @returns the current particle system
  90440. */
  90441. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90442. /**
  90443. * Adds a new drag gradient
  90444. * @param gradient defines the gradient to use (between 0 and 1)
  90445. * @param factor defines the drag value to affect to the specified gradient
  90446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90447. * @returns the current particle system
  90448. */
  90449. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90450. /**
  90451. * Remove a specific drag gradient
  90452. * @param gradient defines the gradient to remove
  90453. * @returns the current particle system
  90454. */
  90455. removeDragGradient(gradient: number): IParticleSystem;
  90456. /**
  90457. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90458. * @param gradient defines the gradient to use (between 0 and 1)
  90459. * @param factor defines the emit rate value to affect to the specified gradient
  90460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90461. * @returns the current particle system
  90462. */
  90463. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90464. /**
  90465. * Remove a specific emit rate gradient
  90466. * @param gradient defines the gradient to remove
  90467. * @returns the current particle system
  90468. */
  90469. removeEmitRateGradient(gradient: number): IParticleSystem;
  90470. /**
  90471. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90472. * @param gradient defines the gradient to use (between 0 and 1)
  90473. * @param factor defines the start size value to affect to the specified gradient
  90474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90475. * @returns the current particle system
  90476. */
  90477. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90478. /**
  90479. * Remove a specific start size gradient
  90480. * @param gradient defines the gradient to remove
  90481. * @returns the current particle system
  90482. */
  90483. removeStartSizeGradient(gradient: number): IParticleSystem;
  90484. private _createRampGradientTexture;
  90485. /**
  90486. * Gets the current list of ramp gradients.
  90487. * You must use addRampGradient and removeRampGradient to udpate this list
  90488. * @returns the list of ramp gradients
  90489. */
  90490. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90491. /** Force the system to rebuild all gradients that need to be resync */
  90492. forceRefreshGradients(): void;
  90493. private _syncRampGradientTexture;
  90494. /**
  90495. * Adds a new ramp gradient used to remap particle colors
  90496. * @param gradient defines the gradient to use (between 0 and 1)
  90497. * @param color defines the color to affect to the specified gradient
  90498. * @returns the current particle system
  90499. */
  90500. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90501. /**
  90502. * Remove a specific ramp gradient
  90503. * @param gradient defines the gradient to remove
  90504. * @returns the current particle system
  90505. */
  90506. removeRampGradient(gradient: number): ParticleSystem;
  90507. /**
  90508. * Adds a new color gradient
  90509. * @param gradient defines the gradient to use (between 0 and 1)
  90510. * @param color1 defines the color to affect to the specified gradient
  90511. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90512. * @returns this particle system
  90513. */
  90514. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90515. /**
  90516. * Remove a specific color gradient
  90517. * @param gradient defines the gradient to remove
  90518. * @returns this particle system
  90519. */
  90520. removeColorGradient(gradient: number): IParticleSystem;
  90521. private _fetchR;
  90522. protected _reset(): void;
  90523. private _resetEffect;
  90524. private _createVertexBuffers;
  90525. private _createIndexBuffer;
  90526. /**
  90527. * Gets the maximum number of particles active at the same time.
  90528. * @returns The max number of active particles.
  90529. */
  90530. getCapacity(): number;
  90531. /**
  90532. * Gets whether there are still active particles in the system.
  90533. * @returns True if it is alive, otherwise false.
  90534. */
  90535. isAlive(): boolean;
  90536. /**
  90537. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90538. * @returns True if it has been started, otherwise false.
  90539. */
  90540. isStarted(): boolean;
  90541. private _prepareSubEmitterInternalArray;
  90542. /**
  90543. * Starts the particle system and begins to emit
  90544. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90545. */
  90546. start(delay?: number): void;
  90547. /**
  90548. * Stops the particle system.
  90549. * @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.
  90550. */
  90551. stop(stopSubEmitters?: boolean): void;
  90552. /**
  90553. * Remove all active particles
  90554. */
  90555. reset(): void;
  90556. /**
  90557. * @hidden (for internal use only)
  90558. */
  90559. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90560. /**
  90561. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90562. * Its lifetime will start back at 0.
  90563. */
  90564. recycleParticle: (particle: Particle) => void;
  90565. private _stopSubEmitters;
  90566. private _createParticle;
  90567. private _removeFromRoot;
  90568. private _emitFromParticle;
  90569. private _update;
  90570. /** @hidden */
  90571. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90572. /** @hidden */
  90573. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90574. /**
  90575. * Fill the defines array according to the current settings of the particle system
  90576. * @param defines Array to be updated
  90577. * @param blendMode blend mode to take into account when updating the array
  90578. */
  90579. fillDefines(defines: Array<string>, blendMode: number): void;
  90580. /**
  90581. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90582. * @param uniforms Uniforms array to fill
  90583. * @param attributes Attributes array to fill
  90584. * @param samplers Samplers array to fill
  90585. */
  90586. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90587. /** @hidden */
  90588. private _getEffect;
  90589. /**
  90590. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90591. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90592. */
  90593. animate(preWarmOnly?: boolean): void;
  90594. private _appendParticleVertices;
  90595. /**
  90596. * Rebuilds the particle system.
  90597. */
  90598. rebuild(): void;
  90599. /**
  90600. * Is this system ready to be used/rendered
  90601. * @return true if the system is ready
  90602. */
  90603. isReady(): boolean;
  90604. private _render;
  90605. /**
  90606. * Renders the particle system in its current state.
  90607. * @returns the current number of particles
  90608. */
  90609. render(): number;
  90610. /**
  90611. * Disposes the particle system and free the associated resources
  90612. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90613. */
  90614. dispose(disposeTexture?: boolean): void;
  90615. /**
  90616. * Clones the particle system.
  90617. * @param name The name of the cloned object
  90618. * @param newEmitter The new emitter to use
  90619. * @returns the cloned particle system
  90620. */
  90621. clone(name: string, newEmitter: any): ParticleSystem;
  90622. /**
  90623. * Serializes the particle system to a JSON object
  90624. * @param serializeTexture defines if the texture must be serialized as well
  90625. * @returns the JSON object
  90626. */
  90627. serialize(serializeTexture?: boolean): any;
  90628. /** @hidden */
  90629. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90630. /** @hidden */
  90631. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90632. /**
  90633. * Parses a JSON object to create a particle system.
  90634. * @param parsedParticleSystem The JSON object to parse
  90635. * @param scene The scene to create the particle system in
  90636. * @param rootUrl The root url to use to load external dependencies like texture
  90637. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90638. * @returns the Parsed particle system
  90639. */
  90640. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90641. }
  90642. }
  90643. declare module BABYLON {
  90644. /**
  90645. * A particle represents one of the element emitted by a particle system.
  90646. * This is mainly define by its coordinates, direction, velocity and age.
  90647. */
  90648. export class Particle {
  90649. /**
  90650. * The particle system the particle belongs to.
  90651. */
  90652. particleSystem: ParticleSystem;
  90653. private static _Count;
  90654. /**
  90655. * Unique ID of the particle
  90656. */
  90657. id: number;
  90658. /**
  90659. * The world position of the particle in the scene.
  90660. */
  90661. position: Vector3;
  90662. /**
  90663. * The world direction of the particle in the scene.
  90664. */
  90665. direction: Vector3;
  90666. /**
  90667. * The color of the particle.
  90668. */
  90669. color: Color4;
  90670. /**
  90671. * The color change of the particle per step.
  90672. */
  90673. colorStep: Color4;
  90674. /**
  90675. * Defines how long will the life of the particle be.
  90676. */
  90677. lifeTime: number;
  90678. /**
  90679. * The current age of the particle.
  90680. */
  90681. age: number;
  90682. /**
  90683. * The current size of the particle.
  90684. */
  90685. size: number;
  90686. /**
  90687. * The current scale of the particle.
  90688. */
  90689. scale: Vector2;
  90690. /**
  90691. * The current angle of the particle.
  90692. */
  90693. angle: number;
  90694. /**
  90695. * Defines how fast is the angle changing.
  90696. */
  90697. angularSpeed: number;
  90698. /**
  90699. * Defines the cell index used by the particle to be rendered from a sprite.
  90700. */
  90701. cellIndex: number;
  90702. /**
  90703. * The information required to support color remapping
  90704. */
  90705. remapData: Vector4;
  90706. /** @hidden */
  90707. _randomCellOffset?: number;
  90708. /** @hidden */
  90709. _initialDirection: Nullable<Vector3>;
  90710. /** @hidden */
  90711. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90712. /** @hidden */
  90713. _initialStartSpriteCellID: number;
  90714. /** @hidden */
  90715. _initialEndSpriteCellID: number;
  90716. /** @hidden */
  90717. _currentColorGradient: Nullable<ColorGradient>;
  90718. /** @hidden */
  90719. _currentColor1: Color4;
  90720. /** @hidden */
  90721. _currentColor2: Color4;
  90722. /** @hidden */
  90723. _currentSizeGradient: Nullable<FactorGradient>;
  90724. /** @hidden */
  90725. _currentSize1: number;
  90726. /** @hidden */
  90727. _currentSize2: number;
  90728. /** @hidden */
  90729. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90730. /** @hidden */
  90731. _currentAngularSpeed1: number;
  90732. /** @hidden */
  90733. _currentAngularSpeed2: number;
  90734. /** @hidden */
  90735. _currentVelocityGradient: Nullable<FactorGradient>;
  90736. /** @hidden */
  90737. _currentVelocity1: number;
  90738. /** @hidden */
  90739. _currentVelocity2: number;
  90740. /** @hidden */
  90741. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90742. /** @hidden */
  90743. _currentLimitVelocity1: number;
  90744. /** @hidden */
  90745. _currentLimitVelocity2: number;
  90746. /** @hidden */
  90747. _currentDragGradient: Nullable<FactorGradient>;
  90748. /** @hidden */
  90749. _currentDrag1: number;
  90750. /** @hidden */
  90751. _currentDrag2: number;
  90752. /** @hidden */
  90753. _randomNoiseCoordinates1: Vector3;
  90754. /** @hidden */
  90755. _randomNoiseCoordinates2: Vector3;
  90756. /** @hidden */
  90757. _localPosition?: Vector3;
  90758. /**
  90759. * Creates a new instance Particle
  90760. * @param particleSystem the particle system the particle belongs to
  90761. */
  90762. constructor(
  90763. /**
  90764. * The particle system the particle belongs to.
  90765. */
  90766. particleSystem: ParticleSystem);
  90767. private updateCellInfoFromSystem;
  90768. /**
  90769. * Defines how the sprite cell index is updated for the particle
  90770. */
  90771. updateCellIndex(): void;
  90772. /** @hidden */
  90773. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90774. /** @hidden */
  90775. _inheritParticleInfoToSubEmitters(): void;
  90776. /** @hidden */
  90777. _reset(): void;
  90778. /**
  90779. * Copy the properties of particle to another one.
  90780. * @param other the particle to copy the information to.
  90781. */
  90782. copyTo(other: Particle): void;
  90783. }
  90784. }
  90785. declare module BABYLON {
  90786. /**
  90787. * Particle emitter represents a volume emitting particles.
  90788. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90789. */
  90790. export interface IParticleEmitterType {
  90791. /**
  90792. * Called by the particle System when the direction is computed for the created particle.
  90793. * @param worldMatrix is the world matrix of the particle system
  90794. * @param directionToUpdate is the direction vector to update with the result
  90795. * @param particle is the particle we are computed the direction for
  90796. * @param isLocal defines if the direction should be set in local space
  90797. */
  90798. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90799. /**
  90800. * Called by the particle System when the position is computed for the created particle.
  90801. * @param worldMatrix is the world matrix of the particle system
  90802. * @param positionToUpdate is the position vector to update with the result
  90803. * @param particle is the particle we are computed the position for
  90804. * @param isLocal defines if the position should be set in local space
  90805. */
  90806. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90807. /**
  90808. * Clones the current emitter and returns a copy of it
  90809. * @returns the new emitter
  90810. */
  90811. clone(): IParticleEmitterType;
  90812. /**
  90813. * Called by the GPUParticleSystem to setup the update shader
  90814. * @param effect defines the update shader
  90815. */
  90816. applyToShader(effect: Effect): void;
  90817. /**
  90818. * Returns a string to use to update the GPU particles update shader
  90819. * @returns the effect defines string
  90820. */
  90821. getEffectDefines(): string;
  90822. /**
  90823. * Returns a string representing the class name
  90824. * @returns a string containing the class name
  90825. */
  90826. getClassName(): string;
  90827. /**
  90828. * Serializes the particle system to a JSON object.
  90829. * @returns the JSON object
  90830. */
  90831. serialize(): any;
  90832. /**
  90833. * Parse properties from a JSON object
  90834. * @param serializationObject defines the JSON object
  90835. * @param scene defines the hosting scene
  90836. */
  90837. parse(serializationObject: any, scene: Scene): void;
  90838. }
  90839. }
  90840. declare module BABYLON {
  90841. /**
  90842. * Particle emitter emitting particles from the inside of a box.
  90843. * It emits the particles randomly between 2 given directions.
  90844. */
  90845. export class BoxParticleEmitter implements IParticleEmitterType {
  90846. /**
  90847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90848. */
  90849. direction1: Vector3;
  90850. /**
  90851. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90852. */
  90853. direction2: Vector3;
  90854. /**
  90855. * 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.
  90856. */
  90857. minEmitBox: Vector3;
  90858. /**
  90859. * 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.
  90860. */
  90861. maxEmitBox: Vector3;
  90862. /**
  90863. * Creates a new instance BoxParticleEmitter
  90864. */
  90865. constructor();
  90866. /**
  90867. * Called by the particle System when the direction is computed for the created particle.
  90868. * @param worldMatrix is the world matrix of the particle system
  90869. * @param directionToUpdate is the direction vector to update with the result
  90870. * @param particle is the particle we are computed the direction for
  90871. * @param isLocal defines if the direction should be set in local space
  90872. */
  90873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90874. /**
  90875. * Called by the particle System when the position is computed for the created particle.
  90876. * @param worldMatrix is the world matrix of the particle system
  90877. * @param positionToUpdate is the position vector to update with the result
  90878. * @param particle is the particle we are computed the position for
  90879. * @param isLocal defines if the position should be set in local space
  90880. */
  90881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90882. /**
  90883. * Clones the current emitter and returns a copy of it
  90884. * @returns the new emitter
  90885. */
  90886. clone(): BoxParticleEmitter;
  90887. /**
  90888. * Called by the GPUParticleSystem to setup the update shader
  90889. * @param effect defines the update shader
  90890. */
  90891. applyToShader(effect: Effect): void;
  90892. /**
  90893. * Returns a string to use to update the GPU particles update shader
  90894. * @returns a string containng the defines string
  90895. */
  90896. getEffectDefines(): string;
  90897. /**
  90898. * Returns the string "BoxParticleEmitter"
  90899. * @returns a string containing the class name
  90900. */
  90901. getClassName(): string;
  90902. /**
  90903. * Serializes the particle system to a JSON object.
  90904. * @returns the JSON object
  90905. */
  90906. serialize(): any;
  90907. /**
  90908. * Parse properties from a JSON object
  90909. * @param serializationObject defines the JSON object
  90910. */
  90911. parse(serializationObject: any): void;
  90912. }
  90913. }
  90914. declare module BABYLON {
  90915. /**
  90916. * Particle emitter emitting particles from the inside of a cone.
  90917. * It emits the particles alongside the cone volume from the base to the particle.
  90918. * The emission direction might be randomized.
  90919. */
  90920. export class ConeParticleEmitter implements IParticleEmitterType {
  90921. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90922. directionRandomizer: number;
  90923. private _radius;
  90924. private _angle;
  90925. private _height;
  90926. /**
  90927. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90928. */
  90929. radiusRange: number;
  90930. /**
  90931. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90932. */
  90933. heightRange: number;
  90934. /**
  90935. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90936. */
  90937. emitFromSpawnPointOnly: boolean;
  90938. /**
  90939. * Gets or sets the radius of the emission cone
  90940. */
  90941. get radius(): number;
  90942. set radius(value: number);
  90943. /**
  90944. * Gets or sets the angle of the emission cone
  90945. */
  90946. get angle(): number;
  90947. set angle(value: number);
  90948. private _buildHeight;
  90949. /**
  90950. * Creates a new instance ConeParticleEmitter
  90951. * @param radius the radius of the emission cone (1 by default)
  90952. * @param angle the cone base angle (PI by default)
  90953. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90954. */
  90955. constructor(radius?: number, angle?: number,
  90956. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90957. directionRandomizer?: number);
  90958. /**
  90959. * Called by the particle System when the direction is computed for the created particle.
  90960. * @param worldMatrix is the world matrix of the particle system
  90961. * @param directionToUpdate is the direction vector to update with the result
  90962. * @param particle is the particle we are computed the direction for
  90963. * @param isLocal defines if the direction should be set in local space
  90964. */
  90965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90966. /**
  90967. * Called by the particle System when the position is computed for the created particle.
  90968. * @param worldMatrix is the world matrix of the particle system
  90969. * @param positionToUpdate is the position vector to update with the result
  90970. * @param particle is the particle we are computed the position for
  90971. * @param isLocal defines if the position should be set in local space
  90972. */
  90973. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90974. /**
  90975. * Clones the current emitter and returns a copy of it
  90976. * @returns the new emitter
  90977. */
  90978. clone(): ConeParticleEmitter;
  90979. /**
  90980. * Called by the GPUParticleSystem to setup the update shader
  90981. * @param effect defines the update shader
  90982. */
  90983. applyToShader(effect: Effect): void;
  90984. /**
  90985. * Returns a string to use to update the GPU particles update shader
  90986. * @returns a string containng the defines string
  90987. */
  90988. getEffectDefines(): string;
  90989. /**
  90990. * Returns the string "ConeParticleEmitter"
  90991. * @returns a string containing the class name
  90992. */
  90993. getClassName(): string;
  90994. /**
  90995. * Serializes the particle system to a JSON object.
  90996. * @returns the JSON object
  90997. */
  90998. serialize(): any;
  90999. /**
  91000. * Parse properties from a JSON object
  91001. * @param serializationObject defines the JSON object
  91002. */
  91003. parse(serializationObject: any): void;
  91004. }
  91005. }
  91006. declare module BABYLON {
  91007. /**
  91008. * Particle emitter emitting particles from the inside of a cylinder.
  91009. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91010. */
  91011. export class CylinderParticleEmitter implements IParticleEmitterType {
  91012. /**
  91013. * The radius of the emission cylinder.
  91014. */
  91015. radius: number;
  91016. /**
  91017. * The height of the emission cylinder.
  91018. */
  91019. height: number;
  91020. /**
  91021. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91022. */
  91023. radiusRange: number;
  91024. /**
  91025. * How much to randomize the particle direction [0-1].
  91026. */
  91027. directionRandomizer: number;
  91028. /**
  91029. * Creates a new instance CylinderParticleEmitter
  91030. * @param radius the radius of the emission cylinder (1 by default)
  91031. * @param height the height of the emission cylinder (1 by default)
  91032. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91033. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91034. */
  91035. constructor(
  91036. /**
  91037. * The radius of the emission cylinder.
  91038. */
  91039. radius?: number,
  91040. /**
  91041. * The height of the emission cylinder.
  91042. */
  91043. height?: number,
  91044. /**
  91045. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91046. */
  91047. radiusRange?: number,
  91048. /**
  91049. * How much to randomize the particle direction [0-1].
  91050. */
  91051. directionRandomizer?: number);
  91052. /**
  91053. * Called by the particle System when the direction is computed for the created particle.
  91054. * @param worldMatrix is the world matrix of the particle system
  91055. * @param directionToUpdate is the direction vector to update with the result
  91056. * @param particle is the particle we are computed the direction for
  91057. * @param isLocal defines if the direction should be set in local space
  91058. */
  91059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91060. /**
  91061. * Called by the particle System when the position is computed for the created particle.
  91062. * @param worldMatrix is the world matrix of the particle system
  91063. * @param positionToUpdate is the position vector to update with the result
  91064. * @param particle is the particle we are computed the position for
  91065. * @param isLocal defines if the position should be set in local space
  91066. */
  91067. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91068. /**
  91069. * Clones the current emitter and returns a copy of it
  91070. * @returns the new emitter
  91071. */
  91072. clone(): CylinderParticleEmitter;
  91073. /**
  91074. * Called by the GPUParticleSystem to setup the update shader
  91075. * @param effect defines the update shader
  91076. */
  91077. applyToShader(effect: Effect): void;
  91078. /**
  91079. * Returns a string to use to update the GPU particles update shader
  91080. * @returns a string containng the defines string
  91081. */
  91082. getEffectDefines(): string;
  91083. /**
  91084. * Returns the string "CylinderParticleEmitter"
  91085. * @returns a string containing the class name
  91086. */
  91087. getClassName(): string;
  91088. /**
  91089. * Serializes the particle system to a JSON object.
  91090. * @returns the JSON object
  91091. */
  91092. serialize(): any;
  91093. /**
  91094. * Parse properties from a JSON object
  91095. * @param serializationObject defines the JSON object
  91096. */
  91097. parse(serializationObject: any): void;
  91098. }
  91099. /**
  91100. * Particle emitter emitting particles from the inside of a cylinder.
  91101. * It emits the particles randomly between two vectors.
  91102. */
  91103. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91104. /**
  91105. * The min limit of the emission direction.
  91106. */
  91107. direction1: Vector3;
  91108. /**
  91109. * The max limit of the emission direction.
  91110. */
  91111. direction2: Vector3;
  91112. /**
  91113. * Creates a new instance CylinderDirectedParticleEmitter
  91114. * @param radius the radius of the emission cylinder (1 by default)
  91115. * @param height the height of the emission cylinder (1 by default)
  91116. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91117. * @param direction1 the min limit of the emission direction (up vector by default)
  91118. * @param direction2 the max limit of the emission direction (up vector by default)
  91119. */
  91120. constructor(radius?: number, height?: number, radiusRange?: number,
  91121. /**
  91122. * The min limit of the emission direction.
  91123. */
  91124. direction1?: Vector3,
  91125. /**
  91126. * The max limit of the emission direction.
  91127. */
  91128. direction2?: Vector3);
  91129. /**
  91130. * Called by the particle System when the direction is computed for the created particle.
  91131. * @param worldMatrix is the world matrix of the particle system
  91132. * @param directionToUpdate is the direction vector to update with the result
  91133. * @param particle is the particle we are computed the direction for
  91134. */
  91135. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91136. /**
  91137. * Clones the current emitter and returns a copy of it
  91138. * @returns the new emitter
  91139. */
  91140. clone(): CylinderDirectedParticleEmitter;
  91141. /**
  91142. * Called by the GPUParticleSystem to setup the update shader
  91143. * @param effect defines the update shader
  91144. */
  91145. applyToShader(effect: Effect): void;
  91146. /**
  91147. * Returns a string to use to update the GPU particles update shader
  91148. * @returns a string containng the defines string
  91149. */
  91150. getEffectDefines(): string;
  91151. /**
  91152. * Returns the string "CylinderDirectedParticleEmitter"
  91153. * @returns a string containing the class name
  91154. */
  91155. getClassName(): string;
  91156. /**
  91157. * Serializes the particle system to a JSON object.
  91158. * @returns the JSON object
  91159. */
  91160. serialize(): any;
  91161. /**
  91162. * Parse properties from a JSON object
  91163. * @param serializationObject defines the JSON object
  91164. */
  91165. parse(serializationObject: any): void;
  91166. }
  91167. }
  91168. declare module BABYLON {
  91169. /**
  91170. * Particle emitter emitting particles from the inside of a hemisphere.
  91171. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91172. */
  91173. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91174. /**
  91175. * The radius of the emission hemisphere.
  91176. */
  91177. radius: number;
  91178. /**
  91179. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91180. */
  91181. radiusRange: number;
  91182. /**
  91183. * How much to randomize the particle direction [0-1].
  91184. */
  91185. directionRandomizer: number;
  91186. /**
  91187. * Creates a new instance HemisphericParticleEmitter
  91188. * @param radius the radius of the emission hemisphere (1 by default)
  91189. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91190. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91191. */
  91192. constructor(
  91193. /**
  91194. * The radius of the emission hemisphere.
  91195. */
  91196. radius?: number,
  91197. /**
  91198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91199. */
  91200. radiusRange?: number,
  91201. /**
  91202. * How much to randomize the particle direction [0-1].
  91203. */
  91204. directionRandomizer?: number);
  91205. /**
  91206. * Called by the particle System when the direction is computed for the created particle.
  91207. * @param worldMatrix is the world matrix of the particle system
  91208. * @param directionToUpdate is the direction vector to update with the result
  91209. * @param particle is the particle we are computed the direction for
  91210. * @param isLocal defines if the direction should be set in local space
  91211. */
  91212. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91213. /**
  91214. * Called by the particle System when the position is computed for the created particle.
  91215. * @param worldMatrix is the world matrix of the particle system
  91216. * @param positionToUpdate is the position vector to update with the result
  91217. * @param particle is the particle we are computed the position for
  91218. * @param isLocal defines if the position should be set in local space
  91219. */
  91220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91221. /**
  91222. * Clones the current emitter and returns a copy of it
  91223. * @returns the new emitter
  91224. */
  91225. clone(): HemisphericParticleEmitter;
  91226. /**
  91227. * Called by the GPUParticleSystem to setup the update shader
  91228. * @param effect defines the update shader
  91229. */
  91230. applyToShader(effect: Effect): void;
  91231. /**
  91232. * Returns a string to use to update the GPU particles update shader
  91233. * @returns a string containng the defines string
  91234. */
  91235. getEffectDefines(): string;
  91236. /**
  91237. * Returns the string "HemisphericParticleEmitter"
  91238. * @returns a string containing the class name
  91239. */
  91240. getClassName(): string;
  91241. /**
  91242. * Serializes the particle system to a JSON object.
  91243. * @returns the JSON object
  91244. */
  91245. serialize(): any;
  91246. /**
  91247. * Parse properties from a JSON object
  91248. * @param serializationObject defines the JSON object
  91249. */
  91250. parse(serializationObject: any): void;
  91251. }
  91252. }
  91253. declare module BABYLON {
  91254. /**
  91255. * Particle emitter emitting particles from a point.
  91256. * It emits the particles randomly between 2 given directions.
  91257. */
  91258. export class PointParticleEmitter implements IParticleEmitterType {
  91259. /**
  91260. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91261. */
  91262. direction1: Vector3;
  91263. /**
  91264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91265. */
  91266. direction2: Vector3;
  91267. /**
  91268. * Creates a new instance PointParticleEmitter
  91269. */
  91270. constructor();
  91271. /**
  91272. * Called by the particle System when the direction is computed for the created particle.
  91273. * @param worldMatrix is the world matrix of the particle system
  91274. * @param directionToUpdate is the direction vector to update with the result
  91275. * @param particle is the particle we are computed the direction for
  91276. * @param isLocal defines if the direction should be set in local space
  91277. */
  91278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91279. /**
  91280. * Called by the particle System when the position is computed for the created particle.
  91281. * @param worldMatrix is the world matrix of the particle system
  91282. * @param positionToUpdate is the position vector to update with the result
  91283. * @param particle is the particle we are computed the position for
  91284. * @param isLocal defines if the position should be set in local space
  91285. */
  91286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91287. /**
  91288. * Clones the current emitter and returns a copy of it
  91289. * @returns the new emitter
  91290. */
  91291. clone(): PointParticleEmitter;
  91292. /**
  91293. * Called by the GPUParticleSystem to setup the update shader
  91294. * @param effect defines the update shader
  91295. */
  91296. applyToShader(effect: Effect): void;
  91297. /**
  91298. * Returns a string to use to update the GPU particles update shader
  91299. * @returns a string containng the defines string
  91300. */
  91301. getEffectDefines(): string;
  91302. /**
  91303. * Returns the string "PointParticleEmitter"
  91304. * @returns a string containing the class name
  91305. */
  91306. getClassName(): string;
  91307. /**
  91308. * Serializes the particle system to a JSON object.
  91309. * @returns the JSON object
  91310. */
  91311. serialize(): any;
  91312. /**
  91313. * Parse properties from a JSON object
  91314. * @param serializationObject defines the JSON object
  91315. */
  91316. parse(serializationObject: any): void;
  91317. }
  91318. }
  91319. declare module BABYLON {
  91320. /**
  91321. * Particle emitter emitting particles from the inside of a sphere.
  91322. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91323. */
  91324. export class SphereParticleEmitter implements IParticleEmitterType {
  91325. /**
  91326. * The radius of the emission sphere.
  91327. */
  91328. radius: number;
  91329. /**
  91330. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91331. */
  91332. radiusRange: number;
  91333. /**
  91334. * How much to randomize the particle direction [0-1].
  91335. */
  91336. directionRandomizer: number;
  91337. /**
  91338. * Creates a new instance SphereParticleEmitter
  91339. * @param radius the radius of the emission sphere (1 by default)
  91340. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91342. */
  91343. constructor(
  91344. /**
  91345. * The radius of the emission sphere.
  91346. */
  91347. radius?: number,
  91348. /**
  91349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91350. */
  91351. radiusRange?: number,
  91352. /**
  91353. * How much to randomize the particle direction [0-1].
  91354. */
  91355. directionRandomizer?: number);
  91356. /**
  91357. * Called by the particle System when the direction is computed for the created particle.
  91358. * @param worldMatrix is the world matrix of the particle system
  91359. * @param directionToUpdate is the direction vector to update with the result
  91360. * @param particle is the particle we are computed the direction for
  91361. * @param isLocal defines if the direction should be set in local space
  91362. */
  91363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91364. /**
  91365. * Called by the particle System when the position is computed for the created particle.
  91366. * @param worldMatrix is the world matrix of the particle system
  91367. * @param positionToUpdate is the position vector to update with the result
  91368. * @param particle is the particle we are computed the position for
  91369. * @param isLocal defines if the position should be set in local space
  91370. */
  91371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91372. /**
  91373. * Clones the current emitter and returns a copy of it
  91374. * @returns the new emitter
  91375. */
  91376. clone(): SphereParticleEmitter;
  91377. /**
  91378. * Called by the GPUParticleSystem to setup the update shader
  91379. * @param effect defines the update shader
  91380. */
  91381. applyToShader(effect: Effect): void;
  91382. /**
  91383. * Returns a string to use to update the GPU particles update shader
  91384. * @returns a string containng the defines string
  91385. */
  91386. getEffectDefines(): string;
  91387. /**
  91388. * Returns the string "SphereParticleEmitter"
  91389. * @returns a string containing the class name
  91390. */
  91391. getClassName(): string;
  91392. /**
  91393. * Serializes the particle system to a JSON object.
  91394. * @returns the JSON object
  91395. */
  91396. serialize(): any;
  91397. /**
  91398. * Parse properties from a JSON object
  91399. * @param serializationObject defines the JSON object
  91400. */
  91401. parse(serializationObject: any): void;
  91402. }
  91403. /**
  91404. * Particle emitter emitting particles from the inside of a sphere.
  91405. * It emits the particles randomly between two vectors.
  91406. */
  91407. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91408. /**
  91409. * The min limit of the emission direction.
  91410. */
  91411. direction1: Vector3;
  91412. /**
  91413. * The max limit of the emission direction.
  91414. */
  91415. direction2: Vector3;
  91416. /**
  91417. * Creates a new instance SphereDirectedParticleEmitter
  91418. * @param radius the radius of the emission sphere (1 by default)
  91419. * @param direction1 the min limit of the emission direction (up vector by default)
  91420. * @param direction2 the max limit of the emission direction (up vector by default)
  91421. */
  91422. constructor(radius?: number,
  91423. /**
  91424. * The min limit of the emission direction.
  91425. */
  91426. direction1?: Vector3,
  91427. /**
  91428. * The max limit of the emission direction.
  91429. */
  91430. direction2?: Vector3);
  91431. /**
  91432. * Called by the particle System when the direction is computed for the created particle.
  91433. * @param worldMatrix is the world matrix of the particle system
  91434. * @param directionToUpdate is the direction vector to update with the result
  91435. * @param particle is the particle we are computed the direction for
  91436. */
  91437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91438. /**
  91439. * Clones the current emitter and returns a copy of it
  91440. * @returns the new emitter
  91441. */
  91442. clone(): SphereDirectedParticleEmitter;
  91443. /**
  91444. * Called by the GPUParticleSystem to setup the update shader
  91445. * @param effect defines the update shader
  91446. */
  91447. applyToShader(effect: Effect): void;
  91448. /**
  91449. * Returns a string to use to update the GPU particles update shader
  91450. * @returns a string containng the defines string
  91451. */
  91452. getEffectDefines(): string;
  91453. /**
  91454. * Returns the string "SphereDirectedParticleEmitter"
  91455. * @returns a string containing the class name
  91456. */
  91457. getClassName(): string;
  91458. /**
  91459. * Serializes the particle system to a JSON object.
  91460. * @returns the JSON object
  91461. */
  91462. serialize(): any;
  91463. /**
  91464. * Parse properties from a JSON object
  91465. * @param serializationObject defines the JSON object
  91466. */
  91467. parse(serializationObject: any): void;
  91468. }
  91469. }
  91470. declare module BABYLON {
  91471. /**
  91472. * Particle emitter emitting particles from a custom list of positions.
  91473. */
  91474. export class CustomParticleEmitter implements IParticleEmitterType {
  91475. /**
  91476. * Gets or sets the position generator that will create the inital position of each particle.
  91477. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91478. */
  91479. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91480. /**
  91481. * Gets or sets the destination generator that will create the final destination of each particle.
  91482. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91483. */
  91484. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91485. /**
  91486. * Creates a new instance CustomParticleEmitter
  91487. */
  91488. constructor();
  91489. /**
  91490. * Called by the particle System when the direction is computed for the created particle.
  91491. * @param worldMatrix is the world matrix of the particle system
  91492. * @param directionToUpdate is the direction vector to update with the result
  91493. * @param particle is the particle we are computed the direction for
  91494. * @param isLocal defines if the direction should be set in local space
  91495. */
  91496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91497. /**
  91498. * Called by the particle System when the position is computed for the created particle.
  91499. * @param worldMatrix is the world matrix of the particle system
  91500. * @param positionToUpdate is the position vector to update with the result
  91501. * @param particle is the particle we are computed the position for
  91502. * @param isLocal defines if the position should be set in local space
  91503. */
  91504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91505. /**
  91506. * Clones the current emitter and returns a copy of it
  91507. * @returns the new emitter
  91508. */
  91509. clone(): CustomParticleEmitter;
  91510. /**
  91511. * Called by the GPUParticleSystem to setup the update shader
  91512. * @param effect defines the update shader
  91513. */
  91514. applyToShader(effect: Effect): void;
  91515. /**
  91516. * Returns a string to use to update the GPU particles update shader
  91517. * @returns a string containng the defines string
  91518. */
  91519. getEffectDefines(): string;
  91520. /**
  91521. * Returns the string "PointParticleEmitter"
  91522. * @returns a string containing the class name
  91523. */
  91524. getClassName(): string;
  91525. /**
  91526. * Serializes the particle system to a JSON object.
  91527. * @returns the JSON object
  91528. */
  91529. serialize(): any;
  91530. /**
  91531. * Parse properties from a JSON object
  91532. * @param serializationObject defines the JSON object
  91533. */
  91534. parse(serializationObject: any): void;
  91535. }
  91536. }
  91537. declare module BABYLON {
  91538. /**
  91539. * Particle emitter emitting particles from the inside of a box.
  91540. * It emits the particles randomly between 2 given directions.
  91541. */
  91542. export class MeshParticleEmitter implements IParticleEmitterType {
  91543. private _indices;
  91544. private _positions;
  91545. private _normals;
  91546. private _storedNormal;
  91547. private _mesh;
  91548. /**
  91549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91550. */
  91551. direction1: Vector3;
  91552. /**
  91553. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91554. */
  91555. direction2: Vector3;
  91556. /**
  91557. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91558. */
  91559. useMeshNormalsForDirection: boolean;
  91560. /** Defines the mesh to use as source */
  91561. get mesh(): Nullable<AbstractMesh>;
  91562. set mesh(value: Nullable<AbstractMesh>);
  91563. /**
  91564. * Creates a new instance MeshParticleEmitter
  91565. * @param mesh defines the mesh to use as source
  91566. */
  91567. constructor(mesh?: Nullable<AbstractMesh>);
  91568. /**
  91569. * Called by the particle System when the direction is computed for the created particle.
  91570. * @param worldMatrix is the world matrix of the particle system
  91571. * @param directionToUpdate is the direction vector to update with the result
  91572. * @param particle is the particle we are computed the direction for
  91573. * @param isLocal defines if the direction should be set in local space
  91574. */
  91575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91576. /**
  91577. * Called by the particle System when the position is computed for the created particle.
  91578. * @param worldMatrix is the world matrix of the particle system
  91579. * @param positionToUpdate is the position vector to update with the result
  91580. * @param particle is the particle we are computed the position for
  91581. * @param isLocal defines if the position should be set in local space
  91582. */
  91583. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91584. /**
  91585. * Clones the current emitter and returns a copy of it
  91586. * @returns the new emitter
  91587. */
  91588. clone(): MeshParticleEmitter;
  91589. /**
  91590. * Called by the GPUParticleSystem to setup the update shader
  91591. * @param effect defines the update shader
  91592. */
  91593. applyToShader(effect: Effect): void;
  91594. /**
  91595. * Returns a string to use to update the GPU particles update shader
  91596. * @returns a string containng the defines string
  91597. */
  91598. getEffectDefines(): string;
  91599. /**
  91600. * Returns the string "BoxParticleEmitter"
  91601. * @returns a string containing the class name
  91602. */
  91603. getClassName(): string;
  91604. /**
  91605. * Serializes the particle system to a JSON object.
  91606. * @returns the JSON object
  91607. */
  91608. serialize(): any;
  91609. /**
  91610. * Parse properties from a JSON object
  91611. * @param serializationObject defines the JSON object
  91612. * @param scene defines the hosting scene
  91613. */
  91614. parse(serializationObject: any, scene: Scene): void;
  91615. }
  91616. }
  91617. declare module BABYLON {
  91618. /**
  91619. * Interface representing a particle system in Babylon.js.
  91620. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91621. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91622. */
  91623. export interface IParticleSystem {
  91624. /**
  91625. * List of animations used by the particle system.
  91626. */
  91627. animations: Animation[];
  91628. /**
  91629. * The id of the Particle system.
  91630. */
  91631. id: string;
  91632. /**
  91633. * The name of the Particle system.
  91634. */
  91635. name: string;
  91636. /**
  91637. * The emitter represents the Mesh or position we are attaching the particle system to.
  91638. */
  91639. emitter: Nullable<AbstractMesh | Vector3>;
  91640. /**
  91641. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91642. */
  91643. isBillboardBased: boolean;
  91644. /**
  91645. * The rendering group used by the Particle system to chose when to render.
  91646. */
  91647. renderingGroupId: number;
  91648. /**
  91649. * The layer mask we are rendering the particles through.
  91650. */
  91651. layerMask: number;
  91652. /**
  91653. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91654. */
  91655. updateSpeed: number;
  91656. /**
  91657. * The amount of time the particle system is running (depends of the overall update speed).
  91658. */
  91659. targetStopDuration: number;
  91660. /**
  91661. * The texture used to render each particle. (this can be a spritesheet)
  91662. */
  91663. particleTexture: Nullable<Texture>;
  91664. /**
  91665. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91666. */
  91667. blendMode: number;
  91668. /**
  91669. * Minimum life time of emitting particles.
  91670. */
  91671. minLifeTime: number;
  91672. /**
  91673. * Maximum life time of emitting particles.
  91674. */
  91675. maxLifeTime: number;
  91676. /**
  91677. * Minimum Size of emitting particles.
  91678. */
  91679. minSize: number;
  91680. /**
  91681. * Maximum Size of emitting particles.
  91682. */
  91683. maxSize: number;
  91684. /**
  91685. * Minimum scale of emitting particles on X axis.
  91686. */
  91687. minScaleX: number;
  91688. /**
  91689. * Maximum scale of emitting particles on X axis.
  91690. */
  91691. maxScaleX: number;
  91692. /**
  91693. * Minimum scale of emitting particles on Y axis.
  91694. */
  91695. minScaleY: number;
  91696. /**
  91697. * Maximum scale of emitting particles on Y axis.
  91698. */
  91699. maxScaleY: number;
  91700. /**
  91701. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91702. */
  91703. color1: Color4;
  91704. /**
  91705. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91706. */
  91707. color2: Color4;
  91708. /**
  91709. * Color the particle will have at the end of its lifetime.
  91710. */
  91711. colorDead: Color4;
  91712. /**
  91713. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91714. */
  91715. emitRate: number;
  91716. /**
  91717. * You can use gravity if you want to give an orientation to your particles.
  91718. */
  91719. gravity: Vector3;
  91720. /**
  91721. * Minimum power of emitting particles.
  91722. */
  91723. minEmitPower: number;
  91724. /**
  91725. * Maximum power of emitting particles.
  91726. */
  91727. maxEmitPower: number;
  91728. /**
  91729. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91730. */
  91731. minAngularSpeed: number;
  91732. /**
  91733. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91734. */
  91735. maxAngularSpeed: number;
  91736. /**
  91737. * Gets or sets the minimal initial rotation in radians.
  91738. */
  91739. minInitialRotation: number;
  91740. /**
  91741. * Gets or sets the maximal initial rotation in radians.
  91742. */
  91743. maxInitialRotation: number;
  91744. /**
  91745. * The particle emitter type defines the emitter used by the particle system.
  91746. * It can be for example box, sphere, or cone...
  91747. */
  91748. particleEmitterType: Nullable<IParticleEmitterType>;
  91749. /**
  91750. * Defines the delay in milliseconds before starting the system (0 by default)
  91751. */
  91752. startDelay: number;
  91753. /**
  91754. * 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
  91755. */
  91756. preWarmCycles: number;
  91757. /**
  91758. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91759. */
  91760. preWarmStepOffset: number;
  91761. /**
  91762. * 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)
  91763. */
  91764. spriteCellChangeSpeed: number;
  91765. /**
  91766. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91767. */
  91768. startSpriteCellID: number;
  91769. /**
  91770. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91771. */
  91772. endSpriteCellID: number;
  91773. /**
  91774. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91775. */
  91776. spriteCellWidth: number;
  91777. /**
  91778. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91779. */
  91780. spriteCellHeight: number;
  91781. /**
  91782. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91783. */
  91784. spriteRandomStartCell: boolean;
  91785. /**
  91786. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91787. */
  91788. isAnimationSheetEnabled: boolean;
  91789. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91790. translationPivot: Vector2;
  91791. /**
  91792. * Gets or sets a texture used to add random noise to particle positions
  91793. */
  91794. noiseTexture: Nullable<BaseTexture>;
  91795. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91796. noiseStrength: Vector3;
  91797. /**
  91798. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91799. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91800. */
  91801. billboardMode: number;
  91802. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91803. limitVelocityDamping: number;
  91804. /**
  91805. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91806. */
  91807. beginAnimationOnStart: boolean;
  91808. /**
  91809. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91810. */
  91811. beginAnimationFrom: number;
  91812. /**
  91813. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91814. */
  91815. beginAnimationTo: number;
  91816. /**
  91817. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91818. */
  91819. beginAnimationLoop: boolean;
  91820. /**
  91821. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91822. */
  91823. disposeOnStop: boolean;
  91824. /**
  91825. * Specifies if the particles are updated in emitter local space or world space
  91826. */
  91827. isLocal: boolean;
  91828. /** Snippet ID if the particle system was created from the snippet server */
  91829. snippetId: string;
  91830. /**
  91831. * Gets the maximum number of particles active at the same time.
  91832. * @returns The max number of active particles.
  91833. */
  91834. getCapacity(): number;
  91835. /**
  91836. * Gets the number of particles active at the same time.
  91837. * @returns The number of active particles.
  91838. */
  91839. getActiveCount(): number;
  91840. /**
  91841. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91842. * @returns True if it has been started, otherwise false.
  91843. */
  91844. isStarted(): boolean;
  91845. /**
  91846. * Animates the particle system for this frame.
  91847. */
  91848. animate(): void;
  91849. /**
  91850. * Renders the particle system in its current state.
  91851. * @returns the current number of particles
  91852. */
  91853. render(): number;
  91854. /**
  91855. * Dispose the particle system and frees its associated resources.
  91856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91857. */
  91858. dispose(disposeTexture?: boolean): void;
  91859. /**
  91860. * An event triggered when the system is disposed
  91861. */
  91862. onDisposeObservable: Observable<IParticleSystem>;
  91863. /**
  91864. * Clones the particle system.
  91865. * @param name The name of the cloned object
  91866. * @param newEmitter The new emitter to use
  91867. * @returns the cloned particle system
  91868. */
  91869. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91870. /**
  91871. * Serializes the particle system to a JSON object
  91872. * @param serializeTexture defines if the texture must be serialized as well
  91873. * @returns the JSON object
  91874. */
  91875. serialize(serializeTexture: boolean): any;
  91876. /**
  91877. * Rebuild the particle system
  91878. */
  91879. rebuild(): void;
  91880. /** Force the system to rebuild all gradients that need to be resync */
  91881. forceRefreshGradients(): void;
  91882. /**
  91883. * Starts the particle system and begins to emit
  91884. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91885. */
  91886. start(delay?: number): void;
  91887. /**
  91888. * Stops the particle system.
  91889. */
  91890. stop(): void;
  91891. /**
  91892. * Remove all active particles
  91893. */
  91894. reset(): void;
  91895. /**
  91896. * Gets a boolean indicating that the system is stopping
  91897. * @returns true if the system is currently stopping
  91898. */
  91899. isStopping(): boolean;
  91900. /**
  91901. * Is this system ready to be used/rendered
  91902. * @return true if the system is ready
  91903. */
  91904. isReady(): boolean;
  91905. /**
  91906. * Returns the string "ParticleSystem"
  91907. * @returns a string containing the class name
  91908. */
  91909. getClassName(): string;
  91910. /**
  91911. * Gets the custom effect used to render the particles
  91912. * @param blendMode Blend mode for which the effect should be retrieved
  91913. * @returns The effect
  91914. */
  91915. getCustomEffect(blendMode: number): Nullable<Effect>;
  91916. /**
  91917. * Sets the custom effect used to render the particles
  91918. * @param effect The effect to set
  91919. * @param blendMode Blend mode for which the effect should be set
  91920. */
  91921. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91922. /**
  91923. * Fill the defines array according to the current settings of the particle system
  91924. * @param defines Array to be updated
  91925. * @param blendMode blend mode to take into account when updating the array
  91926. */
  91927. fillDefines(defines: Array<string>, blendMode: number): void;
  91928. /**
  91929. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91930. * @param uniforms Uniforms array to fill
  91931. * @param attributes Attributes array to fill
  91932. * @param samplers Samplers array to fill
  91933. */
  91934. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91935. /**
  91936. * Observable that will be called just before the particles are drawn
  91937. */
  91938. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91939. /**
  91940. * Gets the name of the particle vertex shader
  91941. */
  91942. vertexShaderName: string;
  91943. /**
  91944. * Adds a new color gradient
  91945. * @param gradient defines the gradient to use (between 0 and 1)
  91946. * @param color1 defines the color to affect to the specified gradient
  91947. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91948. * @returns the current particle system
  91949. */
  91950. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91951. /**
  91952. * Remove a specific color gradient
  91953. * @param gradient defines the gradient to remove
  91954. * @returns the current particle system
  91955. */
  91956. removeColorGradient(gradient: number): IParticleSystem;
  91957. /**
  91958. * Adds a new size gradient
  91959. * @param gradient defines the gradient to use (between 0 and 1)
  91960. * @param factor defines the size factor to affect to the specified gradient
  91961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91962. * @returns the current particle system
  91963. */
  91964. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91965. /**
  91966. * Remove a specific size gradient
  91967. * @param gradient defines the gradient to remove
  91968. * @returns the current particle system
  91969. */
  91970. removeSizeGradient(gradient: number): IParticleSystem;
  91971. /**
  91972. * Gets the current list of color gradients.
  91973. * You must use addColorGradient and removeColorGradient to udpate this list
  91974. * @returns the list of color gradients
  91975. */
  91976. getColorGradients(): Nullable<Array<ColorGradient>>;
  91977. /**
  91978. * Gets the current list of size gradients.
  91979. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91980. * @returns the list of size gradients
  91981. */
  91982. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91983. /**
  91984. * Gets the current list of angular speed gradients.
  91985. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91986. * @returns the list of angular speed gradients
  91987. */
  91988. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91989. /**
  91990. * Adds a new angular speed gradient
  91991. * @param gradient defines the gradient to use (between 0 and 1)
  91992. * @param factor defines the angular speed to affect to the specified gradient
  91993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91994. * @returns the current particle system
  91995. */
  91996. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91997. /**
  91998. * Remove a specific angular speed gradient
  91999. * @param gradient defines the gradient to remove
  92000. * @returns the current particle system
  92001. */
  92002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92003. /**
  92004. * Gets the current list of velocity gradients.
  92005. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92006. * @returns the list of velocity gradients
  92007. */
  92008. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92009. /**
  92010. * Adds a new velocity gradient
  92011. * @param gradient defines the gradient to use (between 0 and 1)
  92012. * @param factor defines the velocity to affect to the specified gradient
  92013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92014. * @returns the current particle system
  92015. */
  92016. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92017. /**
  92018. * Remove a specific velocity gradient
  92019. * @param gradient defines the gradient to remove
  92020. * @returns the current particle system
  92021. */
  92022. removeVelocityGradient(gradient: number): IParticleSystem;
  92023. /**
  92024. * Gets the current list of limit velocity gradients.
  92025. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92026. * @returns the list of limit velocity gradients
  92027. */
  92028. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92029. /**
  92030. * Adds a new limit velocity gradient
  92031. * @param gradient defines the gradient to use (between 0 and 1)
  92032. * @param factor defines the limit velocity to affect to the specified gradient
  92033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92034. * @returns the current particle system
  92035. */
  92036. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92037. /**
  92038. * Remove a specific limit velocity gradient
  92039. * @param gradient defines the gradient to remove
  92040. * @returns the current particle system
  92041. */
  92042. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92043. /**
  92044. * Adds a new drag gradient
  92045. * @param gradient defines the gradient to use (between 0 and 1)
  92046. * @param factor defines the drag to affect to the specified gradient
  92047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92048. * @returns the current particle system
  92049. */
  92050. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92051. /**
  92052. * Remove a specific drag gradient
  92053. * @param gradient defines the gradient to remove
  92054. * @returns the current particle system
  92055. */
  92056. removeDragGradient(gradient: number): IParticleSystem;
  92057. /**
  92058. * Gets the current list of drag gradients.
  92059. * You must use addDragGradient and removeDragGradient to udpate this list
  92060. * @returns the list of drag gradients
  92061. */
  92062. getDragGradients(): Nullable<Array<FactorGradient>>;
  92063. /**
  92064. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92065. * @param gradient defines the gradient to use (between 0 and 1)
  92066. * @param factor defines the emit rate to affect to the specified gradient
  92067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92068. * @returns the current particle system
  92069. */
  92070. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92071. /**
  92072. * Remove a specific emit rate gradient
  92073. * @param gradient defines the gradient to remove
  92074. * @returns the current particle system
  92075. */
  92076. removeEmitRateGradient(gradient: number): IParticleSystem;
  92077. /**
  92078. * Gets the current list of emit rate gradients.
  92079. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92080. * @returns the list of emit rate gradients
  92081. */
  92082. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92083. /**
  92084. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92085. * @param gradient defines the gradient to use (between 0 and 1)
  92086. * @param factor defines the start size to affect to the specified gradient
  92087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92088. * @returns the current particle system
  92089. */
  92090. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92091. /**
  92092. * Remove a specific start size gradient
  92093. * @param gradient defines the gradient to remove
  92094. * @returns the current particle system
  92095. */
  92096. removeStartSizeGradient(gradient: number): IParticleSystem;
  92097. /**
  92098. * Gets the current list of start size gradients.
  92099. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92100. * @returns the list of start size gradients
  92101. */
  92102. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92103. /**
  92104. * Adds a new life time gradient
  92105. * @param gradient defines the gradient to use (between 0 and 1)
  92106. * @param factor defines the life time factor to affect to the specified gradient
  92107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92108. * @returns the current particle system
  92109. */
  92110. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92111. /**
  92112. * Remove a specific life time gradient
  92113. * @param gradient defines the gradient to remove
  92114. * @returns the current particle system
  92115. */
  92116. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92117. /**
  92118. * Gets the current list of life time gradients.
  92119. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92120. * @returns the list of life time gradients
  92121. */
  92122. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92123. /**
  92124. * Gets the current list of color gradients.
  92125. * You must use addColorGradient and removeColorGradient to udpate this list
  92126. * @returns the list of color gradients
  92127. */
  92128. getColorGradients(): Nullable<Array<ColorGradient>>;
  92129. /**
  92130. * Adds a new ramp gradient used to remap particle colors
  92131. * @param gradient defines the gradient to use (between 0 and 1)
  92132. * @param color defines the color to affect to the specified gradient
  92133. * @returns the current particle system
  92134. */
  92135. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92136. /**
  92137. * Gets the current list of ramp gradients.
  92138. * You must use addRampGradient and removeRampGradient to udpate this list
  92139. * @returns the list of ramp gradients
  92140. */
  92141. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92142. /** Gets or sets a boolean indicating that ramp gradients must be used
  92143. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92144. */
  92145. useRampGradients: boolean;
  92146. /**
  92147. * Adds a new color remap gradient
  92148. * @param gradient defines the gradient to use (between 0 and 1)
  92149. * @param min defines the color remap minimal range
  92150. * @param max defines the color remap maximal range
  92151. * @returns the current particle system
  92152. */
  92153. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92154. /**
  92155. * Gets the current list of color remap gradients.
  92156. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92157. * @returns the list of color remap gradients
  92158. */
  92159. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92160. /**
  92161. * Adds a new alpha remap gradient
  92162. * @param gradient defines the gradient to use (between 0 and 1)
  92163. * @param min defines the alpha remap minimal range
  92164. * @param max defines the alpha remap maximal range
  92165. * @returns the current particle system
  92166. */
  92167. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92168. /**
  92169. * Gets the current list of alpha remap gradients.
  92170. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92171. * @returns the list of alpha remap gradients
  92172. */
  92173. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92174. /**
  92175. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92176. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92177. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92178. * @returns the emitter
  92179. */
  92180. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92181. /**
  92182. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92183. * @param radius The radius of the hemisphere to emit from
  92184. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92185. * @returns the emitter
  92186. */
  92187. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92188. /**
  92189. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92190. * @param radius The radius of the sphere to emit from
  92191. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92192. * @returns the emitter
  92193. */
  92194. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92195. /**
  92196. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92197. * @param radius The radius of the sphere to emit from
  92198. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92199. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92200. * @returns the emitter
  92201. */
  92202. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92203. /**
  92204. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92205. * @param radius The radius of the emission cylinder
  92206. * @param height The height of the emission cylinder
  92207. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92208. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92209. * @returns the emitter
  92210. */
  92211. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92212. /**
  92213. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92214. * @param radius The radius of the cylinder to emit from
  92215. * @param height The height of the emission cylinder
  92216. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92217. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92218. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92219. * @returns the emitter
  92220. */
  92221. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92222. /**
  92223. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92224. * @param radius The radius of the cone to emit from
  92225. * @param angle The base angle of the cone
  92226. * @returns the emitter
  92227. */
  92228. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92229. /**
  92230. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92231. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92232. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92233. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92234. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92235. * @returns the emitter
  92236. */
  92237. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92238. /**
  92239. * Get hosting scene
  92240. * @returns the scene
  92241. */
  92242. getScene(): Scene;
  92243. }
  92244. }
  92245. declare module BABYLON {
  92246. /**
  92247. * 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.
  92248. * @see https://doc.babylonjs.com/how_to/transformnode
  92249. */
  92250. export class TransformNode extends Node {
  92251. /**
  92252. * Object will not rotate to face the camera
  92253. */
  92254. static BILLBOARDMODE_NONE: number;
  92255. /**
  92256. * Object will rotate to face the camera but only on the x axis
  92257. */
  92258. static BILLBOARDMODE_X: number;
  92259. /**
  92260. * Object will rotate to face the camera but only on the y axis
  92261. */
  92262. static BILLBOARDMODE_Y: number;
  92263. /**
  92264. * Object will rotate to face the camera but only on the z axis
  92265. */
  92266. static BILLBOARDMODE_Z: number;
  92267. /**
  92268. * Object will rotate to face the camera
  92269. */
  92270. static BILLBOARDMODE_ALL: number;
  92271. /**
  92272. * Object will rotate to face the camera's position instead of orientation
  92273. */
  92274. static BILLBOARDMODE_USE_POSITION: number;
  92275. private static _TmpRotation;
  92276. private static _TmpScaling;
  92277. private static _TmpTranslation;
  92278. private _forward;
  92279. private _forwardInverted;
  92280. private _up;
  92281. private _right;
  92282. private _rightInverted;
  92283. private _position;
  92284. private _rotation;
  92285. private _rotationQuaternion;
  92286. protected _scaling: Vector3;
  92287. protected _isDirty: boolean;
  92288. private _transformToBoneReferal;
  92289. private _isAbsoluteSynced;
  92290. private _billboardMode;
  92291. /**
  92292. * Gets or sets the billboard mode. Default is 0.
  92293. *
  92294. * | Value | Type | Description |
  92295. * | --- | --- | --- |
  92296. * | 0 | BILLBOARDMODE_NONE | |
  92297. * | 1 | BILLBOARDMODE_X | |
  92298. * | 2 | BILLBOARDMODE_Y | |
  92299. * | 4 | BILLBOARDMODE_Z | |
  92300. * | 7 | BILLBOARDMODE_ALL | |
  92301. *
  92302. */
  92303. get billboardMode(): number;
  92304. set billboardMode(value: number);
  92305. private _preserveParentRotationForBillboard;
  92306. /**
  92307. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92308. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92309. */
  92310. get preserveParentRotationForBillboard(): boolean;
  92311. set preserveParentRotationForBillboard(value: boolean);
  92312. /**
  92313. * 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
  92314. */
  92315. scalingDeterminant: number;
  92316. private _infiniteDistance;
  92317. /**
  92318. * Gets or sets the distance of the object to max, often used by skybox
  92319. */
  92320. get infiniteDistance(): boolean;
  92321. set infiniteDistance(value: boolean);
  92322. /**
  92323. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92324. * By default the system will update normals to compensate
  92325. */
  92326. ignoreNonUniformScaling: boolean;
  92327. /**
  92328. * 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
  92329. */
  92330. reIntegrateRotationIntoRotationQuaternion: boolean;
  92331. /** @hidden */
  92332. _poseMatrix: Nullable<Matrix>;
  92333. /** @hidden */
  92334. _localMatrix: Matrix;
  92335. private _usePivotMatrix;
  92336. private _absolutePosition;
  92337. private _absoluteScaling;
  92338. private _absoluteRotationQuaternion;
  92339. private _pivotMatrix;
  92340. private _pivotMatrixInverse;
  92341. protected _postMultiplyPivotMatrix: boolean;
  92342. protected _isWorldMatrixFrozen: boolean;
  92343. /** @hidden */
  92344. _indexInSceneTransformNodesArray: number;
  92345. /**
  92346. * An event triggered after the world matrix is updated
  92347. */
  92348. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92349. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92350. /**
  92351. * Gets a string identifying the name of the class
  92352. * @returns "TransformNode" string
  92353. */
  92354. getClassName(): string;
  92355. /**
  92356. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92357. */
  92358. get position(): Vector3;
  92359. set position(newPosition: Vector3);
  92360. /**
  92361. * 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)).
  92362. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92363. */
  92364. get rotation(): Vector3;
  92365. set rotation(newRotation: Vector3);
  92366. /**
  92367. * 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)).
  92368. */
  92369. get scaling(): Vector3;
  92370. set scaling(newScaling: Vector3);
  92371. /**
  92372. * 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).
  92373. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92374. */
  92375. get rotationQuaternion(): Nullable<Quaternion>;
  92376. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92377. /**
  92378. * The forward direction of that transform in world space.
  92379. */
  92380. get forward(): Vector3;
  92381. /**
  92382. * The up direction of that transform in world space.
  92383. */
  92384. get up(): Vector3;
  92385. /**
  92386. * The right direction of that transform in world space.
  92387. */
  92388. get right(): Vector3;
  92389. /**
  92390. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92391. * @param matrix the matrix to copy the pose from
  92392. * @returns this TransformNode.
  92393. */
  92394. updatePoseMatrix(matrix: Matrix): TransformNode;
  92395. /**
  92396. * Returns the mesh Pose matrix.
  92397. * @returns the pose matrix
  92398. */
  92399. getPoseMatrix(): Matrix;
  92400. /** @hidden */
  92401. _isSynchronized(): boolean;
  92402. /** @hidden */
  92403. _initCache(): void;
  92404. /**
  92405. * Flag the transform node as dirty (Forcing it to update everything)
  92406. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92407. * @returns this transform node
  92408. */
  92409. markAsDirty(property: string): TransformNode;
  92410. /**
  92411. * Returns the current mesh absolute position.
  92412. * Returns a Vector3.
  92413. */
  92414. get absolutePosition(): Vector3;
  92415. /**
  92416. * Returns the current mesh absolute scaling.
  92417. * Returns a Vector3.
  92418. */
  92419. get absoluteScaling(): Vector3;
  92420. /**
  92421. * Returns the current mesh absolute rotation.
  92422. * Returns a Quaternion.
  92423. */
  92424. get absoluteRotationQuaternion(): Quaternion;
  92425. /**
  92426. * Sets a new matrix to apply before all other transformation
  92427. * @param matrix defines the transform matrix
  92428. * @returns the current TransformNode
  92429. */
  92430. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92431. /**
  92432. * Sets a new pivot matrix to the current node
  92433. * @param matrix defines the new pivot matrix to use
  92434. * @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
  92435. * @returns the current TransformNode
  92436. */
  92437. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92438. /**
  92439. * Returns the mesh pivot matrix.
  92440. * Default : Identity.
  92441. * @returns the matrix
  92442. */
  92443. getPivotMatrix(): Matrix;
  92444. /**
  92445. * Instantiate (when possible) or clone that node with its hierarchy
  92446. * @param newParent defines the new parent to use for the instance (or clone)
  92447. * @param options defines options to configure how copy is done
  92448. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92449. * @returns an instance (or a clone) of the current node with its hiearchy
  92450. */
  92451. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92452. doNotInstantiate: boolean;
  92453. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92454. /**
  92455. * Prevents the World matrix to be computed any longer
  92456. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92457. * @returns the TransformNode.
  92458. */
  92459. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92460. /**
  92461. * Allows back the World matrix computation.
  92462. * @returns the TransformNode.
  92463. */
  92464. unfreezeWorldMatrix(): this;
  92465. /**
  92466. * True if the World matrix has been frozen.
  92467. */
  92468. get isWorldMatrixFrozen(): boolean;
  92469. /**
  92470. * Retuns the mesh absolute position in the World.
  92471. * @returns a Vector3.
  92472. */
  92473. getAbsolutePosition(): Vector3;
  92474. /**
  92475. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92476. * @param absolutePosition the absolute position to set
  92477. * @returns the TransformNode.
  92478. */
  92479. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92480. /**
  92481. * Sets the mesh position in its local space.
  92482. * @param vector3 the position to set in localspace
  92483. * @returns the TransformNode.
  92484. */
  92485. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92486. /**
  92487. * Returns the mesh position in the local space from the current World matrix values.
  92488. * @returns a new Vector3.
  92489. */
  92490. getPositionExpressedInLocalSpace(): Vector3;
  92491. /**
  92492. * Translates the mesh along the passed Vector3 in its local space.
  92493. * @param vector3 the distance to translate in localspace
  92494. * @returns the TransformNode.
  92495. */
  92496. locallyTranslate(vector3: Vector3): TransformNode;
  92497. private static _lookAtVectorCache;
  92498. /**
  92499. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92500. * @param targetPoint the position (must be in same space as current mesh) to look at
  92501. * @param yawCor optional yaw (y-axis) correction in radians
  92502. * @param pitchCor optional pitch (x-axis) correction in radians
  92503. * @param rollCor optional roll (z-axis) correction in radians
  92504. * @param space the choosen space of the target
  92505. * @returns the TransformNode.
  92506. */
  92507. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92508. /**
  92509. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92510. * This Vector3 is expressed in the World space.
  92511. * @param localAxis axis to rotate
  92512. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92513. */
  92514. getDirection(localAxis: Vector3): Vector3;
  92515. /**
  92516. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92517. * localAxis is expressed in the mesh local space.
  92518. * result is computed in the Wordl space from the mesh World matrix.
  92519. * @param localAxis axis to rotate
  92520. * @param result the resulting transformnode
  92521. * @returns this TransformNode.
  92522. */
  92523. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92524. /**
  92525. * Sets this transform node rotation to the given local axis.
  92526. * @param localAxis the axis in local space
  92527. * @param yawCor optional yaw (y-axis) correction in radians
  92528. * @param pitchCor optional pitch (x-axis) correction in radians
  92529. * @param rollCor optional roll (z-axis) correction in radians
  92530. * @returns this TransformNode
  92531. */
  92532. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92533. /**
  92534. * Sets a new pivot point to the current node
  92535. * @param point defines the new pivot point to use
  92536. * @param space defines if the point is in world or local space (local by default)
  92537. * @returns the current TransformNode
  92538. */
  92539. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92540. /**
  92541. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92542. * @returns the pivot point
  92543. */
  92544. getPivotPoint(): Vector3;
  92545. /**
  92546. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92547. * @param result the vector3 to store the result
  92548. * @returns this TransformNode.
  92549. */
  92550. getPivotPointToRef(result: Vector3): TransformNode;
  92551. /**
  92552. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92553. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92554. */
  92555. getAbsolutePivotPoint(): Vector3;
  92556. /**
  92557. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92558. * @param result vector3 to store the result
  92559. * @returns this TransformNode.
  92560. */
  92561. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92562. /**
  92563. * Defines the passed node as the parent of the current node.
  92564. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92565. * @see https://doc.babylonjs.com/how_to/parenting
  92566. * @param node the node ot set as the parent
  92567. * @returns this TransformNode.
  92568. */
  92569. setParent(node: Nullable<Node>): TransformNode;
  92570. private _nonUniformScaling;
  92571. /**
  92572. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92573. */
  92574. get nonUniformScaling(): boolean;
  92575. /** @hidden */
  92576. _updateNonUniformScalingState(value: boolean): boolean;
  92577. /**
  92578. * Attach the current TransformNode to another TransformNode associated with a bone
  92579. * @param bone Bone affecting the TransformNode
  92580. * @param affectedTransformNode TransformNode associated with the bone
  92581. * @returns this object
  92582. */
  92583. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92584. /**
  92585. * Detach the transform node if its associated with a bone
  92586. * @returns this object
  92587. */
  92588. detachFromBone(): TransformNode;
  92589. private static _rotationAxisCache;
  92590. /**
  92591. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92592. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92593. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92594. * The passed axis is also normalized.
  92595. * @param axis the axis to rotate around
  92596. * @param amount the amount to rotate in radians
  92597. * @param space Space to rotate in (Default: local)
  92598. * @returns the TransformNode.
  92599. */
  92600. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92601. /**
  92602. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92603. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92604. * The passed axis is also normalized. .
  92605. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92606. * @param point the point to rotate around
  92607. * @param axis the axis to rotate around
  92608. * @param amount the amount to rotate in radians
  92609. * @returns the TransformNode
  92610. */
  92611. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92612. /**
  92613. * Translates the mesh along the axis vector for the passed distance in the given space.
  92614. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92615. * @param axis the axis to translate in
  92616. * @param distance the distance to translate
  92617. * @param space Space to rotate in (Default: local)
  92618. * @returns the TransformNode.
  92619. */
  92620. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92621. /**
  92622. * Adds a rotation step to the mesh current rotation.
  92623. * x, y, z are Euler angles expressed in radians.
  92624. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92625. * This means this rotation is made in the mesh local space only.
  92626. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92627. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92628. * ```javascript
  92629. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92630. * ```
  92631. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92632. * 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.
  92633. * @param x Rotation to add
  92634. * @param y Rotation to add
  92635. * @param z Rotation to add
  92636. * @returns the TransformNode.
  92637. */
  92638. addRotation(x: number, y: number, z: number): TransformNode;
  92639. /**
  92640. * @hidden
  92641. */
  92642. protected _getEffectiveParent(): Nullable<Node>;
  92643. /**
  92644. * Computes the world matrix of the node
  92645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92646. * @returns the world matrix
  92647. */
  92648. computeWorldMatrix(force?: boolean): Matrix;
  92649. /**
  92650. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92651. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92652. */
  92653. resetLocalMatrix(independentOfChildren?: boolean): void;
  92654. protected _afterComputeWorldMatrix(): void;
  92655. /**
  92656. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92657. * @param func callback function to add
  92658. *
  92659. * @returns the TransformNode.
  92660. */
  92661. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92662. /**
  92663. * Removes a registered callback function.
  92664. * @param func callback function to remove
  92665. * @returns the TransformNode.
  92666. */
  92667. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92668. /**
  92669. * Gets the position of the current mesh in camera space
  92670. * @param camera defines the camera to use
  92671. * @returns a position
  92672. */
  92673. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92674. /**
  92675. * Returns the distance from the mesh to the active camera
  92676. * @param camera defines the camera to use
  92677. * @returns the distance
  92678. */
  92679. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92680. /**
  92681. * Clone the current transform node
  92682. * @param name Name of the new clone
  92683. * @param newParent New parent for the clone
  92684. * @param doNotCloneChildren Do not clone children hierarchy
  92685. * @returns the new transform node
  92686. */
  92687. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92688. /**
  92689. * Serializes the objects information.
  92690. * @param currentSerializationObject defines the object to serialize in
  92691. * @returns the serialized object
  92692. */
  92693. serialize(currentSerializationObject?: any): any;
  92694. /**
  92695. * Returns a new TransformNode object parsed from the source provided.
  92696. * @param parsedTransformNode is the source.
  92697. * @param scene the scne the object belongs to
  92698. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92699. * @returns a new TransformNode object parsed from the source provided.
  92700. */
  92701. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92702. /**
  92703. * Get all child-transformNodes of this node
  92704. * @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
  92705. * @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
  92706. * @returns an array of TransformNode
  92707. */
  92708. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92709. /**
  92710. * Releases resources associated with this transform node.
  92711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92713. */
  92714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92715. /**
  92716. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92717. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92718. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92719. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92720. * @returns the current mesh
  92721. */
  92722. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92723. private _syncAbsoluteScalingAndRotation;
  92724. }
  92725. }
  92726. declare module BABYLON {
  92727. /**
  92728. * Class used to override all child animations of a given target
  92729. */
  92730. export class AnimationPropertiesOverride {
  92731. /**
  92732. * Gets or sets a value indicating if animation blending must be used
  92733. */
  92734. enableBlending: boolean;
  92735. /**
  92736. * Gets or sets the blending speed to use when enableBlending is true
  92737. */
  92738. blendingSpeed: number;
  92739. /**
  92740. * Gets or sets the default loop mode to use
  92741. */
  92742. loopMode: number;
  92743. }
  92744. }
  92745. declare module BABYLON {
  92746. /**
  92747. * Class used to store bone information
  92748. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92749. */
  92750. export class Bone extends Node {
  92751. /**
  92752. * defines the bone name
  92753. */
  92754. name: string;
  92755. private static _tmpVecs;
  92756. private static _tmpQuat;
  92757. private static _tmpMats;
  92758. /**
  92759. * Gets the list of child bones
  92760. */
  92761. children: Bone[];
  92762. /** Gets the animations associated with this bone */
  92763. animations: Animation[];
  92764. /**
  92765. * Gets or sets bone length
  92766. */
  92767. length: number;
  92768. /**
  92769. * @hidden Internal only
  92770. * Set this value to map this bone to a different index in the transform matrices
  92771. * Set this value to -1 to exclude the bone from the transform matrices
  92772. */
  92773. _index: Nullable<number>;
  92774. private _skeleton;
  92775. private _localMatrix;
  92776. private _restPose;
  92777. private _baseMatrix;
  92778. private _absoluteTransform;
  92779. private _invertedAbsoluteTransform;
  92780. private _parent;
  92781. private _scalingDeterminant;
  92782. private _worldTransform;
  92783. private _localScaling;
  92784. private _localRotation;
  92785. private _localPosition;
  92786. private _needToDecompose;
  92787. private _needToCompose;
  92788. /** @hidden */
  92789. _linkedTransformNode: Nullable<TransformNode>;
  92790. /** @hidden */
  92791. _waitingTransformNodeId: Nullable<string>;
  92792. /** @hidden */
  92793. get _matrix(): Matrix;
  92794. /** @hidden */
  92795. set _matrix(value: Matrix);
  92796. /**
  92797. * Create a new bone
  92798. * @param name defines the bone name
  92799. * @param skeleton defines the parent skeleton
  92800. * @param parentBone defines the parent (can be null if the bone is the root)
  92801. * @param localMatrix defines the local matrix
  92802. * @param restPose defines the rest pose matrix
  92803. * @param baseMatrix defines the base matrix
  92804. * @param index defines index of the bone in the hiearchy
  92805. */
  92806. constructor(
  92807. /**
  92808. * defines the bone name
  92809. */
  92810. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92811. /**
  92812. * Gets the current object class name.
  92813. * @return the class name
  92814. */
  92815. getClassName(): string;
  92816. /**
  92817. * Gets the parent skeleton
  92818. * @returns a skeleton
  92819. */
  92820. getSkeleton(): Skeleton;
  92821. /**
  92822. * Gets parent bone
  92823. * @returns a bone or null if the bone is the root of the bone hierarchy
  92824. */
  92825. getParent(): Nullable<Bone>;
  92826. /**
  92827. * Returns an array containing the root bones
  92828. * @returns an array containing the root bones
  92829. */
  92830. getChildren(): Array<Bone>;
  92831. /**
  92832. * Gets the node index in matrix array generated for rendering
  92833. * @returns the node index
  92834. */
  92835. getIndex(): number;
  92836. /**
  92837. * Sets the parent bone
  92838. * @param parent defines the parent (can be null if the bone is the root)
  92839. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92840. */
  92841. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92842. /**
  92843. * Gets the local matrix
  92844. * @returns a matrix
  92845. */
  92846. getLocalMatrix(): Matrix;
  92847. /**
  92848. * Gets the base matrix (initial matrix which remains unchanged)
  92849. * @returns a matrix
  92850. */
  92851. getBaseMatrix(): Matrix;
  92852. /**
  92853. * Gets the rest pose matrix
  92854. * @returns a matrix
  92855. */
  92856. getRestPose(): Matrix;
  92857. /**
  92858. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92859. */
  92860. getWorldMatrix(): Matrix;
  92861. /**
  92862. * Sets the local matrix to rest pose matrix
  92863. */
  92864. returnToRest(): void;
  92865. /**
  92866. * Gets the inverse of the absolute transform matrix.
  92867. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92868. * @returns a matrix
  92869. */
  92870. getInvertedAbsoluteTransform(): Matrix;
  92871. /**
  92872. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92873. * @returns a matrix
  92874. */
  92875. getAbsoluteTransform(): Matrix;
  92876. /**
  92877. * Links with the given transform node.
  92878. * The local matrix of this bone is copied from the transform node every frame.
  92879. * @param transformNode defines the transform node to link to
  92880. */
  92881. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92882. /**
  92883. * Gets the node used to drive the bone's transformation
  92884. * @returns a transform node or null
  92885. */
  92886. getTransformNode(): Nullable<TransformNode>;
  92887. /** Gets or sets current position (in local space) */
  92888. get position(): Vector3;
  92889. set position(newPosition: Vector3);
  92890. /** Gets or sets current rotation (in local space) */
  92891. get rotation(): Vector3;
  92892. set rotation(newRotation: Vector3);
  92893. /** Gets or sets current rotation quaternion (in local space) */
  92894. get rotationQuaternion(): Quaternion;
  92895. set rotationQuaternion(newRotation: Quaternion);
  92896. /** Gets or sets current scaling (in local space) */
  92897. get scaling(): Vector3;
  92898. set scaling(newScaling: Vector3);
  92899. /**
  92900. * Gets the animation properties override
  92901. */
  92902. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92903. private _decompose;
  92904. private _compose;
  92905. /**
  92906. * Update the base and local matrices
  92907. * @param matrix defines the new base or local matrix
  92908. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92909. * @param updateLocalMatrix defines if the local matrix should be updated
  92910. */
  92911. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92912. /** @hidden */
  92913. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92914. /**
  92915. * Flag the bone as dirty (Forcing it to update everything)
  92916. */
  92917. markAsDirty(): void;
  92918. /** @hidden */
  92919. _markAsDirtyAndCompose(): void;
  92920. private _markAsDirtyAndDecompose;
  92921. /**
  92922. * Translate the bone in local or world space
  92923. * @param vec The amount to translate the bone
  92924. * @param space The space that the translation is in
  92925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92926. */
  92927. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92928. /**
  92929. * Set the postion of the bone in local or world space
  92930. * @param position The position to set the bone
  92931. * @param space The space that the position is in
  92932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92933. */
  92934. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92935. /**
  92936. * Set the absolute position of the bone (world space)
  92937. * @param position The position to set the bone
  92938. * @param mesh The mesh that this bone is attached to
  92939. */
  92940. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92941. /**
  92942. * Scale the bone on the x, y and z axes (in local space)
  92943. * @param x The amount to scale the bone on the x axis
  92944. * @param y The amount to scale the bone on the y axis
  92945. * @param z The amount to scale the bone on the z axis
  92946. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92947. */
  92948. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92949. /**
  92950. * Set the bone scaling in local space
  92951. * @param scale defines the scaling vector
  92952. */
  92953. setScale(scale: Vector3): void;
  92954. /**
  92955. * Gets the current scaling in local space
  92956. * @returns the current scaling vector
  92957. */
  92958. getScale(): Vector3;
  92959. /**
  92960. * Gets the current scaling in local space and stores it in a target vector
  92961. * @param result defines the target vector
  92962. */
  92963. getScaleToRef(result: Vector3): void;
  92964. /**
  92965. * Set the yaw, pitch, and roll of the bone in local or world space
  92966. * @param yaw The rotation of the bone on the y axis
  92967. * @param pitch The rotation of the bone on the x axis
  92968. * @param roll The rotation of the bone on the z axis
  92969. * @param space The space that the axes of rotation are in
  92970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92971. */
  92972. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92973. /**
  92974. * Add a rotation to the bone on an axis in local or world space
  92975. * @param axis The axis to rotate the bone on
  92976. * @param amount The amount to rotate the bone
  92977. * @param space The space that the axis is in
  92978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92979. */
  92980. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92981. /**
  92982. * Set the rotation of the bone to a particular axis angle in local or world space
  92983. * @param axis The axis to rotate the bone on
  92984. * @param angle The angle that the bone should be rotated to
  92985. * @param space The space that the axis is in
  92986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92987. */
  92988. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92989. /**
  92990. * Set the euler rotation of the bone in local of world space
  92991. * @param rotation The euler rotation that the bone should be set to
  92992. * @param space The space that the rotation is in
  92993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92994. */
  92995. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92996. /**
  92997. * Set the quaternion rotation of the bone in local of world space
  92998. * @param quat The quaternion rotation that the bone should be set to
  92999. * @param space The space that the rotation is in
  93000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93001. */
  93002. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93003. /**
  93004. * Set the rotation matrix of the bone in local of world space
  93005. * @param rotMat The rotation matrix that the bone should be set to
  93006. * @param space The space that the rotation is in
  93007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93008. */
  93009. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93010. private _rotateWithMatrix;
  93011. private _getNegativeRotationToRef;
  93012. /**
  93013. * Get the position of the bone in local or world space
  93014. * @param space The space that the returned position is in
  93015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93016. * @returns The position of the bone
  93017. */
  93018. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93019. /**
  93020. * Copy the position of the bone to a vector3 in local or world space
  93021. * @param space The space that the returned position is in
  93022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93023. * @param result The vector3 to copy the position to
  93024. */
  93025. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93026. /**
  93027. * Get the absolute position of the bone (world space)
  93028. * @param mesh The mesh that this bone is attached to
  93029. * @returns The absolute position of the bone
  93030. */
  93031. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93032. /**
  93033. * Copy the absolute position of the bone (world space) to the result param
  93034. * @param mesh The mesh that this bone is attached to
  93035. * @param result The vector3 to copy the absolute position to
  93036. */
  93037. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93038. /**
  93039. * Compute the absolute transforms of this bone and its children
  93040. */
  93041. computeAbsoluteTransforms(): void;
  93042. /**
  93043. * Get the world direction from an axis that is in the local space of the bone
  93044. * @param localAxis The local direction that is used to compute the world direction
  93045. * @param mesh The mesh that this bone is attached to
  93046. * @returns The world direction
  93047. */
  93048. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93049. /**
  93050. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93051. * @param localAxis The local direction that is used to compute the world direction
  93052. * @param mesh The mesh that this bone is attached to
  93053. * @param result The vector3 that the world direction will be copied to
  93054. */
  93055. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93056. /**
  93057. * Get the euler rotation of the bone in local or world space
  93058. * @param space The space that the rotation should be in
  93059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93060. * @returns The euler rotation
  93061. */
  93062. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93063. /**
  93064. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93065. * @param space The space that the rotation should be in
  93066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93067. * @param result The vector3 that the rotation should be copied to
  93068. */
  93069. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93070. /**
  93071. * Get the quaternion rotation of the bone in either local or world space
  93072. * @param space The space that the rotation should be in
  93073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93074. * @returns The quaternion rotation
  93075. */
  93076. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93077. /**
  93078. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93079. * @param space The space that the rotation should be in
  93080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93081. * @param result The quaternion that the rotation should be copied to
  93082. */
  93083. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93084. /**
  93085. * Get the rotation matrix of the bone in local or world space
  93086. * @param space The space that the rotation should be in
  93087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93088. * @returns The rotation matrix
  93089. */
  93090. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93091. /**
  93092. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93093. * @param space The space that the rotation should be in
  93094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93095. * @param result The quaternion that the rotation should be copied to
  93096. */
  93097. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93098. /**
  93099. * Get the world position of a point that is in the local space of the bone
  93100. * @param position The local position
  93101. * @param mesh The mesh that this bone is attached to
  93102. * @returns The world position
  93103. */
  93104. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93105. /**
  93106. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93107. * @param position The local position
  93108. * @param mesh The mesh that this bone is attached to
  93109. * @param result The vector3 that the world position should be copied to
  93110. */
  93111. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93112. /**
  93113. * Get the local position of a point that is in world space
  93114. * @param position The world position
  93115. * @param mesh The mesh that this bone is attached to
  93116. * @returns The local position
  93117. */
  93118. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93119. /**
  93120. * Get the local position of a point that is in world space and copy it to the result param
  93121. * @param position The world position
  93122. * @param mesh The mesh that this bone is attached to
  93123. * @param result The vector3 that the local position should be copied to
  93124. */
  93125. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93126. }
  93127. }
  93128. declare module BABYLON {
  93129. /**
  93130. * Defines a runtime animation
  93131. */
  93132. export class RuntimeAnimation {
  93133. private _events;
  93134. /**
  93135. * The current frame of the runtime animation
  93136. */
  93137. private _currentFrame;
  93138. /**
  93139. * The animation used by the runtime animation
  93140. */
  93141. private _animation;
  93142. /**
  93143. * The target of the runtime animation
  93144. */
  93145. private _target;
  93146. /**
  93147. * The initiating animatable
  93148. */
  93149. private _host;
  93150. /**
  93151. * The original value of the runtime animation
  93152. */
  93153. private _originalValue;
  93154. /**
  93155. * The original blend value of the runtime animation
  93156. */
  93157. private _originalBlendValue;
  93158. /**
  93159. * The offsets cache of the runtime animation
  93160. */
  93161. private _offsetsCache;
  93162. /**
  93163. * The high limits cache of the runtime animation
  93164. */
  93165. private _highLimitsCache;
  93166. /**
  93167. * Specifies if the runtime animation has been stopped
  93168. */
  93169. private _stopped;
  93170. /**
  93171. * The blending factor of the runtime animation
  93172. */
  93173. private _blendingFactor;
  93174. /**
  93175. * The BabylonJS scene
  93176. */
  93177. private _scene;
  93178. /**
  93179. * The current value of the runtime animation
  93180. */
  93181. private _currentValue;
  93182. /** @hidden */
  93183. _animationState: _IAnimationState;
  93184. /**
  93185. * The active target of the runtime animation
  93186. */
  93187. private _activeTargets;
  93188. private _currentActiveTarget;
  93189. private _directTarget;
  93190. /**
  93191. * The target path of the runtime animation
  93192. */
  93193. private _targetPath;
  93194. /**
  93195. * The weight of the runtime animation
  93196. */
  93197. private _weight;
  93198. /**
  93199. * The ratio offset of the runtime animation
  93200. */
  93201. private _ratioOffset;
  93202. /**
  93203. * The previous delay of the runtime animation
  93204. */
  93205. private _previousDelay;
  93206. /**
  93207. * The previous ratio of the runtime animation
  93208. */
  93209. private _previousRatio;
  93210. private _enableBlending;
  93211. private _keys;
  93212. private _minFrame;
  93213. private _maxFrame;
  93214. private _minValue;
  93215. private _maxValue;
  93216. private _targetIsArray;
  93217. /**
  93218. * Gets the current frame of the runtime animation
  93219. */
  93220. get currentFrame(): number;
  93221. /**
  93222. * Gets the weight of the runtime animation
  93223. */
  93224. get weight(): number;
  93225. /**
  93226. * Gets the current value of the runtime animation
  93227. */
  93228. get currentValue(): any;
  93229. /**
  93230. * Gets the target path of the runtime animation
  93231. */
  93232. get targetPath(): string;
  93233. /**
  93234. * Gets the actual target of the runtime animation
  93235. */
  93236. get target(): any;
  93237. /**
  93238. * Gets the additive state of the runtime animation
  93239. */
  93240. get isAdditive(): boolean;
  93241. /** @hidden */
  93242. _onLoop: () => void;
  93243. /**
  93244. * Create a new RuntimeAnimation object
  93245. * @param target defines the target of the animation
  93246. * @param animation defines the source animation object
  93247. * @param scene defines the hosting scene
  93248. * @param host defines the initiating Animatable
  93249. */
  93250. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93251. private _preparePath;
  93252. /**
  93253. * Gets the animation from the runtime animation
  93254. */
  93255. get animation(): Animation;
  93256. /**
  93257. * Resets the runtime animation to the beginning
  93258. * @param restoreOriginal defines whether to restore the target property to the original value
  93259. */
  93260. reset(restoreOriginal?: boolean): void;
  93261. /**
  93262. * Specifies if the runtime animation is stopped
  93263. * @returns Boolean specifying if the runtime animation is stopped
  93264. */
  93265. isStopped(): boolean;
  93266. /**
  93267. * Disposes of the runtime animation
  93268. */
  93269. dispose(): void;
  93270. /**
  93271. * Apply the interpolated value to the target
  93272. * @param currentValue defines the value computed by the animation
  93273. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93274. */
  93275. setValue(currentValue: any, weight: number): void;
  93276. private _getOriginalValues;
  93277. private _setValue;
  93278. /**
  93279. * Gets the loop pmode of the runtime animation
  93280. * @returns Loop Mode
  93281. */
  93282. private _getCorrectLoopMode;
  93283. /**
  93284. * Move the current animation to a given frame
  93285. * @param frame defines the frame to move to
  93286. */
  93287. goToFrame(frame: number): void;
  93288. /**
  93289. * @hidden Internal use only
  93290. */
  93291. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93292. /**
  93293. * Execute the current animation
  93294. * @param delay defines the delay to add to the current frame
  93295. * @param from defines the lower bound of the animation range
  93296. * @param to defines the upper bound of the animation range
  93297. * @param loop defines if the current animation must loop
  93298. * @param speedRatio defines the current speed ratio
  93299. * @param weight defines the weight of the animation (default is -1 so no weight)
  93300. * @param onLoop optional callback called when animation loops
  93301. * @returns a boolean indicating if the animation is running
  93302. */
  93303. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93304. }
  93305. }
  93306. declare module BABYLON {
  93307. /**
  93308. * Class used to store an actual running animation
  93309. */
  93310. export class Animatable {
  93311. /** defines the target object */
  93312. target: any;
  93313. /** defines the starting frame number (default is 0) */
  93314. fromFrame: number;
  93315. /** defines the ending frame number (default is 100) */
  93316. toFrame: number;
  93317. /** defines if the animation must loop (default is false) */
  93318. loopAnimation: boolean;
  93319. /** defines a callback to call when animation ends if it is not looping */
  93320. onAnimationEnd?: (() => void) | null | undefined;
  93321. /** defines a callback to call when animation loops */
  93322. onAnimationLoop?: (() => void) | null | undefined;
  93323. /** defines whether the animation should be evaluated additively */
  93324. isAdditive: boolean;
  93325. private _localDelayOffset;
  93326. private _pausedDelay;
  93327. private _runtimeAnimations;
  93328. private _paused;
  93329. private _scene;
  93330. private _speedRatio;
  93331. private _weight;
  93332. private _syncRoot;
  93333. /**
  93334. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93335. * This will only apply for non looping animation (default is true)
  93336. */
  93337. disposeOnEnd: boolean;
  93338. /**
  93339. * Gets a boolean indicating if the animation has started
  93340. */
  93341. animationStarted: boolean;
  93342. /**
  93343. * Observer raised when the animation ends
  93344. */
  93345. onAnimationEndObservable: Observable<Animatable>;
  93346. /**
  93347. * Observer raised when the animation loops
  93348. */
  93349. onAnimationLoopObservable: Observable<Animatable>;
  93350. /**
  93351. * Gets the root Animatable used to synchronize and normalize animations
  93352. */
  93353. get syncRoot(): Nullable<Animatable>;
  93354. /**
  93355. * Gets the current frame of the first RuntimeAnimation
  93356. * Used to synchronize Animatables
  93357. */
  93358. get masterFrame(): number;
  93359. /**
  93360. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93361. */
  93362. get weight(): number;
  93363. set weight(value: number);
  93364. /**
  93365. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93366. */
  93367. get speedRatio(): number;
  93368. set speedRatio(value: number);
  93369. /**
  93370. * Creates a new Animatable
  93371. * @param scene defines the hosting scene
  93372. * @param target defines the target object
  93373. * @param fromFrame defines the starting frame number (default is 0)
  93374. * @param toFrame defines the ending frame number (default is 100)
  93375. * @param loopAnimation defines if the animation must loop (default is false)
  93376. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93377. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93378. * @param animations defines a group of animation to add to the new Animatable
  93379. * @param onAnimationLoop defines a callback to call when animation loops
  93380. * @param isAdditive defines whether the animation should be evaluated additively
  93381. */
  93382. constructor(scene: Scene,
  93383. /** defines the target object */
  93384. target: any,
  93385. /** defines the starting frame number (default is 0) */
  93386. fromFrame?: number,
  93387. /** defines the ending frame number (default is 100) */
  93388. toFrame?: number,
  93389. /** defines if the animation must loop (default is false) */
  93390. loopAnimation?: boolean, speedRatio?: number,
  93391. /** defines a callback to call when animation ends if it is not looping */
  93392. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93393. /** defines a callback to call when animation loops */
  93394. onAnimationLoop?: (() => void) | null | undefined,
  93395. /** defines whether the animation should be evaluated additively */
  93396. isAdditive?: boolean);
  93397. /**
  93398. * Synchronize and normalize current Animatable with a source Animatable
  93399. * This is useful when using animation weights and when animations are not of the same length
  93400. * @param root defines the root Animatable to synchronize with
  93401. * @returns the current Animatable
  93402. */
  93403. syncWith(root: Animatable): Animatable;
  93404. /**
  93405. * Gets the list of runtime animations
  93406. * @returns an array of RuntimeAnimation
  93407. */
  93408. getAnimations(): RuntimeAnimation[];
  93409. /**
  93410. * Adds more animations to the current animatable
  93411. * @param target defines the target of the animations
  93412. * @param animations defines the new animations to add
  93413. */
  93414. appendAnimations(target: any, animations: Animation[]): void;
  93415. /**
  93416. * Gets the source animation for a specific property
  93417. * @param property defines the propertyu to look for
  93418. * @returns null or the source animation for the given property
  93419. */
  93420. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93421. /**
  93422. * Gets the runtime animation for a specific property
  93423. * @param property defines the propertyu to look for
  93424. * @returns null or the runtime animation for the given property
  93425. */
  93426. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93427. /**
  93428. * Resets the animatable to its original state
  93429. */
  93430. reset(): void;
  93431. /**
  93432. * Allows the animatable to blend with current running animations
  93433. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93434. * @param blendingSpeed defines the blending speed to use
  93435. */
  93436. enableBlending(blendingSpeed: number): void;
  93437. /**
  93438. * Disable animation blending
  93439. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93440. */
  93441. disableBlending(): void;
  93442. /**
  93443. * Jump directly to a given frame
  93444. * @param frame defines the frame to jump to
  93445. */
  93446. goToFrame(frame: number): void;
  93447. /**
  93448. * Pause the animation
  93449. */
  93450. pause(): void;
  93451. /**
  93452. * Restart the animation
  93453. */
  93454. restart(): void;
  93455. private _raiseOnAnimationEnd;
  93456. /**
  93457. * Stop and delete the current animation
  93458. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93459. * @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)
  93460. */
  93461. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93462. /**
  93463. * Wait asynchronously for the animation to end
  93464. * @returns a promise which will be fullfilled when the animation ends
  93465. */
  93466. waitAsync(): Promise<Animatable>;
  93467. /** @hidden */
  93468. _animate(delay: number): boolean;
  93469. }
  93470. interface Scene {
  93471. /** @hidden */
  93472. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93473. /** @hidden */
  93474. _processLateAnimationBindingsForMatrices(holder: {
  93475. totalWeight: number;
  93476. totalAdditiveWeight: number;
  93477. animations: RuntimeAnimation[];
  93478. additiveAnimations: RuntimeAnimation[];
  93479. originalValue: Matrix;
  93480. }): any;
  93481. /** @hidden */
  93482. _processLateAnimationBindingsForQuaternions(holder: {
  93483. totalWeight: number;
  93484. totalAdditiveWeight: number;
  93485. animations: RuntimeAnimation[];
  93486. additiveAnimations: RuntimeAnimation[];
  93487. originalValue: Quaternion;
  93488. }, refQuaternion: Quaternion): Quaternion;
  93489. /** @hidden */
  93490. _processLateAnimationBindings(): void;
  93491. /**
  93492. * Will start the animation sequence of a given target
  93493. * @param target defines the target
  93494. * @param from defines from which frame should animation start
  93495. * @param to defines until which frame should animation run.
  93496. * @param weight defines the weight to apply to the animation (1.0 by default)
  93497. * @param loop defines if the animation loops
  93498. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93499. * @param onAnimationEnd defines the function to be executed when the animation ends
  93500. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93501. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93502. * @param onAnimationLoop defines the callback to call when an animation loops
  93503. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93504. * @returns the animatable object created for this animation
  93505. */
  93506. 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;
  93507. /**
  93508. * Will start the animation sequence of a given target
  93509. * @param target defines the target
  93510. * @param from defines from which frame should animation start
  93511. * @param to defines until which frame should animation run.
  93512. * @param loop defines if the animation loops
  93513. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93514. * @param onAnimationEnd defines the function to be executed when the animation ends
  93515. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93516. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93517. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93518. * @param onAnimationLoop defines the callback to call when an animation loops
  93519. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93520. * @returns the animatable object created for this animation
  93521. */
  93522. 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;
  93523. /**
  93524. * Will start the animation sequence of a given target and its hierarchy
  93525. * @param target defines the target
  93526. * @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.
  93527. * @param from defines from which frame should animation start
  93528. * @param to defines until which frame should animation run.
  93529. * @param loop defines if the animation loops
  93530. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93531. * @param onAnimationEnd defines the function to be executed when the animation ends
  93532. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93533. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93534. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93535. * @param onAnimationLoop defines the callback to call when an animation loops
  93536. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93537. * @returns the list of created animatables
  93538. */
  93539. 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[];
  93540. /**
  93541. * Begin a new animation on a given node
  93542. * @param target defines the target where the animation will take place
  93543. * @param animations defines the list of animations to start
  93544. * @param from defines the initial value
  93545. * @param to defines the final value
  93546. * @param loop defines if you want animation to loop (off by default)
  93547. * @param speedRatio defines the speed ratio to apply to all animations
  93548. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93549. * @param onAnimationLoop defines the callback to call when an animation loops
  93550. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93551. * @returns the list of created animatables
  93552. */
  93553. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93554. /**
  93555. * Begin a new animation on a given node and its hierarchy
  93556. * @param target defines the root node where the animation will take place
  93557. * @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.
  93558. * @param animations defines the list of animations to start
  93559. * @param from defines the initial value
  93560. * @param to defines the final value
  93561. * @param loop defines if you want animation to loop (off by default)
  93562. * @param speedRatio defines the speed ratio to apply to all animations
  93563. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93564. * @param onAnimationLoop defines the callback to call when an animation loops
  93565. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93566. * @returns the list of animatables created for all nodes
  93567. */
  93568. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93569. /**
  93570. * Gets the animatable associated with a specific target
  93571. * @param target defines the target of the animatable
  93572. * @returns the required animatable if found
  93573. */
  93574. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93575. /**
  93576. * Gets all animatables associated with a given target
  93577. * @param target defines the target to look animatables for
  93578. * @returns an array of Animatables
  93579. */
  93580. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93581. /**
  93582. * Stops and removes all animations that have been applied to the scene
  93583. */
  93584. stopAllAnimations(): void;
  93585. /**
  93586. * Gets the current delta time used by animation engine
  93587. */
  93588. deltaTime: number;
  93589. }
  93590. interface Bone {
  93591. /**
  93592. * Copy an animation range from another bone
  93593. * @param source defines the source bone
  93594. * @param rangeName defines the range name to copy
  93595. * @param frameOffset defines the frame offset
  93596. * @param rescaleAsRequired defines if rescaling must be applied if required
  93597. * @param skelDimensionsRatio defines the scaling ratio
  93598. * @returns true if operation was successful
  93599. */
  93600. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93601. }
  93602. }
  93603. declare module BABYLON {
  93604. /**
  93605. * Class used to handle skinning animations
  93606. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93607. */
  93608. export class Skeleton implements IAnimatable {
  93609. /** defines the skeleton name */
  93610. name: string;
  93611. /** defines the skeleton Id */
  93612. id: string;
  93613. /**
  93614. * Defines the list of child bones
  93615. */
  93616. bones: Bone[];
  93617. /**
  93618. * Defines an estimate of the dimension of the skeleton at rest
  93619. */
  93620. dimensionsAtRest: Vector3;
  93621. /**
  93622. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93623. */
  93624. needInitialSkinMatrix: boolean;
  93625. /**
  93626. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93627. */
  93628. overrideMesh: Nullable<AbstractMesh>;
  93629. /**
  93630. * Gets the list of animations attached to this skeleton
  93631. */
  93632. animations: Array<Animation>;
  93633. private _scene;
  93634. private _isDirty;
  93635. private _transformMatrices;
  93636. private _transformMatrixTexture;
  93637. private _meshesWithPoseMatrix;
  93638. private _animatables;
  93639. private _identity;
  93640. private _synchronizedWithMesh;
  93641. private _ranges;
  93642. private _lastAbsoluteTransformsUpdateId;
  93643. private _canUseTextureForBones;
  93644. private _uniqueId;
  93645. /** @hidden */
  93646. _numBonesWithLinkedTransformNode: number;
  93647. /** @hidden */
  93648. _hasWaitingData: Nullable<boolean>;
  93649. /**
  93650. * Specifies if the skeleton should be serialized
  93651. */
  93652. doNotSerialize: boolean;
  93653. private _useTextureToStoreBoneMatrices;
  93654. /**
  93655. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93656. * Please note that this option is not available if the hardware does not support it
  93657. */
  93658. get useTextureToStoreBoneMatrices(): boolean;
  93659. set useTextureToStoreBoneMatrices(value: boolean);
  93660. private _animationPropertiesOverride;
  93661. /**
  93662. * Gets or sets the animation properties override
  93663. */
  93664. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93665. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93666. /**
  93667. * List of inspectable custom properties (used by the Inspector)
  93668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93669. */
  93670. inspectableCustomProperties: IInspectable[];
  93671. /**
  93672. * An observable triggered before computing the skeleton's matrices
  93673. */
  93674. onBeforeComputeObservable: Observable<Skeleton>;
  93675. /**
  93676. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93677. */
  93678. get isUsingTextureForMatrices(): boolean;
  93679. /**
  93680. * Gets the unique ID of this skeleton
  93681. */
  93682. get uniqueId(): number;
  93683. /**
  93684. * Creates a new skeleton
  93685. * @param name defines the skeleton name
  93686. * @param id defines the skeleton Id
  93687. * @param scene defines the hosting scene
  93688. */
  93689. constructor(
  93690. /** defines the skeleton name */
  93691. name: string,
  93692. /** defines the skeleton Id */
  93693. id: string, scene: Scene);
  93694. /**
  93695. * Gets the current object class name.
  93696. * @return the class name
  93697. */
  93698. getClassName(): string;
  93699. /**
  93700. * Returns an array containing the root bones
  93701. * @returns an array containing the root bones
  93702. */
  93703. getChildren(): Array<Bone>;
  93704. /**
  93705. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93706. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93707. * @returns a Float32Array containing matrices data
  93708. */
  93709. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93710. /**
  93711. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93712. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93713. * @returns a raw texture containing the data
  93714. */
  93715. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93716. /**
  93717. * Gets the current hosting scene
  93718. * @returns a scene object
  93719. */
  93720. getScene(): Scene;
  93721. /**
  93722. * Gets a string representing the current skeleton data
  93723. * @param fullDetails defines a boolean indicating if we want a verbose version
  93724. * @returns a string representing the current skeleton data
  93725. */
  93726. toString(fullDetails?: boolean): string;
  93727. /**
  93728. * Get bone's index searching by name
  93729. * @param name defines bone's name to search for
  93730. * @return the indice of the bone. Returns -1 if not found
  93731. */
  93732. getBoneIndexByName(name: string): number;
  93733. /**
  93734. * Creater a new animation range
  93735. * @param name defines the name of the range
  93736. * @param from defines the start key
  93737. * @param to defines the end key
  93738. */
  93739. createAnimationRange(name: string, from: number, to: number): void;
  93740. /**
  93741. * Delete a specific animation range
  93742. * @param name defines the name of the range
  93743. * @param deleteFrames defines if frames must be removed as well
  93744. */
  93745. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93746. /**
  93747. * Gets a specific animation range
  93748. * @param name defines the name of the range to look for
  93749. * @returns the requested animation range or null if not found
  93750. */
  93751. getAnimationRange(name: string): Nullable<AnimationRange>;
  93752. /**
  93753. * Gets the list of all animation ranges defined on this skeleton
  93754. * @returns an array
  93755. */
  93756. getAnimationRanges(): Nullable<AnimationRange>[];
  93757. /**
  93758. * Copy animation range from a source skeleton.
  93759. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93760. * @param source defines the source skeleton
  93761. * @param name defines the name of the range to copy
  93762. * @param rescaleAsRequired defines if rescaling must be applied if required
  93763. * @returns true if operation was successful
  93764. */
  93765. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93766. /**
  93767. * Forces the skeleton to go to rest pose
  93768. */
  93769. returnToRest(): void;
  93770. private _getHighestAnimationFrame;
  93771. /**
  93772. * Begin a specific animation range
  93773. * @param name defines the name of the range to start
  93774. * @param loop defines if looping must be turned on (false by default)
  93775. * @param speedRatio defines the speed ratio to apply (1 by default)
  93776. * @param onAnimationEnd defines a callback which will be called when animation will end
  93777. * @returns a new animatable
  93778. */
  93779. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93780. /**
  93781. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93782. * @param skeleton defines the Skeleton containing the animation range to convert
  93783. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93784. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93785. * @returns the original skeleton
  93786. */
  93787. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93788. /** @hidden */
  93789. _markAsDirty(): void;
  93790. /** @hidden */
  93791. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93792. /** @hidden */
  93793. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93794. private _computeTransformMatrices;
  93795. /**
  93796. * Build all resources required to render a skeleton
  93797. */
  93798. prepare(): void;
  93799. /**
  93800. * Gets the list of animatables currently running for this skeleton
  93801. * @returns an array of animatables
  93802. */
  93803. getAnimatables(): IAnimatable[];
  93804. /**
  93805. * Clone the current skeleton
  93806. * @param name defines the name of the new skeleton
  93807. * @param id defines the id of the new skeleton
  93808. * @returns the new skeleton
  93809. */
  93810. clone(name: string, id?: string): Skeleton;
  93811. /**
  93812. * Enable animation blending for this skeleton
  93813. * @param blendingSpeed defines the blending speed to apply
  93814. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93815. */
  93816. enableBlending(blendingSpeed?: number): void;
  93817. /**
  93818. * Releases all resources associated with the current skeleton
  93819. */
  93820. dispose(): void;
  93821. /**
  93822. * Serialize the skeleton in a JSON object
  93823. * @returns a JSON object
  93824. */
  93825. serialize(): any;
  93826. /**
  93827. * Creates a new skeleton from serialized data
  93828. * @param parsedSkeleton defines the serialized data
  93829. * @param scene defines the hosting scene
  93830. * @returns a new skeleton
  93831. */
  93832. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93833. /**
  93834. * Compute all node absolute transforms
  93835. * @param forceUpdate defines if computation must be done even if cache is up to date
  93836. */
  93837. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93838. /**
  93839. * Gets the root pose matrix
  93840. * @returns a matrix
  93841. */
  93842. getPoseMatrix(): Nullable<Matrix>;
  93843. /**
  93844. * Sorts bones per internal index
  93845. */
  93846. sortBones(): void;
  93847. private _sortBones;
  93848. }
  93849. }
  93850. declare module BABYLON {
  93851. /**
  93852. * Creates an instance based on a source mesh.
  93853. */
  93854. export class InstancedMesh extends AbstractMesh {
  93855. private _sourceMesh;
  93856. private _currentLOD;
  93857. /** @hidden */
  93858. _indexInSourceMeshInstanceArray: number;
  93859. constructor(name: string, source: Mesh);
  93860. /**
  93861. * Returns the string "InstancedMesh".
  93862. */
  93863. getClassName(): string;
  93864. /** Gets the list of lights affecting that mesh */
  93865. get lightSources(): Light[];
  93866. _resyncLightSources(): void;
  93867. _resyncLightSource(light: Light): void;
  93868. _removeLightSource(light: Light, dispose: boolean): void;
  93869. /**
  93870. * If the source mesh receives shadows
  93871. */
  93872. get receiveShadows(): boolean;
  93873. /**
  93874. * The material of the source mesh
  93875. */
  93876. get material(): Nullable<Material>;
  93877. /**
  93878. * Visibility of the source mesh
  93879. */
  93880. get visibility(): number;
  93881. /**
  93882. * Skeleton of the source mesh
  93883. */
  93884. get skeleton(): Nullable<Skeleton>;
  93885. /**
  93886. * Rendering ground id of the source mesh
  93887. */
  93888. get renderingGroupId(): number;
  93889. set renderingGroupId(value: number);
  93890. /**
  93891. * Returns the total number of vertices (integer).
  93892. */
  93893. getTotalVertices(): number;
  93894. /**
  93895. * Returns a positive integer : the total number of indices in this mesh geometry.
  93896. * @returns the numner of indices or zero if the mesh has no geometry.
  93897. */
  93898. getTotalIndices(): number;
  93899. /**
  93900. * The source mesh of the instance
  93901. */
  93902. get sourceMesh(): Mesh;
  93903. /**
  93904. * Creates a new InstancedMesh object from the mesh model.
  93905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93906. * @param name defines the name of the new instance
  93907. * @returns a new InstancedMesh
  93908. */
  93909. createInstance(name: string): InstancedMesh;
  93910. /**
  93911. * Is this node ready to be used/rendered
  93912. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93913. * @return {boolean} is it ready
  93914. */
  93915. isReady(completeCheck?: boolean): boolean;
  93916. /**
  93917. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93918. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93919. * @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.
  93920. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93921. */
  93922. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93923. /**
  93924. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93925. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93926. * The `data` are either a numeric array either a Float32Array.
  93927. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93928. * 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).
  93929. * Note that a new underlying VertexBuffer object is created each call.
  93930. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93931. *
  93932. * Possible `kind` values :
  93933. * - VertexBuffer.PositionKind
  93934. * - VertexBuffer.UVKind
  93935. * - VertexBuffer.UV2Kind
  93936. * - VertexBuffer.UV3Kind
  93937. * - VertexBuffer.UV4Kind
  93938. * - VertexBuffer.UV5Kind
  93939. * - VertexBuffer.UV6Kind
  93940. * - VertexBuffer.ColorKind
  93941. * - VertexBuffer.MatricesIndicesKind
  93942. * - VertexBuffer.MatricesIndicesExtraKind
  93943. * - VertexBuffer.MatricesWeightsKind
  93944. * - VertexBuffer.MatricesWeightsExtraKind
  93945. *
  93946. * Returns the Mesh.
  93947. */
  93948. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93949. /**
  93950. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93951. * If the mesh has no geometry, it is simply returned as it is.
  93952. * The `data` are either a numeric array either a Float32Array.
  93953. * No new underlying VertexBuffer object is created.
  93954. * 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.
  93955. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93956. *
  93957. * Possible `kind` values :
  93958. * - VertexBuffer.PositionKind
  93959. * - VertexBuffer.UVKind
  93960. * - VertexBuffer.UV2Kind
  93961. * - VertexBuffer.UV3Kind
  93962. * - VertexBuffer.UV4Kind
  93963. * - VertexBuffer.UV5Kind
  93964. * - VertexBuffer.UV6Kind
  93965. * - VertexBuffer.ColorKind
  93966. * - VertexBuffer.MatricesIndicesKind
  93967. * - VertexBuffer.MatricesIndicesExtraKind
  93968. * - VertexBuffer.MatricesWeightsKind
  93969. * - VertexBuffer.MatricesWeightsExtraKind
  93970. *
  93971. * Returns the Mesh.
  93972. */
  93973. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93974. /**
  93975. * Sets the mesh indices.
  93976. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93977. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93978. * This method creates a new index buffer each call.
  93979. * Returns the Mesh.
  93980. */
  93981. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93982. /**
  93983. * Boolean : True if the mesh owns the requested kind of data.
  93984. */
  93985. isVerticesDataPresent(kind: string): boolean;
  93986. /**
  93987. * Returns an array of indices (IndicesArray).
  93988. */
  93989. getIndices(): Nullable<IndicesArray>;
  93990. get _positions(): Nullable<Vector3[]>;
  93991. /**
  93992. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93993. * This means the mesh underlying bounding box and sphere are recomputed.
  93994. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93995. * @returns the current mesh
  93996. */
  93997. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93998. /** @hidden */
  93999. _preActivate(): InstancedMesh;
  94000. /** @hidden */
  94001. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94002. /** @hidden */
  94003. _postActivate(): void;
  94004. getWorldMatrix(): Matrix;
  94005. get isAnInstance(): boolean;
  94006. /**
  94007. * Returns the current associated LOD AbstractMesh.
  94008. */
  94009. getLOD(camera: Camera): AbstractMesh;
  94010. /** @hidden */
  94011. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94012. /** @hidden */
  94013. _syncSubMeshes(): InstancedMesh;
  94014. /** @hidden */
  94015. _generatePointsArray(): boolean;
  94016. /**
  94017. * Creates a new InstancedMesh from the current mesh.
  94018. * - name (string) : the cloned mesh name
  94019. * - newParent (optional Node) : the optional Node to parent the clone to.
  94020. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94021. *
  94022. * Returns the clone.
  94023. */
  94024. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94025. /**
  94026. * Disposes the InstancedMesh.
  94027. * Returns nothing.
  94028. */
  94029. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94030. }
  94031. interface Mesh {
  94032. /**
  94033. * Register a custom buffer that will be instanced
  94034. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94035. * @param kind defines the buffer kind
  94036. * @param stride defines the stride in floats
  94037. */
  94038. registerInstancedBuffer(kind: string, stride: number): void;
  94039. /**
  94040. * true to use the edge renderer for all instances of this mesh
  94041. */
  94042. edgesShareWithInstances: boolean;
  94043. /** @hidden */
  94044. _userInstancedBuffersStorage: {
  94045. data: {
  94046. [key: string]: Float32Array;
  94047. };
  94048. sizes: {
  94049. [key: string]: number;
  94050. };
  94051. vertexBuffers: {
  94052. [key: string]: Nullable<VertexBuffer>;
  94053. };
  94054. strides: {
  94055. [key: string]: number;
  94056. };
  94057. };
  94058. }
  94059. interface AbstractMesh {
  94060. /**
  94061. * Object used to store instanced buffers defined by user
  94062. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94063. */
  94064. instancedBuffers: {
  94065. [key: string]: any;
  94066. };
  94067. }
  94068. }
  94069. declare module BABYLON {
  94070. /**
  94071. * Defines the options associated with the creation of a shader material.
  94072. */
  94073. export interface IShaderMaterialOptions {
  94074. /**
  94075. * Does the material work in alpha blend mode
  94076. */
  94077. needAlphaBlending: boolean;
  94078. /**
  94079. * Does the material work in alpha test mode
  94080. */
  94081. needAlphaTesting: boolean;
  94082. /**
  94083. * The list of attribute names used in the shader
  94084. */
  94085. attributes: string[];
  94086. /**
  94087. * The list of unifrom names used in the shader
  94088. */
  94089. uniforms: string[];
  94090. /**
  94091. * The list of UBO names used in the shader
  94092. */
  94093. uniformBuffers: string[];
  94094. /**
  94095. * The list of sampler names used in the shader
  94096. */
  94097. samplers: string[];
  94098. /**
  94099. * The list of defines used in the shader
  94100. */
  94101. defines: string[];
  94102. }
  94103. /**
  94104. * 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.
  94105. *
  94106. * This returned material effects how the mesh will look based on the code in the shaders.
  94107. *
  94108. * @see http://doc.babylonjs.com/how_to/shader_material
  94109. */
  94110. export class ShaderMaterial extends Material {
  94111. private _shaderPath;
  94112. private _options;
  94113. private _textures;
  94114. private _textureArrays;
  94115. private _floats;
  94116. private _ints;
  94117. private _floatsArrays;
  94118. private _colors3;
  94119. private _colors3Arrays;
  94120. private _colors4;
  94121. private _colors4Arrays;
  94122. private _vectors2;
  94123. private _vectors3;
  94124. private _vectors4;
  94125. private _matrices;
  94126. private _matrixArrays;
  94127. private _matrices3x3;
  94128. private _matrices2x2;
  94129. private _vectors2Arrays;
  94130. private _vectors3Arrays;
  94131. private _vectors4Arrays;
  94132. private _cachedWorldViewMatrix;
  94133. private _cachedWorldViewProjectionMatrix;
  94134. private _renderId;
  94135. private _multiview;
  94136. private _cachedDefines;
  94137. /** Define the Url to load snippets */
  94138. static SnippetUrl: string;
  94139. /** Snippet ID if the material was created from the snippet server */
  94140. snippetId: string;
  94141. /**
  94142. * Instantiate a new shader material.
  94143. * 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.
  94144. * This returned material effects how the mesh will look based on the code in the shaders.
  94145. * @see http://doc.babylonjs.com/how_to/shader_material
  94146. * @param name Define the name of the material in the scene
  94147. * @param scene Define the scene the material belongs to
  94148. * @param shaderPath Defines the route to the shader code in one of three ways:
  94149. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94150. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94151. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94152. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94153. * @param options Define the options used to create the shader
  94154. */
  94155. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94156. /**
  94157. * Gets the shader path used to define the shader code
  94158. * It can be modified to trigger a new compilation
  94159. */
  94160. get shaderPath(): any;
  94161. /**
  94162. * Sets the shader path used to define the shader code
  94163. * It can be modified to trigger a new compilation
  94164. */
  94165. set shaderPath(shaderPath: any);
  94166. /**
  94167. * Gets the options used to compile the shader.
  94168. * They can be modified to trigger a new compilation
  94169. */
  94170. get options(): IShaderMaterialOptions;
  94171. /**
  94172. * Gets the current class name of the material e.g. "ShaderMaterial"
  94173. * Mainly use in serialization.
  94174. * @returns the class name
  94175. */
  94176. getClassName(): string;
  94177. /**
  94178. * Specifies if the material will require alpha blending
  94179. * @returns a boolean specifying if alpha blending is needed
  94180. */
  94181. needAlphaBlending(): boolean;
  94182. /**
  94183. * Specifies if this material should be rendered in alpha test mode
  94184. * @returns a boolean specifying if an alpha test is needed.
  94185. */
  94186. needAlphaTesting(): boolean;
  94187. private _checkUniform;
  94188. /**
  94189. * Set a texture in the shader.
  94190. * @param name Define the name of the uniform samplers as defined in the shader
  94191. * @param texture Define the texture to bind to this sampler
  94192. * @return the material itself allowing "fluent" like uniform updates
  94193. */
  94194. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94195. /**
  94196. * Set a texture array in the shader.
  94197. * @param name Define the name of the uniform sampler array as defined in the shader
  94198. * @param textures Define the list of textures to bind to this sampler
  94199. * @return the material itself allowing "fluent" like uniform updates
  94200. */
  94201. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94202. /**
  94203. * Set a float in the shader.
  94204. * @param name Define the name of the uniform as defined in the shader
  94205. * @param value Define the value to give to the uniform
  94206. * @return the material itself allowing "fluent" like uniform updates
  94207. */
  94208. setFloat(name: string, value: number): ShaderMaterial;
  94209. /**
  94210. * Set a int in the shader.
  94211. * @param name Define the name of the uniform as defined in the shader
  94212. * @param value Define the value to give to the uniform
  94213. * @return the material itself allowing "fluent" like uniform updates
  94214. */
  94215. setInt(name: string, value: number): ShaderMaterial;
  94216. /**
  94217. * Set an array of floats in the shader.
  94218. * @param name Define the name of the uniform as defined in the shader
  94219. * @param value Define the value to give to the uniform
  94220. * @return the material itself allowing "fluent" like uniform updates
  94221. */
  94222. setFloats(name: string, value: number[]): ShaderMaterial;
  94223. /**
  94224. * Set a vec3 in the shader from a Color3.
  94225. * @param name Define the name of the uniform as defined in the shader
  94226. * @param value Define the value to give to the uniform
  94227. * @return the material itself allowing "fluent" like uniform updates
  94228. */
  94229. setColor3(name: string, value: Color3): ShaderMaterial;
  94230. /**
  94231. * Set a vec3 array in the shader from a Color3 array.
  94232. * @param name Define the name of the uniform as defined in the shader
  94233. * @param value Define the value to give to the uniform
  94234. * @return the material itself allowing "fluent" like uniform updates
  94235. */
  94236. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94237. /**
  94238. * Set a vec4 in the shader from a Color4.
  94239. * @param name Define the name of the uniform as defined in the shader
  94240. * @param value Define the value to give to the uniform
  94241. * @return the material itself allowing "fluent" like uniform updates
  94242. */
  94243. setColor4(name: string, value: Color4): ShaderMaterial;
  94244. /**
  94245. * Set a vec4 array in the shader from a Color4 array.
  94246. * @param name Define the name of the uniform as defined in the shader
  94247. * @param value Define the value to give to the uniform
  94248. * @return the material itself allowing "fluent" like uniform updates
  94249. */
  94250. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94251. /**
  94252. * Set a vec2 in the shader from a Vector2.
  94253. * @param name Define the name of the uniform as defined in the shader
  94254. * @param value Define the value to give to the uniform
  94255. * @return the material itself allowing "fluent" like uniform updates
  94256. */
  94257. setVector2(name: string, value: Vector2): ShaderMaterial;
  94258. /**
  94259. * Set a vec3 in the shader from a Vector3.
  94260. * @param name Define the name of the uniform as defined in the shader
  94261. * @param value Define the value to give to the uniform
  94262. * @return the material itself allowing "fluent" like uniform updates
  94263. */
  94264. setVector3(name: string, value: Vector3): ShaderMaterial;
  94265. /**
  94266. * Set a vec4 in the shader from a Vector4.
  94267. * @param name Define the name of the uniform as defined in the shader
  94268. * @param value Define the value to give to the uniform
  94269. * @return the material itself allowing "fluent" like uniform updates
  94270. */
  94271. setVector4(name: string, value: Vector4): ShaderMaterial;
  94272. /**
  94273. * Set a mat4 in the shader from a Matrix.
  94274. * @param name Define the name of the uniform as defined in the shader
  94275. * @param value Define the value to give to the uniform
  94276. * @return the material itself allowing "fluent" like uniform updates
  94277. */
  94278. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94279. /**
  94280. * Set a float32Array in the shader from a matrix array.
  94281. * @param name Define the name of the uniform as defined in the shader
  94282. * @param value Define the value to give to the uniform
  94283. * @return the material itself allowing "fluent" like uniform updates
  94284. */
  94285. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94286. /**
  94287. * Set a mat3 in the shader from a Float32Array.
  94288. * @param name Define the name of the uniform as defined in the shader
  94289. * @param value Define the value to give to the uniform
  94290. * @return the material itself allowing "fluent" like uniform updates
  94291. */
  94292. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94293. /**
  94294. * Set a mat2 in the shader from a Float32Array.
  94295. * @param name Define the name of the uniform as defined in the shader
  94296. * @param value Define the value to give to the uniform
  94297. * @return the material itself allowing "fluent" like uniform updates
  94298. */
  94299. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94300. /**
  94301. * Set a vec2 array in the shader from a number array.
  94302. * @param name Define the name of the uniform as defined in the shader
  94303. * @param value Define the value to give to the uniform
  94304. * @return the material itself allowing "fluent" like uniform updates
  94305. */
  94306. setArray2(name: string, value: number[]): ShaderMaterial;
  94307. /**
  94308. * Set a vec3 array in the shader from a number array.
  94309. * @param name Define the name of the uniform as defined in the shader
  94310. * @param value Define the value to give to the uniform
  94311. * @return the material itself allowing "fluent" like uniform updates
  94312. */
  94313. setArray3(name: string, value: number[]): ShaderMaterial;
  94314. /**
  94315. * Set a vec4 array in the shader from a number array.
  94316. * @param name Define the name of the uniform as defined in the shader
  94317. * @param value Define the value to give to the uniform
  94318. * @return the material itself allowing "fluent" like uniform updates
  94319. */
  94320. setArray4(name: string, value: number[]): ShaderMaterial;
  94321. private _checkCache;
  94322. /**
  94323. * Specifies that the submesh is ready to be used
  94324. * @param mesh defines the mesh to check
  94325. * @param subMesh defines which submesh to check
  94326. * @param useInstances specifies that instances should be used
  94327. * @returns a boolean indicating that the submesh is ready or not
  94328. */
  94329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94330. /**
  94331. * Checks if the material is ready to render the requested mesh
  94332. * @param mesh Define the mesh to render
  94333. * @param useInstances Define whether or not the material is used with instances
  94334. * @returns true if ready, otherwise false
  94335. */
  94336. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94337. /**
  94338. * Binds the world matrix to the material
  94339. * @param world defines the world transformation matrix
  94340. * @param effectOverride - If provided, use this effect instead of internal effect
  94341. */
  94342. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94343. /**
  94344. * Binds the submesh to this material by preparing the effect and shader to draw
  94345. * @param world defines the world transformation matrix
  94346. * @param mesh defines the mesh containing the submesh
  94347. * @param subMesh defines the submesh to bind the material to
  94348. */
  94349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94350. /**
  94351. * Binds the material to the mesh
  94352. * @param world defines the world transformation matrix
  94353. * @param mesh defines the mesh to bind the material to
  94354. * @param effectOverride - If provided, use this effect instead of internal effect
  94355. */
  94356. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94357. protected _afterBind(mesh?: Mesh): void;
  94358. /**
  94359. * Gets the active textures from the material
  94360. * @returns an array of textures
  94361. */
  94362. getActiveTextures(): BaseTexture[];
  94363. /**
  94364. * Specifies if the material uses a texture
  94365. * @param texture defines the texture to check against the material
  94366. * @returns a boolean specifying if the material uses the texture
  94367. */
  94368. hasTexture(texture: BaseTexture): boolean;
  94369. /**
  94370. * Makes a duplicate of the material, and gives it a new name
  94371. * @param name defines the new name for the duplicated material
  94372. * @returns the cloned material
  94373. */
  94374. clone(name: string): ShaderMaterial;
  94375. /**
  94376. * Disposes the material
  94377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94378. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94379. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94380. */
  94381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94382. /**
  94383. * Serializes this material in a JSON representation
  94384. * @returns the serialized material object
  94385. */
  94386. serialize(): any;
  94387. /**
  94388. * Creates a shader material from parsed shader material data
  94389. * @param source defines the JSON represnetation of the material
  94390. * @param scene defines the hosting scene
  94391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94392. * @returns a new material
  94393. */
  94394. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94395. /**
  94396. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94397. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94398. * @param url defines the url to load from
  94399. * @param scene defines the hosting scene
  94400. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94401. * @returns a promise that will resolve to the new ShaderMaterial
  94402. */
  94403. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94404. /**
  94405. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94406. * @param snippetId defines the snippet to load
  94407. * @param scene defines the hosting scene
  94408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94409. * @returns a promise that will resolve to the new ShaderMaterial
  94410. */
  94411. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94412. }
  94413. }
  94414. declare module BABYLON {
  94415. /** @hidden */
  94416. export var colorPixelShader: {
  94417. name: string;
  94418. shader: string;
  94419. };
  94420. }
  94421. declare module BABYLON {
  94422. /** @hidden */
  94423. export var colorVertexShader: {
  94424. name: string;
  94425. shader: string;
  94426. };
  94427. }
  94428. declare module BABYLON {
  94429. /**
  94430. * Line mesh
  94431. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94432. */
  94433. export class LinesMesh extends Mesh {
  94434. /**
  94435. * If vertex color should be applied to the mesh
  94436. */
  94437. readonly useVertexColor?: boolean | undefined;
  94438. /**
  94439. * If vertex alpha should be applied to the mesh
  94440. */
  94441. readonly useVertexAlpha?: boolean | undefined;
  94442. /**
  94443. * Color of the line (Default: White)
  94444. */
  94445. color: Color3;
  94446. /**
  94447. * Alpha of the line (Default: 1)
  94448. */
  94449. alpha: number;
  94450. /**
  94451. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94452. * This margin is expressed in world space coordinates, so its value may vary.
  94453. * Default value is 0.1
  94454. */
  94455. intersectionThreshold: number;
  94456. private _colorShader;
  94457. private color4;
  94458. /**
  94459. * Creates a new LinesMesh
  94460. * @param name defines the name
  94461. * @param scene defines the hosting scene
  94462. * @param parent defines the parent mesh if any
  94463. * @param source defines the optional source LinesMesh used to clone data from
  94464. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94465. * When false, achieved by calling a clone(), also passing False.
  94466. * This will make creation of children, recursive.
  94467. * @param useVertexColor defines if this LinesMesh supports vertex color
  94468. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94469. */
  94470. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94471. /**
  94472. * If vertex color should be applied to the mesh
  94473. */
  94474. useVertexColor?: boolean | undefined,
  94475. /**
  94476. * If vertex alpha should be applied to the mesh
  94477. */
  94478. useVertexAlpha?: boolean | undefined);
  94479. private _addClipPlaneDefine;
  94480. private _removeClipPlaneDefine;
  94481. isReady(): boolean;
  94482. /**
  94483. * Returns the string "LineMesh"
  94484. */
  94485. getClassName(): string;
  94486. /**
  94487. * @hidden
  94488. */
  94489. get material(): Material;
  94490. /**
  94491. * @hidden
  94492. */
  94493. set material(value: Material);
  94494. /**
  94495. * @hidden
  94496. */
  94497. get checkCollisions(): boolean;
  94498. /** @hidden */
  94499. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94500. /** @hidden */
  94501. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94502. /**
  94503. * Disposes of the line mesh
  94504. * @param doNotRecurse If children should be disposed
  94505. */
  94506. dispose(doNotRecurse?: boolean): void;
  94507. /**
  94508. * Returns a new LineMesh object cloned from the current one.
  94509. */
  94510. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94511. /**
  94512. * Creates a new InstancedLinesMesh object from the mesh model.
  94513. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94514. * @param name defines the name of the new instance
  94515. * @returns a new InstancedLinesMesh
  94516. */
  94517. createInstance(name: string): InstancedLinesMesh;
  94518. }
  94519. /**
  94520. * Creates an instance based on a source LinesMesh
  94521. */
  94522. export class InstancedLinesMesh extends InstancedMesh {
  94523. /**
  94524. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94525. * This margin is expressed in world space coordinates, so its value may vary.
  94526. * Initilized with the intersectionThreshold value of the source LinesMesh
  94527. */
  94528. intersectionThreshold: number;
  94529. constructor(name: string, source: LinesMesh);
  94530. /**
  94531. * Returns the string "InstancedLinesMesh".
  94532. */
  94533. getClassName(): string;
  94534. }
  94535. }
  94536. declare module BABYLON {
  94537. /** @hidden */
  94538. export var linePixelShader: {
  94539. name: string;
  94540. shader: string;
  94541. };
  94542. }
  94543. declare module BABYLON {
  94544. /** @hidden */
  94545. export var lineVertexShader: {
  94546. name: string;
  94547. shader: string;
  94548. };
  94549. }
  94550. declare module BABYLON {
  94551. interface Scene {
  94552. /** @hidden */
  94553. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94554. }
  94555. interface AbstractMesh {
  94556. /**
  94557. * Gets the edgesRenderer associated with the mesh
  94558. */
  94559. edgesRenderer: Nullable<EdgesRenderer>;
  94560. }
  94561. interface LinesMesh {
  94562. /**
  94563. * Enables the edge rendering mode on the mesh.
  94564. * This mode makes the mesh edges visible
  94565. * @param epsilon defines the maximal distance between two angles to detect a face
  94566. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94567. * @returns the currentAbstractMesh
  94568. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94569. */
  94570. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94571. }
  94572. interface InstancedLinesMesh {
  94573. /**
  94574. * Enables the edge rendering mode on the mesh.
  94575. * This mode makes the mesh edges visible
  94576. * @param epsilon defines the maximal distance between two angles to detect a face
  94577. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94578. * @returns the current InstancedLinesMesh
  94579. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94580. */
  94581. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94582. }
  94583. /**
  94584. * Defines the minimum contract an Edges renderer should follow.
  94585. */
  94586. export interface IEdgesRenderer extends IDisposable {
  94587. /**
  94588. * Gets or sets a boolean indicating if the edgesRenderer is active
  94589. */
  94590. isEnabled: boolean;
  94591. /**
  94592. * Renders the edges of the attached mesh,
  94593. */
  94594. render(): void;
  94595. /**
  94596. * Checks wether or not the edges renderer is ready to render.
  94597. * @return true if ready, otherwise false.
  94598. */
  94599. isReady(): boolean;
  94600. /**
  94601. * List of instances to render in case the source mesh has instances
  94602. */
  94603. customInstances: SmartArray<Matrix>;
  94604. }
  94605. /**
  94606. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94607. */
  94608. export class EdgesRenderer implements IEdgesRenderer {
  94609. /**
  94610. * Define the size of the edges with an orthographic camera
  94611. */
  94612. edgesWidthScalerForOrthographic: number;
  94613. /**
  94614. * Define the size of the edges with a perspective camera
  94615. */
  94616. edgesWidthScalerForPerspective: number;
  94617. protected _source: AbstractMesh;
  94618. protected _linesPositions: number[];
  94619. protected _linesNormals: number[];
  94620. protected _linesIndices: number[];
  94621. protected _epsilon: number;
  94622. protected _indicesCount: number;
  94623. protected _lineShader: ShaderMaterial;
  94624. protected _ib: DataBuffer;
  94625. protected _buffers: {
  94626. [key: string]: Nullable<VertexBuffer>;
  94627. };
  94628. protected _buffersForInstances: {
  94629. [key: string]: Nullable<VertexBuffer>;
  94630. };
  94631. protected _checkVerticesInsteadOfIndices: boolean;
  94632. private _meshRebuildObserver;
  94633. private _meshDisposeObserver;
  94634. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94635. isEnabled: boolean;
  94636. /**
  94637. * List of instances to render in case the source mesh has instances
  94638. */
  94639. customInstances: SmartArray<Matrix>;
  94640. private static GetShader;
  94641. /**
  94642. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94643. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94644. * @param source Mesh used to create edges
  94645. * @param epsilon sum of angles in adjacency to check for edge
  94646. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94647. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94648. */
  94649. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94650. protected _prepareRessources(): void;
  94651. /** @hidden */
  94652. _rebuild(): void;
  94653. /**
  94654. * Releases the required resources for the edges renderer
  94655. */
  94656. dispose(): void;
  94657. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94658. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94659. /**
  94660. * Checks if the pair of p0 and p1 is en edge
  94661. * @param faceIndex
  94662. * @param edge
  94663. * @param faceNormals
  94664. * @param p0
  94665. * @param p1
  94666. * @private
  94667. */
  94668. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94669. /**
  94670. * push line into the position, normal and index buffer
  94671. * @protected
  94672. */
  94673. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94674. /**
  94675. * Generates lines edges from adjacencjes
  94676. * @private
  94677. */
  94678. _generateEdgesLines(): void;
  94679. /**
  94680. * Checks wether or not the edges renderer is ready to render.
  94681. * @return true if ready, otherwise false.
  94682. */
  94683. isReady(): boolean;
  94684. /**
  94685. * Renders the edges of the attached mesh,
  94686. */
  94687. render(): void;
  94688. }
  94689. /**
  94690. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94691. */
  94692. export class LineEdgesRenderer extends EdgesRenderer {
  94693. /**
  94694. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94695. * @param source LineMesh used to generate edges
  94696. * @param epsilon not important (specified angle for edge detection)
  94697. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94698. */
  94699. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94700. /**
  94701. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94702. */
  94703. _generateEdgesLines(): void;
  94704. }
  94705. }
  94706. declare module BABYLON {
  94707. /**
  94708. * This represents the object necessary to create a rendering group.
  94709. * This is exclusively used and created by the rendering manager.
  94710. * To modify the behavior, you use the available helpers in your scene or meshes.
  94711. * @hidden
  94712. */
  94713. export class RenderingGroup {
  94714. index: number;
  94715. private static _zeroVector;
  94716. private _scene;
  94717. private _opaqueSubMeshes;
  94718. private _transparentSubMeshes;
  94719. private _alphaTestSubMeshes;
  94720. private _depthOnlySubMeshes;
  94721. private _particleSystems;
  94722. private _spriteManagers;
  94723. private _opaqueSortCompareFn;
  94724. private _alphaTestSortCompareFn;
  94725. private _transparentSortCompareFn;
  94726. private _renderOpaque;
  94727. private _renderAlphaTest;
  94728. private _renderTransparent;
  94729. /** @hidden */
  94730. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94731. onBeforeTransparentRendering: () => void;
  94732. /**
  94733. * Set the opaque sort comparison function.
  94734. * If null the sub meshes will be render in the order they were created
  94735. */
  94736. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94737. /**
  94738. * Set the alpha test sort comparison function.
  94739. * If null the sub meshes will be render in the order they were created
  94740. */
  94741. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94742. /**
  94743. * Set the transparent sort comparison function.
  94744. * If null the sub meshes will be render in the order they were created
  94745. */
  94746. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94747. /**
  94748. * Creates a new rendering group.
  94749. * @param index The rendering group index
  94750. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94751. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94752. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94753. */
  94754. 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>);
  94755. /**
  94756. * Render all the sub meshes contained in the group.
  94757. * @param customRenderFunction Used to override the default render behaviour of the group.
  94758. * @returns true if rendered some submeshes.
  94759. */
  94760. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94761. /**
  94762. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94763. * @param subMeshes The submeshes to render
  94764. */
  94765. private renderOpaqueSorted;
  94766. /**
  94767. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94768. * @param subMeshes The submeshes to render
  94769. */
  94770. private renderAlphaTestSorted;
  94771. /**
  94772. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94773. * @param subMeshes The submeshes to render
  94774. */
  94775. private renderTransparentSorted;
  94776. /**
  94777. * Renders the submeshes in a specified order.
  94778. * @param subMeshes The submeshes to sort before render
  94779. * @param sortCompareFn The comparison function use to sort
  94780. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94781. * @param transparent Specifies to activate blending if true
  94782. */
  94783. private static renderSorted;
  94784. /**
  94785. * Renders the submeshes in the order they were dispatched (no sort applied).
  94786. * @param subMeshes The submeshes to render
  94787. */
  94788. private static renderUnsorted;
  94789. /**
  94790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94791. * are rendered back to front if in the same alpha index.
  94792. *
  94793. * @param a The first submesh
  94794. * @param b The second submesh
  94795. * @returns The result of the comparison
  94796. */
  94797. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94798. /**
  94799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94800. * are rendered back to front.
  94801. *
  94802. * @param a The first submesh
  94803. * @param b The second submesh
  94804. * @returns The result of the comparison
  94805. */
  94806. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94807. /**
  94808. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94809. * are rendered front to back (prevent overdraw).
  94810. *
  94811. * @param a The first submesh
  94812. * @param b The second submesh
  94813. * @returns The result of the comparison
  94814. */
  94815. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94816. /**
  94817. * Resets the different lists of submeshes to prepare a new frame.
  94818. */
  94819. prepare(): void;
  94820. dispose(): void;
  94821. /**
  94822. * Inserts the submesh in its correct queue depending on its material.
  94823. * @param subMesh The submesh to dispatch
  94824. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94825. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94826. */
  94827. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94828. dispatchSprites(spriteManager: ISpriteManager): void;
  94829. dispatchParticles(particleSystem: IParticleSystem): void;
  94830. private _renderParticles;
  94831. private _renderSprites;
  94832. }
  94833. }
  94834. declare module BABYLON {
  94835. /**
  94836. * Interface describing the different options available in the rendering manager
  94837. * regarding Auto Clear between groups.
  94838. */
  94839. export interface IRenderingManagerAutoClearSetup {
  94840. /**
  94841. * Defines whether or not autoclear is enable.
  94842. */
  94843. autoClear: boolean;
  94844. /**
  94845. * Defines whether or not to autoclear the depth buffer.
  94846. */
  94847. depth: boolean;
  94848. /**
  94849. * Defines whether or not to autoclear the stencil buffer.
  94850. */
  94851. stencil: boolean;
  94852. }
  94853. /**
  94854. * This class is used by the onRenderingGroupObservable
  94855. */
  94856. export class RenderingGroupInfo {
  94857. /**
  94858. * The Scene that being rendered
  94859. */
  94860. scene: Scene;
  94861. /**
  94862. * The camera currently used for the rendering pass
  94863. */
  94864. camera: Nullable<Camera>;
  94865. /**
  94866. * The ID of the renderingGroup being processed
  94867. */
  94868. renderingGroupId: number;
  94869. }
  94870. /**
  94871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94872. * It is enable to manage the different groups as well as the different necessary sort functions.
  94873. * This should not be used directly aside of the few static configurations
  94874. */
  94875. export class RenderingManager {
  94876. /**
  94877. * The max id used for rendering groups (not included)
  94878. */
  94879. static MAX_RENDERINGGROUPS: number;
  94880. /**
  94881. * The min id used for rendering groups (included)
  94882. */
  94883. static MIN_RENDERINGGROUPS: number;
  94884. /**
  94885. * Used to globally prevent autoclearing scenes.
  94886. */
  94887. static AUTOCLEAR: boolean;
  94888. /**
  94889. * @hidden
  94890. */
  94891. _useSceneAutoClearSetup: boolean;
  94892. private _scene;
  94893. private _renderingGroups;
  94894. private _depthStencilBufferAlreadyCleaned;
  94895. private _autoClearDepthStencil;
  94896. private _customOpaqueSortCompareFn;
  94897. private _customAlphaTestSortCompareFn;
  94898. private _customTransparentSortCompareFn;
  94899. private _renderingGroupInfo;
  94900. /**
  94901. * Instantiates a new rendering group for a particular scene
  94902. * @param scene Defines the scene the groups belongs to
  94903. */
  94904. constructor(scene: Scene);
  94905. private _clearDepthStencilBuffer;
  94906. /**
  94907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94908. * @hidden
  94909. */
  94910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94911. /**
  94912. * Resets the different information of the group to prepare a new frame
  94913. * @hidden
  94914. */
  94915. reset(): void;
  94916. /**
  94917. * Dispose and release the group and its associated resources.
  94918. * @hidden
  94919. */
  94920. dispose(): void;
  94921. /**
  94922. * Clear the info related to rendering groups preventing retention points during dispose.
  94923. */
  94924. freeRenderingGroups(): void;
  94925. private _prepareRenderingGroup;
  94926. /**
  94927. * Add a sprite manager to the rendering manager in order to render it this frame.
  94928. * @param spriteManager Define the sprite manager to render
  94929. */
  94930. dispatchSprites(spriteManager: ISpriteManager): void;
  94931. /**
  94932. * Add a particle system to the rendering manager in order to render it this frame.
  94933. * @param particleSystem Define the particle system to render
  94934. */
  94935. dispatchParticles(particleSystem: IParticleSystem): void;
  94936. /**
  94937. * Add a submesh to the manager in order to render it this frame
  94938. * @param subMesh The submesh to dispatch
  94939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94941. */
  94942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94943. /**
  94944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94945. * This allowed control for front to back rendering or reversly depending of the special needs.
  94946. *
  94947. * @param renderingGroupId The rendering group id corresponding to its index
  94948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94951. */
  94952. 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;
  94953. /**
  94954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94955. *
  94956. * @param renderingGroupId The rendering group id corresponding to its index
  94957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94960. */
  94961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94962. /**
  94963. * Gets the current auto clear configuration for one rendering group of the rendering
  94964. * manager.
  94965. * @param index the rendering group index to get the information for
  94966. * @returns The auto clear setup for the requested rendering group
  94967. */
  94968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94969. }
  94970. }
  94971. declare module BABYLON {
  94972. /**
  94973. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94974. */
  94975. export interface ICustomShaderOptions {
  94976. /**
  94977. * Gets or sets the custom shader name to use
  94978. */
  94979. shaderName: string;
  94980. /**
  94981. * The list of attribute names used in the shader
  94982. */
  94983. attributes?: string[];
  94984. /**
  94985. * The list of unifrom names used in the shader
  94986. */
  94987. uniforms?: string[];
  94988. /**
  94989. * The list of sampler names used in the shader
  94990. */
  94991. samplers?: string[];
  94992. /**
  94993. * The list of defines used in the shader
  94994. */
  94995. defines?: string[];
  94996. }
  94997. /**
  94998. * Interface to implement to create a shadow generator compatible with BJS.
  94999. */
  95000. export interface IShadowGenerator {
  95001. /**
  95002. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95003. * @returns The render target texture if present otherwise, null
  95004. */
  95005. getShadowMap(): Nullable<RenderTargetTexture>;
  95006. /**
  95007. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95008. * @param subMesh The submesh we want to render in the shadow map
  95009. * @param useInstances Defines wether will draw in the map using instances
  95010. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95011. * @returns true if ready otherwise, false
  95012. */
  95013. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95014. /**
  95015. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95016. * @param defines Defines of the material we want to update
  95017. * @param lightIndex Index of the light in the enabled light list of the material
  95018. */
  95019. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95020. /**
  95021. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95022. * defined in the generator but impacting the effect).
  95023. * It implies the unifroms available on the materials are the standard BJS ones.
  95024. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95025. * @param effect The effect we are binfing the information for
  95026. */
  95027. bindShadowLight(lightIndex: string, effect: Effect): void;
  95028. /**
  95029. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95030. * (eq to shadow prjection matrix * light transform matrix)
  95031. * @returns The transform matrix used to create the shadow map
  95032. */
  95033. getTransformMatrix(): Matrix;
  95034. /**
  95035. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95036. * Cube and 2D textures for instance.
  95037. */
  95038. recreateShadowMap(): void;
  95039. /**
  95040. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95041. * @param onCompiled Callback triggered at the and of the effects compilation
  95042. * @param options Sets of optional options forcing the compilation with different modes
  95043. */
  95044. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95045. useInstances: boolean;
  95046. }>): void;
  95047. /**
  95048. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95049. * @param options Sets of optional options forcing the compilation with different modes
  95050. * @returns A promise that resolves when the compilation completes
  95051. */
  95052. forceCompilationAsync(options?: Partial<{
  95053. useInstances: boolean;
  95054. }>): Promise<void>;
  95055. /**
  95056. * Serializes the shadow generator setup to a json object.
  95057. * @returns The serialized JSON object
  95058. */
  95059. serialize(): any;
  95060. /**
  95061. * Disposes the Shadow map and related Textures and effects.
  95062. */
  95063. dispose(): void;
  95064. }
  95065. /**
  95066. * Default implementation IShadowGenerator.
  95067. * This is the main object responsible of generating shadows in the framework.
  95068. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95069. */
  95070. export class ShadowGenerator implements IShadowGenerator {
  95071. /**
  95072. * Name of the shadow generator class
  95073. */
  95074. static CLASSNAME: string;
  95075. /**
  95076. * Shadow generator mode None: no filtering applied.
  95077. */
  95078. static readonly FILTER_NONE: number;
  95079. /**
  95080. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95081. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95082. */
  95083. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95084. /**
  95085. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95086. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95087. */
  95088. static readonly FILTER_POISSONSAMPLING: number;
  95089. /**
  95090. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95091. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95092. */
  95093. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95094. /**
  95095. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95096. * edge artifacts on steep falloff.
  95097. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95098. */
  95099. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95100. /**
  95101. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95102. * edge artifacts on steep falloff.
  95103. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95104. */
  95105. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95106. /**
  95107. * Shadow generator mode PCF: Percentage Closer Filtering
  95108. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95109. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95110. */
  95111. static readonly FILTER_PCF: number;
  95112. /**
  95113. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95114. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95115. * Contact Hardening
  95116. */
  95117. static readonly FILTER_PCSS: number;
  95118. /**
  95119. * Reserved for PCF and PCSS
  95120. * Highest Quality.
  95121. *
  95122. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95123. *
  95124. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95125. */
  95126. static readonly QUALITY_HIGH: number;
  95127. /**
  95128. * Reserved for PCF and PCSS
  95129. * Good tradeoff for quality/perf cross devices
  95130. *
  95131. * Execute PCF on a 3*3 kernel.
  95132. *
  95133. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95134. */
  95135. static readonly QUALITY_MEDIUM: number;
  95136. /**
  95137. * Reserved for PCF and PCSS
  95138. * The lowest quality but the fastest.
  95139. *
  95140. * Execute PCF on a 1*1 kernel.
  95141. *
  95142. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95143. */
  95144. static readonly QUALITY_LOW: number;
  95145. /** Gets or sets the custom shader name to use */
  95146. customShaderOptions: ICustomShaderOptions;
  95147. /**
  95148. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95149. */
  95150. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95151. /**
  95152. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95153. */
  95154. onAfterShadowMapRenderObservable: Observable<Effect>;
  95155. /**
  95156. * Observable triggered before a mesh is rendered in the shadow map.
  95157. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95158. */
  95159. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95160. /**
  95161. * Observable triggered after a mesh is rendered in the shadow map.
  95162. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95163. */
  95164. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95165. protected _bias: number;
  95166. /**
  95167. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95168. */
  95169. get bias(): number;
  95170. /**
  95171. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95172. */
  95173. set bias(bias: number);
  95174. protected _normalBias: number;
  95175. /**
  95176. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95177. */
  95178. get normalBias(): number;
  95179. /**
  95180. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95181. */
  95182. set normalBias(normalBias: number);
  95183. protected _blurBoxOffset: number;
  95184. /**
  95185. * Gets the blur box offset: offset applied during the blur pass.
  95186. * Only useful if useKernelBlur = false
  95187. */
  95188. get blurBoxOffset(): number;
  95189. /**
  95190. * Sets the blur box offset: offset applied during the blur pass.
  95191. * Only useful if useKernelBlur = false
  95192. */
  95193. set blurBoxOffset(value: number);
  95194. protected _blurScale: number;
  95195. /**
  95196. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95197. * 2 means half of the size.
  95198. */
  95199. get blurScale(): number;
  95200. /**
  95201. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95202. * 2 means half of the size.
  95203. */
  95204. set blurScale(value: number);
  95205. protected _blurKernel: number;
  95206. /**
  95207. * Gets the blur kernel: kernel size of the blur pass.
  95208. * Only useful if useKernelBlur = true
  95209. */
  95210. get blurKernel(): number;
  95211. /**
  95212. * Sets the blur kernel: kernel size of the blur pass.
  95213. * Only useful if useKernelBlur = true
  95214. */
  95215. set blurKernel(value: number);
  95216. protected _useKernelBlur: boolean;
  95217. /**
  95218. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95219. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95220. */
  95221. get useKernelBlur(): boolean;
  95222. /**
  95223. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95224. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95225. */
  95226. set useKernelBlur(value: boolean);
  95227. protected _depthScale: number;
  95228. /**
  95229. * Gets the depth scale used in ESM mode.
  95230. */
  95231. get depthScale(): number;
  95232. /**
  95233. * Sets the depth scale used in ESM mode.
  95234. * This can override the scale stored on the light.
  95235. */
  95236. set depthScale(value: number);
  95237. protected _validateFilter(filter: number): number;
  95238. protected _filter: number;
  95239. /**
  95240. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95241. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95242. */
  95243. get filter(): number;
  95244. /**
  95245. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95246. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95247. */
  95248. set filter(value: number);
  95249. /**
  95250. * Gets if the current filter is set to Poisson Sampling.
  95251. */
  95252. get usePoissonSampling(): boolean;
  95253. /**
  95254. * Sets the current filter to Poisson Sampling.
  95255. */
  95256. set usePoissonSampling(value: boolean);
  95257. /**
  95258. * Gets if the current filter is set to ESM.
  95259. */
  95260. get useExponentialShadowMap(): boolean;
  95261. /**
  95262. * Sets the current filter is to ESM.
  95263. */
  95264. set useExponentialShadowMap(value: boolean);
  95265. /**
  95266. * Gets if the current filter is set to filtered ESM.
  95267. */
  95268. get useBlurExponentialShadowMap(): boolean;
  95269. /**
  95270. * Gets if the current filter is set to filtered ESM.
  95271. */
  95272. set useBlurExponentialShadowMap(value: boolean);
  95273. /**
  95274. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95275. * exponential to prevent steep falloff artifacts).
  95276. */
  95277. get useCloseExponentialShadowMap(): boolean;
  95278. /**
  95279. * Sets the current filter to "close ESM" (using the inverse of the
  95280. * exponential to prevent steep falloff artifacts).
  95281. */
  95282. set useCloseExponentialShadowMap(value: boolean);
  95283. /**
  95284. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95285. * exponential to prevent steep falloff artifacts).
  95286. */
  95287. get useBlurCloseExponentialShadowMap(): boolean;
  95288. /**
  95289. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95290. * exponential to prevent steep falloff artifacts).
  95291. */
  95292. set useBlurCloseExponentialShadowMap(value: boolean);
  95293. /**
  95294. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95295. */
  95296. get usePercentageCloserFiltering(): boolean;
  95297. /**
  95298. * Sets the current filter to "PCF" (percentage closer filtering).
  95299. */
  95300. set usePercentageCloserFiltering(value: boolean);
  95301. protected _filteringQuality: number;
  95302. /**
  95303. * Gets the PCF or PCSS Quality.
  95304. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95305. */
  95306. get filteringQuality(): number;
  95307. /**
  95308. * Sets the PCF or PCSS Quality.
  95309. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95310. */
  95311. set filteringQuality(filteringQuality: number);
  95312. /**
  95313. * Gets if the current filter is set to "PCSS" (contact hardening).
  95314. */
  95315. get useContactHardeningShadow(): boolean;
  95316. /**
  95317. * Sets the current filter to "PCSS" (contact hardening).
  95318. */
  95319. set useContactHardeningShadow(value: boolean);
  95320. protected _contactHardeningLightSizeUVRatio: number;
  95321. /**
  95322. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95323. * Using a ratio helps keeping shape stability independently of the map size.
  95324. *
  95325. * It does not account for the light projection as it was having too much
  95326. * instability during the light setup or during light position changes.
  95327. *
  95328. * Only valid if useContactHardeningShadow is true.
  95329. */
  95330. get contactHardeningLightSizeUVRatio(): number;
  95331. /**
  95332. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95333. * Using a ratio helps keeping shape stability independently of the map size.
  95334. *
  95335. * It does not account for the light projection as it was having too much
  95336. * instability during the light setup or during light position changes.
  95337. *
  95338. * Only valid if useContactHardeningShadow is true.
  95339. */
  95340. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95341. protected _darkness: number;
  95342. /** Gets or sets the actual darkness of a shadow */
  95343. get darkness(): number;
  95344. set darkness(value: number);
  95345. /**
  95346. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95347. * 0 means strongest and 1 would means no shadow.
  95348. * @returns the darkness.
  95349. */
  95350. getDarkness(): number;
  95351. /**
  95352. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95353. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95354. * @returns the shadow generator allowing fluent coding.
  95355. */
  95356. setDarkness(darkness: number): ShadowGenerator;
  95357. protected _transparencyShadow: boolean;
  95358. /** Gets or sets the ability to have transparent shadow */
  95359. get transparencyShadow(): boolean;
  95360. set transparencyShadow(value: boolean);
  95361. /**
  95362. * Sets the ability to have transparent shadow (boolean).
  95363. * @param transparent True if transparent else False
  95364. * @returns the shadow generator allowing fluent coding
  95365. */
  95366. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95367. /**
  95368. * Enables or disables shadows with varying strength based on the transparency
  95369. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95370. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95371. * mesh.visibility * alphaTexture.a
  95372. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95373. */
  95374. enableSoftTransparentShadow: boolean;
  95375. protected _shadowMap: Nullable<RenderTargetTexture>;
  95376. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95377. /**
  95378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95379. * @returns The render target texture if present otherwise, null
  95380. */
  95381. getShadowMap(): Nullable<RenderTargetTexture>;
  95382. /**
  95383. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95384. * @returns The render target texture if the shadow map is present otherwise, null
  95385. */
  95386. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95387. /**
  95388. * Gets the class name of that object
  95389. * @returns "ShadowGenerator"
  95390. */
  95391. getClassName(): string;
  95392. /**
  95393. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95394. * @param mesh Mesh to add
  95395. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95396. * @returns the Shadow Generator itself
  95397. */
  95398. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95399. /**
  95400. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95401. * @param mesh Mesh to remove
  95402. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95403. * @returns the Shadow Generator itself
  95404. */
  95405. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95406. /**
  95407. * Controls the extent to which the shadows fade out at the edge of the frustum
  95408. */
  95409. frustumEdgeFalloff: number;
  95410. protected _light: IShadowLight;
  95411. /**
  95412. * Returns the associated light object.
  95413. * @returns the light generating the shadow
  95414. */
  95415. getLight(): IShadowLight;
  95416. /**
  95417. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95418. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95419. * It might on the other hand introduce peter panning.
  95420. */
  95421. forceBackFacesOnly: boolean;
  95422. protected _scene: Scene;
  95423. protected _lightDirection: Vector3;
  95424. protected _effect: Effect;
  95425. protected _viewMatrix: Matrix;
  95426. protected _projectionMatrix: Matrix;
  95427. protected _transformMatrix: Matrix;
  95428. protected _cachedPosition: Vector3;
  95429. protected _cachedDirection: Vector3;
  95430. protected _cachedDefines: string;
  95431. protected _currentRenderID: number;
  95432. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95433. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95434. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95435. protected _blurPostProcesses: PostProcess[];
  95436. protected _mapSize: number;
  95437. protected _currentFaceIndex: number;
  95438. protected _currentFaceIndexCache: number;
  95439. protected _textureType: number;
  95440. protected _defaultTextureMatrix: Matrix;
  95441. protected _storedUniqueId: Nullable<number>;
  95442. /** @hidden */
  95443. static _SceneComponentInitialization: (scene: Scene) => void;
  95444. /**
  95445. * Creates a ShadowGenerator object.
  95446. * A ShadowGenerator is the required tool to use the shadows.
  95447. * Each light casting shadows needs to use its own ShadowGenerator.
  95448. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95449. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95450. * @param light The light object generating the shadows.
  95451. * @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.
  95452. */
  95453. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95454. protected _initializeGenerator(): void;
  95455. protected _createTargetRenderTexture(): void;
  95456. protected _initializeShadowMap(): void;
  95457. protected _initializeBlurRTTAndPostProcesses(): void;
  95458. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95459. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95460. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95461. protected _applyFilterValues(): void;
  95462. /**
  95463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95464. * @param onCompiled Callback triggered at the and of the effects compilation
  95465. * @param options Sets of optional options forcing the compilation with different modes
  95466. */
  95467. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95468. useInstances: boolean;
  95469. }>): void;
  95470. /**
  95471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95472. * @param options Sets of optional options forcing the compilation with different modes
  95473. * @returns A promise that resolves when the compilation completes
  95474. */
  95475. forceCompilationAsync(options?: Partial<{
  95476. useInstances: boolean;
  95477. }>): Promise<void>;
  95478. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95479. private _prepareShadowDefines;
  95480. /**
  95481. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95482. * @param subMesh The submesh we want to render in the shadow map
  95483. * @param useInstances Defines wether will draw in the map using instances
  95484. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95485. * @returns true if ready otherwise, false
  95486. */
  95487. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95488. /**
  95489. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95490. * @param defines Defines of the material we want to update
  95491. * @param lightIndex Index of the light in the enabled light list of the material
  95492. */
  95493. prepareDefines(defines: any, lightIndex: number): void;
  95494. /**
  95495. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95496. * defined in the generator but impacting the effect).
  95497. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95498. * @param effect The effect we are binfing the information for
  95499. */
  95500. bindShadowLight(lightIndex: string, effect: Effect): void;
  95501. /**
  95502. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95503. * (eq to shadow prjection matrix * light transform matrix)
  95504. * @returns The transform matrix used to create the shadow map
  95505. */
  95506. getTransformMatrix(): Matrix;
  95507. /**
  95508. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95509. * Cube and 2D textures for instance.
  95510. */
  95511. recreateShadowMap(): void;
  95512. protected _disposeBlurPostProcesses(): void;
  95513. protected _disposeRTTandPostProcesses(): void;
  95514. /**
  95515. * Disposes the ShadowGenerator.
  95516. * Returns nothing.
  95517. */
  95518. dispose(): void;
  95519. /**
  95520. * Serializes the shadow generator setup to a json object.
  95521. * @returns The serialized JSON object
  95522. */
  95523. serialize(): any;
  95524. /**
  95525. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95526. * @param parsedShadowGenerator The JSON object to parse
  95527. * @param scene The scene to create the shadow map for
  95528. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95529. * @returns The parsed shadow generator
  95530. */
  95531. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95532. }
  95533. }
  95534. declare module BABYLON {
  95535. /**
  95536. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95537. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95538. * 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.
  95539. */
  95540. export abstract class Light extends Node {
  95541. /**
  95542. * Falloff Default: light is falling off following the material specification:
  95543. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95544. */
  95545. static readonly FALLOFF_DEFAULT: number;
  95546. /**
  95547. * Falloff Physical: light is falling off following the inverse squared distance law.
  95548. */
  95549. static readonly FALLOFF_PHYSICAL: number;
  95550. /**
  95551. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95552. * to enhance interoperability with other engines.
  95553. */
  95554. static readonly FALLOFF_GLTF: number;
  95555. /**
  95556. * Falloff Standard: light is falling off like in the standard material
  95557. * to enhance interoperability with other materials.
  95558. */
  95559. static readonly FALLOFF_STANDARD: number;
  95560. /**
  95561. * If every light affecting the material is in this lightmapMode,
  95562. * material.lightmapTexture adds or multiplies
  95563. * (depends on material.useLightmapAsShadowmap)
  95564. * after every other light calculations.
  95565. */
  95566. static readonly LIGHTMAP_DEFAULT: number;
  95567. /**
  95568. * material.lightmapTexture as only diffuse lighting from this light
  95569. * adds only specular lighting from this light
  95570. * adds dynamic shadows
  95571. */
  95572. static readonly LIGHTMAP_SPECULAR: number;
  95573. /**
  95574. * material.lightmapTexture as only lighting
  95575. * no light calculation from this light
  95576. * only adds dynamic shadows from this light
  95577. */
  95578. static readonly LIGHTMAP_SHADOWSONLY: number;
  95579. /**
  95580. * Each light type uses the default quantity according to its type:
  95581. * point/spot lights use luminous intensity
  95582. * directional lights use illuminance
  95583. */
  95584. static readonly INTENSITYMODE_AUTOMATIC: number;
  95585. /**
  95586. * lumen (lm)
  95587. */
  95588. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95589. /**
  95590. * candela (lm/sr)
  95591. */
  95592. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95593. /**
  95594. * lux (lm/m^2)
  95595. */
  95596. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95597. /**
  95598. * nit (cd/m^2)
  95599. */
  95600. static readonly INTENSITYMODE_LUMINANCE: number;
  95601. /**
  95602. * Light type const id of the point light.
  95603. */
  95604. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95605. /**
  95606. * Light type const id of the directional light.
  95607. */
  95608. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95609. /**
  95610. * Light type const id of the spot light.
  95611. */
  95612. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95613. /**
  95614. * Light type const id of the hemispheric light.
  95615. */
  95616. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95617. /**
  95618. * Diffuse gives the basic color to an object.
  95619. */
  95620. diffuse: Color3;
  95621. /**
  95622. * Specular produces a highlight color on an object.
  95623. * Note: This is note affecting PBR materials.
  95624. */
  95625. specular: Color3;
  95626. /**
  95627. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95628. * falling off base on range or angle.
  95629. * This can be set to any values in Light.FALLOFF_x.
  95630. *
  95631. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95632. * other types of materials.
  95633. */
  95634. falloffType: number;
  95635. /**
  95636. * Strength of the light.
  95637. * Note: By default it is define in the framework own unit.
  95638. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95639. */
  95640. intensity: number;
  95641. private _range;
  95642. protected _inverseSquaredRange: number;
  95643. /**
  95644. * Defines how far from the source the light is impacting in scene units.
  95645. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95646. */
  95647. get range(): number;
  95648. /**
  95649. * Defines how far from the source the light is impacting in scene units.
  95650. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95651. */
  95652. set range(value: number);
  95653. /**
  95654. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95655. * of light.
  95656. */
  95657. private _photometricScale;
  95658. private _intensityMode;
  95659. /**
  95660. * Gets the photometric scale used to interpret the intensity.
  95661. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95662. */
  95663. get intensityMode(): number;
  95664. /**
  95665. * Sets the photometric scale used to interpret the intensity.
  95666. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95667. */
  95668. set intensityMode(value: number);
  95669. private _radius;
  95670. /**
  95671. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95672. */
  95673. get radius(): number;
  95674. /**
  95675. * sets the light radius used by PBR Materials to simulate soft area lights.
  95676. */
  95677. set radius(value: number);
  95678. private _renderPriority;
  95679. /**
  95680. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95681. * exceeding the number allowed of the materials.
  95682. */
  95683. renderPriority: number;
  95684. private _shadowEnabled;
  95685. /**
  95686. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95687. * the current shadow generator.
  95688. */
  95689. get shadowEnabled(): boolean;
  95690. /**
  95691. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95692. * the current shadow generator.
  95693. */
  95694. set shadowEnabled(value: boolean);
  95695. private _includedOnlyMeshes;
  95696. /**
  95697. * Gets the only meshes impacted by this light.
  95698. */
  95699. get includedOnlyMeshes(): AbstractMesh[];
  95700. /**
  95701. * Sets the only meshes impacted by this light.
  95702. */
  95703. set includedOnlyMeshes(value: AbstractMesh[]);
  95704. private _excludedMeshes;
  95705. /**
  95706. * Gets the meshes not impacted by this light.
  95707. */
  95708. get excludedMeshes(): AbstractMesh[];
  95709. /**
  95710. * Sets the meshes not impacted by this light.
  95711. */
  95712. set excludedMeshes(value: AbstractMesh[]);
  95713. private _excludeWithLayerMask;
  95714. /**
  95715. * Gets the layer id use to find what meshes are not impacted by the light.
  95716. * Inactive if 0
  95717. */
  95718. get excludeWithLayerMask(): number;
  95719. /**
  95720. * Sets the layer id use to find what meshes are not impacted by the light.
  95721. * Inactive if 0
  95722. */
  95723. set excludeWithLayerMask(value: number);
  95724. private _includeOnlyWithLayerMask;
  95725. /**
  95726. * Gets the layer id use to find what meshes are impacted by the light.
  95727. * Inactive if 0
  95728. */
  95729. get includeOnlyWithLayerMask(): number;
  95730. /**
  95731. * Sets the layer id use to find what meshes are impacted by the light.
  95732. * Inactive if 0
  95733. */
  95734. set includeOnlyWithLayerMask(value: number);
  95735. private _lightmapMode;
  95736. /**
  95737. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95738. */
  95739. get lightmapMode(): number;
  95740. /**
  95741. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95742. */
  95743. set lightmapMode(value: number);
  95744. /**
  95745. * Shadow generator associted to the light.
  95746. * @hidden Internal use only.
  95747. */
  95748. _shadowGenerator: Nullable<IShadowGenerator>;
  95749. /**
  95750. * @hidden Internal use only.
  95751. */
  95752. _excludedMeshesIds: string[];
  95753. /**
  95754. * @hidden Internal use only.
  95755. */
  95756. _includedOnlyMeshesIds: string[];
  95757. /**
  95758. * The current light unifom buffer.
  95759. * @hidden Internal use only.
  95760. */
  95761. _uniformBuffer: UniformBuffer;
  95762. /** @hidden */
  95763. _renderId: number;
  95764. /**
  95765. * Creates a Light object in the scene.
  95766. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95767. * @param name The firendly name of the light
  95768. * @param scene The scene the light belongs too
  95769. */
  95770. constructor(name: string, scene: Scene);
  95771. protected abstract _buildUniformLayout(): void;
  95772. /**
  95773. * Sets the passed Effect "effect" with the Light information.
  95774. * @param effect The effect to update
  95775. * @param lightIndex The index of the light in the effect to update
  95776. * @returns The light
  95777. */
  95778. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95779. /**
  95780. * Sets the passed Effect "effect" with the Light textures.
  95781. * @param effect The effect to update
  95782. * @param lightIndex The index of the light in the effect to update
  95783. * @returns The light
  95784. */
  95785. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95786. /**
  95787. * Binds the lights information from the scene to the effect for the given mesh.
  95788. * @param lightIndex Light index
  95789. * @param scene The scene where the light belongs to
  95790. * @param effect The effect we are binding the data to
  95791. * @param useSpecular Defines if specular is supported
  95792. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95793. */
  95794. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95795. /**
  95796. * Sets the passed Effect "effect" with the Light information.
  95797. * @param effect The effect to update
  95798. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95799. * @returns The light
  95800. */
  95801. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95802. /**
  95803. * Returns the string "Light".
  95804. * @returns the class name
  95805. */
  95806. getClassName(): string;
  95807. /** @hidden */
  95808. readonly _isLight: boolean;
  95809. /**
  95810. * Converts the light information to a readable string for debug purpose.
  95811. * @param fullDetails Supports for multiple levels of logging within scene loading
  95812. * @returns the human readable light info
  95813. */
  95814. toString(fullDetails?: boolean): string;
  95815. /** @hidden */
  95816. protected _syncParentEnabledState(): void;
  95817. /**
  95818. * Set the enabled state of this node.
  95819. * @param value - the new enabled state
  95820. */
  95821. setEnabled(value: boolean): void;
  95822. /**
  95823. * Returns the Light associated shadow generator if any.
  95824. * @return the associated shadow generator.
  95825. */
  95826. getShadowGenerator(): Nullable<IShadowGenerator>;
  95827. /**
  95828. * Returns a Vector3, the absolute light position in the World.
  95829. * @returns the world space position of the light
  95830. */
  95831. getAbsolutePosition(): Vector3;
  95832. /**
  95833. * Specifies if the light will affect the passed mesh.
  95834. * @param mesh The mesh to test against the light
  95835. * @return true the mesh is affected otherwise, false.
  95836. */
  95837. canAffectMesh(mesh: AbstractMesh): boolean;
  95838. /**
  95839. * Sort function to order lights for rendering.
  95840. * @param a First Light object to compare to second.
  95841. * @param b Second Light object to compare first.
  95842. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95843. */
  95844. static CompareLightsPriority(a: Light, b: Light): number;
  95845. /**
  95846. * Releases resources associated with this node.
  95847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95849. */
  95850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95851. /**
  95852. * Returns the light type ID (integer).
  95853. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95854. */
  95855. getTypeID(): number;
  95856. /**
  95857. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95858. * @returns the scaled intensity in intensity mode unit
  95859. */
  95860. getScaledIntensity(): number;
  95861. /**
  95862. * Returns a new Light object, named "name", from the current one.
  95863. * @param name The name of the cloned light
  95864. * @param newParent The parent of this light, if it has one
  95865. * @returns the new created light
  95866. */
  95867. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95868. /**
  95869. * Serializes the current light into a Serialization object.
  95870. * @returns the serialized object.
  95871. */
  95872. serialize(): any;
  95873. /**
  95874. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95875. * This new light is named "name" and added to the passed scene.
  95876. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95877. * @param name The friendly name of the light
  95878. * @param scene The scene the new light will belong to
  95879. * @returns the constructor function
  95880. */
  95881. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95882. /**
  95883. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95884. * @param parsedLight The JSON representation of the light
  95885. * @param scene The scene to create the parsed light in
  95886. * @returns the created light after parsing
  95887. */
  95888. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95889. private _hookArrayForExcluded;
  95890. private _hookArrayForIncludedOnly;
  95891. private _resyncMeshes;
  95892. /**
  95893. * Forces the meshes to update their light related information in their rendering used effects
  95894. * @hidden Internal Use Only
  95895. */
  95896. _markMeshesAsLightDirty(): void;
  95897. /**
  95898. * Recomputes the cached photometric scale if needed.
  95899. */
  95900. private _computePhotometricScale;
  95901. /**
  95902. * Returns the Photometric Scale according to the light type and intensity mode.
  95903. */
  95904. private _getPhotometricScale;
  95905. /**
  95906. * Reorder the light in the scene according to their defined priority.
  95907. * @hidden Internal Use Only
  95908. */
  95909. _reorderLightsInScene(): void;
  95910. /**
  95911. * Prepares the list of defines specific to the light type.
  95912. * @param defines the list of defines
  95913. * @param lightIndex defines the index of the light for the effect
  95914. */
  95915. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95916. }
  95917. }
  95918. declare module BABYLON {
  95919. /**
  95920. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95921. * This is the base of the follow, arc rotate cameras and Free camera
  95922. * @see http://doc.babylonjs.com/features/cameras
  95923. */
  95924. export class TargetCamera extends Camera {
  95925. private static _RigCamTransformMatrix;
  95926. private static _TargetTransformMatrix;
  95927. private static _TargetFocalPoint;
  95928. private _tmpUpVector;
  95929. private _tmpTargetVector;
  95930. /**
  95931. * Define the current direction the camera is moving to
  95932. */
  95933. cameraDirection: Vector3;
  95934. /**
  95935. * Define the current rotation the camera is rotating to
  95936. */
  95937. cameraRotation: Vector2;
  95938. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  95939. ignoreParentScaling: boolean;
  95940. /**
  95941. * When set, the up vector of the camera will be updated by the rotation of the camera
  95942. */
  95943. updateUpVectorFromRotation: boolean;
  95944. private _tmpQuaternion;
  95945. /**
  95946. * Define the current rotation of the camera
  95947. */
  95948. rotation: Vector3;
  95949. /**
  95950. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95951. */
  95952. rotationQuaternion: Quaternion;
  95953. /**
  95954. * Define the current speed of the camera
  95955. */
  95956. speed: number;
  95957. /**
  95958. * Add constraint to the camera to prevent it to move freely in all directions and
  95959. * around all axis.
  95960. */
  95961. noRotationConstraint: boolean;
  95962. /**
  95963. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95964. * panning
  95965. */
  95966. invertRotation: boolean;
  95967. /**
  95968. * Speed multiplier for inverse camera panning
  95969. */
  95970. inverseRotationSpeed: number;
  95971. /**
  95972. * Define the current target of the camera as an object or a position.
  95973. */
  95974. lockedTarget: any;
  95975. /** @hidden */
  95976. _currentTarget: Vector3;
  95977. /** @hidden */
  95978. _initialFocalDistance: number;
  95979. /** @hidden */
  95980. _viewMatrix: Matrix;
  95981. /** @hidden */
  95982. _camMatrix: Matrix;
  95983. /** @hidden */
  95984. _cameraTransformMatrix: Matrix;
  95985. /** @hidden */
  95986. _cameraRotationMatrix: Matrix;
  95987. /** @hidden */
  95988. _referencePoint: Vector3;
  95989. /** @hidden */
  95990. _transformedReferencePoint: Vector3;
  95991. /** @hidden */
  95992. _reset: () => void;
  95993. private _defaultUp;
  95994. /**
  95995. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95996. * This is the base of the follow, arc rotate cameras and Free camera
  95997. * @see http://doc.babylonjs.com/features/cameras
  95998. * @param name Defines the name of the camera in the scene
  95999. * @param position Defines the start position of the camera in the scene
  96000. * @param scene Defines the scene the camera belongs to
  96001. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96002. */
  96003. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96004. /**
  96005. * Gets the position in front of the camera at a given distance.
  96006. * @param distance The distance from the camera we want the position to be
  96007. * @returns the position
  96008. */
  96009. getFrontPosition(distance: number): Vector3;
  96010. /** @hidden */
  96011. _getLockedTargetPosition(): Nullable<Vector3>;
  96012. private _storedPosition;
  96013. private _storedRotation;
  96014. private _storedRotationQuaternion;
  96015. /**
  96016. * Store current camera state of the camera (fov, position, rotation, etc..)
  96017. * @returns the camera
  96018. */
  96019. storeState(): Camera;
  96020. /**
  96021. * Restored camera state. You must call storeState() first
  96022. * @returns whether it was successful or not
  96023. * @hidden
  96024. */
  96025. _restoreStateValues(): boolean;
  96026. /** @hidden */
  96027. _initCache(): void;
  96028. /** @hidden */
  96029. _updateCache(ignoreParentClass?: boolean): void;
  96030. /** @hidden */
  96031. _isSynchronizedViewMatrix(): boolean;
  96032. /** @hidden */
  96033. _computeLocalCameraSpeed(): number;
  96034. /**
  96035. * Defines the target the camera should look at.
  96036. * @param target Defines the new target as a Vector or a mesh
  96037. */
  96038. setTarget(target: Vector3): void;
  96039. /**
  96040. * Return the current target position of the camera. This value is expressed in local space.
  96041. * @returns the target position
  96042. */
  96043. getTarget(): Vector3;
  96044. /** @hidden */
  96045. _decideIfNeedsToMove(): boolean;
  96046. /** @hidden */
  96047. _updatePosition(): void;
  96048. /** @hidden */
  96049. _checkInputs(): void;
  96050. protected _updateCameraRotationMatrix(): void;
  96051. /**
  96052. * 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)
  96053. * @returns the current camera
  96054. */
  96055. private _rotateUpVectorWithCameraRotationMatrix;
  96056. private _cachedRotationZ;
  96057. private _cachedQuaternionRotationZ;
  96058. /** @hidden */
  96059. _getViewMatrix(): Matrix;
  96060. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96061. /**
  96062. * @hidden
  96063. */
  96064. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96065. /**
  96066. * @hidden
  96067. */
  96068. _updateRigCameras(): void;
  96069. private _getRigCamPositionAndTarget;
  96070. /**
  96071. * Gets the current object class name.
  96072. * @return the class name
  96073. */
  96074. getClassName(): string;
  96075. }
  96076. }
  96077. declare module BABYLON {
  96078. /**
  96079. * Gather the list of keyboard event types as constants.
  96080. */
  96081. export class KeyboardEventTypes {
  96082. /**
  96083. * The keydown event is fired when a key becomes active (pressed).
  96084. */
  96085. static readonly KEYDOWN: number;
  96086. /**
  96087. * The keyup event is fired when a key has been released.
  96088. */
  96089. static readonly KEYUP: number;
  96090. }
  96091. /**
  96092. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96093. */
  96094. export class KeyboardInfo {
  96095. /**
  96096. * Defines the type of event (KeyboardEventTypes)
  96097. */
  96098. type: number;
  96099. /**
  96100. * Defines the related dom event
  96101. */
  96102. event: KeyboardEvent;
  96103. /**
  96104. * Instantiates a new keyboard info.
  96105. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96106. * @param type Defines the type of event (KeyboardEventTypes)
  96107. * @param event Defines the related dom event
  96108. */
  96109. constructor(
  96110. /**
  96111. * Defines the type of event (KeyboardEventTypes)
  96112. */
  96113. type: number,
  96114. /**
  96115. * Defines the related dom event
  96116. */
  96117. event: KeyboardEvent);
  96118. }
  96119. /**
  96120. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96121. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96122. */
  96123. export class KeyboardInfoPre extends KeyboardInfo {
  96124. /**
  96125. * Defines the type of event (KeyboardEventTypes)
  96126. */
  96127. type: number;
  96128. /**
  96129. * Defines the related dom event
  96130. */
  96131. event: KeyboardEvent;
  96132. /**
  96133. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96134. */
  96135. skipOnPointerObservable: boolean;
  96136. /**
  96137. * Instantiates a new keyboard pre info.
  96138. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96139. * @param type Defines the type of event (KeyboardEventTypes)
  96140. * @param event Defines the related dom event
  96141. */
  96142. constructor(
  96143. /**
  96144. * Defines the type of event (KeyboardEventTypes)
  96145. */
  96146. type: number,
  96147. /**
  96148. * Defines the related dom event
  96149. */
  96150. event: KeyboardEvent);
  96151. }
  96152. }
  96153. declare module BABYLON {
  96154. /**
  96155. * Manage the keyboard inputs to control the movement of a free camera.
  96156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96157. */
  96158. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96159. /**
  96160. * Defines the camera the input is attached to.
  96161. */
  96162. camera: FreeCamera;
  96163. /**
  96164. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96165. */
  96166. keysUp: number[];
  96167. /**
  96168. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96169. */
  96170. keysUpward: number[];
  96171. /**
  96172. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96173. */
  96174. keysDown: number[];
  96175. /**
  96176. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96177. */
  96178. keysDownward: number[];
  96179. /**
  96180. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96181. */
  96182. keysLeft: number[];
  96183. /**
  96184. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96185. */
  96186. keysRight: number[];
  96187. private _keys;
  96188. private _onCanvasBlurObserver;
  96189. private _onKeyboardObserver;
  96190. private _engine;
  96191. private _scene;
  96192. /**
  96193. * Attach the input controls to a specific dom element to get the input from.
  96194. * @param element Defines the element the controls should be listened from
  96195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96196. */
  96197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96198. /**
  96199. * Detach the current controls from the specified dom element.
  96200. * @param element Defines the element to stop listening the inputs from
  96201. */
  96202. detachControl(element: Nullable<HTMLElement>): void;
  96203. /**
  96204. * Update the current camera state depending on the inputs that have been used this frame.
  96205. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96206. */
  96207. checkInputs(): void;
  96208. /**
  96209. * Gets the class name of the current intput.
  96210. * @returns the class name
  96211. */
  96212. getClassName(): string;
  96213. /** @hidden */
  96214. _onLostFocus(): void;
  96215. /**
  96216. * Get the friendly name associated with the input class.
  96217. * @returns the input friendly name
  96218. */
  96219. getSimpleName(): string;
  96220. }
  96221. }
  96222. declare module BABYLON {
  96223. /**
  96224. * Gather the list of pointer event types as constants.
  96225. */
  96226. export class PointerEventTypes {
  96227. /**
  96228. * 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.
  96229. */
  96230. static readonly POINTERDOWN: number;
  96231. /**
  96232. * The pointerup event is fired when a pointer is no longer active.
  96233. */
  96234. static readonly POINTERUP: number;
  96235. /**
  96236. * The pointermove event is fired when a pointer changes coordinates.
  96237. */
  96238. static readonly POINTERMOVE: number;
  96239. /**
  96240. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96241. */
  96242. static readonly POINTERWHEEL: number;
  96243. /**
  96244. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96245. */
  96246. static readonly POINTERPICK: number;
  96247. /**
  96248. * The pointertap event is fired when a the object has been touched and released without drag.
  96249. */
  96250. static readonly POINTERTAP: number;
  96251. /**
  96252. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96253. */
  96254. static readonly POINTERDOUBLETAP: number;
  96255. }
  96256. /**
  96257. * Base class of pointer info types.
  96258. */
  96259. export class PointerInfoBase {
  96260. /**
  96261. * Defines the type of event (PointerEventTypes)
  96262. */
  96263. type: number;
  96264. /**
  96265. * Defines the related dom event
  96266. */
  96267. event: PointerEvent | MouseWheelEvent;
  96268. /**
  96269. * Instantiates the base class of pointers info.
  96270. * @param type Defines the type of event (PointerEventTypes)
  96271. * @param event Defines the related dom event
  96272. */
  96273. constructor(
  96274. /**
  96275. * Defines the type of event (PointerEventTypes)
  96276. */
  96277. type: number,
  96278. /**
  96279. * Defines the related dom event
  96280. */
  96281. event: PointerEvent | MouseWheelEvent);
  96282. }
  96283. /**
  96284. * This class is used to store pointer related info for the onPrePointerObservable event.
  96285. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96286. */
  96287. export class PointerInfoPre extends PointerInfoBase {
  96288. /**
  96289. * Ray from a pointer if availible (eg. 6dof controller)
  96290. */
  96291. ray: Nullable<Ray>;
  96292. /**
  96293. * Defines the local position of the pointer on the canvas.
  96294. */
  96295. localPosition: Vector2;
  96296. /**
  96297. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96298. */
  96299. skipOnPointerObservable: boolean;
  96300. /**
  96301. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96302. * @param type Defines the type of event (PointerEventTypes)
  96303. * @param event Defines the related dom event
  96304. * @param localX Defines the local x coordinates of the pointer when the event occured
  96305. * @param localY Defines the local y coordinates of the pointer when the event occured
  96306. */
  96307. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96308. }
  96309. /**
  96310. * This type contains all the data related to a pointer event in Babylon.js.
  96311. * 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.
  96312. */
  96313. export class PointerInfo extends PointerInfoBase {
  96314. /**
  96315. * Defines the picking info associated to the info (if any)\
  96316. */
  96317. pickInfo: Nullable<PickingInfo>;
  96318. /**
  96319. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96320. * @param type Defines the type of event (PointerEventTypes)
  96321. * @param event Defines the related dom event
  96322. * @param pickInfo Defines the picking info associated to the info (if any)\
  96323. */
  96324. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96325. /**
  96326. * Defines the picking info associated to the info (if any)\
  96327. */
  96328. pickInfo: Nullable<PickingInfo>);
  96329. }
  96330. /**
  96331. * Data relating to a touch event on the screen.
  96332. */
  96333. export interface PointerTouch {
  96334. /**
  96335. * X coordinate of touch.
  96336. */
  96337. x: number;
  96338. /**
  96339. * Y coordinate of touch.
  96340. */
  96341. y: number;
  96342. /**
  96343. * Id of touch. Unique for each finger.
  96344. */
  96345. pointerId: number;
  96346. /**
  96347. * Event type passed from DOM.
  96348. */
  96349. type: any;
  96350. }
  96351. }
  96352. declare module BABYLON {
  96353. /**
  96354. * Manage the mouse inputs to control the movement of a free camera.
  96355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96356. */
  96357. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96358. /**
  96359. * Define if touch is enabled in the mouse input
  96360. */
  96361. touchEnabled: boolean;
  96362. /**
  96363. * Defines the camera the input is attached to.
  96364. */
  96365. camera: FreeCamera;
  96366. /**
  96367. * Defines the buttons associated with the input to handle camera move.
  96368. */
  96369. buttons: number[];
  96370. /**
  96371. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96372. */
  96373. angularSensibility: number;
  96374. private _pointerInput;
  96375. private _onMouseMove;
  96376. private _observer;
  96377. private previousPosition;
  96378. /**
  96379. * Observable for when a pointer move event occurs containing the move offset
  96380. */
  96381. onPointerMovedObservable: Observable<{
  96382. offsetX: number;
  96383. offsetY: number;
  96384. }>;
  96385. /**
  96386. * @hidden
  96387. * If the camera should be rotated automatically based on pointer movement
  96388. */
  96389. _allowCameraRotation: boolean;
  96390. /**
  96391. * Manage the mouse inputs to control the movement of a free camera.
  96392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96393. * @param touchEnabled Defines if touch is enabled or not
  96394. */
  96395. constructor(
  96396. /**
  96397. * Define if touch is enabled in the mouse input
  96398. */
  96399. touchEnabled?: boolean);
  96400. /**
  96401. * Attach the input controls to a specific dom element to get the input from.
  96402. * @param element Defines the element the controls should be listened from
  96403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96404. */
  96405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96406. /**
  96407. * Called on JS contextmenu event.
  96408. * Override this method to provide functionality.
  96409. */
  96410. protected onContextMenu(evt: PointerEvent): void;
  96411. /**
  96412. * Detach the current controls from the specified dom element.
  96413. * @param element Defines the element to stop listening the inputs from
  96414. */
  96415. detachControl(element: Nullable<HTMLElement>): void;
  96416. /**
  96417. * Gets the class name of the current intput.
  96418. * @returns the class name
  96419. */
  96420. getClassName(): string;
  96421. /**
  96422. * Get the friendly name associated with the input class.
  96423. * @returns the input friendly name
  96424. */
  96425. getSimpleName(): string;
  96426. }
  96427. }
  96428. declare module BABYLON {
  96429. /**
  96430. * Manage the touch inputs to control the movement of a free camera.
  96431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96432. */
  96433. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96434. /**
  96435. * Defines the camera the input is attached to.
  96436. */
  96437. camera: FreeCamera;
  96438. /**
  96439. * Defines the touch sensibility for rotation.
  96440. * The higher the faster.
  96441. */
  96442. touchAngularSensibility: number;
  96443. /**
  96444. * Defines the touch sensibility for move.
  96445. * The higher the faster.
  96446. */
  96447. touchMoveSensibility: number;
  96448. private _offsetX;
  96449. private _offsetY;
  96450. private _pointerPressed;
  96451. private _pointerInput;
  96452. private _observer;
  96453. private _onLostFocus;
  96454. /**
  96455. * Attach the input controls to a specific dom element to get the input from.
  96456. * @param element Defines the element the controls should be listened from
  96457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96458. */
  96459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96460. /**
  96461. * Detach the current controls from the specified dom element.
  96462. * @param element Defines the element to stop listening the inputs from
  96463. */
  96464. detachControl(element: Nullable<HTMLElement>): void;
  96465. /**
  96466. * Update the current camera state depending on the inputs that have been used this frame.
  96467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96468. */
  96469. checkInputs(): void;
  96470. /**
  96471. * Gets the class name of the current intput.
  96472. * @returns the class name
  96473. */
  96474. getClassName(): string;
  96475. /**
  96476. * Get the friendly name associated with the input class.
  96477. * @returns the input friendly name
  96478. */
  96479. getSimpleName(): string;
  96480. }
  96481. }
  96482. declare module BABYLON {
  96483. /**
  96484. * Default Inputs manager for the FreeCamera.
  96485. * It groups all the default supported inputs for ease of use.
  96486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96487. */
  96488. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96489. /**
  96490. * @hidden
  96491. */
  96492. _mouseInput: Nullable<FreeCameraMouseInput>;
  96493. /**
  96494. * Instantiates a new FreeCameraInputsManager.
  96495. * @param camera Defines the camera the inputs belong to
  96496. */
  96497. constructor(camera: FreeCamera);
  96498. /**
  96499. * Add keyboard input support to the input manager.
  96500. * @returns the current input manager
  96501. */
  96502. addKeyboard(): FreeCameraInputsManager;
  96503. /**
  96504. * Add mouse input support to the input manager.
  96505. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96506. * @returns the current input manager
  96507. */
  96508. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96509. /**
  96510. * Removes the mouse input support from the manager
  96511. * @returns the current input manager
  96512. */
  96513. removeMouse(): FreeCameraInputsManager;
  96514. /**
  96515. * Add touch input support to the input manager.
  96516. * @returns the current input manager
  96517. */
  96518. addTouch(): FreeCameraInputsManager;
  96519. /**
  96520. * Remove all attached input methods from a camera
  96521. */
  96522. clear(): void;
  96523. }
  96524. }
  96525. declare module BABYLON {
  96526. /**
  96527. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96528. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96530. */
  96531. export class FreeCamera extends TargetCamera {
  96532. /**
  96533. * Define the collision ellipsoid of the camera.
  96534. * This is helpful to simulate a camera body like the player body around the camera
  96535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96536. */
  96537. ellipsoid: Vector3;
  96538. /**
  96539. * Define an offset for the position of the ellipsoid around the camera.
  96540. * This can be helpful to determine the center of the body near the gravity center of the body
  96541. * instead of its head.
  96542. */
  96543. ellipsoidOffset: Vector3;
  96544. /**
  96545. * Enable or disable collisions of the camera with the rest of the scene objects.
  96546. */
  96547. checkCollisions: boolean;
  96548. /**
  96549. * Enable or disable gravity on the camera.
  96550. */
  96551. applyGravity: boolean;
  96552. /**
  96553. * Define the input manager associated to the camera.
  96554. */
  96555. inputs: FreeCameraInputsManager;
  96556. /**
  96557. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96558. * Higher values reduce sensitivity.
  96559. */
  96560. get angularSensibility(): number;
  96561. /**
  96562. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96563. * Higher values reduce sensitivity.
  96564. */
  96565. set angularSensibility(value: number);
  96566. /**
  96567. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96568. */
  96569. get keysUp(): number[];
  96570. set keysUp(value: number[]);
  96571. /**
  96572. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96573. */
  96574. get keysUpward(): number[];
  96575. set keysUpward(value: number[]);
  96576. /**
  96577. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96578. */
  96579. get keysDown(): number[];
  96580. set keysDown(value: number[]);
  96581. /**
  96582. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96583. */
  96584. get keysDownward(): number[];
  96585. set keysDownward(value: number[]);
  96586. /**
  96587. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96588. */
  96589. get keysLeft(): number[];
  96590. set keysLeft(value: number[]);
  96591. /**
  96592. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96593. */
  96594. get keysRight(): number[];
  96595. set keysRight(value: number[]);
  96596. /**
  96597. * Event raised when the camera collide with a mesh in the scene.
  96598. */
  96599. onCollide: (collidedMesh: AbstractMesh) => void;
  96600. private _collider;
  96601. private _needMoveForGravity;
  96602. private _oldPosition;
  96603. private _diffPosition;
  96604. private _newPosition;
  96605. /** @hidden */
  96606. _localDirection: Vector3;
  96607. /** @hidden */
  96608. _transformedDirection: Vector3;
  96609. /**
  96610. * Instantiates a Free Camera.
  96611. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96612. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96613. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96614. * @param name Define the name of the camera in the scene
  96615. * @param position Define the start position of the camera in the scene
  96616. * @param scene Define the scene the camera belongs to
  96617. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96618. */
  96619. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96620. /**
  96621. * Attached controls to the current camera.
  96622. * @param element Defines the element the controls should be listened from
  96623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96624. */
  96625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96626. /**
  96627. * Detach the current controls from the camera.
  96628. * The camera will stop reacting to inputs.
  96629. * @param element Defines the element to stop listening the inputs from
  96630. */
  96631. detachControl(element: HTMLElement): void;
  96632. private _collisionMask;
  96633. /**
  96634. * Define a collision mask to limit the list of object the camera can collide with
  96635. */
  96636. get collisionMask(): number;
  96637. set collisionMask(mask: number);
  96638. /** @hidden */
  96639. _collideWithWorld(displacement: Vector3): void;
  96640. private _onCollisionPositionChange;
  96641. /** @hidden */
  96642. _checkInputs(): void;
  96643. /** @hidden */
  96644. _decideIfNeedsToMove(): boolean;
  96645. /** @hidden */
  96646. _updatePosition(): void;
  96647. /**
  96648. * Destroy the camera and release the current resources hold by it.
  96649. */
  96650. dispose(): void;
  96651. /**
  96652. * Gets the current object class name.
  96653. * @return the class name
  96654. */
  96655. getClassName(): string;
  96656. }
  96657. }
  96658. declare module BABYLON {
  96659. /**
  96660. * Represents a gamepad control stick position
  96661. */
  96662. export class StickValues {
  96663. /**
  96664. * The x component of the control stick
  96665. */
  96666. x: number;
  96667. /**
  96668. * The y component of the control stick
  96669. */
  96670. y: number;
  96671. /**
  96672. * Initializes the gamepad x and y control stick values
  96673. * @param x The x component of the gamepad control stick value
  96674. * @param y The y component of the gamepad control stick value
  96675. */
  96676. constructor(
  96677. /**
  96678. * The x component of the control stick
  96679. */
  96680. x: number,
  96681. /**
  96682. * The y component of the control stick
  96683. */
  96684. y: number);
  96685. }
  96686. /**
  96687. * An interface which manages callbacks for gamepad button changes
  96688. */
  96689. export interface GamepadButtonChanges {
  96690. /**
  96691. * Called when a gamepad has been changed
  96692. */
  96693. changed: boolean;
  96694. /**
  96695. * Called when a gamepad press event has been triggered
  96696. */
  96697. pressChanged: boolean;
  96698. /**
  96699. * Called when a touch event has been triggered
  96700. */
  96701. touchChanged: boolean;
  96702. /**
  96703. * Called when a value has changed
  96704. */
  96705. valueChanged: boolean;
  96706. }
  96707. /**
  96708. * Represents a gamepad
  96709. */
  96710. export class Gamepad {
  96711. /**
  96712. * The id of the gamepad
  96713. */
  96714. id: string;
  96715. /**
  96716. * The index of the gamepad
  96717. */
  96718. index: number;
  96719. /**
  96720. * The browser gamepad
  96721. */
  96722. browserGamepad: any;
  96723. /**
  96724. * Specifies what type of gamepad this represents
  96725. */
  96726. type: number;
  96727. private _leftStick;
  96728. private _rightStick;
  96729. /** @hidden */
  96730. _isConnected: boolean;
  96731. private _leftStickAxisX;
  96732. private _leftStickAxisY;
  96733. private _rightStickAxisX;
  96734. private _rightStickAxisY;
  96735. /**
  96736. * Triggered when the left control stick has been changed
  96737. */
  96738. private _onleftstickchanged;
  96739. /**
  96740. * Triggered when the right control stick has been changed
  96741. */
  96742. private _onrightstickchanged;
  96743. /**
  96744. * Represents a gamepad controller
  96745. */
  96746. static GAMEPAD: number;
  96747. /**
  96748. * Represents a generic controller
  96749. */
  96750. static GENERIC: number;
  96751. /**
  96752. * Represents an XBox controller
  96753. */
  96754. static XBOX: number;
  96755. /**
  96756. * Represents a pose-enabled controller
  96757. */
  96758. static POSE_ENABLED: number;
  96759. /**
  96760. * Represents an Dual Shock controller
  96761. */
  96762. static DUALSHOCK: number;
  96763. /**
  96764. * Specifies whether the left control stick should be Y-inverted
  96765. */
  96766. protected _invertLeftStickY: boolean;
  96767. /**
  96768. * Specifies if the gamepad has been connected
  96769. */
  96770. get isConnected(): boolean;
  96771. /**
  96772. * Initializes the gamepad
  96773. * @param id The id of the gamepad
  96774. * @param index The index of the gamepad
  96775. * @param browserGamepad The browser gamepad
  96776. * @param leftStickX The x component of the left joystick
  96777. * @param leftStickY The y component of the left joystick
  96778. * @param rightStickX The x component of the right joystick
  96779. * @param rightStickY The y component of the right joystick
  96780. */
  96781. constructor(
  96782. /**
  96783. * The id of the gamepad
  96784. */
  96785. id: string,
  96786. /**
  96787. * The index of the gamepad
  96788. */
  96789. index: number,
  96790. /**
  96791. * The browser gamepad
  96792. */
  96793. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96794. /**
  96795. * Callback triggered when the left joystick has changed
  96796. * @param callback
  96797. */
  96798. onleftstickchanged(callback: (values: StickValues) => void): void;
  96799. /**
  96800. * Callback triggered when the right joystick has changed
  96801. * @param callback
  96802. */
  96803. onrightstickchanged(callback: (values: StickValues) => void): void;
  96804. /**
  96805. * Gets the left joystick
  96806. */
  96807. get leftStick(): StickValues;
  96808. /**
  96809. * Sets the left joystick values
  96810. */
  96811. set leftStick(newValues: StickValues);
  96812. /**
  96813. * Gets the right joystick
  96814. */
  96815. get rightStick(): StickValues;
  96816. /**
  96817. * Sets the right joystick value
  96818. */
  96819. set rightStick(newValues: StickValues);
  96820. /**
  96821. * Updates the gamepad joystick positions
  96822. */
  96823. update(): void;
  96824. /**
  96825. * Disposes the gamepad
  96826. */
  96827. dispose(): void;
  96828. }
  96829. /**
  96830. * Represents a generic gamepad
  96831. */
  96832. export class GenericPad extends Gamepad {
  96833. private _buttons;
  96834. private _onbuttondown;
  96835. private _onbuttonup;
  96836. /**
  96837. * Observable triggered when a button has been pressed
  96838. */
  96839. onButtonDownObservable: Observable<number>;
  96840. /**
  96841. * Observable triggered when a button has been released
  96842. */
  96843. onButtonUpObservable: Observable<number>;
  96844. /**
  96845. * Callback triggered when a button has been pressed
  96846. * @param callback Called when a button has been pressed
  96847. */
  96848. onbuttondown(callback: (buttonPressed: number) => void): void;
  96849. /**
  96850. * Callback triggered when a button has been released
  96851. * @param callback Called when a button has been released
  96852. */
  96853. onbuttonup(callback: (buttonReleased: number) => void): void;
  96854. /**
  96855. * Initializes the generic gamepad
  96856. * @param id The id of the generic gamepad
  96857. * @param index The index of the generic gamepad
  96858. * @param browserGamepad The browser gamepad
  96859. */
  96860. constructor(id: string, index: number, browserGamepad: any);
  96861. private _setButtonValue;
  96862. /**
  96863. * Updates the generic gamepad
  96864. */
  96865. update(): void;
  96866. /**
  96867. * Disposes the generic gamepad
  96868. */
  96869. dispose(): void;
  96870. }
  96871. }
  96872. declare module BABYLON {
  96873. /**
  96874. * Defines the types of pose enabled controllers that are supported
  96875. */
  96876. export enum PoseEnabledControllerType {
  96877. /**
  96878. * HTC Vive
  96879. */
  96880. VIVE = 0,
  96881. /**
  96882. * Oculus Rift
  96883. */
  96884. OCULUS = 1,
  96885. /**
  96886. * Windows mixed reality
  96887. */
  96888. WINDOWS = 2,
  96889. /**
  96890. * Samsung gear VR
  96891. */
  96892. GEAR_VR = 3,
  96893. /**
  96894. * Google Daydream
  96895. */
  96896. DAYDREAM = 4,
  96897. /**
  96898. * Generic
  96899. */
  96900. GENERIC = 5
  96901. }
  96902. /**
  96903. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96904. */
  96905. export interface MutableGamepadButton {
  96906. /**
  96907. * Value of the button/trigger
  96908. */
  96909. value: number;
  96910. /**
  96911. * If the button/trigger is currently touched
  96912. */
  96913. touched: boolean;
  96914. /**
  96915. * If the button/trigger is currently pressed
  96916. */
  96917. pressed: boolean;
  96918. }
  96919. /**
  96920. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96921. * @hidden
  96922. */
  96923. export interface ExtendedGamepadButton extends GamepadButton {
  96924. /**
  96925. * If the button/trigger is currently pressed
  96926. */
  96927. readonly pressed: boolean;
  96928. /**
  96929. * If the button/trigger is currently touched
  96930. */
  96931. readonly touched: boolean;
  96932. /**
  96933. * Value of the button/trigger
  96934. */
  96935. readonly value: number;
  96936. }
  96937. /** @hidden */
  96938. export interface _GamePadFactory {
  96939. /**
  96940. * Returns whether or not the current gamepad can be created for this type of controller.
  96941. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96942. * @returns true if it can be created, otherwise false
  96943. */
  96944. canCreate(gamepadInfo: any): boolean;
  96945. /**
  96946. * Creates a new instance of the Gamepad.
  96947. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96948. * @returns the new gamepad instance
  96949. */
  96950. create(gamepadInfo: any): Gamepad;
  96951. }
  96952. /**
  96953. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96954. */
  96955. export class PoseEnabledControllerHelper {
  96956. /** @hidden */
  96957. static _ControllerFactories: _GamePadFactory[];
  96958. /** @hidden */
  96959. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96960. /**
  96961. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96962. * @param vrGamepad the gamepad to initialized
  96963. * @returns a vr controller of the type the gamepad identified as
  96964. */
  96965. static InitiateController(vrGamepad: any): Gamepad;
  96966. }
  96967. /**
  96968. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96969. */
  96970. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96971. /**
  96972. * If the controller is used in a webXR session
  96973. */
  96974. isXR: boolean;
  96975. private _deviceRoomPosition;
  96976. private _deviceRoomRotationQuaternion;
  96977. /**
  96978. * The device position in babylon space
  96979. */
  96980. devicePosition: Vector3;
  96981. /**
  96982. * The device rotation in babylon space
  96983. */
  96984. deviceRotationQuaternion: Quaternion;
  96985. /**
  96986. * The scale factor of the device in babylon space
  96987. */
  96988. deviceScaleFactor: number;
  96989. /**
  96990. * (Likely devicePosition should be used instead) The device position in its room space
  96991. */
  96992. position: Vector3;
  96993. /**
  96994. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96995. */
  96996. rotationQuaternion: Quaternion;
  96997. /**
  96998. * The type of controller (Eg. Windows mixed reality)
  96999. */
  97000. controllerType: PoseEnabledControllerType;
  97001. protected _calculatedPosition: Vector3;
  97002. private _calculatedRotation;
  97003. /**
  97004. * The raw pose from the device
  97005. */
  97006. rawPose: DevicePose;
  97007. private _trackPosition;
  97008. private _maxRotationDistFromHeadset;
  97009. private _draggedRoomRotation;
  97010. /**
  97011. * @hidden
  97012. */
  97013. _disableTrackPosition(fixedPosition: Vector3): void;
  97014. /**
  97015. * Internal, the mesh attached to the controller
  97016. * @hidden
  97017. */
  97018. _mesh: Nullable<AbstractMesh>;
  97019. private _poseControlledCamera;
  97020. private _leftHandSystemQuaternion;
  97021. /**
  97022. * Internal, matrix used to convert room space to babylon space
  97023. * @hidden
  97024. */
  97025. _deviceToWorld: Matrix;
  97026. /**
  97027. * Node to be used when casting a ray from the controller
  97028. * @hidden
  97029. */
  97030. _pointingPoseNode: Nullable<TransformNode>;
  97031. /**
  97032. * Name of the child mesh that can be used to cast a ray from the controller
  97033. */
  97034. static readonly POINTING_POSE: string;
  97035. /**
  97036. * Creates a new PoseEnabledController from a gamepad
  97037. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97038. */
  97039. constructor(browserGamepad: any);
  97040. private _workingMatrix;
  97041. /**
  97042. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97043. */
  97044. update(): void;
  97045. /**
  97046. * Updates only the pose device and mesh without doing any button event checking
  97047. */
  97048. protected _updatePoseAndMesh(): void;
  97049. /**
  97050. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97051. * @param poseData raw pose fromthe device
  97052. */
  97053. updateFromDevice(poseData: DevicePose): void;
  97054. /**
  97055. * @hidden
  97056. */
  97057. _meshAttachedObservable: Observable<AbstractMesh>;
  97058. /**
  97059. * Attaches a mesh to the controller
  97060. * @param mesh the mesh to be attached
  97061. */
  97062. attachToMesh(mesh: AbstractMesh): void;
  97063. /**
  97064. * Attaches the controllers mesh to a camera
  97065. * @param camera the camera the mesh should be attached to
  97066. */
  97067. attachToPoseControlledCamera(camera: TargetCamera): void;
  97068. /**
  97069. * Disposes of the controller
  97070. */
  97071. dispose(): void;
  97072. /**
  97073. * The mesh that is attached to the controller
  97074. */
  97075. get mesh(): Nullable<AbstractMesh>;
  97076. /**
  97077. * Gets the ray of the controller in the direction the controller is pointing
  97078. * @param length the length the resulting ray should be
  97079. * @returns a ray in the direction the controller is pointing
  97080. */
  97081. getForwardRay(length?: number): Ray;
  97082. }
  97083. }
  97084. declare module BABYLON {
  97085. /**
  97086. * Defines the WebVRController object that represents controllers tracked in 3D space
  97087. */
  97088. export abstract class WebVRController extends PoseEnabledController {
  97089. /**
  97090. * Internal, the default controller model for the controller
  97091. */
  97092. protected _defaultModel: Nullable<AbstractMesh>;
  97093. /**
  97094. * Fired when the trigger state has changed
  97095. */
  97096. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97097. /**
  97098. * Fired when the main button state has changed
  97099. */
  97100. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97101. /**
  97102. * Fired when the secondary button state has changed
  97103. */
  97104. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97105. /**
  97106. * Fired when the pad state has changed
  97107. */
  97108. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97109. /**
  97110. * Fired when controllers stick values have changed
  97111. */
  97112. onPadValuesChangedObservable: Observable<StickValues>;
  97113. /**
  97114. * Array of button availible on the controller
  97115. */
  97116. protected _buttons: Array<MutableGamepadButton>;
  97117. private _onButtonStateChange;
  97118. /**
  97119. * Fired when a controller button's state has changed
  97120. * @param callback the callback containing the button that was modified
  97121. */
  97122. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97123. /**
  97124. * X and Y axis corresponding to the controllers joystick
  97125. */
  97126. pad: StickValues;
  97127. /**
  97128. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97129. */
  97130. hand: string;
  97131. /**
  97132. * The default controller model for the controller
  97133. */
  97134. get defaultModel(): Nullable<AbstractMesh>;
  97135. /**
  97136. * Creates a new WebVRController from a gamepad
  97137. * @param vrGamepad the gamepad that the WebVRController should be created from
  97138. */
  97139. constructor(vrGamepad: any);
  97140. /**
  97141. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97142. */
  97143. update(): void;
  97144. /**
  97145. * Function to be called when a button is modified
  97146. */
  97147. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97148. /**
  97149. * Loads a mesh and attaches it to the controller
  97150. * @param scene the scene the mesh should be added to
  97151. * @param meshLoaded callback for when the mesh has been loaded
  97152. */
  97153. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97154. private _setButtonValue;
  97155. private _changes;
  97156. private _checkChanges;
  97157. /**
  97158. * Disposes of th webVRCOntroller
  97159. */
  97160. dispose(): void;
  97161. }
  97162. }
  97163. declare module BABYLON {
  97164. /**
  97165. * The HemisphericLight simulates the ambient environment light,
  97166. * so the passed direction is the light reflection direction, not the incoming direction.
  97167. */
  97168. export class HemisphericLight extends Light {
  97169. /**
  97170. * The groundColor is the light in the opposite direction to the one specified during creation.
  97171. * 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.
  97172. */
  97173. groundColor: Color3;
  97174. /**
  97175. * The light reflection direction, not the incoming direction.
  97176. */
  97177. direction: Vector3;
  97178. /**
  97179. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97180. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97181. * The HemisphericLight can't cast shadows.
  97182. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97183. * @param name The friendly name of the light
  97184. * @param direction The direction of the light reflection
  97185. * @param scene The scene the light belongs to
  97186. */
  97187. constructor(name: string, direction: Vector3, scene: Scene);
  97188. protected _buildUniformLayout(): void;
  97189. /**
  97190. * Returns the string "HemisphericLight".
  97191. * @return The class name
  97192. */
  97193. getClassName(): string;
  97194. /**
  97195. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97196. * Returns the updated direction.
  97197. * @param target The target the direction should point to
  97198. * @return The computed direction
  97199. */
  97200. setDirectionToTarget(target: Vector3): Vector3;
  97201. /**
  97202. * Returns the shadow generator associated to the light.
  97203. * @returns Always null for hemispheric lights because it does not support shadows.
  97204. */
  97205. getShadowGenerator(): Nullable<IShadowGenerator>;
  97206. /**
  97207. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97208. * @param effect The effect to update
  97209. * @param lightIndex The index of the light in the effect to update
  97210. * @returns The hemispheric light
  97211. */
  97212. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97213. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97214. /**
  97215. * Computes the world matrix of the node
  97216. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97217. * @param useWasUpdatedFlag defines a reserved property
  97218. * @returns the world matrix
  97219. */
  97220. computeWorldMatrix(): Matrix;
  97221. /**
  97222. * Returns the integer 3.
  97223. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97224. */
  97225. getTypeID(): number;
  97226. /**
  97227. * Prepares the list of defines specific to the light type.
  97228. * @param defines the list of defines
  97229. * @param lightIndex defines the index of the light for the effect
  97230. */
  97231. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97232. }
  97233. }
  97234. declare module BABYLON {
  97235. /** @hidden */
  97236. export var vrMultiviewToSingleviewPixelShader: {
  97237. name: string;
  97238. shader: string;
  97239. };
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Renders to multiple views with a single draw call
  97244. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97245. */
  97246. export class MultiviewRenderTarget extends RenderTargetTexture {
  97247. /**
  97248. * Creates a multiview render target
  97249. * @param scene scene used with the render target
  97250. * @param size the size of the render target (used for each view)
  97251. */
  97252. constructor(scene: Scene, size?: number | {
  97253. width: number;
  97254. height: number;
  97255. } | {
  97256. ratio: number;
  97257. });
  97258. /**
  97259. * @hidden
  97260. * @param faceIndex the face index, if its a cube texture
  97261. */
  97262. _bindFrameBuffer(faceIndex?: number): void;
  97263. /**
  97264. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97265. * @returns the view count
  97266. */
  97267. getViewCount(): number;
  97268. }
  97269. }
  97270. declare module BABYLON {
  97271. interface Engine {
  97272. /**
  97273. * Creates a new multiview render target
  97274. * @param width defines the width of the texture
  97275. * @param height defines the height of the texture
  97276. * @returns the created multiview texture
  97277. */
  97278. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97279. /**
  97280. * Binds a multiview framebuffer to be drawn to
  97281. * @param multiviewTexture texture to bind
  97282. */
  97283. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97284. }
  97285. interface Camera {
  97286. /**
  97287. * @hidden
  97288. * 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)
  97289. */
  97290. _useMultiviewToSingleView: boolean;
  97291. /**
  97292. * @hidden
  97293. * 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)
  97294. */
  97295. _multiviewTexture: Nullable<RenderTargetTexture>;
  97296. /**
  97297. * @hidden
  97298. * ensures the multiview texture of the camera exists and has the specified width/height
  97299. * @param width height to set on the multiview texture
  97300. * @param height width to set on the multiview texture
  97301. */
  97302. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97303. }
  97304. interface Scene {
  97305. /** @hidden */
  97306. _transformMatrixR: Matrix;
  97307. /** @hidden */
  97308. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97309. /** @hidden */
  97310. _createMultiviewUbo(): void;
  97311. /** @hidden */
  97312. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97313. /** @hidden */
  97314. _renderMultiviewToSingleView(camera: Camera): void;
  97315. }
  97316. }
  97317. declare module BABYLON {
  97318. /**
  97319. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97320. * This will not be used for webXR as it supports displaying texture arrays directly
  97321. */
  97322. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97323. /**
  97324. * Initializes a VRMultiviewToSingleview
  97325. * @param name name of the post process
  97326. * @param camera camera to be applied to
  97327. * @param scaleFactor scaling factor to the size of the output texture
  97328. */
  97329. constructor(name: string, camera: Camera, scaleFactor: number);
  97330. }
  97331. }
  97332. declare module BABYLON {
  97333. /**
  97334. * Interface used to define additional presentation attributes
  97335. */
  97336. export interface IVRPresentationAttributes {
  97337. /**
  97338. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97339. */
  97340. highRefreshRate: boolean;
  97341. /**
  97342. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97343. */
  97344. foveationLevel: number;
  97345. }
  97346. interface Engine {
  97347. /** @hidden */
  97348. _vrDisplay: any;
  97349. /** @hidden */
  97350. _vrSupported: boolean;
  97351. /** @hidden */
  97352. _oldSize: Size;
  97353. /** @hidden */
  97354. _oldHardwareScaleFactor: number;
  97355. /** @hidden */
  97356. _vrExclusivePointerMode: boolean;
  97357. /** @hidden */
  97358. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97359. /** @hidden */
  97360. _onVRDisplayPointerRestricted: () => void;
  97361. /** @hidden */
  97362. _onVRDisplayPointerUnrestricted: () => void;
  97363. /** @hidden */
  97364. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97365. /** @hidden */
  97366. _onVrDisplayDisconnect: Nullable<() => void>;
  97367. /** @hidden */
  97368. _onVrDisplayPresentChange: Nullable<() => void>;
  97369. /**
  97370. * Observable signaled when VR display mode changes
  97371. */
  97372. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97373. /**
  97374. * Observable signaled when VR request present is complete
  97375. */
  97376. onVRRequestPresentComplete: Observable<boolean>;
  97377. /**
  97378. * Observable signaled when VR request present starts
  97379. */
  97380. onVRRequestPresentStart: Observable<Engine>;
  97381. /**
  97382. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97383. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97384. */
  97385. isInVRExclusivePointerMode: boolean;
  97386. /**
  97387. * Gets a boolean indicating if a webVR device was detected
  97388. * @returns true if a webVR device was detected
  97389. */
  97390. isVRDevicePresent(): boolean;
  97391. /**
  97392. * Gets the current webVR device
  97393. * @returns the current webVR device (or null)
  97394. */
  97395. getVRDevice(): any;
  97396. /**
  97397. * Initializes a webVR display and starts listening to display change events
  97398. * The onVRDisplayChangedObservable will be notified upon these changes
  97399. * @returns A promise containing a VRDisplay and if vr is supported
  97400. */
  97401. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97402. /** @hidden */
  97403. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97404. /**
  97405. * Gets or sets the presentation attributes used to configure VR rendering
  97406. */
  97407. vrPresentationAttributes?: IVRPresentationAttributes;
  97408. /**
  97409. * Call this function to switch to webVR mode
  97410. * Will do nothing if webVR is not supported or if there is no webVR device
  97411. * @param options the webvr options provided to the camera. mainly used for multiview
  97412. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97413. */
  97414. enableVR(options: WebVROptions): void;
  97415. /** @hidden */
  97416. _onVRFullScreenTriggered(): void;
  97417. }
  97418. }
  97419. declare module BABYLON {
  97420. /**
  97421. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97422. * IMPORTANT!! The data is right-hand data.
  97423. * @export
  97424. * @interface DevicePose
  97425. */
  97426. export interface DevicePose {
  97427. /**
  97428. * The position of the device, values in array are [x,y,z].
  97429. */
  97430. readonly position: Nullable<Float32Array>;
  97431. /**
  97432. * The linearVelocity of the device, values in array are [x,y,z].
  97433. */
  97434. readonly linearVelocity: Nullable<Float32Array>;
  97435. /**
  97436. * The linearAcceleration of the device, values in array are [x,y,z].
  97437. */
  97438. readonly linearAcceleration: Nullable<Float32Array>;
  97439. /**
  97440. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97441. */
  97442. readonly orientation: Nullable<Float32Array>;
  97443. /**
  97444. * The angularVelocity of the device, values in array are [x,y,z].
  97445. */
  97446. readonly angularVelocity: Nullable<Float32Array>;
  97447. /**
  97448. * The angularAcceleration of the device, values in array are [x,y,z].
  97449. */
  97450. readonly angularAcceleration: Nullable<Float32Array>;
  97451. }
  97452. /**
  97453. * Interface representing a pose controlled object in Babylon.
  97454. * A pose controlled object has both regular pose values as well as pose values
  97455. * from an external device such as a VR head mounted display
  97456. */
  97457. export interface PoseControlled {
  97458. /**
  97459. * The position of the object in babylon space.
  97460. */
  97461. position: Vector3;
  97462. /**
  97463. * The rotation quaternion of the object in babylon space.
  97464. */
  97465. rotationQuaternion: Quaternion;
  97466. /**
  97467. * The position of the device in babylon space.
  97468. */
  97469. devicePosition?: Vector3;
  97470. /**
  97471. * The rotation quaternion of the device in babylon space.
  97472. */
  97473. deviceRotationQuaternion: Quaternion;
  97474. /**
  97475. * The raw pose coming from the device.
  97476. */
  97477. rawPose: Nullable<DevicePose>;
  97478. /**
  97479. * The scale of the device to be used when translating from device space to babylon space.
  97480. */
  97481. deviceScaleFactor: number;
  97482. /**
  97483. * Updates the poseControlled values based on the input device pose.
  97484. * @param poseData the pose data to update the object with
  97485. */
  97486. updateFromDevice(poseData: DevicePose): void;
  97487. }
  97488. /**
  97489. * Set of options to customize the webVRCamera
  97490. */
  97491. export interface WebVROptions {
  97492. /**
  97493. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97494. */
  97495. trackPosition?: boolean;
  97496. /**
  97497. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97498. */
  97499. positionScale?: number;
  97500. /**
  97501. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97502. */
  97503. displayName?: string;
  97504. /**
  97505. * Should the native controller meshes be initialized. (default: true)
  97506. */
  97507. controllerMeshes?: boolean;
  97508. /**
  97509. * Creating a default HemiLight only on controllers. (default: true)
  97510. */
  97511. defaultLightingOnControllers?: boolean;
  97512. /**
  97513. * If you don't want to use the default VR button of the helper. (default: false)
  97514. */
  97515. useCustomVRButton?: boolean;
  97516. /**
  97517. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97518. */
  97519. customVRButton?: HTMLButtonElement;
  97520. /**
  97521. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97522. */
  97523. rayLength?: number;
  97524. /**
  97525. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97526. */
  97527. defaultHeight?: number;
  97528. /**
  97529. * If multiview should be used if availible (default: false)
  97530. */
  97531. useMultiview?: boolean;
  97532. }
  97533. /**
  97534. * This represents a WebVR camera.
  97535. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97536. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97537. */
  97538. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97539. private webVROptions;
  97540. /**
  97541. * @hidden
  97542. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97543. */
  97544. _vrDevice: any;
  97545. /**
  97546. * The rawPose of the vrDevice.
  97547. */
  97548. rawPose: Nullable<DevicePose>;
  97549. private _onVREnabled;
  97550. private _specsVersion;
  97551. private _attached;
  97552. private _frameData;
  97553. protected _descendants: Array<Node>;
  97554. private _deviceRoomPosition;
  97555. /** @hidden */
  97556. _deviceRoomRotationQuaternion: Quaternion;
  97557. private _standingMatrix;
  97558. /**
  97559. * Represents device position in babylon space.
  97560. */
  97561. devicePosition: Vector3;
  97562. /**
  97563. * Represents device rotation in babylon space.
  97564. */
  97565. deviceRotationQuaternion: Quaternion;
  97566. /**
  97567. * The scale of the device to be used when translating from device space to babylon space.
  97568. */
  97569. deviceScaleFactor: number;
  97570. private _deviceToWorld;
  97571. private _worldToDevice;
  97572. /**
  97573. * References to the webVR controllers for the vrDevice.
  97574. */
  97575. controllers: Array<WebVRController>;
  97576. /**
  97577. * Emits an event when a controller is attached.
  97578. */
  97579. onControllersAttachedObservable: Observable<WebVRController[]>;
  97580. /**
  97581. * Emits an event when a controller's mesh has been loaded;
  97582. */
  97583. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97584. /**
  97585. * Emits an event when the HMD's pose has been updated.
  97586. */
  97587. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97588. private _poseSet;
  97589. /**
  97590. * If the rig cameras be used as parent instead of this camera.
  97591. */
  97592. rigParenting: boolean;
  97593. private _lightOnControllers;
  97594. private _defaultHeight?;
  97595. /**
  97596. * Instantiates a WebVRFreeCamera.
  97597. * @param name The name of the WebVRFreeCamera
  97598. * @param position The starting anchor position for the camera
  97599. * @param scene The scene the camera belongs to
  97600. * @param webVROptions a set of customizable options for the webVRCamera
  97601. */
  97602. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97603. /**
  97604. * Gets the device distance from the ground in meters.
  97605. * @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.
  97606. */
  97607. deviceDistanceToRoomGround(): number;
  97608. /**
  97609. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97610. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97611. */
  97612. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97613. /**
  97614. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97615. * @returns A promise with a boolean set to if the standing matrix is supported.
  97616. */
  97617. useStandingMatrixAsync(): Promise<boolean>;
  97618. /**
  97619. * Disposes the camera
  97620. */
  97621. dispose(): void;
  97622. /**
  97623. * Gets a vrController by name.
  97624. * @param name The name of the controller to retreive
  97625. * @returns the controller matching the name specified or null if not found
  97626. */
  97627. getControllerByName(name: string): Nullable<WebVRController>;
  97628. private _leftController;
  97629. /**
  97630. * The controller corresponding to the users left hand.
  97631. */
  97632. get leftController(): Nullable<WebVRController>;
  97633. private _rightController;
  97634. /**
  97635. * The controller corresponding to the users right hand.
  97636. */
  97637. get rightController(): Nullable<WebVRController>;
  97638. /**
  97639. * Casts a ray forward from the vrCamera's gaze.
  97640. * @param length Length of the ray (default: 100)
  97641. * @returns the ray corresponding to the gaze
  97642. */
  97643. getForwardRay(length?: number): Ray;
  97644. /**
  97645. * @hidden
  97646. * Updates the camera based on device's frame data
  97647. */
  97648. _checkInputs(): void;
  97649. /**
  97650. * Updates the poseControlled values based on the input device pose.
  97651. * @param poseData Pose coming from the device
  97652. */
  97653. updateFromDevice(poseData: DevicePose): void;
  97654. private _htmlElementAttached;
  97655. private _detachIfAttached;
  97656. /**
  97657. * WebVR's attach control will start broadcasting frames to the device.
  97658. * Note that in certain browsers (chrome for example) this function must be called
  97659. * within a user-interaction callback. Example:
  97660. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97661. *
  97662. * @param element html element to attach the vrDevice to
  97663. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97664. */
  97665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97666. /**
  97667. * Detaches the camera from the html element and disables VR
  97668. *
  97669. * @param element html element to detach from
  97670. */
  97671. detachControl(element: HTMLElement): void;
  97672. /**
  97673. * @returns the name of this class
  97674. */
  97675. getClassName(): string;
  97676. /**
  97677. * Calls resetPose on the vrDisplay
  97678. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97679. */
  97680. resetToCurrentRotation(): void;
  97681. /**
  97682. * @hidden
  97683. * Updates the rig cameras (left and right eye)
  97684. */
  97685. _updateRigCameras(): void;
  97686. private _workingVector;
  97687. private _oneVector;
  97688. private _workingMatrix;
  97689. private updateCacheCalled;
  97690. private _correctPositionIfNotTrackPosition;
  97691. /**
  97692. * @hidden
  97693. * Updates the cached values of the camera
  97694. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97695. */
  97696. _updateCache(ignoreParentClass?: boolean): void;
  97697. /**
  97698. * @hidden
  97699. * Get current device position in babylon world
  97700. */
  97701. _computeDevicePosition(): void;
  97702. /**
  97703. * Updates the current device position and rotation in the babylon world
  97704. */
  97705. update(): void;
  97706. /**
  97707. * @hidden
  97708. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97709. * @returns an identity matrix
  97710. */
  97711. _getViewMatrix(): Matrix;
  97712. private _tmpMatrix;
  97713. /**
  97714. * This function is called by the two RIG cameras.
  97715. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97716. * @hidden
  97717. */
  97718. _getWebVRViewMatrix(): Matrix;
  97719. /** @hidden */
  97720. _getWebVRProjectionMatrix(): Matrix;
  97721. private _onGamepadConnectedObserver;
  97722. private _onGamepadDisconnectedObserver;
  97723. private _updateCacheWhenTrackingDisabledObserver;
  97724. /**
  97725. * Initializes the controllers and their meshes
  97726. */
  97727. initControllers(): void;
  97728. }
  97729. }
  97730. declare module BABYLON {
  97731. /**
  97732. * "Static Class" containing the most commonly used helper while dealing with material for
  97733. * rendering purpose.
  97734. *
  97735. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97736. *
  97737. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97738. */
  97739. export class MaterialHelper {
  97740. /**
  97741. * Bind the current view position to an effect.
  97742. * @param effect The effect to be bound
  97743. * @param scene The scene the eyes position is used from
  97744. * @param variableName name of the shader variable that will hold the eye position
  97745. */
  97746. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97747. /**
  97748. * Helps preparing the defines values about the UVs in used in the effect.
  97749. * UVs are shared as much as we can accross channels in the shaders.
  97750. * @param texture The texture we are preparing the UVs for
  97751. * @param defines The defines to update
  97752. * @param key The channel key "diffuse", "specular"... used in the shader
  97753. */
  97754. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97755. /**
  97756. * Binds a texture matrix value to its corrsponding uniform
  97757. * @param texture The texture to bind the matrix for
  97758. * @param uniformBuffer The uniform buffer receivin the data
  97759. * @param key The channel key "diffuse", "specular"... used in the shader
  97760. */
  97761. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97762. /**
  97763. * Gets the current status of the fog (should it be enabled?)
  97764. * @param mesh defines the mesh to evaluate for fog support
  97765. * @param scene defines the hosting scene
  97766. * @returns true if fog must be enabled
  97767. */
  97768. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97769. /**
  97770. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97771. * @param mesh defines the current mesh
  97772. * @param scene defines the current scene
  97773. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97774. * @param pointsCloud defines if point cloud rendering has to be turned on
  97775. * @param fogEnabled defines if fog has to be turned on
  97776. * @param alphaTest defines if alpha testing has to be turned on
  97777. * @param defines defines the current list of defines
  97778. */
  97779. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97780. /**
  97781. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97782. * @param scene defines the current scene
  97783. * @param engine defines the current engine
  97784. * @param defines specifies the list of active defines
  97785. * @param useInstances defines if instances have to be turned on
  97786. * @param useClipPlane defines if clip plane have to be turned on
  97787. * @param useInstances defines if instances have to be turned on
  97788. * @param useThinInstances defines if thin instances have to be turned on
  97789. */
  97790. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97791. /**
  97792. * Prepares the defines for bones
  97793. * @param mesh The mesh containing the geometry data we will draw
  97794. * @param defines The defines to update
  97795. */
  97796. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97797. /**
  97798. * Prepares the defines for morph targets
  97799. * @param mesh The mesh containing the geometry data we will draw
  97800. * @param defines The defines to update
  97801. */
  97802. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97803. /**
  97804. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97805. * @param mesh The mesh containing the geometry data we will draw
  97806. * @param defines The defines to update
  97807. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97808. * @param useBones Precise whether bones should be used or not (override mesh info)
  97809. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97810. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97811. * @returns false if defines are considered not dirty and have not been checked
  97812. */
  97813. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97814. /**
  97815. * Prepares the defines related to multiview
  97816. * @param scene The scene we are intending to draw
  97817. * @param defines The defines to update
  97818. */
  97819. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97820. /**
  97821. * Prepares the defines related to the light information passed in parameter
  97822. * @param scene The scene we are intending to draw
  97823. * @param mesh The mesh the effect is compiling for
  97824. * @param light The light the effect is compiling for
  97825. * @param lightIndex The index of the light
  97826. * @param defines The defines to update
  97827. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97828. * @param state Defines the current state regarding what is needed (normals, etc...)
  97829. */
  97830. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97831. needNormals: boolean;
  97832. needRebuild: boolean;
  97833. shadowEnabled: boolean;
  97834. specularEnabled: boolean;
  97835. lightmapMode: boolean;
  97836. }): void;
  97837. /**
  97838. * Prepares the defines related to the light information passed in parameter
  97839. * @param scene The scene we are intending to draw
  97840. * @param mesh The mesh the effect is compiling for
  97841. * @param defines The defines to update
  97842. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97843. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97844. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97845. * @returns true if normals will be required for the rest of the effect
  97846. */
  97847. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97848. /**
  97849. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97850. * @param lightIndex defines the light index
  97851. * @param uniformsList The uniform list
  97852. * @param samplersList The sampler list
  97853. * @param projectedLightTexture defines if projected texture must be used
  97854. * @param uniformBuffersList defines an optional list of uniform buffers
  97855. */
  97856. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97857. /**
  97858. * Prepares the uniforms and samplers list to be used in the effect
  97859. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97860. * @param samplersList The sampler list
  97861. * @param defines The defines helping in the list generation
  97862. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97863. */
  97864. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97865. /**
  97866. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97867. * @param defines The defines to update while falling back
  97868. * @param fallbacks The authorized effect fallbacks
  97869. * @param maxSimultaneousLights The maximum number of lights allowed
  97870. * @param rank the current rank of the Effect
  97871. * @returns The newly affected rank
  97872. */
  97873. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97874. private static _TmpMorphInfluencers;
  97875. /**
  97876. * Prepares the list of attributes required for morph targets according to the effect defines.
  97877. * @param attribs The current list of supported attribs
  97878. * @param mesh The mesh to prepare the morph targets attributes for
  97879. * @param influencers The number of influencers
  97880. */
  97881. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97882. /**
  97883. * Prepares the list of attributes required for morph targets according to the effect defines.
  97884. * @param attribs The current list of supported attribs
  97885. * @param mesh The mesh to prepare the morph targets attributes for
  97886. * @param defines The current Defines of the effect
  97887. */
  97888. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97889. /**
  97890. * Prepares the list of attributes required for bones according to the effect defines.
  97891. * @param attribs The current list of supported attribs
  97892. * @param mesh The mesh to prepare the bones attributes for
  97893. * @param defines The current Defines of the effect
  97894. * @param fallbacks The current efffect fallback strategy
  97895. */
  97896. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97897. /**
  97898. * Check and prepare the list of attributes required for instances according to the effect defines.
  97899. * @param attribs The current list of supported attribs
  97900. * @param defines The current MaterialDefines of the effect
  97901. */
  97902. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97903. /**
  97904. * Add the list of attributes required for instances to the attribs array.
  97905. * @param attribs The current list of supported attribs
  97906. */
  97907. static PushAttributesForInstances(attribs: string[]): void;
  97908. /**
  97909. * Binds the light information to the effect.
  97910. * @param light The light containing the generator
  97911. * @param effect The effect we are binding the data to
  97912. * @param lightIndex The light index in the effect used to render
  97913. */
  97914. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97915. /**
  97916. * Binds the lights information from the scene to the effect for the given mesh.
  97917. * @param light Light to bind
  97918. * @param lightIndex Light index
  97919. * @param scene The scene where the light belongs to
  97920. * @param effect The effect we are binding the data to
  97921. * @param useSpecular Defines if specular is supported
  97922. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97923. */
  97924. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97925. /**
  97926. * Binds the lights information from the scene to the effect for the given mesh.
  97927. * @param scene The scene the lights belongs to
  97928. * @param mesh The mesh we are binding the information to render
  97929. * @param effect The effect we are binding the data to
  97930. * @param defines The generated defines for the effect
  97931. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97932. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97933. */
  97934. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97935. private static _tempFogColor;
  97936. /**
  97937. * Binds the fog information from the scene to the effect for the given mesh.
  97938. * @param scene The scene the lights belongs to
  97939. * @param mesh The mesh we are binding the information to render
  97940. * @param effect The effect we are binding the data to
  97941. * @param linearSpace Defines if the fog effect is applied in linear space
  97942. */
  97943. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97944. /**
  97945. * Binds the bones information from the mesh to the effect.
  97946. * @param mesh The mesh we are binding the information to render
  97947. * @param effect The effect we are binding the data to
  97948. */
  97949. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97950. /**
  97951. * Binds the morph targets information from the mesh to the effect.
  97952. * @param abstractMesh The mesh we are binding the information to render
  97953. * @param effect The effect we are binding the data to
  97954. */
  97955. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97956. /**
  97957. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97958. * @param defines The generated defines used in the effect
  97959. * @param effect The effect we are binding the data to
  97960. * @param scene The scene we are willing to render with logarithmic scale for
  97961. */
  97962. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97963. /**
  97964. * Binds the clip plane information from the scene to the effect.
  97965. * @param scene The scene the clip plane information are extracted from
  97966. * @param effect The effect we are binding the data to
  97967. */
  97968. static BindClipPlane(effect: Effect, scene: Scene): void;
  97969. }
  97970. }
  97971. declare module BABYLON {
  97972. /**
  97973. * Block used to expose an input value
  97974. */
  97975. export class InputBlock extends NodeMaterialBlock {
  97976. private _mode;
  97977. private _associatedVariableName;
  97978. private _storedValue;
  97979. private _valueCallback;
  97980. private _type;
  97981. private _animationType;
  97982. /** Gets or set a value used to limit the range of float values */
  97983. min: number;
  97984. /** Gets or set a value used to limit the range of float values */
  97985. max: number;
  97986. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97987. isBoolean: boolean;
  97988. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97989. matrixMode: number;
  97990. /** @hidden */
  97991. _systemValue: Nullable<NodeMaterialSystemValues>;
  97992. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97993. visibleInInspector: boolean;
  97994. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97995. isConstant: boolean;
  97996. /** Gets or sets the group to use to display this block in the Inspector */
  97997. groupInInspector: string;
  97998. /** Gets an observable raised when the value is changed */
  97999. onValueChangedObservable: Observable<InputBlock>;
  98000. /**
  98001. * Gets or sets the connection point type (default is float)
  98002. */
  98003. get type(): NodeMaterialBlockConnectionPointTypes;
  98004. /**
  98005. * Creates a new InputBlock
  98006. * @param name defines the block name
  98007. * @param target defines the target of that block (Vertex by default)
  98008. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98009. */
  98010. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98011. /**
  98012. * Gets the output component
  98013. */
  98014. get output(): NodeMaterialConnectionPoint;
  98015. /**
  98016. * Set the source of this connection point to a vertex attribute
  98017. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98018. * @returns the current connection point
  98019. */
  98020. setAsAttribute(attributeName?: string): InputBlock;
  98021. /**
  98022. * Set the source of this connection point to a system value
  98023. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98024. * @returns the current connection point
  98025. */
  98026. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98027. /**
  98028. * Gets or sets the value of that point.
  98029. * Please note that this value will be ignored if valueCallback is defined
  98030. */
  98031. get value(): any;
  98032. set value(value: any);
  98033. /**
  98034. * Gets or sets a callback used to get the value of that point.
  98035. * Please note that setting this value will force the connection point to ignore the value property
  98036. */
  98037. get valueCallback(): () => any;
  98038. set valueCallback(value: () => any);
  98039. /**
  98040. * Gets or sets the associated variable name in the shader
  98041. */
  98042. get associatedVariableName(): string;
  98043. set associatedVariableName(value: string);
  98044. /** Gets or sets the type of animation applied to the input */
  98045. get animationType(): AnimatedInputBlockTypes;
  98046. set animationType(value: AnimatedInputBlockTypes);
  98047. /**
  98048. * Gets a boolean indicating that this connection point not defined yet
  98049. */
  98050. get isUndefined(): boolean;
  98051. /**
  98052. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98053. * In this case the connection point name must be the name of the uniform to use.
  98054. * Can only be set on inputs
  98055. */
  98056. get isUniform(): boolean;
  98057. set isUniform(value: boolean);
  98058. /**
  98059. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98060. * In this case the connection point name must be the name of the attribute to use
  98061. * Can only be set on inputs
  98062. */
  98063. get isAttribute(): boolean;
  98064. set isAttribute(value: boolean);
  98065. /**
  98066. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98067. * Can only be set on exit points
  98068. */
  98069. get isVarying(): boolean;
  98070. set isVarying(value: boolean);
  98071. /**
  98072. * Gets a boolean indicating that the current connection point is a system value
  98073. */
  98074. get isSystemValue(): boolean;
  98075. /**
  98076. * Gets or sets the current well known value or null if not defined as a system value
  98077. */
  98078. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98079. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98080. /**
  98081. * Gets the current class name
  98082. * @returns the class name
  98083. */
  98084. getClassName(): string;
  98085. /**
  98086. * Animate the input if animationType !== None
  98087. * @param scene defines the rendering scene
  98088. */
  98089. animate(scene: Scene): void;
  98090. private _emitDefine;
  98091. initialize(state: NodeMaterialBuildState): void;
  98092. /**
  98093. * Set the input block to its default value (based on its type)
  98094. */
  98095. setDefaultValue(): void;
  98096. private _emitConstant;
  98097. /** @hidden */
  98098. get _noContextSwitch(): boolean;
  98099. private _emit;
  98100. /** @hidden */
  98101. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98102. /** @hidden */
  98103. _transmit(effect: Effect, scene: Scene): void;
  98104. protected _buildBlock(state: NodeMaterialBuildState): void;
  98105. protected _dumpPropertiesCode(): string;
  98106. dispose(): void;
  98107. serialize(): any;
  98108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98109. }
  98110. }
  98111. declare module BABYLON {
  98112. /**
  98113. * Enum used to define the compatibility state between two connection points
  98114. */
  98115. export enum NodeMaterialConnectionPointCompatibilityStates {
  98116. /** Points are compatibles */
  98117. Compatible = 0,
  98118. /** Points are incompatible because of their types */
  98119. TypeIncompatible = 1,
  98120. /** Points are incompatible because of their targets (vertex vs fragment) */
  98121. TargetIncompatible = 2
  98122. }
  98123. /**
  98124. * Defines the direction of a connection point
  98125. */
  98126. export enum NodeMaterialConnectionPointDirection {
  98127. /** Input */
  98128. Input = 0,
  98129. /** Output */
  98130. Output = 1
  98131. }
  98132. /**
  98133. * Defines a connection point for a block
  98134. */
  98135. export class NodeMaterialConnectionPoint {
  98136. /** @hidden */
  98137. _ownerBlock: NodeMaterialBlock;
  98138. /** @hidden */
  98139. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98140. private _endpoints;
  98141. private _associatedVariableName;
  98142. private _direction;
  98143. /** @hidden */
  98144. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98145. /** @hidden */
  98146. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98147. private _type;
  98148. /** @hidden */
  98149. _enforceAssociatedVariableName: boolean;
  98150. /** Gets the direction of the point */
  98151. get direction(): NodeMaterialConnectionPointDirection;
  98152. /** Indicates that this connection point needs dual validation before being connected to another point */
  98153. needDualDirectionValidation: boolean;
  98154. /**
  98155. * Gets or sets the additional types supported by this connection point
  98156. */
  98157. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98158. /**
  98159. * Gets or sets the additional types excluded by this connection point
  98160. */
  98161. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98162. /**
  98163. * Observable triggered when this point is connected
  98164. */
  98165. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98166. /**
  98167. * Gets or sets the associated variable name in the shader
  98168. */
  98169. get associatedVariableName(): string;
  98170. set associatedVariableName(value: string);
  98171. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98172. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98173. /**
  98174. * Gets or sets the connection point type (default is float)
  98175. */
  98176. get type(): NodeMaterialBlockConnectionPointTypes;
  98177. set type(value: NodeMaterialBlockConnectionPointTypes);
  98178. /**
  98179. * Gets or sets the connection point name
  98180. */
  98181. name: string;
  98182. /**
  98183. * Gets or sets the connection point name
  98184. */
  98185. displayName: string;
  98186. /**
  98187. * Gets or sets a boolean indicating that this connection point can be omitted
  98188. */
  98189. isOptional: boolean;
  98190. /**
  98191. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98192. */
  98193. isExposedOnFrame: boolean;
  98194. /**
  98195. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98196. */
  98197. define: string;
  98198. /** @hidden */
  98199. _prioritizeVertex: boolean;
  98200. private _target;
  98201. /** Gets or sets the target of that connection point */
  98202. get target(): NodeMaterialBlockTargets;
  98203. set target(value: NodeMaterialBlockTargets);
  98204. /**
  98205. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98206. */
  98207. get isConnected(): boolean;
  98208. /**
  98209. * Gets a boolean indicating that the current point is connected to an input block
  98210. */
  98211. get isConnectedToInputBlock(): boolean;
  98212. /**
  98213. * Gets a the connected input block (if any)
  98214. */
  98215. get connectInputBlock(): Nullable<InputBlock>;
  98216. /** Get the other side of the connection (if any) */
  98217. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98218. /** Get the block that owns this connection point */
  98219. get ownerBlock(): NodeMaterialBlock;
  98220. /** Get the block connected on the other side of this connection (if any) */
  98221. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98222. /** Get the block connected on the endpoints of this connection (if any) */
  98223. get connectedBlocks(): Array<NodeMaterialBlock>;
  98224. /** Gets the list of connected endpoints */
  98225. get endpoints(): NodeMaterialConnectionPoint[];
  98226. /** Gets a boolean indicating if that output point is connected to at least one input */
  98227. get hasEndpoints(): boolean;
  98228. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98229. get isConnectedInVertexShader(): boolean;
  98230. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98231. get isConnectedInFragmentShader(): boolean;
  98232. /**
  98233. * Creates a block suitable to be used as an input for this input point.
  98234. * If null is returned, a block based on the point type will be created.
  98235. * @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
  98236. */
  98237. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98238. /**
  98239. * Creates a new connection point
  98240. * @param name defines the connection point name
  98241. * @param ownerBlock defines the block hosting this connection point
  98242. * @param direction defines the direction of the connection point
  98243. */
  98244. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98245. /**
  98246. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98247. * @returns the class name
  98248. */
  98249. getClassName(): string;
  98250. /**
  98251. * Gets a boolean indicating if the current point can be connected to another point
  98252. * @param connectionPoint defines the other connection point
  98253. * @returns a boolean
  98254. */
  98255. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98256. /**
  98257. * Gets a number indicating if the current point can be connected to another point
  98258. * @param connectionPoint defines the other connection point
  98259. * @returns a number defining the compatibility state
  98260. */
  98261. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98262. /**
  98263. * Connect this point to another connection point
  98264. * @param connectionPoint defines the other connection point
  98265. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98266. * @returns the current connection point
  98267. */
  98268. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98269. /**
  98270. * Disconnect this point from one of his endpoint
  98271. * @param endpoint defines the other connection point
  98272. * @returns the current connection point
  98273. */
  98274. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98275. /**
  98276. * Serializes this point in a JSON representation
  98277. * @param isInput defines if the connection point is an input (default is true)
  98278. * @returns the serialized point object
  98279. */
  98280. serialize(isInput?: boolean): any;
  98281. /**
  98282. * Release resources
  98283. */
  98284. dispose(): void;
  98285. }
  98286. }
  98287. declare module BABYLON {
  98288. /**
  98289. * Enum used to define the material modes
  98290. */
  98291. export enum NodeMaterialModes {
  98292. /** Regular material */
  98293. Material = 0,
  98294. /** For post process */
  98295. PostProcess = 1,
  98296. /** For particle system */
  98297. Particle = 2
  98298. }
  98299. }
  98300. declare module BABYLON {
  98301. /**
  98302. * Block used to read a texture from a sampler
  98303. */
  98304. export class TextureBlock extends NodeMaterialBlock {
  98305. private _defineName;
  98306. private _linearDefineName;
  98307. private _gammaDefineName;
  98308. private _tempTextureRead;
  98309. private _samplerName;
  98310. private _transformedUVName;
  98311. private _textureTransformName;
  98312. private _textureInfoName;
  98313. private _mainUVName;
  98314. private _mainUVDefineName;
  98315. private _fragmentOnly;
  98316. /**
  98317. * Gets or sets the texture associated with the node
  98318. */
  98319. texture: Nullable<Texture>;
  98320. /**
  98321. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98322. */
  98323. convertToGammaSpace: boolean;
  98324. /**
  98325. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98326. */
  98327. convertToLinearSpace: boolean;
  98328. /**
  98329. * Create a new TextureBlock
  98330. * @param name defines the block name
  98331. */
  98332. constructor(name: string, fragmentOnly?: boolean);
  98333. /**
  98334. * Gets the current class name
  98335. * @returns the class name
  98336. */
  98337. getClassName(): string;
  98338. /**
  98339. * Gets the uv input component
  98340. */
  98341. get uv(): NodeMaterialConnectionPoint;
  98342. /**
  98343. * Gets the rgba output component
  98344. */
  98345. get rgba(): NodeMaterialConnectionPoint;
  98346. /**
  98347. * Gets the rgb output component
  98348. */
  98349. get rgb(): NodeMaterialConnectionPoint;
  98350. /**
  98351. * Gets the r output component
  98352. */
  98353. get r(): NodeMaterialConnectionPoint;
  98354. /**
  98355. * Gets the g output component
  98356. */
  98357. get g(): NodeMaterialConnectionPoint;
  98358. /**
  98359. * Gets the b output component
  98360. */
  98361. get b(): NodeMaterialConnectionPoint;
  98362. /**
  98363. * Gets the a output component
  98364. */
  98365. get a(): NodeMaterialConnectionPoint;
  98366. get target(): NodeMaterialBlockTargets;
  98367. autoConfigure(material: NodeMaterial): void;
  98368. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98370. isReady(): boolean;
  98371. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98372. private get _isMixed();
  98373. private _injectVertexCode;
  98374. private _writeTextureRead;
  98375. private _writeOutput;
  98376. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98377. protected _dumpPropertiesCode(): string;
  98378. serialize(): any;
  98379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98380. }
  98381. }
  98382. declare module BABYLON {
  98383. /** @hidden */
  98384. export var reflectionFunction: {
  98385. name: string;
  98386. shader: string;
  98387. };
  98388. }
  98389. declare module BABYLON {
  98390. /**
  98391. * Base block used to read a reflection texture from a sampler
  98392. */
  98393. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98394. /** @hidden */
  98395. _define3DName: string;
  98396. /** @hidden */
  98397. _defineCubicName: string;
  98398. /** @hidden */
  98399. _defineExplicitName: string;
  98400. /** @hidden */
  98401. _defineProjectionName: string;
  98402. /** @hidden */
  98403. _defineLocalCubicName: string;
  98404. /** @hidden */
  98405. _defineSphericalName: string;
  98406. /** @hidden */
  98407. _definePlanarName: string;
  98408. /** @hidden */
  98409. _defineEquirectangularName: string;
  98410. /** @hidden */
  98411. _defineMirroredEquirectangularFixedName: string;
  98412. /** @hidden */
  98413. _defineEquirectangularFixedName: string;
  98414. /** @hidden */
  98415. _defineSkyboxName: string;
  98416. /** @hidden */
  98417. _defineOppositeZ: string;
  98418. /** @hidden */
  98419. _cubeSamplerName: string;
  98420. /** @hidden */
  98421. _2DSamplerName: string;
  98422. protected _positionUVWName: string;
  98423. protected _directionWName: string;
  98424. protected _reflectionVectorName: string;
  98425. /** @hidden */
  98426. _reflectionCoordsName: string;
  98427. /** @hidden */
  98428. _reflectionMatrixName: string;
  98429. protected _reflectionColorName: string;
  98430. /**
  98431. * Gets or sets the texture associated with the node
  98432. */
  98433. texture: Nullable<BaseTexture>;
  98434. /**
  98435. * Create a new ReflectionTextureBaseBlock
  98436. * @param name defines the block name
  98437. */
  98438. constructor(name: string);
  98439. /**
  98440. * Gets the current class name
  98441. * @returns the class name
  98442. */
  98443. getClassName(): string;
  98444. /**
  98445. * Gets the world position input component
  98446. */
  98447. abstract get position(): NodeMaterialConnectionPoint;
  98448. /**
  98449. * Gets the world position input component
  98450. */
  98451. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98452. /**
  98453. * Gets the world normal input component
  98454. */
  98455. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98456. /**
  98457. * Gets the world input component
  98458. */
  98459. abstract get world(): NodeMaterialConnectionPoint;
  98460. /**
  98461. * Gets the camera (or eye) position component
  98462. */
  98463. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98464. /**
  98465. * Gets the view input component
  98466. */
  98467. abstract get view(): NodeMaterialConnectionPoint;
  98468. protected _getTexture(): Nullable<BaseTexture>;
  98469. autoConfigure(material: NodeMaterial): void;
  98470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98471. isReady(): boolean;
  98472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98473. /**
  98474. * Gets the code to inject in the vertex shader
  98475. * @param state current state of the node material building
  98476. * @returns the shader code
  98477. */
  98478. handleVertexSide(state: NodeMaterialBuildState): string;
  98479. /**
  98480. * Handles the inits for the fragment code path
  98481. * @param state node material build state
  98482. */
  98483. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98484. /**
  98485. * Generates the reflection coords code for the fragment code path
  98486. * @param worldNormalVarName name of the world normal variable
  98487. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98488. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98489. * @returns the shader code
  98490. */
  98491. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98492. /**
  98493. * Generates the reflection color code for the fragment code path
  98494. * @param lodVarName name of the lod variable
  98495. * @param swizzleLookupTexture swizzle to use for the final color variable
  98496. * @returns the shader code
  98497. */
  98498. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98499. /**
  98500. * Generates the code corresponding to the connected output points
  98501. * @param state node material build state
  98502. * @param varName name of the variable to output
  98503. * @returns the shader code
  98504. */
  98505. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98506. protected _buildBlock(state: NodeMaterialBuildState): this;
  98507. protected _dumpPropertiesCode(): string;
  98508. serialize(): any;
  98509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98510. }
  98511. }
  98512. declare module BABYLON {
  98513. /**
  98514. * Defines a connection point to be used for points with a custom object type
  98515. */
  98516. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98517. private _blockType;
  98518. private _blockName;
  98519. private _nameForCheking?;
  98520. /**
  98521. * Creates a new connection point
  98522. * @param name defines the connection point name
  98523. * @param ownerBlock defines the block hosting this connection point
  98524. * @param direction defines the direction of the connection point
  98525. */
  98526. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98527. /**
  98528. * Gets a number indicating if the current point can be connected to another point
  98529. * @param connectionPoint defines the other connection point
  98530. * @returns a number defining the compatibility state
  98531. */
  98532. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98533. /**
  98534. * Creates a block suitable to be used as an input for this input point.
  98535. * If null is returned, a block based on the point type will be created.
  98536. * @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
  98537. */
  98538. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98539. }
  98540. }
  98541. declare module BABYLON {
  98542. /**
  98543. * Enum defining the type of properties that can be edited in the property pages in the NME
  98544. */
  98545. export enum PropertyTypeForEdition {
  98546. /** property is a boolean */
  98547. Boolean = 0,
  98548. /** property is a float */
  98549. Float = 1,
  98550. /** property is a Vector2 */
  98551. Vector2 = 2,
  98552. /** property is a list of values */
  98553. List = 3
  98554. }
  98555. /**
  98556. * Interface that defines an option in a variable of type list
  98557. */
  98558. export interface IEditablePropertyListOption {
  98559. /** label of the option */
  98560. "label": string;
  98561. /** value of the option */
  98562. "value": number;
  98563. }
  98564. /**
  98565. * Interface that defines the options available for an editable property
  98566. */
  98567. export interface IEditablePropertyOption {
  98568. /** min value */
  98569. "min"?: number;
  98570. /** max value */
  98571. "max"?: number;
  98572. /** notifiers: indicates which actions to take when the property is changed */
  98573. "notifiers"?: {
  98574. /** the material should be rebuilt */
  98575. "rebuild"?: boolean;
  98576. /** the preview should be updated */
  98577. "update"?: boolean;
  98578. };
  98579. /** list of the options for a variable of type list */
  98580. "options"?: IEditablePropertyListOption[];
  98581. }
  98582. /**
  98583. * Interface that describes an editable property
  98584. */
  98585. export interface IPropertyDescriptionForEdition {
  98586. /** name of the property */
  98587. "propertyName": string;
  98588. /** display name of the property */
  98589. "displayName": string;
  98590. /** type of the property */
  98591. "type": PropertyTypeForEdition;
  98592. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98593. "groupName": string;
  98594. /** options for the property */
  98595. "options": IEditablePropertyOption;
  98596. }
  98597. /**
  98598. * Decorator that flags a property in a node material block as being editable
  98599. */
  98600. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98601. }
  98602. declare module BABYLON {
  98603. /**
  98604. * Block used to implement the refraction part of the sub surface module of the PBR material
  98605. */
  98606. export class RefractionBlock extends NodeMaterialBlock {
  98607. /** @hidden */
  98608. _define3DName: string;
  98609. /** @hidden */
  98610. _refractionMatrixName: string;
  98611. /** @hidden */
  98612. _defineLODRefractionAlpha: string;
  98613. /** @hidden */
  98614. _defineLinearSpecularRefraction: string;
  98615. /** @hidden */
  98616. _defineOppositeZ: string;
  98617. /** @hidden */
  98618. _cubeSamplerName: string;
  98619. /** @hidden */
  98620. _2DSamplerName: string;
  98621. /** @hidden */
  98622. _vRefractionMicrosurfaceInfosName: string;
  98623. /** @hidden */
  98624. _vRefractionInfosName: string;
  98625. private _scene;
  98626. /**
  98627. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98628. * Materials half opaque for instance using refraction could benefit from this control.
  98629. */
  98630. linkRefractionWithTransparency: boolean;
  98631. /**
  98632. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98633. */
  98634. invertRefractionY: boolean;
  98635. /**
  98636. * Gets or sets the texture associated with the node
  98637. */
  98638. texture: Nullable<BaseTexture>;
  98639. /**
  98640. * Create a new RefractionBlock
  98641. * @param name defines the block name
  98642. */
  98643. constructor(name: string);
  98644. /**
  98645. * Gets the current class name
  98646. * @returns the class name
  98647. */
  98648. getClassName(): string;
  98649. /**
  98650. * Gets the intensity input component
  98651. */
  98652. get intensity(): NodeMaterialConnectionPoint;
  98653. /**
  98654. * Gets the index of refraction input component
  98655. */
  98656. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98657. /**
  98658. * Gets the tint at distance input component
  98659. */
  98660. get tintAtDistance(): NodeMaterialConnectionPoint;
  98661. /**
  98662. * Gets the view input component
  98663. */
  98664. get view(): NodeMaterialConnectionPoint;
  98665. /**
  98666. * Gets the refraction object output component
  98667. */
  98668. get refraction(): NodeMaterialConnectionPoint;
  98669. /**
  98670. * Returns true if the block has a texture
  98671. */
  98672. get hasTexture(): boolean;
  98673. protected _getTexture(): Nullable<BaseTexture>;
  98674. autoConfigure(material: NodeMaterial): void;
  98675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98676. isReady(): boolean;
  98677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98678. /**
  98679. * Gets the main code of the block (fragment side)
  98680. * @param state current state of the node material building
  98681. * @returns the shader code
  98682. */
  98683. getCode(state: NodeMaterialBuildState): string;
  98684. protected _buildBlock(state: NodeMaterialBuildState): this;
  98685. protected _dumpPropertiesCode(): string;
  98686. serialize(): any;
  98687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98688. }
  98689. }
  98690. declare module BABYLON {
  98691. /**
  98692. * Base block used as input for post process
  98693. */
  98694. export class CurrentScreenBlock extends NodeMaterialBlock {
  98695. private _samplerName;
  98696. private _linearDefineName;
  98697. private _gammaDefineName;
  98698. private _mainUVName;
  98699. private _tempTextureRead;
  98700. /**
  98701. * Gets or sets the texture associated with the node
  98702. */
  98703. texture: Nullable<BaseTexture>;
  98704. /**
  98705. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98706. */
  98707. convertToGammaSpace: boolean;
  98708. /**
  98709. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98710. */
  98711. convertToLinearSpace: boolean;
  98712. /**
  98713. * Create a new CurrentScreenBlock
  98714. * @param name defines the block name
  98715. */
  98716. constructor(name: string);
  98717. /**
  98718. * Gets the current class name
  98719. * @returns the class name
  98720. */
  98721. getClassName(): string;
  98722. /**
  98723. * Gets the uv input component
  98724. */
  98725. get uv(): NodeMaterialConnectionPoint;
  98726. /**
  98727. * Gets the rgba output component
  98728. */
  98729. get rgba(): NodeMaterialConnectionPoint;
  98730. /**
  98731. * Gets the rgb output component
  98732. */
  98733. get rgb(): NodeMaterialConnectionPoint;
  98734. /**
  98735. * Gets the r output component
  98736. */
  98737. get r(): NodeMaterialConnectionPoint;
  98738. /**
  98739. * Gets the g output component
  98740. */
  98741. get g(): NodeMaterialConnectionPoint;
  98742. /**
  98743. * Gets the b output component
  98744. */
  98745. get b(): NodeMaterialConnectionPoint;
  98746. /**
  98747. * Gets the a output component
  98748. */
  98749. get a(): NodeMaterialConnectionPoint;
  98750. /**
  98751. * Initialize the block and prepare the context for build
  98752. * @param state defines the state that will be used for the build
  98753. */
  98754. initialize(state: NodeMaterialBuildState): void;
  98755. get target(): NodeMaterialBlockTargets;
  98756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98757. isReady(): boolean;
  98758. private _injectVertexCode;
  98759. private _writeTextureRead;
  98760. private _writeOutput;
  98761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98762. serialize(): any;
  98763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98764. }
  98765. }
  98766. declare module BABYLON {
  98767. /**
  98768. * Base block used for the particle texture
  98769. */
  98770. export class ParticleTextureBlock extends NodeMaterialBlock {
  98771. private _samplerName;
  98772. private _linearDefineName;
  98773. private _gammaDefineName;
  98774. private _tempTextureRead;
  98775. /**
  98776. * Gets or sets the texture associated with the node
  98777. */
  98778. texture: Nullable<BaseTexture>;
  98779. /**
  98780. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98781. */
  98782. convertToGammaSpace: boolean;
  98783. /**
  98784. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98785. */
  98786. convertToLinearSpace: boolean;
  98787. /**
  98788. * Create a new ParticleTextureBlock
  98789. * @param name defines the block name
  98790. */
  98791. constructor(name: string);
  98792. /**
  98793. * Gets the current class name
  98794. * @returns the class name
  98795. */
  98796. getClassName(): string;
  98797. /**
  98798. * Gets the uv input component
  98799. */
  98800. get uv(): NodeMaterialConnectionPoint;
  98801. /**
  98802. * Gets the rgba output component
  98803. */
  98804. get rgba(): NodeMaterialConnectionPoint;
  98805. /**
  98806. * Gets the rgb output component
  98807. */
  98808. get rgb(): NodeMaterialConnectionPoint;
  98809. /**
  98810. * Gets the r output component
  98811. */
  98812. get r(): NodeMaterialConnectionPoint;
  98813. /**
  98814. * Gets the g output component
  98815. */
  98816. get g(): NodeMaterialConnectionPoint;
  98817. /**
  98818. * Gets the b output component
  98819. */
  98820. get b(): NodeMaterialConnectionPoint;
  98821. /**
  98822. * Gets the a output component
  98823. */
  98824. get a(): NodeMaterialConnectionPoint;
  98825. /**
  98826. * Initialize the block and prepare the context for build
  98827. * @param state defines the state that will be used for the build
  98828. */
  98829. initialize(state: NodeMaterialBuildState): void;
  98830. autoConfigure(material: NodeMaterial): void;
  98831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98832. isReady(): boolean;
  98833. private _writeOutput;
  98834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98835. serialize(): any;
  98836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98837. }
  98838. }
  98839. declare module BABYLON {
  98840. /**
  98841. * Class used to store shared data between 2 NodeMaterialBuildState
  98842. */
  98843. export class NodeMaterialBuildStateSharedData {
  98844. /**
  98845. * Gets the list of emitted varyings
  98846. */
  98847. temps: string[];
  98848. /**
  98849. * Gets the list of emitted varyings
  98850. */
  98851. varyings: string[];
  98852. /**
  98853. * Gets the varying declaration string
  98854. */
  98855. varyingDeclaration: string;
  98856. /**
  98857. * Input blocks
  98858. */
  98859. inputBlocks: InputBlock[];
  98860. /**
  98861. * Input blocks
  98862. */
  98863. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98864. /**
  98865. * Bindable blocks (Blocks that need to set data to the effect)
  98866. */
  98867. bindableBlocks: NodeMaterialBlock[];
  98868. /**
  98869. * List of blocks that can provide a compilation fallback
  98870. */
  98871. blocksWithFallbacks: NodeMaterialBlock[];
  98872. /**
  98873. * List of blocks that can provide a define update
  98874. */
  98875. blocksWithDefines: NodeMaterialBlock[];
  98876. /**
  98877. * List of blocks that can provide a repeatable content
  98878. */
  98879. repeatableContentBlocks: NodeMaterialBlock[];
  98880. /**
  98881. * List of blocks that can provide a dynamic list of uniforms
  98882. */
  98883. dynamicUniformBlocks: NodeMaterialBlock[];
  98884. /**
  98885. * List of blocks that can block the isReady function for the material
  98886. */
  98887. blockingBlocks: NodeMaterialBlock[];
  98888. /**
  98889. * Gets the list of animated inputs
  98890. */
  98891. animatedInputs: InputBlock[];
  98892. /**
  98893. * Build Id used to avoid multiple recompilations
  98894. */
  98895. buildId: number;
  98896. /** List of emitted variables */
  98897. variableNames: {
  98898. [key: string]: number;
  98899. };
  98900. /** List of emitted defines */
  98901. defineNames: {
  98902. [key: string]: number;
  98903. };
  98904. /** Should emit comments? */
  98905. emitComments: boolean;
  98906. /** Emit build activity */
  98907. verbose: boolean;
  98908. /** Gets or sets the hosting scene */
  98909. scene: Scene;
  98910. /**
  98911. * Gets the compilation hints emitted at compilation time
  98912. */
  98913. hints: {
  98914. needWorldViewMatrix: boolean;
  98915. needWorldViewProjectionMatrix: boolean;
  98916. needAlphaBlending: boolean;
  98917. needAlphaTesting: boolean;
  98918. };
  98919. /**
  98920. * List of compilation checks
  98921. */
  98922. checks: {
  98923. emitVertex: boolean;
  98924. emitFragment: boolean;
  98925. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98926. };
  98927. /**
  98928. * Is vertex program allowed to be empty?
  98929. */
  98930. allowEmptyVertexProgram: boolean;
  98931. /** Creates a new shared data */
  98932. constructor();
  98933. /**
  98934. * Emits console errors and exceptions if there is a failing check
  98935. */
  98936. emitErrors(): void;
  98937. }
  98938. }
  98939. declare module BABYLON {
  98940. /**
  98941. * Class used to store node based material build state
  98942. */
  98943. export class NodeMaterialBuildState {
  98944. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98945. supportUniformBuffers: boolean;
  98946. /**
  98947. * Gets the list of emitted attributes
  98948. */
  98949. attributes: string[];
  98950. /**
  98951. * Gets the list of emitted uniforms
  98952. */
  98953. uniforms: string[];
  98954. /**
  98955. * Gets the list of emitted constants
  98956. */
  98957. constants: string[];
  98958. /**
  98959. * Gets the list of emitted samplers
  98960. */
  98961. samplers: string[];
  98962. /**
  98963. * Gets the list of emitted functions
  98964. */
  98965. functions: {
  98966. [key: string]: string;
  98967. };
  98968. /**
  98969. * Gets the list of emitted extensions
  98970. */
  98971. extensions: {
  98972. [key: string]: string;
  98973. };
  98974. /**
  98975. * Gets the target of the compilation state
  98976. */
  98977. target: NodeMaterialBlockTargets;
  98978. /**
  98979. * Gets the list of emitted counters
  98980. */
  98981. counters: {
  98982. [key: string]: number;
  98983. };
  98984. /**
  98985. * Shared data between multiple NodeMaterialBuildState instances
  98986. */
  98987. sharedData: NodeMaterialBuildStateSharedData;
  98988. /** @hidden */
  98989. _vertexState: NodeMaterialBuildState;
  98990. /** @hidden */
  98991. _attributeDeclaration: string;
  98992. /** @hidden */
  98993. _uniformDeclaration: string;
  98994. /** @hidden */
  98995. _constantDeclaration: string;
  98996. /** @hidden */
  98997. _samplerDeclaration: string;
  98998. /** @hidden */
  98999. _varyingTransfer: string;
  99000. /** @hidden */
  99001. _injectAtEnd: string;
  99002. private _repeatableContentAnchorIndex;
  99003. /** @hidden */
  99004. _builtCompilationString: string;
  99005. /**
  99006. * Gets the emitted compilation strings
  99007. */
  99008. compilationString: string;
  99009. /**
  99010. * Finalize the compilation strings
  99011. * @param state defines the current compilation state
  99012. */
  99013. finalize(state: NodeMaterialBuildState): void;
  99014. /** @hidden */
  99015. get _repeatableContentAnchor(): string;
  99016. /** @hidden */
  99017. _getFreeVariableName(prefix: string): string;
  99018. /** @hidden */
  99019. _getFreeDefineName(prefix: string): string;
  99020. /** @hidden */
  99021. _excludeVariableName(name: string): void;
  99022. /** @hidden */
  99023. _emit2DSampler(name: string): void;
  99024. /** @hidden */
  99025. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99026. /** @hidden */
  99027. _emitExtension(name: string, extension: string, define?: string): void;
  99028. /** @hidden */
  99029. _emitFunction(name: string, code: string, comments: string): void;
  99030. /** @hidden */
  99031. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99032. replaceStrings?: {
  99033. search: RegExp;
  99034. replace: string;
  99035. }[];
  99036. repeatKey?: string;
  99037. }): string;
  99038. /** @hidden */
  99039. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99040. repeatKey?: string;
  99041. removeAttributes?: boolean;
  99042. removeUniforms?: boolean;
  99043. removeVaryings?: boolean;
  99044. removeIfDef?: boolean;
  99045. replaceStrings?: {
  99046. search: RegExp;
  99047. replace: string;
  99048. }[];
  99049. }, storeKey?: string): void;
  99050. /** @hidden */
  99051. _registerTempVariable(name: string): boolean;
  99052. /** @hidden */
  99053. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99054. /** @hidden */
  99055. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99056. /** @hidden */
  99057. _emitFloat(value: number): string;
  99058. }
  99059. }
  99060. declare module BABYLON {
  99061. /**
  99062. * Helper class used to generate session unique ID
  99063. */
  99064. export class UniqueIdGenerator {
  99065. private static _UniqueIdCounter;
  99066. /**
  99067. * Gets an unique (relatively to the current scene) Id
  99068. */
  99069. static get UniqueId(): number;
  99070. }
  99071. }
  99072. declare module BABYLON {
  99073. /**
  99074. * Defines a block that can be used inside a node based material
  99075. */
  99076. export class NodeMaterialBlock {
  99077. private _buildId;
  99078. private _buildTarget;
  99079. private _target;
  99080. private _isFinalMerger;
  99081. private _isInput;
  99082. protected _isUnique: boolean;
  99083. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99084. inputsAreExclusive: boolean;
  99085. /** @hidden */
  99086. _codeVariableName: string;
  99087. /** @hidden */
  99088. _inputs: NodeMaterialConnectionPoint[];
  99089. /** @hidden */
  99090. _outputs: NodeMaterialConnectionPoint[];
  99091. /** @hidden */
  99092. _preparationId: number;
  99093. /**
  99094. * Gets or sets the name of the block
  99095. */
  99096. name: string;
  99097. /**
  99098. * Gets or sets the unique id of the node
  99099. */
  99100. uniqueId: number;
  99101. /**
  99102. * Gets or sets the comments associated with this block
  99103. */
  99104. comments: string;
  99105. /**
  99106. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99107. */
  99108. get isUnique(): boolean;
  99109. /**
  99110. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99111. */
  99112. get isFinalMerger(): boolean;
  99113. /**
  99114. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99115. */
  99116. get isInput(): boolean;
  99117. /**
  99118. * Gets or sets the build Id
  99119. */
  99120. get buildId(): number;
  99121. set buildId(value: number);
  99122. /**
  99123. * Gets or sets the target of the block
  99124. */
  99125. get target(): NodeMaterialBlockTargets;
  99126. set target(value: NodeMaterialBlockTargets);
  99127. /**
  99128. * Gets the list of input points
  99129. */
  99130. get inputs(): NodeMaterialConnectionPoint[];
  99131. /** Gets the list of output points */
  99132. get outputs(): NodeMaterialConnectionPoint[];
  99133. /**
  99134. * Find an input by its name
  99135. * @param name defines the name of the input to look for
  99136. * @returns the input or null if not found
  99137. */
  99138. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99139. /**
  99140. * Find an output by its name
  99141. * @param name defines the name of the outputto look for
  99142. * @returns the output or null if not found
  99143. */
  99144. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99145. /**
  99146. * Creates a new NodeMaterialBlock
  99147. * @param name defines the block name
  99148. * @param target defines the target of that block (Vertex by default)
  99149. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99150. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99151. */
  99152. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99153. /**
  99154. * Initialize the block and prepare the context for build
  99155. * @param state defines the state that will be used for the build
  99156. */
  99157. initialize(state: NodeMaterialBuildState): void;
  99158. /**
  99159. * Bind data to effect. Will only be called for blocks with isBindable === true
  99160. * @param effect defines the effect to bind data to
  99161. * @param nodeMaterial defines the hosting NodeMaterial
  99162. * @param mesh defines the mesh that will be rendered
  99163. * @param subMesh defines the submesh that will be rendered
  99164. */
  99165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99166. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99167. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99168. protected _writeFloat(value: number): string;
  99169. /**
  99170. * Gets the current class name e.g. "NodeMaterialBlock"
  99171. * @returns the class name
  99172. */
  99173. getClassName(): string;
  99174. /**
  99175. * Register a new input. Must be called inside a block constructor
  99176. * @param name defines the connection point name
  99177. * @param type defines the connection point type
  99178. * @param isOptional defines a boolean indicating that this input can be omitted
  99179. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99180. * @param point an already created connection point. If not provided, create a new one
  99181. * @returns the current block
  99182. */
  99183. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99184. /**
  99185. * Register a new output. Must be called inside a block constructor
  99186. * @param name defines the connection point name
  99187. * @param type defines the connection point type
  99188. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99189. * @param point an already created connection point. If not provided, create a new one
  99190. * @returns the current block
  99191. */
  99192. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99193. /**
  99194. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99195. * @param forOutput defines an optional connection point to check compatibility with
  99196. * @returns the first available input or null
  99197. */
  99198. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99199. /**
  99200. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99201. * @param forBlock defines an optional block to check compatibility with
  99202. * @returns the first available input or null
  99203. */
  99204. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99205. /**
  99206. * Gets the sibling of the given output
  99207. * @param current defines the current output
  99208. * @returns the next output in the list or null
  99209. */
  99210. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99211. /**
  99212. * Connect current block with another block
  99213. * @param other defines the block to connect with
  99214. * @param options define the various options to help pick the right connections
  99215. * @returns the current block
  99216. */
  99217. connectTo(other: NodeMaterialBlock, options?: {
  99218. input?: string;
  99219. output?: string;
  99220. outputSwizzle?: string;
  99221. }): this | undefined;
  99222. protected _buildBlock(state: NodeMaterialBuildState): void;
  99223. /**
  99224. * Add uniforms, samplers and uniform buffers at compilation time
  99225. * @param state defines the state to update
  99226. * @param nodeMaterial defines the node material requesting the update
  99227. * @param defines defines the material defines to update
  99228. * @param uniformBuffers defines the list of uniform buffer names
  99229. */
  99230. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99231. /**
  99232. * Add potential fallbacks if shader compilation fails
  99233. * @param mesh defines the mesh to be rendered
  99234. * @param fallbacks defines the current prioritized list of fallbacks
  99235. */
  99236. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99237. /**
  99238. * Initialize defines for shader compilation
  99239. * @param mesh defines the mesh to be rendered
  99240. * @param nodeMaterial defines the node material requesting the update
  99241. * @param defines defines the material defines to update
  99242. * @param useInstances specifies that instances should be used
  99243. */
  99244. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99245. /**
  99246. * Update defines for shader compilation
  99247. * @param mesh defines the mesh to be rendered
  99248. * @param nodeMaterial defines the node material requesting the update
  99249. * @param defines defines the material defines to update
  99250. * @param useInstances specifies that instances should be used
  99251. * @param subMesh defines which submesh to render
  99252. */
  99253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99254. /**
  99255. * Lets the block try to connect some inputs automatically
  99256. * @param material defines the hosting NodeMaterial
  99257. */
  99258. autoConfigure(material: NodeMaterial): void;
  99259. /**
  99260. * Function called when a block is declared as repeatable content generator
  99261. * @param vertexShaderState defines the current compilation state for the vertex shader
  99262. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99263. * @param mesh defines the mesh to be rendered
  99264. * @param defines defines the material defines to update
  99265. */
  99266. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99267. /**
  99268. * Checks if the block is ready
  99269. * @param mesh defines the mesh to be rendered
  99270. * @param nodeMaterial defines the node material requesting the update
  99271. * @param defines defines the material defines to update
  99272. * @param useInstances specifies that instances should be used
  99273. * @returns true if the block is ready
  99274. */
  99275. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99276. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99277. private _processBuild;
  99278. /**
  99279. * Compile the current node and generate the shader code
  99280. * @param state defines the current compilation state (uniforms, samplers, current string)
  99281. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99282. * @returns true if already built
  99283. */
  99284. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99285. protected _inputRename(name: string): string;
  99286. protected _outputRename(name: string): string;
  99287. protected _dumpPropertiesCode(): string;
  99288. /** @hidden */
  99289. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99290. /** @hidden */
  99291. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99292. /**
  99293. * Clone the current block to a new identical block
  99294. * @param scene defines the hosting scene
  99295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99296. * @returns a copy of the current block
  99297. */
  99298. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99299. /**
  99300. * Serializes this block in a JSON representation
  99301. * @returns the serialized block object
  99302. */
  99303. serialize(): any;
  99304. /** @hidden */
  99305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99306. private _deserializePortDisplayNamesAndExposedOnFrame;
  99307. /**
  99308. * Release resources
  99309. */
  99310. dispose(): void;
  99311. }
  99312. }
  99313. declare module BABYLON {
  99314. /**
  99315. * Base class of materials working in push mode in babylon JS
  99316. * @hidden
  99317. */
  99318. export class PushMaterial extends Material {
  99319. protected _activeEffect: Effect;
  99320. protected _normalMatrix: Matrix;
  99321. constructor(name: string, scene: Scene);
  99322. getEffect(): Effect;
  99323. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99324. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99325. /**
  99326. * Binds the given world matrix to the active effect
  99327. *
  99328. * @param world the matrix to bind
  99329. */
  99330. bindOnlyWorldMatrix(world: Matrix): void;
  99331. /**
  99332. * Binds the given normal matrix to the active effect
  99333. *
  99334. * @param normalMatrix the matrix to bind
  99335. */
  99336. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99337. bind(world: Matrix, mesh?: Mesh): void;
  99338. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99339. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99340. }
  99341. }
  99342. declare module BABYLON {
  99343. /**
  99344. * Root class for all node material optimizers
  99345. */
  99346. export class NodeMaterialOptimizer {
  99347. /**
  99348. * Function used to optimize a NodeMaterial graph
  99349. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99350. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99351. */
  99352. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99353. }
  99354. }
  99355. declare module BABYLON {
  99356. /**
  99357. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99358. */
  99359. export class TransformBlock extends NodeMaterialBlock {
  99360. /**
  99361. * Defines the value to use to complement W value to transform it to a Vector4
  99362. */
  99363. complementW: number;
  99364. /**
  99365. * Defines the value to use to complement z value to transform it to a Vector4
  99366. */
  99367. complementZ: number;
  99368. /**
  99369. * Creates a new TransformBlock
  99370. * @param name defines the block name
  99371. */
  99372. constructor(name: string);
  99373. /**
  99374. * Gets the current class name
  99375. * @returns the class name
  99376. */
  99377. getClassName(): string;
  99378. /**
  99379. * Gets the vector input
  99380. */
  99381. get vector(): NodeMaterialConnectionPoint;
  99382. /**
  99383. * Gets the output component
  99384. */
  99385. get output(): NodeMaterialConnectionPoint;
  99386. /**
  99387. * Gets the xyz output component
  99388. */
  99389. get xyz(): NodeMaterialConnectionPoint;
  99390. /**
  99391. * Gets the matrix transform input
  99392. */
  99393. get transform(): NodeMaterialConnectionPoint;
  99394. protected _buildBlock(state: NodeMaterialBuildState): this;
  99395. /**
  99396. * Update defines for shader compilation
  99397. * @param mesh defines the mesh to be rendered
  99398. * @param nodeMaterial defines the node material requesting the update
  99399. * @param defines defines the material defines to update
  99400. * @param useInstances specifies that instances should be used
  99401. * @param subMesh defines which submesh to render
  99402. */
  99403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99404. serialize(): any;
  99405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99406. protected _dumpPropertiesCode(): string;
  99407. }
  99408. }
  99409. declare module BABYLON {
  99410. /**
  99411. * Block used to output the vertex position
  99412. */
  99413. export class VertexOutputBlock extends NodeMaterialBlock {
  99414. /**
  99415. * Creates a new VertexOutputBlock
  99416. * @param name defines the block name
  99417. */
  99418. constructor(name: string);
  99419. /**
  99420. * Gets the current class name
  99421. * @returns the class name
  99422. */
  99423. getClassName(): string;
  99424. /**
  99425. * Gets the vector input component
  99426. */
  99427. get vector(): NodeMaterialConnectionPoint;
  99428. protected _buildBlock(state: NodeMaterialBuildState): this;
  99429. }
  99430. }
  99431. declare module BABYLON {
  99432. /**
  99433. * Block used to output the final color
  99434. */
  99435. export class FragmentOutputBlock extends NodeMaterialBlock {
  99436. /**
  99437. * Create a new FragmentOutputBlock
  99438. * @param name defines the block name
  99439. */
  99440. constructor(name: string);
  99441. /**
  99442. * Gets the current class name
  99443. * @returns the class name
  99444. */
  99445. getClassName(): string;
  99446. /**
  99447. * Gets the rgba input component
  99448. */
  99449. get rgba(): NodeMaterialConnectionPoint;
  99450. /**
  99451. * Gets the rgb input component
  99452. */
  99453. get rgb(): NodeMaterialConnectionPoint;
  99454. /**
  99455. * Gets the a input component
  99456. */
  99457. get a(): NodeMaterialConnectionPoint;
  99458. protected _buildBlock(state: NodeMaterialBuildState): this;
  99459. }
  99460. }
  99461. declare module BABYLON {
  99462. /**
  99463. * Block used for the particle ramp gradient section
  99464. */
  99465. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99466. /**
  99467. * Create a new ParticleRampGradientBlock
  99468. * @param name defines the block name
  99469. */
  99470. constructor(name: string);
  99471. /**
  99472. * Gets the current class name
  99473. * @returns the class name
  99474. */
  99475. getClassName(): string;
  99476. /**
  99477. * Gets the color input component
  99478. */
  99479. get color(): NodeMaterialConnectionPoint;
  99480. /**
  99481. * Gets the rampColor output component
  99482. */
  99483. get rampColor(): NodeMaterialConnectionPoint;
  99484. /**
  99485. * Initialize the block and prepare the context for build
  99486. * @param state defines the state that will be used for the build
  99487. */
  99488. initialize(state: NodeMaterialBuildState): void;
  99489. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99490. }
  99491. }
  99492. declare module BABYLON {
  99493. /**
  99494. * Block used for the particle blend multiply section
  99495. */
  99496. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99497. /**
  99498. * Create a new ParticleBlendMultiplyBlock
  99499. * @param name defines the block name
  99500. */
  99501. constructor(name: string);
  99502. /**
  99503. * Gets the current class name
  99504. * @returns the class name
  99505. */
  99506. getClassName(): string;
  99507. /**
  99508. * Gets the color input component
  99509. */
  99510. get color(): NodeMaterialConnectionPoint;
  99511. /**
  99512. * Gets the alphaTexture input component
  99513. */
  99514. get alphaTexture(): NodeMaterialConnectionPoint;
  99515. /**
  99516. * Gets the alphaColor input component
  99517. */
  99518. get alphaColor(): NodeMaterialConnectionPoint;
  99519. /**
  99520. * Gets the blendColor output component
  99521. */
  99522. get blendColor(): NodeMaterialConnectionPoint;
  99523. /**
  99524. * Initialize the block and prepare the context for build
  99525. * @param state defines the state that will be used for the build
  99526. */
  99527. initialize(state: NodeMaterialBuildState): void;
  99528. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99529. }
  99530. }
  99531. declare module BABYLON {
  99532. /**
  99533. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99534. */
  99535. export class VectorMergerBlock extends NodeMaterialBlock {
  99536. /**
  99537. * Create a new VectorMergerBlock
  99538. * @param name defines the block name
  99539. */
  99540. constructor(name: string);
  99541. /**
  99542. * Gets the current class name
  99543. * @returns the class name
  99544. */
  99545. getClassName(): string;
  99546. /**
  99547. * Gets the xyz component (input)
  99548. */
  99549. get xyzIn(): NodeMaterialConnectionPoint;
  99550. /**
  99551. * Gets the xy component (input)
  99552. */
  99553. get xyIn(): NodeMaterialConnectionPoint;
  99554. /**
  99555. * Gets the x component (input)
  99556. */
  99557. get x(): NodeMaterialConnectionPoint;
  99558. /**
  99559. * Gets the y component (input)
  99560. */
  99561. get y(): NodeMaterialConnectionPoint;
  99562. /**
  99563. * Gets the z component (input)
  99564. */
  99565. get z(): NodeMaterialConnectionPoint;
  99566. /**
  99567. * Gets the w component (input)
  99568. */
  99569. get w(): NodeMaterialConnectionPoint;
  99570. /**
  99571. * Gets the xyzw component (output)
  99572. */
  99573. get xyzw(): NodeMaterialConnectionPoint;
  99574. /**
  99575. * Gets the xyz component (output)
  99576. */
  99577. get xyzOut(): NodeMaterialConnectionPoint;
  99578. /**
  99579. * Gets the xy component (output)
  99580. */
  99581. get xyOut(): NodeMaterialConnectionPoint;
  99582. /**
  99583. * Gets the xy component (output)
  99584. * @deprecated Please use xyOut instead.
  99585. */
  99586. get xy(): NodeMaterialConnectionPoint;
  99587. /**
  99588. * Gets the xyz component (output)
  99589. * @deprecated Please use xyzOut instead.
  99590. */
  99591. get xyz(): NodeMaterialConnectionPoint;
  99592. protected _buildBlock(state: NodeMaterialBuildState): this;
  99593. }
  99594. }
  99595. declare module BABYLON {
  99596. /**
  99597. * Block used to remap a float from a range to a new one
  99598. */
  99599. export class RemapBlock extends NodeMaterialBlock {
  99600. /**
  99601. * Gets or sets the source range
  99602. */
  99603. sourceRange: Vector2;
  99604. /**
  99605. * Gets or sets the target range
  99606. */
  99607. targetRange: Vector2;
  99608. /**
  99609. * Creates a new RemapBlock
  99610. * @param name defines the block name
  99611. */
  99612. constructor(name: string);
  99613. /**
  99614. * Gets the current class name
  99615. * @returns the class name
  99616. */
  99617. getClassName(): string;
  99618. /**
  99619. * Gets the input component
  99620. */
  99621. get input(): NodeMaterialConnectionPoint;
  99622. /**
  99623. * Gets the source min input component
  99624. */
  99625. get sourceMin(): NodeMaterialConnectionPoint;
  99626. /**
  99627. * Gets the source max input component
  99628. */
  99629. get sourceMax(): NodeMaterialConnectionPoint;
  99630. /**
  99631. * Gets the target min input component
  99632. */
  99633. get targetMin(): NodeMaterialConnectionPoint;
  99634. /**
  99635. * Gets the target max input component
  99636. */
  99637. get targetMax(): NodeMaterialConnectionPoint;
  99638. /**
  99639. * Gets the output component
  99640. */
  99641. get output(): NodeMaterialConnectionPoint;
  99642. protected _buildBlock(state: NodeMaterialBuildState): this;
  99643. protected _dumpPropertiesCode(): string;
  99644. serialize(): any;
  99645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99646. }
  99647. }
  99648. declare module BABYLON {
  99649. /**
  99650. * Block used to multiply 2 values
  99651. */
  99652. export class MultiplyBlock extends NodeMaterialBlock {
  99653. /**
  99654. * Creates a new MultiplyBlock
  99655. * @param name defines the block name
  99656. */
  99657. constructor(name: string);
  99658. /**
  99659. * Gets the current class name
  99660. * @returns the class name
  99661. */
  99662. getClassName(): string;
  99663. /**
  99664. * Gets the left operand input component
  99665. */
  99666. get left(): NodeMaterialConnectionPoint;
  99667. /**
  99668. * Gets the right operand input component
  99669. */
  99670. get right(): NodeMaterialConnectionPoint;
  99671. /**
  99672. * Gets the output component
  99673. */
  99674. get output(): NodeMaterialConnectionPoint;
  99675. protected _buildBlock(state: NodeMaterialBuildState): this;
  99676. }
  99677. }
  99678. declare module BABYLON {
  99679. /**
  99680. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99681. */
  99682. export class ColorSplitterBlock extends NodeMaterialBlock {
  99683. /**
  99684. * Create a new ColorSplitterBlock
  99685. * @param name defines the block name
  99686. */
  99687. constructor(name: string);
  99688. /**
  99689. * Gets the current class name
  99690. * @returns the class name
  99691. */
  99692. getClassName(): string;
  99693. /**
  99694. * Gets the rgba component (input)
  99695. */
  99696. get rgba(): NodeMaterialConnectionPoint;
  99697. /**
  99698. * Gets the rgb component (input)
  99699. */
  99700. get rgbIn(): NodeMaterialConnectionPoint;
  99701. /**
  99702. * Gets the rgb component (output)
  99703. */
  99704. get rgbOut(): NodeMaterialConnectionPoint;
  99705. /**
  99706. * Gets the r component (output)
  99707. */
  99708. get r(): NodeMaterialConnectionPoint;
  99709. /**
  99710. * Gets the g component (output)
  99711. */
  99712. get g(): NodeMaterialConnectionPoint;
  99713. /**
  99714. * Gets the b component (output)
  99715. */
  99716. get b(): NodeMaterialConnectionPoint;
  99717. /**
  99718. * Gets the a component (output)
  99719. */
  99720. get a(): NodeMaterialConnectionPoint;
  99721. protected _inputRename(name: string): string;
  99722. protected _outputRename(name: string): string;
  99723. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99724. }
  99725. }
  99726. declare module BABYLON {
  99727. /**
  99728. * Interface used to configure the node material editor
  99729. */
  99730. export interface INodeMaterialEditorOptions {
  99731. /** Define the URl to load node editor script */
  99732. editorURL?: string;
  99733. }
  99734. /** @hidden */
  99735. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99736. NORMAL: boolean;
  99737. TANGENT: boolean;
  99738. UV1: boolean;
  99739. /** BONES */
  99740. NUM_BONE_INFLUENCERS: number;
  99741. BonesPerMesh: number;
  99742. BONETEXTURE: boolean;
  99743. /** MORPH TARGETS */
  99744. MORPHTARGETS: boolean;
  99745. MORPHTARGETS_NORMAL: boolean;
  99746. MORPHTARGETS_TANGENT: boolean;
  99747. MORPHTARGETS_UV: boolean;
  99748. NUM_MORPH_INFLUENCERS: number;
  99749. /** IMAGE PROCESSING */
  99750. IMAGEPROCESSING: boolean;
  99751. VIGNETTE: boolean;
  99752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99753. VIGNETTEBLENDMODEOPAQUE: boolean;
  99754. TONEMAPPING: boolean;
  99755. TONEMAPPING_ACES: boolean;
  99756. CONTRAST: boolean;
  99757. EXPOSURE: boolean;
  99758. COLORCURVES: boolean;
  99759. COLORGRADING: boolean;
  99760. COLORGRADING3D: boolean;
  99761. SAMPLER3DGREENDEPTH: boolean;
  99762. SAMPLER3DBGRMAP: boolean;
  99763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99764. /** MISC. */
  99765. BUMPDIRECTUV: number;
  99766. constructor();
  99767. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99768. }
  99769. /**
  99770. * Class used to configure NodeMaterial
  99771. */
  99772. export interface INodeMaterialOptions {
  99773. /**
  99774. * Defines if blocks should emit comments
  99775. */
  99776. emitComments: boolean;
  99777. }
  99778. /**
  99779. * Class used to create a node based material built by assembling shader blocks
  99780. */
  99781. export class NodeMaterial extends PushMaterial {
  99782. private static _BuildIdGenerator;
  99783. private _options;
  99784. private _vertexCompilationState;
  99785. private _fragmentCompilationState;
  99786. private _sharedData;
  99787. private _buildId;
  99788. private _buildWasSuccessful;
  99789. private _cachedWorldViewMatrix;
  99790. private _cachedWorldViewProjectionMatrix;
  99791. private _optimizers;
  99792. private _animationFrame;
  99793. /** Define the Url to load node editor script */
  99794. static EditorURL: string;
  99795. /** Define the Url to load snippets */
  99796. static SnippetUrl: string;
  99797. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99798. static IgnoreTexturesAtLoadTime: boolean;
  99799. private BJSNODEMATERIALEDITOR;
  99800. /** Get the inspector from bundle or global */
  99801. private _getGlobalNodeMaterialEditor;
  99802. /**
  99803. * Snippet ID if the material was created from the snippet server
  99804. */
  99805. snippetId: string;
  99806. /**
  99807. * Gets or sets data used by visual editor
  99808. * @see https://nme.babylonjs.com
  99809. */
  99810. editorData: any;
  99811. /**
  99812. * 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)
  99813. */
  99814. ignoreAlpha: boolean;
  99815. /**
  99816. * Defines the maximum number of lights that can be used in the material
  99817. */
  99818. maxSimultaneousLights: number;
  99819. /**
  99820. * Observable raised when the material is built
  99821. */
  99822. onBuildObservable: Observable<NodeMaterial>;
  99823. /**
  99824. * Gets or sets the root nodes of the material vertex shader
  99825. */
  99826. _vertexOutputNodes: NodeMaterialBlock[];
  99827. /**
  99828. * Gets or sets the root nodes of the material fragment (pixel) shader
  99829. */
  99830. _fragmentOutputNodes: NodeMaterialBlock[];
  99831. /** Gets or sets options to control the node material overall behavior */
  99832. get options(): INodeMaterialOptions;
  99833. set options(options: INodeMaterialOptions);
  99834. /**
  99835. * Default configuration related to image processing available in the standard Material.
  99836. */
  99837. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99838. /**
  99839. * Gets the image processing configuration used either in this material.
  99840. */
  99841. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99842. /**
  99843. * Sets the Default image processing configuration used either in the this material.
  99844. *
  99845. * If sets to null, the scene one is in use.
  99846. */
  99847. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99848. /**
  99849. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99850. */
  99851. attachedBlocks: NodeMaterialBlock[];
  99852. /**
  99853. * Specifies the mode of the node material
  99854. * @hidden
  99855. */
  99856. _mode: NodeMaterialModes;
  99857. /**
  99858. * Gets the mode property
  99859. */
  99860. get mode(): NodeMaterialModes;
  99861. /**
  99862. * Create a new node based material
  99863. * @param name defines the material name
  99864. * @param scene defines the hosting scene
  99865. * @param options defines creation option
  99866. */
  99867. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99868. /**
  99869. * Gets the current class name of the material e.g. "NodeMaterial"
  99870. * @returns the class name
  99871. */
  99872. getClassName(): string;
  99873. /**
  99874. * Keep track of the image processing observer to allow dispose and replace.
  99875. */
  99876. private _imageProcessingObserver;
  99877. /**
  99878. * Attaches a new image processing configuration to the Standard Material.
  99879. * @param configuration
  99880. */
  99881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99882. /**
  99883. * Get a block by its name
  99884. * @param name defines the name of the block to retrieve
  99885. * @returns the required block or null if not found
  99886. */
  99887. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99888. /**
  99889. * Get a block by its name
  99890. * @param predicate defines the predicate used to find the good candidate
  99891. * @returns the required block or null if not found
  99892. */
  99893. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99894. /**
  99895. * Get an input block by its name
  99896. * @param predicate defines the predicate used to find the good candidate
  99897. * @returns the required input block or null if not found
  99898. */
  99899. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99900. /**
  99901. * Gets the list of input blocks attached to this material
  99902. * @returns an array of InputBlocks
  99903. */
  99904. getInputBlocks(): InputBlock[];
  99905. /**
  99906. * Adds a new optimizer to the list of optimizers
  99907. * @param optimizer defines the optimizers to add
  99908. * @returns the current material
  99909. */
  99910. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99911. /**
  99912. * Remove an optimizer from the list of optimizers
  99913. * @param optimizer defines the optimizers to remove
  99914. * @returns the current material
  99915. */
  99916. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99917. /**
  99918. * Add a new block to the list of output nodes
  99919. * @param node defines the node to add
  99920. * @returns the current material
  99921. */
  99922. addOutputNode(node: NodeMaterialBlock): this;
  99923. /**
  99924. * Remove a block from the list of root nodes
  99925. * @param node defines the node to remove
  99926. * @returns the current material
  99927. */
  99928. removeOutputNode(node: NodeMaterialBlock): this;
  99929. private _addVertexOutputNode;
  99930. private _removeVertexOutputNode;
  99931. private _addFragmentOutputNode;
  99932. private _removeFragmentOutputNode;
  99933. /**
  99934. * Specifies if the material will require alpha blending
  99935. * @returns a boolean specifying if alpha blending is needed
  99936. */
  99937. needAlphaBlending(): boolean;
  99938. /**
  99939. * Specifies if this material should be rendered in alpha test mode
  99940. * @returns a boolean specifying if an alpha test is needed.
  99941. */
  99942. needAlphaTesting(): boolean;
  99943. private _initializeBlock;
  99944. private _resetDualBlocks;
  99945. /**
  99946. * Remove a block from the current node material
  99947. * @param block defines the block to remove
  99948. */
  99949. removeBlock(block: NodeMaterialBlock): void;
  99950. /**
  99951. * Build the material and generates the inner effect
  99952. * @param verbose defines if the build should log activity
  99953. */
  99954. build(verbose?: boolean): void;
  99955. /**
  99956. * Runs an otpimization phase to try to improve the shader code
  99957. */
  99958. optimize(): void;
  99959. private _prepareDefinesForAttributes;
  99960. /**
  99961. * Create a post process from the material
  99962. * @param camera The camera to apply the render pass to.
  99963. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99965. * @param engine The engine which the post process will be applied. (default: current engine)
  99966. * @param reusable If the post process can be reused on the same frame. (default: false)
  99967. * @param textureType Type of textures used when performing the post process. (default: 0)
  99968. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99969. * @returns the post process created
  99970. */
  99971. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99972. /**
  99973. * Create the post process effect from the material
  99974. * @param postProcess The post process to create the effect for
  99975. */
  99976. createEffectForPostProcess(postProcess: PostProcess): void;
  99977. private _createEffectOrPostProcess;
  99978. private _createEffectForParticles;
  99979. /**
  99980. * Create the effect to be used as the custom effect for a particle system
  99981. * @param particleSystem Particle system to create the effect for
  99982. * @param onCompiled defines a function to call when the effect creation is successful
  99983. * @param onError defines a function to call when the effect creation has failed
  99984. */
  99985. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99986. private _processDefines;
  99987. /**
  99988. * Get if the submesh is ready to be used and all its information available.
  99989. * Child classes can use it to update shaders
  99990. * @param mesh defines the mesh to check
  99991. * @param subMesh defines which submesh to check
  99992. * @param useInstances specifies that instances should be used
  99993. * @returns a boolean indicating that the submesh is ready or not
  99994. */
  99995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99996. /**
  99997. * Get a string representing the shaders built by the current node graph
  99998. */
  99999. get compiledShaders(): string;
  100000. /**
  100001. * Binds the world matrix to the material
  100002. * @param world defines the world transformation matrix
  100003. */
  100004. bindOnlyWorldMatrix(world: Matrix): void;
  100005. /**
  100006. * Binds the submesh to this material by preparing the effect and shader to draw
  100007. * @param world defines the world transformation matrix
  100008. * @param mesh defines the mesh containing the submesh
  100009. * @param subMesh defines the submesh to bind the material to
  100010. */
  100011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100012. /**
  100013. * Gets the active textures from the material
  100014. * @returns an array of textures
  100015. */
  100016. getActiveTextures(): BaseTexture[];
  100017. /**
  100018. * Gets the list of texture blocks
  100019. * @returns an array of texture blocks
  100020. */
  100021. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100022. /**
  100023. * Specifies if the material uses a texture
  100024. * @param texture defines the texture to check against the material
  100025. * @returns a boolean specifying if the material uses the texture
  100026. */
  100027. hasTexture(texture: BaseTexture): boolean;
  100028. /**
  100029. * Disposes the material
  100030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100032. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100033. */
  100034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100035. /** Creates the node editor window. */
  100036. private _createNodeEditor;
  100037. /**
  100038. * Launch the node material editor
  100039. * @param config Define the configuration of the editor
  100040. * @return a promise fulfilled when the node editor is visible
  100041. */
  100042. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100043. /**
  100044. * Clear the current material
  100045. */
  100046. clear(): void;
  100047. /**
  100048. * Clear the current material and set it to a default state
  100049. */
  100050. setToDefault(): void;
  100051. /**
  100052. * Clear the current material and set it to a default state for post process
  100053. */
  100054. setToDefaultPostProcess(): void;
  100055. /**
  100056. * Clear the current material and set it to a default state for particle
  100057. */
  100058. setToDefaultParticle(): void;
  100059. /**
  100060. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100061. * @param url defines the url to load from
  100062. * @returns a promise that will fullfil when the material is fully loaded
  100063. */
  100064. loadAsync(url: string): Promise<void>;
  100065. private _gatherBlocks;
  100066. /**
  100067. * Generate a string containing the code declaration required to create an equivalent of this material
  100068. * @returns a string
  100069. */
  100070. generateCode(): string;
  100071. /**
  100072. * Serializes this material in a JSON representation
  100073. * @returns the serialized material object
  100074. */
  100075. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100076. private _restoreConnections;
  100077. /**
  100078. * Clear the current graph and load a new one from a serialization object
  100079. * @param source defines the JSON representation of the material
  100080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100081. * @param merge defines whether or not the source must be merged or replace the current content
  100082. */
  100083. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100084. /**
  100085. * Makes a duplicate of the current material.
  100086. * @param name - name to use for the new material.
  100087. */
  100088. clone(name: string): NodeMaterial;
  100089. /**
  100090. * Creates a node material from parsed material data
  100091. * @param source defines the JSON representation of the material
  100092. * @param scene defines the hosting scene
  100093. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100094. * @returns a new node material
  100095. */
  100096. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100097. /**
  100098. * Creates a node material from a snippet saved in a remote file
  100099. * @param name defines the name of the material to create
  100100. * @param url defines the url to load from
  100101. * @param scene defines the hosting scene
  100102. * @returns a promise that will resolve to the new node material
  100103. */
  100104. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100105. /**
  100106. * Creates a node material from a snippet saved by the node material editor
  100107. * @param snippetId defines the snippet to load
  100108. * @param scene defines the hosting scene
  100109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100110. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100111. * @returns a promise that will resolve to the new node material
  100112. */
  100113. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100114. /**
  100115. * Creates a new node material set to default basic configuration
  100116. * @param name defines the name of the material
  100117. * @param scene defines the hosting scene
  100118. * @returns a new NodeMaterial
  100119. */
  100120. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100121. }
  100122. }
  100123. declare module BABYLON {
  100124. /**
  100125. * Size options for a post process
  100126. */
  100127. export type PostProcessOptions = {
  100128. width: number;
  100129. height: number;
  100130. };
  100131. /**
  100132. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100133. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100134. */
  100135. export class PostProcess {
  100136. /** Name of the PostProcess. */
  100137. name: string;
  100138. /**
  100139. * Gets or sets the unique id of the post process
  100140. */
  100141. uniqueId: number;
  100142. /**
  100143. * Width of the texture to apply the post process on
  100144. */
  100145. width: number;
  100146. /**
  100147. * Height of the texture to apply the post process on
  100148. */
  100149. height: number;
  100150. /**
  100151. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100152. */
  100153. nodeMaterialSource: Nullable<NodeMaterial>;
  100154. /**
  100155. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100156. * @hidden
  100157. */
  100158. _outputTexture: Nullable<InternalTexture>;
  100159. /**
  100160. * Sampling mode used by the shader
  100161. * See https://doc.babylonjs.com/classes/3.1/texture
  100162. */
  100163. renderTargetSamplingMode: number;
  100164. /**
  100165. * Clear color to use when screen clearing
  100166. */
  100167. clearColor: Color4;
  100168. /**
  100169. * If the buffer needs to be cleared before applying the post process. (default: true)
  100170. * Should be set to false if shader will overwrite all previous pixels.
  100171. */
  100172. autoClear: boolean;
  100173. /**
  100174. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100175. */
  100176. alphaMode: number;
  100177. /**
  100178. * Sets the setAlphaBlendConstants of the babylon engine
  100179. */
  100180. alphaConstants: Color4;
  100181. /**
  100182. * Animations to be used for the post processing
  100183. */
  100184. animations: Animation[];
  100185. /**
  100186. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100187. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100188. */
  100189. enablePixelPerfectMode: boolean;
  100190. /**
  100191. * Force the postprocess to be applied without taking in account viewport
  100192. */
  100193. forceFullscreenViewport: boolean;
  100194. /**
  100195. * List of inspectable custom properties (used by the Inspector)
  100196. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100197. */
  100198. inspectableCustomProperties: IInspectable[];
  100199. /**
  100200. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100201. *
  100202. * | Value | Type | Description |
  100203. * | ----- | ----------------------------------- | ----------- |
  100204. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100205. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100206. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100207. *
  100208. */
  100209. scaleMode: number;
  100210. /**
  100211. * Force textures to be a power of two (default: false)
  100212. */
  100213. alwaysForcePOT: boolean;
  100214. private _samples;
  100215. /**
  100216. * Number of sample textures (default: 1)
  100217. */
  100218. get samples(): number;
  100219. set samples(n: number);
  100220. /**
  100221. * Modify the scale of the post process to be the same as the viewport (default: false)
  100222. */
  100223. adaptScaleToCurrentViewport: boolean;
  100224. private _camera;
  100225. private _scene;
  100226. private _engine;
  100227. private _options;
  100228. private _reusable;
  100229. private _textureType;
  100230. private _textureFormat;
  100231. /**
  100232. * Smart array of input and output textures for the post process.
  100233. * @hidden
  100234. */
  100235. _textures: SmartArray<InternalTexture>;
  100236. /**
  100237. * The index in _textures that corresponds to the output texture.
  100238. * @hidden
  100239. */
  100240. _currentRenderTextureInd: number;
  100241. private _effect;
  100242. private _samplers;
  100243. private _fragmentUrl;
  100244. private _vertexUrl;
  100245. private _parameters;
  100246. private _scaleRatio;
  100247. protected _indexParameters: any;
  100248. private _shareOutputWithPostProcess;
  100249. private _texelSize;
  100250. private _forcedOutputTexture;
  100251. /**
  100252. * Returns the fragment url or shader name used in the post process.
  100253. * @returns the fragment url or name in the shader store.
  100254. */
  100255. getEffectName(): string;
  100256. /**
  100257. * An event triggered when the postprocess is activated.
  100258. */
  100259. onActivateObservable: Observable<Camera>;
  100260. private _onActivateObserver;
  100261. /**
  100262. * A function that is added to the onActivateObservable
  100263. */
  100264. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100265. /**
  100266. * An event triggered when the postprocess changes its size.
  100267. */
  100268. onSizeChangedObservable: Observable<PostProcess>;
  100269. private _onSizeChangedObserver;
  100270. /**
  100271. * A function that is added to the onSizeChangedObservable
  100272. */
  100273. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100274. /**
  100275. * An event triggered when the postprocess applies its effect.
  100276. */
  100277. onApplyObservable: Observable<Effect>;
  100278. private _onApplyObserver;
  100279. /**
  100280. * A function that is added to the onApplyObservable
  100281. */
  100282. set onApply(callback: (effect: Effect) => void);
  100283. /**
  100284. * An event triggered before rendering the postprocess
  100285. */
  100286. onBeforeRenderObservable: Observable<Effect>;
  100287. private _onBeforeRenderObserver;
  100288. /**
  100289. * A function that is added to the onBeforeRenderObservable
  100290. */
  100291. set onBeforeRender(callback: (effect: Effect) => void);
  100292. /**
  100293. * An event triggered after rendering the postprocess
  100294. */
  100295. onAfterRenderObservable: Observable<Effect>;
  100296. private _onAfterRenderObserver;
  100297. /**
  100298. * A function that is added to the onAfterRenderObservable
  100299. */
  100300. set onAfterRender(callback: (efect: Effect) => void);
  100301. /**
  100302. * 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
  100303. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100304. */
  100305. get inputTexture(): InternalTexture;
  100306. set inputTexture(value: InternalTexture);
  100307. /**
  100308. * Gets the camera which post process is applied to.
  100309. * @returns The camera the post process is applied to.
  100310. */
  100311. getCamera(): Camera;
  100312. /**
  100313. * Gets the texel size of the postprocess.
  100314. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100315. */
  100316. get texelSize(): Vector2;
  100317. /**
  100318. * Creates a new instance PostProcess
  100319. * @param name The name of the PostProcess.
  100320. * @param fragmentUrl The url of the fragment shader to be used.
  100321. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100322. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100323. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100324. * @param camera The camera to apply the render pass to.
  100325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100326. * @param engine The engine which the post process will be applied. (default: current engine)
  100327. * @param reusable If the post process can be reused on the same frame. (default: false)
  100328. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100329. * @param textureType Type of textures used when performing the post process. (default: 0)
  100330. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100331. * @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
  100332. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100333. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100334. */
  100335. constructor(
  100336. /** Name of the PostProcess. */
  100337. 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);
  100338. /**
  100339. * Gets a string idenfifying the name of the class
  100340. * @returns "PostProcess" string
  100341. */
  100342. getClassName(): string;
  100343. /**
  100344. * Gets the engine which this post process belongs to.
  100345. * @returns The engine the post process was enabled with.
  100346. */
  100347. getEngine(): Engine;
  100348. /**
  100349. * The effect that is created when initializing the post process.
  100350. * @returns The created effect corresponding the the postprocess.
  100351. */
  100352. getEffect(): Effect;
  100353. /**
  100354. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100355. * @param postProcess The post process to share the output with.
  100356. * @returns This post process.
  100357. */
  100358. shareOutputWith(postProcess: PostProcess): PostProcess;
  100359. /**
  100360. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100361. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100362. */
  100363. useOwnOutput(): void;
  100364. /**
  100365. * Updates the effect with the current post process compile time values and recompiles the shader.
  100366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100369. * @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
  100370. * @param onCompiled Called when the shader has been compiled.
  100371. * @param onError Called if there is an error when compiling a shader.
  100372. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100373. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100374. */
  100375. 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;
  100376. /**
  100377. * The post process is reusable if it can be used multiple times within one frame.
  100378. * @returns If the post process is reusable
  100379. */
  100380. isReusable(): boolean;
  100381. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100382. markTextureDirty(): void;
  100383. /**
  100384. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100385. * 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.
  100386. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100387. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100388. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100389. * @returns The target texture that was bound to be written to.
  100390. */
  100391. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100392. /**
  100393. * If the post process is supported.
  100394. */
  100395. get isSupported(): boolean;
  100396. /**
  100397. * The aspect ratio of the output texture.
  100398. */
  100399. get aspectRatio(): number;
  100400. /**
  100401. * Get a value indicating if the post-process is ready to be used
  100402. * @returns true if the post-process is ready (shader is compiled)
  100403. */
  100404. isReady(): boolean;
  100405. /**
  100406. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100407. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100408. */
  100409. apply(): Nullable<Effect>;
  100410. private _disposeTextures;
  100411. /**
  100412. * Disposes the post process.
  100413. * @param camera The camera to dispose the post process on.
  100414. */
  100415. dispose(camera?: Camera): void;
  100416. }
  100417. }
  100418. declare module BABYLON {
  100419. /** @hidden */
  100420. export var kernelBlurVaryingDeclaration: {
  100421. name: string;
  100422. shader: string;
  100423. };
  100424. }
  100425. declare module BABYLON {
  100426. /** @hidden */
  100427. export var kernelBlurFragment: {
  100428. name: string;
  100429. shader: string;
  100430. };
  100431. }
  100432. declare module BABYLON {
  100433. /** @hidden */
  100434. export var kernelBlurFragment2: {
  100435. name: string;
  100436. shader: string;
  100437. };
  100438. }
  100439. declare module BABYLON {
  100440. /** @hidden */
  100441. export var kernelBlurPixelShader: {
  100442. name: string;
  100443. shader: string;
  100444. };
  100445. }
  100446. declare module BABYLON {
  100447. /** @hidden */
  100448. export var kernelBlurVertex: {
  100449. name: string;
  100450. shader: string;
  100451. };
  100452. }
  100453. declare module BABYLON {
  100454. /** @hidden */
  100455. export var kernelBlurVertexShader: {
  100456. name: string;
  100457. shader: string;
  100458. };
  100459. }
  100460. declare module BABYLON {
  100461. /**
  100462. * The Blur Post Process which blurs an image based on a kernel and direction.
  100463. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100464. */
  100465. export class BlurPostProcess extends PostProcess {
  100466. /** The direction in which to blur the image. */
  100467. direction: Vector2;
  100468. private blockCompilation;
  100469. protected _kernel: number;
  100470. protected _idealKernel: number;
  100471. protected _packedFloat: boolean;
  100472. private _staticDefines;
  100473. /**
  100474. * Sets the length in pixels of the blur sample region
  100475. */
  100476. set kernel(v: number);
  100477. /**
  100478. * Gets the length in pixels of the blur sample region
  100479. */
  100480. get kernel(): number;
  100481. /**
  100482. * Sets wether or not the blur needs to unpack/repack floats
  100483. */
  100484. set packedFloat(v: boolean);
  100485. /**
  100486. * Gets wether or not the blur is unpacking/repacking floats
  100487. */
  100488. get packedFloat(): boolean;
  100489. /**
  100490. * Creates a new instance BlurPostProcess
  100491. * @param name The name of the effect.
  100492. * @param direction The direction in which to blur the image.
  100493. * @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.
  100494. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100495. * @param camera The camera to apply the render pass to.
  100496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100497. * @param engine The engine which the post process will be applied. (default: current engine)
  100498. * @param reusable If the post process can be reused on the same frame. (default: false)
  100499. * @param textureType Type of textures used when performing the post process. (default: 0)
  100500. * @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)
  100501. */
  100502. constructor(name: string,
  100503. /** The direction in which to blur the image. */
  100504. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100505. /**
  100506. * Updates the effect with the current post process compile time values and recompiles the shader.
  100507. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100508. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100509. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100510. * @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
  100511. * @param onCompiled Called when the shader has been compiled.
  100512. * @param onError Called if there is an error when compiling a shader.
  100513. */
  100514. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100515. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100516. /**
  100517. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100518. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100519. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100520. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100521. * The gaps between physical kernels are compensated for in the weighting of the samples
  100522. * @param idealKernel Ideal blur kernel.
  100523. * @return Nearest best kernel.
  100524. */
  100525. protected _nearestBestKernel(idealKernel: number): number;
  100526. /**
  100527. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100528. * @param x The point on the Gaussian distribution to sample.
  100529. * @return the value of the Gaussian function at x.
  100530. */
  100531. protected _gaussianWeight(x: number): number;
  100532. /**
  100533. * Generates a string that can be used as a floating point number in GLSL.
  100534. * @param x Value to print.
  100535. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100536. * @return GLSL float string.
  100537. */
  100538. protected _glslFloat(x: number, decimalFigures?: number): string;
  100539. }
  100540. }
  100541. declare module BABYLON {
  100542. /**
  100543. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100544. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100545. * You can then easily use it as a reflectionTexture on a flat surface.
  100546. * In case the surface is not a plane, please consider relying on reflection probes.
  100547. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100548. */
  100549. export class MirrorTexture extends RenderTargetTexture {
  100550. private scene;
  100551. /**
  100552. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100553. * 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.
  100554. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100555. */
  100556. mirrorPlane: Plane;
  100557. /**
  100558. * Define the blur ratio used to blur the reflection if needed.
  100559. */
  100560. set blurRatio(value: number);
  100561. get blurRatio(): number;
  100562. /**
  100563. * Define the adaptive blur kernel used to blur the reflection if needed.
  100564. * This will autocompute the closest best match for the `blurKernel`
  100565. */
  100566. set adaptiveBlurKernel(value: number);
  100567. /**
  100568. * Define the blur kernel used to blur the reflection if needed.
  100569. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100570. */
  100571. set blurKernel(value: number);
  100572. /**
  100573. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100574. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100575. */
  100576. set blurKernelX(value: number);
  100577. get blurKernelX(): number;
  100578. /**
  100579. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100580. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100581. */
  100582. set blurKernelY(value: number);
  100583. get blurKernelY(): number;
  100584. private _autoComputeBlurKernel;
  100585. protected _onRatioRescale(): void;
  100586. private _updateGammaSpace;
  100587. private _imageProcessingConfigChangeObserver;
  100588. private _transformMatrix;
  100589. private _mirrorMatrix;
  100590. private _savedViewMatrix;
  100591. private _blurX;
  100592. private _blurY;
  100593. private _adaptiveBlurKernel;
  100594. private _blurKernelX;
  100595. private _blurKernelY;
  100596. private _blurRatio;
  100597. /**
  100598. * Instantiates a Mirror Texture.
  100599. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100600. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100601. * You can then easily use it as a reflectionTexture on a flat surface.
  100602. * In case the surface is not a plane, please consider relying on reflection probes.
  100603. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100604. * @param name
  100605. * @param size
  100606. * @param scene
  100607. * @param generateMipMaps
  100608. * @param type
  100609. * @param samplingMode
  100610. * @param generateDepthBuffer
  100611. */
  100612. constructor(name: string, size: number | {
  100613. width: number;
  100614. height: number;
  100615. } | {
  100616. ratio: number;
  100617. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100618. private _preparePostProcesses;
  100619. /**
  100620. * Clone the mirror texture.
  100621. * @returns the cloned texture
  100622. */
  100623. clone(): MirrorTexture;
  100624. /**
  100625. * Serialize the texture to a JSON representation you could use in Parse later on
  100626. * @returns the serialized JSON representation
  100627. */
  100628. serialize(): any;
  100629. /**
  100630. * Dispose the texture and release its associated resources.
  100631. */
  100632. dispose(): void;
  100633. }
  100634. }
  100635. declare module BABYLON {
  100636. /**
  100637. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100638. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100639. */
  100640. export class Texture extends BaseTexture {
  100641. /**
  100642. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100643. */
  100644. static SerializeBuffers: boolean;
  100645. /** @hidden */
  100646. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100647. /** @hidden */
  100648. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100649. /** @hidden */
  100650. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100651. /** nearest is mag = nearest and min = nearest and mip = linear */
  100652. static readonly NEAREST_SAMPLINGMODE: number;
  100653. /** nearest is mag = nearest and min = nearest and mip = linear */
  100654. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100655. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100656. static readonly BILINEAR_SAMPLINGMODE: number;
  100657. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100658. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100659. /** Trilinear is mag = linear and min = linear and mip = linear */
  100660. static readonly TRILINEAR_SAMPLINGMODE: number;
  100661. /** Trilinear is mag = linear and min = linear and mip = linear */
  100662. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100663. /** mag = nearest and min = nearest and mip = nearest */
  100664. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100665. /** mag = nearest and min = linear and mip = nearest */
  100666. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100667. /** mag = nearest and min = linear and mip = linear */
  100668. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100669. /** mag = nearest and min = linear and mip = none */
  100670. static readonly NEAREST_LINEAR: number;
  100671. /** mag = nearest and min = nearest and mip = none */
  100672. static readonly NEAREST_NEAREST: number;
  100673. /** mag = linear and min = nearest and mip = nearest */
  100674. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100675. /** mag = linear and min = nearest and mip = linear */
  100676. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100677. /** mag = linear and min = linear and mip = none */
  100678. static readonly LINEAR_LINEAR: number;
  100679. /** mag = linear and min = nearest and mip = none */
  100680. static readonly LINEAR_NEAREST: number;
  100681. /** Explicit coordinates mode */
  100682. static readonly EXPLICIT_MODE: number;
  100683. /** Spherical coordinates mode */
  100684. static readonly SPHERICAL_MODE: number;
  100685. /** Planar coordinates mode */
  100686. static readonly PLANAR_MODE: number;
  100687. /** Cubic coordinates mode */
  100688. static readonly CUBIC_MODE: number;
  100689. /** Projection coordinates mode */
  100690. static readonly PROJECTION_MODE: number;
  100691. /** Inverse Cubic coordinates mode */
  100692. static readonly SKYBOX_MODE: number;
  100693. /** Inverse Cubic coordinates mode */
  100694. static readonly INVCUBIC_MODE: number;
  100695. /** Equirectangular coordinates mode */
  100696. static readonly EQUIRECTANGULAR_MODE: number;
  100697. /** Equirectangular Fixed coordinates mode */
  100698. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100699. /** Equirectangular Fixed Mirrored coordinates mode */
  100700. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100701. /** Texture is not repeating outside of 0..1 UVs */
  100702. static readonly CLAMP_ADDRESSMODE: number;
  100703. /** Texture is repeating outside of 0..1 UVs */
  100704. static readonly WRAP_ADDRESSMODE: number;
  100705. /** Texture is repeating and mirrored */
  100706. static readonly MIRROR_ADDRESSMODE: number;
  100707. /**
  100708. * 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
  100709. */
  100710. static UseSerializedUrlIfAny: boolean;
  100711. /**
  100712. * Define the url of the texture.
  100713. */
  100714. url: Nullable<string>;
  100715. /**
  100716. * Define an offset on the texture to offset the u coordinates of the UVs
  100717. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100718. */
  100719. uOffset: number;
  100720. /**
  100721. * Define an offset on the texture to offset the v coordinates of the UVs
  100722. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100723. */
  100724. vOffset: number;
  100725. /**
  100726. * Define an offset on the texture to scale the u coordinates of the UVs
  100727. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100728. */
  100729. uScale: number;
  100730. /**
  100731. * Define an offset on the texture to scale the v coordinates of the UVs
  100732. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100733. */
  100734. vScale: number;
  100735. /**
  100736. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100737. * @see http://doc.babylonjs.com/how_to/more_materials
  100738. */
  100739. uAng: number;
  100740. /**
  100741. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100742. * @see http://doc.babylonjs.com/how_to/more_materials
  100743. */
  100744. vAng: number;
  100745. /**
  100746. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100747. * @see http://doc.babylonjs.com/how_to/more_materials
  100748. */
  100749. wAng: number;
  100750. /**
  100751. * Defines the center of rotation (U)
  100752. */
  100753. uRotationCenter: number;
  100754. /**
  100755. * Defines the center of rotation (V)
  100756. */
  100757. vRotationCenter: number;
  100758. /**
  100759. * Defines the center of rotation (W)
  100760. */
  100761. wRotationCenter: number;
  100762. /**
  100763. * Are mip maps generated for this texture or not.
  100764. */
  100765. get noMipmap(): boolean;
  100766. /**
  100767. * List of inspectable custom properties (used by the Inspector)
  100768. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100769. */
  100770. inspectableCustomProperties: Nullable<IInspectable[]>;
  100771. private _noMipmap;
  100772. /** @hidden */
  100773. _invertY: boolean;
  100774. private _rowGenerationMatrix;
  100775. private _cachedTextureMatrix;
  100776. private _projectionModeMatrix;
  100777. private _t0;
  100778. private _t1;
  100779. private _t2;
  100780. private _cachedUOffset;
  100781. private _cachedVOffset;
  100782. private _cachedUScale;
  100783. private _cachedVScale;
  100784. private _cachedUAng;
  100785. private _cachedVAng;
  100786. private _cachedWAng;
  100787. private _cachedProjectionMatrixId;
  100788. private _cachedCoordinatesMode;
  100789. /** @hidden */
  100790. protected _initialSamplingMode: number;
  100791. /** @hidden */
  100792. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100793. private _deleteBuffer;
  100794. protected _format: Nullable<number>;
  100795. private _delayedOnLoad;
  100796. private _delayedOnError;
  100797. private _mimeType?;
  100798. /**
  100799. * Observable triggered once the texture has been loaded.
  100800. */
  100801. onLoadObservable: Observable<Texture>;
  100802. protected _isBlocking: boolean;
  100803. /**
  100804. * Is the texture preventing material to render while loading.
  100805. * If false, a default texture will be used instead of the loading one during the preparation step.
  100806. */
  100807. set isBlocking(value: boolean);
  100808. get isBlocking(): boolean;
  100809. /**
  100810. * Get the current sampling mode associated with the texture.
  100811. */
  100812. get samplingMode(): number;
  100813. /**
  100814. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100815. */
  100816. get invertY(): boolean;
  100817. /**
  100818. * Instantiates a new texture.
  100819. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100820. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100821. * @param url defines the url of the picture to load as a texture
  100822. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100823. * @param noMipmap defines if the texture will require mip maps or not
  100824. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100825. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100826. * @param onLoad defines a callback triggered when the texture has been loaded
  100827. * @param onError defines a callback triggered when an error occurred during the loading session
  100828. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100829. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100830. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100831. * @param mimeType defines an optional mime type information
  100832. */
  100833. 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);
  100834. /**
  100835. * Update the url (and optional buffer) of this texture if url was null during construction.
  100836. * @param url the url of the texture
  100837. * @param buffer the buffer of the texture (defaults to null)
  100838. * @param onLoad callback called when the texture is loaded (defaults to null)
  100839. */
  100840. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100841. /**
  100842. * Finish the loading sequence of a texture flagged as delayed load.
  100843. * @hidden
  100844. */
  100845. delayLoad(): void;
  100846. private _prepareRowForTextureGeneration;
  100847. /**
  100848. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100849. * @returns the transform matrix of the texture.
  100850. */
  100851. getTextureMatrix(uBase?: number): Matrix;
  100852. /**
  100853. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100854. * @returns The reflection texture transform
  100855. */
  100856. getReflectionTextureMatrix(): Matrix;
  100857. /**
  100858. * Clones the texture.
  100859. * @returns the cloned texture
  100860. */
  100861. clone(): Texture;
  100862. /**
  100863. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100864. * @returns The JSON representation of the texture
  100865. */
  100866. serialize(): any;
  100867. /**
  100868. * Get the current class name of the texture useful for serialization or dynamic coding.
  100869. * @returns "Texture"
  100870. */
  100871. getClassName(): string;
  100872. /**
  100873. * Dispose the texture and release its associated resources.
  100874. */
  100875. dispose(): void;
  100876. /**
  100877. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100878. * @param parsedTexture Define the JSON representation of the texture
  100879. * @param scene Define the scene the parsed texture should be instantiated in
  100880. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100881. * @returns The parsed texture if successful
  100882. */
  100883. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100884. /**
  100885. * Creates a texture from its base 64 representation.
  100886. * @param data Define the base64 payload without the data: prefix
  100887. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100888. * @param scene Define the scene the texture should belong to
  100889. * @param noMipmap Forces the texture to not create mip map information if true
  100890. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100891. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100892. * @param onLoad define a callback triggered when the texture has been loaded
  100893. * @param onError define a callback triggered when an error occurred during the loading session
  100894. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100895. * @returns the created texture
  100896. */
  100897. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100898. /**
  100899. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100900. * @param data Define the base64 payload without the data: prefix
  100901. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100902. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100903. * @param scene Define the scene the texture should belong to
  100904. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100905. * @param noMipmap Forces the texture to not create mip map information if true
  100906. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100907. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100908. * @param onLoad define a callback triggered when the texture has been loaded
  100909. * @param onError define a callback triggered when an error occurred during the loading session
  100910. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100911. * @returns the created texture
  100912. */
  100913. 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;
  100914. }
  100915. }
  100916. declare module BABYLON {
  100917. /**
  100918. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100919. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100920. */
  100921. export class PostProcessManager {
  100922. private _scene;
  100923. private _indexBuffer;
  100924. private _vertexBuffers;
  100925. /**
  100926. * Creates a new instance PostProcess
  100927. * @param scene The scene that the post process is associated with.
  100928. */
  100929. constructor(scene: Scene);
  100930. private _prepareBuffers;
  100931. private _buildIndexBuffer;
  100932. /**
  100933. * Rebuilds the vertex buffers of the manager.
  100934. * @hidden
  100935. */
  100936. _rebuild(): void;
  100937. /**
  100938. * Prepares a frame to be run through a post process.
  100939. * @param sourceTexture The input texture to the post procesess. (default: null)
  100940. * @param postProcesses An array of post processes to be run. (default: null)
  100941. * @returns True if the post processes were able to be run.
  100942. * @hidden
  100943. */
  100944. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100945. /**
  100946. * Manually render a set of post processes to a texture.
  100947. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100948. * @param postProcesses An array of post processes to be run.
  100949. * @param targetTexture The target texture to render to.
  100950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100951. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100952. * @param lodLevel defines which lod of the texture to render to
  100953. */
  100954. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100955. /**
  100956. * Finalize the result of the output of the postprocesses.
  100957. * @param doNotPresent If true the result will not be displayed to the screen.
  100958. * @param targetTexture The target texture to render to.
  100959. * @param faceIndex The index of the face to bind the target texture to.
  100960. * @param postProcesses The array of post processes to render.
  100961. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100962. * @hidden
  100963. */
  100964. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100965. /**
  100966. * Disposes of the post process manager.
  100967. */
  100968. dispose(): void;
  100969. }
  100970. }
  100971. declare module BABYLON {
  100972. /**
  100973. * This Helps creating a texture that will be created from a camera in your scene.
  100974. * It is basically a dynamic texture that could be used to create special effects for instance.
  100975. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100976. */
  100977. export class RenderTargetTexture extends Texture {
  100978. isCube: boolean;
  100979. /**
  100980. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100981. */
  100982. static readonly REFRESHRATE_RENDER_ONCE: number;
  100983. /**
  100984. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100985. */
  100986. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100987. /**
  100988. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100989. * the central point of your effect and can save a lot of performances.
  100990. */
  100991. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100992. /**
  100993. * Use this predicate to dynamically define the list of mesh you want to render.
  100994. * If set, the renderList property will be overwritten.
  100995. */
  100996. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100997. private _renderList;
  100998. /**
  100999. * Use this list to define the list of mesh you want to render.
  101000. */
  101001. get renderList(): Nullable<Array<AbstractMesh>>;
  101002. set renderList(value: Nullable<Array<AbstractMesh>>);
  101003. /**
  101004. * Use this function to overload the renderList array at rendering time.
  101005. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101006. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101007. * the cube (if the RTT is a cube, else layerOrFace=0).
  101008. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101009. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101010. * hold dummy elements!
  101011. */
  101012. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101013. private _hookArray;
  101014. /**
  101015. * Define if particles should be rendered in your texture.
  101016. */
  101017. renderParticles: boolean;
  101018. /**
  101019. * Define if sprites should be rendered in your texture.
  101020. */
  101021. renderSprites: boolean;
  101022. /**
  101023. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101024. */
  101025. coordinatesMode: number;
  101026. /**
  101027. * Define the camera used to render the texture.
  101028. */
  101029. activeCamera: Nullable<Camera>;
  101030. /**
  101031. * Override the mesh isReady function with your own one.
  101032. */
  101033. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101034. /**
  101035. * Override the render function of the texture with your own one.
  101036. */
  101037. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101038. /**
  101039. * Define if camera post processes should be use while rendering the texture.
  101040. */
  101041. useCameraPostProcesses: boolean;
  101042. /**
  101043. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101044. */
  101045. ignoreCameraViewport: boolean;
  101046. private _postProcessManager;
  101047. private _postProcesses;
  101048. private _resizeObserver;
  101049. /**
  101050. * An event triggered when the texture is unbind.
  101051. */
  101052. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101053. /**
  101054. * An event triggered when the texture is unbind.
  101055. */
  101056. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101057. private _onAfterUnbindObserver;
  101058. /**
  101059. * Set a after unbind callback in the texture.
  101060. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101061. */
  101062. set onAfterUnbind(callback: () => void);
  101063. /**
  101064. * An event triggered before rendering the texture
  101065. */
  101066. onBeforeRenderObservable: Observable<number>;
  101067. private _onBeforeRenderObserver;
  101068. /**
  101069. * Set a before render callback in the texture.
  101070. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101071. */
  101072. set onBeforeRender(callback: (faceIndex: number) => void);
  101073. /**
  101074. * An event triggered after rendering the texture
  101075. */
  101076. onAfterRenderObservable: Observable<number>;
  101077. private _onAfterRenderObserver;
  101078. /**
  101079. * Set a after render callback in the texture.
  101080. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101081. */
  101082. set onAfterRender(callback: (faceIndex: number) => void);
  101083. /**
  101084. * An event triggered after the texture clear
  101085. */
  101086. onClearObservable: Observable<Engine>;
  101087. private _onClearObserver;
  101088. /**
  101089. * Set a clear callback in the texture.
  101090. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101091. */
  101092. set onClear(callback: (Engine: Engine) => void);
  101093. /**
  101094. * An event triggered when the texture is resized.
  101095. */
  101096. onResizeObservable: Observable<RenderTargetTexture>;
  101097. /**
  101098. * Define the clear color of the Render Target if it should be different from the scene.
  101099. */
  101100. clearColor: Color4;
  101101. protected _size: number | {
  101102. width: number;
  101103. height: number;
  101104. layers?: number;
  101105. };
  101106. protected _initialSizeParameter: number | {
  101107. width: number;
  101108. height: number;
  101109. } | {
  101110. ratio: number;
  101111. };
  101112. protected _sizeRatio: Nullable<number>;
  101113. /** @hidden */
  101114. _generateMipMaps: boolean;
  101115. protected _renderingManager: RenderingManager;
  101116. /** @hidden */
  101117. _waitingRenderList: string[];
  101118. protected _doNotChangeAspectRatio: boolean;
  101119. protected _currentRefreshId: number;
  101120. protected _refreshRate: number;
  101121. protected _textureMatrix: Matrix;
  101122. protected _samples: number;
  101123. protected _renderTargetOptions: RenderTargetCreationOptions;
  101124. /**
  101125. * Gets render target creation options that were used.
  101126. */
  101127. get renderTargetOptions(): RenderTargetCreationOptions;
  101128. protected _onRatioRescale(): void;
  101129. /**
  101130. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101131. * It must define where the camera used to render the texture is set
  101132. */
  101133. boundingBoxPosition: Vector3;
  101134. private _boundingBoxSize;
  101135. /**
  101136. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101137. * When defined, the cubemap will switch to local mode
  101138. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101139. * @example https://www.babylonjs-playground.com/#RNASML
  101140. */
  101141. set boundingBoxSize(value: Vector3);
  101142. get boundingBoxSize(): Vector3;
  101143. /**
  101144. * In case the RTT has been created with a depth texture, get the associated
  101145. * depth texture.
  101146. * Otherwise, return null.
  101147. */
  101148. get depthStencilTexture(): Nullable<InternalTexture>;
  101149. /**
  101150. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101151. * or used a shadow, depth texture...
  101152. * @param name The friendly name of the texture
  101153. * @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)
  101154. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101155. * @param generateMipMaps True if mip maps need to be generated after render.
  101156. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101157. * @param type The type of the buffer in the RTT (int, half float, float...)
  101158. * @param isCube True if a cube texture needs to be created
  101159. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101160. * @param generateDepthBuffer True to generate a depth buffer
  101161. * @param generateStencilBuffer True to generate a stencil buffer
  101162. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101163. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101164. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101165. */
  101166. constructor(name: string, size: number | {
  101167. width: number;
  101168. height: number;
  101169. layers?: number;
  101170. } | {
  101171. ratio: number;
  101172. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101173. /**
  101174. * Creates a depth stencil texture.
  101175. * This is only available in WebGL 2 or with the depth texture extension available.
  101176. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101177. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101178. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101179. */
  101180. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101181. private _processSizeParameter;
  101182. /**
  101183. * Define the number of samples to use in case of MSAA.
  101184. * It defaults to one meaning no MSAA has been enabled.
  101185. */
  101186. get samples(): number;
  101187. set samples(value: number);
  101188. /**
  101189. * Resets the refresh counter of the texture and start bak from scratch.
  101190. * Could be useful to regenerate the texture if it is setup to render only once.
  101191. */
  101192. resetRefreshCounter(): void;
  101193. /**
  101194. * Define the refresh rate of the texture or the rendering frequency.
  101195. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101196. */
  101197. get refreshRate(): number;
  101198. set refreshRate(value: number);
  101199. /**
  101200. * Adds a post process to the render target rendering passes.
  101201. * @param postProcess define the post process to add
  101202. */
  101203. addPostProcess(postProcess: PostProcess): void;
  101204. /**
  101205. * Clear all the post processes attached to the render target
  101206. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101207. */
  101208. clearPostProcesses(dispose?: boolean): void;
  101209. /**
  101210. * Remove one of the post process from the list of attached post processes to the texture
  101211. * @param postProcess define the post process to remove from the list
  101212. */
  101213. removePostProcess(postProcess: PostProcess): void;
  101214. /** @hidden */
  101215. _shouldRender(): boolean;
  101216. /**
  101217. * Gets the actual render size of the texture.
  101218. * @returns the width of the render size
  101219. */
  101220. getRenderSize(): number;
  101221. /**
  101222. * Gets the actual render width of the texture.
  101223. * @returns the width of the render size
  101224. */
  101225. getRenderWidth(): number;
  101226. /**
  101227. * Gets the actual render height of the texture.
  101228. * @returns the height of the render size
  101229. */
  101230. getRenderHeight(): number;
  101231. /**
  101232. * Gets the actual number of layers of the texture.
  101233. * @returns the number of layers
  101234. */
  101235. getRenderLayers(): number;
  101236. /**
  101237. * Get if the texture can be rescaled or not.
  101238. */
  101239. get canRescale(): boolean;
  101240. /**
  101241. * Resize the texture using a ratio.
  101242. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101243. */
  101244. scale(ratio: number): void;
  101245. /**
  101246. * Get the texture reflection matrix used to rotate/transform the reflection.
  101247. * @returns the reflection matrix
  101248. */
  101249. getReflectionTextureMatrix(): Matrix;
  101250. /**
  101251. * Resize the texture to a new desired size.
  101252. * Be carrefull as it will recreate all the data in the new texture.
  101253. * @param size Define the new size. It can be:
  101254. * - a number for squared texture,
  101255. * - an object containing { width: number, height: number }
  101256. * - or an object containing a ratio { ratio: number }
  101257. */
  101258. resize(size: number | {
  101259. width: number;
  101260. height: number;
  101261. } | {
  101262. ratio: number;
  101263. }): void;
  101264. private _defaultRenderListPrepared;
  101265. /**
  101266. * Renders all the objects from the render list into the texture.
  101267. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101268. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101269. */
  101270. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101271. private _bestReflectionRenderTargetDimension;
  101272. private _prepareRenderingManager;
  101273. /**
  101274. * @hidden
  101275. * @param faceIndex face index to bind to if this is a cubetexture
  101276. * @param layer defines the index of the texture to bind in the array
  101277. */
  101278. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101279. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101280. private renderToTarget;
  101281. /**
  101282. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101283. * This allowed control for front to back rendering or reversly depending of the special needs.
  101284. *
  101285. * @param renderingGroupId The rendering group id corresponding to its index
  101286. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101287. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101288. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101289. */
  101290. 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;
  101291. /**
  101292. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101293. *
  101294. * @param renderingGroupId The rendering group id corresponding to its index
  101295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101296. */
  101297. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101298. /**
  101299. * Clones the texture.
  101300. * @returns the cloned texture
  101301. */
  101302. clone(): RenderTargetTexture;
  101303. /**
  101304. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101305. * @returns The JSON representation of the texture
  101306. */
  101307. serialize(): any;
  101308. /**
  101309. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101310. */
  101311. disposeFramebufferObjects(): void;
  101312. /**
  101313. * Dispose the texture and release its associated resources.
  101314. */
  101315. dispose(): void;
  101316. /** @hidden */
  101317. _rebuild(): void;
  101318. /**
  101319. * Clear the info related to rendering groups preventing retention point in material dispose.
  101320. */
  101321. freeRenderingGroups(): void;
  101322. /**
  101323. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101324. * @returns the view count
  101325. */
  101326. getViewCount(): number;
  101327. }
  101328. }
  101329. declare module BABYLON {
  101330. /**
  101331. * Class used to manipulate GUIDs
  101332. */
  101333. export class GUID {
  101334. /**
  101335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101336. * Be aware Math.random() could cause collisions, but:
  101337. * "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"
  101338. * @returns a pseudo random id
  101339. */
  101340. static RandomId(): string;
  101341. }
  101342. }
  101343. declare module BABYLON {
  101344. /**
  101345. * Options to be used when creating a shadow depth material
  101346. */
  101347. export interface IIOptionShadowDepthMaterial {
  101348. /** Variables in the vertex shader code that need to have their names remapped.
  101349. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101350. * "var_name" should be either: worldPos or vNormalW
  101351. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101352. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101353. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101354. */
  101355. remappedVariables?: string[];
  101356. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101357. standalone?: boolean;
  101358. }
  101359. /**
  101360. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101361. */
  101362. export class ShadowDepthWrapper {
  101363. private _scene;
  101364. private _options?;
  101365. private _baseMaterial;
  101366. private _onEffectCreatedObserver;
  101367. private _subMeshToEffect;
  101368. private _subMeshToDepthEffect;
  101369. private _meshes;
  101370. /** @hidden */
  101371. _matriceNames: any;
  101372. /** Gets the standalone status of the wrapper */
  101373. get standalone(): boolean;
  101374. /** Gets the base material the wrapper is built upon */
  101375. get baseMaterial(): Material;
  101376. /**
  101377. * Instantiate a new shadow depth wrapper.
  101378. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101379. * generate the shadow depth map. For more information, please refer to the documentation:
  101380. * https://doc.babylonjs.com/babylon101/shadows
  101381. * @param baseMaterial Material to wrap
  101382. * @param scene Define the scene the material belongs to
  101383. * @param options Options used to create the wrapper
  101384. */
  101385. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101386. /**
  101387. * Gets the effect to use to generate the depth map
  101388. * @param subMesh subMesh to get the effect for
  101389. * @param shadowGenerator shadow generator to get the effect for
  101390. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101391. */
  101392. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101393. /**
  101394. * Specifies that the submesh is ready to be used for depth rendering
  101395. * @param subMesh submesh to check
  101396. * @param defines the list of defines to take into account when checking the effect
  101397. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101398. * @param useInstances specifies that instances should be used
  101399. * @returns a boolean indicating that the submesh is ready or not
  101400. */
  101401. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101402. /**
  101403. * Disposes the resources
  101404. */
  101405. dispose(): void;
  101406. private _makeEffect;
  101407. }
  101408. }
  101409. declare module BABYLON {
  101410. /**
  101411. * Options for compiling materials.
  101412. */
  101413. export interface IMaterialCompilationOptions {
  101414. /**
  101415. * Defines whether clip planes are enabled.
  101416. */
  101417. clipPlane: boolean;
  101418. /**
  101419. * Defines whether instances are enabled.
  101420. */
  101421. useInstances: boolean;
  101422. }
  101423. /**
  101424. * Options passed when calling customShaderNameResolve
  101425. */
  101426. export interface ICustomShaderNameResolveOptions {
  101427. /**
  101428. * 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
  101429. */
  101430. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101431. }
  101432. /**
  101433. * Base class for the main features of a material in Babylon.js
  101434. */
  101435. export class Material implements IAnimatable {
  101436. /**
  101437. * Returns the triangle fill mode
  101438. */
  101439. static readonly TriangleFillMode: number;
  101440. /**
  101441. * Returns the wireframe mode
  101442. */
  101443. static readonly WireFrameFillMode: number;
  101444. /**
  101445. * Returns the point fill mode
  101446. */
  101447. static readonly PointFillMode: number;
  101448. /**
  101449. * Returns the point list draw mode
  101450. */
  101451. static readonly PointListDrawMode: number;
  101452. /**
  101453. * Returns the line list draw mode
  101454. */
  101455. static readonly LineListDrawMode: number;
  101456. /**
  101457. * Returns the line loop draw mode
  101458. */
  101459. static readonly LineLoopDrawMode: number;
  101460. /**
  101461. * Returns the line strip draw mode
  101462. */
  101463. static readonly LineStripDrawMode: number;
  101464. /**
  101465. * Returns the triangle strip draw mode
  101466. */
  101467. static readonly TriangleStripDrawMode: number;
  101468. /**
  101469. * Returns the triangle fan draw mode
  101470. */
  101471. static readonly TriangleFanDrawMode: number;
  101472. /**
  101473. * Stores the clock-wise side orientation
  101474. */
  101475. static readonly ClockWiseSideOrientation: number;
  101476. /**
  101477. * Stores the counter clock-wise side orientation
  101478. */
  101479. static readonly CounterClockWiseSideOrientation: number;
  101480. /**
  101481. * The dirty texture flag value
  101482. */
  101483. static readonly TextureDirtyFlag: number;
  101484. /**
  101485. * The dirty light flag value
  101486. */
  101487. static readonly LightDirtyFlag: number;
  101488. /**
  101489. * The dirty fresnel flag value
  101490. */
  101491. static readonly FresnelDirtyFlag: number;
  101492. /**
  101493. * The dirty attribute flag value
  101494. */
  101495. static readonly AttributesDirtyFlag: number;
  101496. /**
  101497. * The dirty misc flag value
  101498. */
  101499. static readonly MiscDirtyFlag: number;
  101500. /**
  101501. * The all dirty flag value
  101502. */
  101503. static readonly AllDirtyFlag: number;
  101504. /**
  101505. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101506. */
  101507. static readonly MATERIAL_OPAQUE: number;
  101508. /**
  101509. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101510. */
  101511. static readonly MATERIAL_ALPHATEST: number;
  101512. /**
  101513. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101514. */
  101515. static readonly MATERIAL_ALPHABLEND: number;
  101516. /**
  101517. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101518. * They are also discarded below the alpha cutoff threshold to improve performances.
  101519. */
  101520. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101521. /**
  101522. * The Whiteout method is used to blend normals.
  101523. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101524. */
  101525. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101526. /**
  101527. * The Reoriented Normal Mapping method is used to blend normals.
  101528. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101529. */
  101530. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101531. /**
  101532. * Custom callback helping to override the default shader used in the material.
  101533. */
  101534. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101535. /**
  101536. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101537. */
  101538. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101539. /**
  101540. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101541. * This means that the material can keep using a previous shader while a new one is being compiled.
  101542. * This is mostly used when shader parallel compilation is supported (true by default)
  101543. */
  101544. allowShaderHotSwapping: boolean;
  101545. /**
  101546. * The ID of the material
  101547. */
  101548. id: string;
  101549. /**
  101550. * Gets or sets the unique id of the material
  101551. */
  101552. uniqueId: number;
  101553. /**
  101554. * The name of the material
  101555. */
  101556. name: string;
  101557. /**
  101558. * Gets or sets user defined metadata
  101559. */
  101560. metadata: any;
  101561. /**
  101562. * For internal use only. Please do not use.
  101563. */
  101564. reservedDataStore: any;
  101565. /**
  101566. * Specifies if the ready state should be checked on each call
  101567. */
  101568. checkReadyOnEveryCall: boolean;
  101569. /**
  101570. * Specifies if the ready state should be checked once
  101571. */
  101572. checkReadyOnlyOnce: boolean;
  101573. /**
  101574. * The state of the material
  101575. */
  101576. state: string;
  101577. /**
  101578. * The alpha value of the material
  101579. */
  101580. protected _alpha: number;
  101581. /**
  101582. * List of inspectable custom properties (used by the Inspector)
  101583. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101584. */
  101585. inspectableCustomProperties: IInspectable[];
  101586. /**
  101587. * Sets the alpha value of the material
  101588. */
  101589. set alpha(value: number);
  101590. /**
  101591. * Gets the alpha value of the material
  101592. */
  101593. get alpha(): number;
  101594. /**
  101595. * Specifies if back face culling is enabled
  101596. */
  101597. protected _backFaceCulling: boolean;
  101598. /**
  101599. * Sets the back-face culling state
  101600. */
  101601. set backFaceCulling(value: boolean);
  101602. /**
  101603. * Gets the back-face culling state
  101604. */
  101605. get backFaceCulling(): boolean;
  101606. /**
  101607. * Stores the value for side orientation
  101608. */
  101609. sideOrientation: number;
  101610. /**
  101611. * Callback triggered when the material is compiled
  101612. */
  101613. onCompiled: Nullable<(effect: Effect) => void>;
  101614. /**
  101615. * Callback triggered when an error occurs
  101616. */
  101617. onError: Nullable<(effect: Effect, errors: string) => void>;
  101618. /**
  101619. * Callback triggered to get the render target textures
  101620. */
  101621. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101622. /**
  101623. * Gets a boolean indicating that current material needs to register RTT
  101624. */
  101625. get hasRenderTargetTextures(): boolean;
  101626. /**
  101627. * Specifies if the material should be serialized
  101628. */
  101629. doNotSerialize: boolean;
  101630. /**
  101631. * @hidden
  101632. */
  101633. _storeEffectOnSubMeshes: boolean;
  101634. /**
  101635. * Stores the animations for the material
  101636. */
  101637. animations: Nullable<Array<Animation>>;
  101638. /**
  101639. * An event triggered when the material is disposed
  101640. */
  101641. onDisposeObservable: Observable<Material>;
  101642. /**
  101643. * An observer which watches for dispose events
  101644. */
  101645. private _onDisposeObserver;
  101646. private _onUnBindObservable;
  101647. /**
  101648. * Called during a dispose event
  101649. */
  101650. set onDispose(callback: () => void);
  101651. private _onBindObservable;
  101652. /**
  101653. * An event triggered when the material is bound
  101654. */
  101655. get onBindObservable(): Observable<AbstractMesh>;
  101656. /**
  101657. * An observer which watches for bind events
  101658. */
  101659. private _onBindObserver;
  101660. /**
  101661. * Called during a bind event
  101662. */
  101663. set onBind(callback: (Mesh: AbstractMesh) => void);
  101664. /**
  101665. * An event triggered when the material is unbound
  101666. */
  101667. get onUnBindObservable(): Observable<Material>;
  101668. protected _onEffectCreatedObservable: Nullable<Observable<{
  101669. effect: Effect;
  101670. subMesh: Nullable<SubMesh>;
  101671. }>>;
  101672. /**
  101673. * An event triggered when the effect is (re)created
  101674. */
  101675. get onEffectCreatedObservable(): Observable<{
  101676. effect: Effect;
  101677. subMesh: Nullable<SubMesh>;
  101678. }>;
  101679. /**
  101680. * Stores the value of the alpha mode
  101681. */
  101682. private _alphaMode;
  101683. /**
  101684. * Sets the value of the alpha mode.
  101685. *
  101686. * | Value | Type | Description |
  101687. * | --- | --- | --- |
  101688. * | 0 | ALPHA_DISABLE | |
  101689. * | 1 | ALPHA_ADD | |
  101690. * | 2 | ALPHA_COMBINE | |
  101691. * | 3 | ALPHA_SUBTRACT | |
  101692. * | 4 | ALPHA_MULTIPLY | |
  101693. * | 5 | ALPHA_MAXIMIZED | |
  101694. * | 6 | ALPHA_ONEONE | |
  101695. * | 7 | ALPHA_PREMULTIPLIED | |
  101696. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101697. * | 9 | ALPHA_INTERPOLATE | |
  101698. * | 10 | ALPHA_SCREENMODE | |
  101699. *
  101700. */
  101701. set alphaMode(value: number);
  101702. /**
  101703. * Gets the value of the alpha mode
  101704. */
  101705. get alphaMode(): number;
  101706. /**
  101707. * Stores the state of the need depth pre-pass value
  101708. */
  101709. private _needDepthPrePass;
  101710. /**
  101711. * Sets the need depth pre-pass value
  101712. */
  101713. set needDepthPrePass(value: boolean);
  101714. /**
  101715. * Gets the depth pre-pass value
  101716. */
  101717. get needDepthPrePass(): boolean;
  101718. /**
  101719. * Specifies if depth writing should be disabled
  101720. */
  101721. disableDepthWrite: boolean;
  101722. /**
  101723. * Specifies if color writing should be disabled
  101724. */
  101725. disableColorWrite: boolean;
  101726. /**
  101727. * Specifies if depth writing should be forced
  101728. */
  101729. forceDepthWrite: boolean;
  101730. /**
  101731. * Specifies the depth function that should be used. 0 means the default engine function
  101732. */
  101733. depthFunction: number;
  101734. /**
  101735. * Specifies if there should be a separate pass for culling
  101736. */
  101737. separateCullingPass: boolean;
  101738. /**
  101739. * Stores the state specifing if fog should be enabled
  101740. */
  101741. private _fogEnabled;
  101742. /**
  101743. * Sets the state for enabling fog
  101744. */
  101745. set fogEnabled(value: boolean);
  101746. /**
  101747. * Gets the value of the fog enabled state
  101748. */
  101749. get fogEnabled(): boolean;
  101750. /**
  101751. * Stores the size of points
  101752. */
  101753. pointSize: number;
  101754. /**
  101755. * Stores the z offset value
  101756. */
  101757. zOffset: number;
  101758. get wireframe(): boolean;
  101759. /**
  101760. * Sets the state of wireframe mode
  101761. */
  101762. set wireframe(value: boolean);
  101763. /**
  101764. * Gets the value specifying if point clouds are enabled
  101765. */
  101766. get pointsCloud(): boolean;
  101767. /**
  101768. * Sets the state of point cloud mode
  101769. */
  101770. set pointsCloud(value: boolean);
  101771. /**
  101772. * Gets the material fill mode
  101773. */
  101774. get fillMode(): number;
  101775. /**
  101776. * Sets the material fill mode
  101777. */
  101778. set fillMode(value: number);
  101779. /**
  101780. * @hidden
  101781. * Stores the effects for the material
  101782. */
  101783. _effect: Nullable<Effect>;
  101784. /**
  101785. * Specifies if uniform buffers should be used
  101786. */
  101787. private _useUBO;
  101788. /**
  101789. * Stores a reference to the scene
  101790. */
  101791. private _scene;
  101792. /**
  101793. * Stores the fill mode state
  101794. */
  101795. private _fillMode;
  101796. /**
  101797. * Specifies if the depth write state should be cached
  101798. */
  101799. private _cachedDepthWriteState;
  101800. /**
  101801. * Specifies if the color write state should be cached
  101802. */
  101803. private _cachedColorWriteState;
  101804. /**
  101805. * Specifies if the depth function state should be cached
  101806. */
  101807. private _cachedDepthFunctionState;
  101808. /**
  101809. * Stores the uniform buffer
  101810. */
  101811. protected _uniformBuffer: UniformBuffer;
  101812. /** @hidden */
  101813. _indexInSceneMaterialArray: number;
  101814. /** @hidden */
  101815. meshMap: Nullable<{
  101816. [id: string]: AbstractMesh | undefined;
  101817. }>;
  101818. /**
  101819. * Creates a material instance
  101820. * @param name defines the name of the material
  101821. * @param scene defines the scene to reference
  101822. * @param doNotAdd specifies if the material should be added to the scene
  101823. */
  101824. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101825. /**
  101826. * Returns a string representation of the current material
  101827. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101828. * @returns a string with material information
  101829. */
  101830. toString(fullDetails?: boolean): string;
  101831. /**
  101832. * Gets the class name of the material
  101833. * @returns a string with the class name of the material
  101834. */
  101835. getClassName(): string;
  101836. /**
  101837. * Specifies if updates for the material been locked
  101838. */
  101839. get isFrozen(): boolean;
  101840. /**
  101841. * Locks updates for the material
  101842. */
  101843. freeze(): void;
  101844. /**
  101845. * Unlocks updates for the material
  101846. */
  101847. unfreeze(): void;
  101848. /**
  101849. * Specifies if the material is ready to be used
  101850. * @param mesh defines the mesh to check
  101851. * @param useInstances specifies if instances should be used
  101852. * @returns a boolean indicating if the material is ready to be used
  101853. */
  101854. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101855. /**
  101856. * Specifies that the submesh is ready to be used
  101857. * @param mesh defines the mesh to check
  101858. * @param subMesh defines which submesh to check
  101859. * @param useInstances specifies that instances should be used
  101860. * @returns a boolean indicating that the submesh is ready or not
  101861. */
  101862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101863. /**
  101864. * Returns the material effect
  101865. * @returns the effect associated with the material
  101866. */
  101867. getEffect(): Nullable<Effect>;
  101868. /**
  101869. * Returns the current scene
  101870. * @returns a Scene
  101871. */
  101872. getScene(): Scene;
  101873. /**
  101874. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101875. */
  101876. protected _forceAlphaTest: boolean;
  101877. /**
  101878. * The transparency mode of the material.
  101879. */
  101880. protected _transparencyMode: Nullable<number>;
  101881. /**
  101882. * Gets the current transparency mode.
  101883. */
  101884. get transparencyMode(): Nullable<number>;
  101885. /**
  101886. * Sets the transparency mode of the material.
  101887. *
  101888. * | Value | Type | Description |
  101889. * | ----- | ----------------------------------- | ----------- |
  101890. * | 0 | OPAQUE | |
  101891. * | 1 | ALPHATEST | |
  101892. * | 2 | ALPHABLEND | |
  101893. * | 3 | ALPHATESTANDBLEND | |
  101894. *
  101895. */
  101896. set transparencyMode(value: Nullable<number>);
  101897. /**
  101898. * Returns true if alpha blending should be disabled.
  101899. */
  101900. protected get _disableAlphaBlending(): boolean;
  101901. /**
  101902. * Specifies whether or not this material should be rendered in alpha blend mode.
  101903. * @returns a boolean specifying if alpha blending is needed
  101904. */
  101905. needAlphaBlending(): boolean;
  101906. /**
  101907. * Specifies if the mesh will require alpha blending
  101908. * @param mesh defines the mesh to check
  101909. * @returns a boolean specifying if alpha blending is needed for the mesh
  101910. */
  101911. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101912. /**
  101913. * Specifies whether or not this material should be rendered in alpha test mode.
  101914. * @returns a boolean specifying if an alpha test is needed.
  101915. */
  101916. needAlphaTesting(): boolean;
  101917. /**
  101918. * Specifies if material alpha testing should be turned on for the mesh
  101919. * @param mesh defines the mesh to check
  101920. */
  101921. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101922. /**
  101923. * Gets the texture used for the alpha test
  101924. * @returns the texture to use for alpha testing
  101925. */
  101926. getAlphaTestTexture(): Nullable<BaseTexture>;
  101927. /**
  101928. * Marks the material to indicate that it needs to be re-calculated
  101929. */
  101930. markDirty(): void;
  101931. /** @hidden */
  101932. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101933. /**
  101934. * Binds the material to the mesh
  101935. * @param world defines the world transformation matrix
  101936. * @param mesh defines the mesh to bind the material to
  101937. */
  101938. bind(world: Matrix, mesh?: Mesh): void;
  101939. /**
  101940. * Binds the submesh to the material
  101941. * @param world defines the world transformation matrix
  101942. * @param mesh defines the mesh containing the submesh
  101943. * @param subMesh defines the submesh to bind the material to
  101944. */
  101945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101946. /**
  101947. * Binds the world matrix to the material
  101948. * @param world defines the world transformation matrix
  101949. */
  101950. bindOnlyWorldMatrix(world: Matrix): void;
  101951. /**
  101952. * Binds the scene's uniform buffer to the effect.
  101953. * @param effect defines the effect to bind to the scene uniform buffer
  101954. * @param sceneUbo defines the uniform buffer storing scene data
  101955. */
  101956. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101957. /**
  101958. * Binds the view matrix to the effect
  101959. * @param effect defines the effect to bind the view matrix to
  101960. */
  101961. bindView(effect: Effect): void;
  101962. /**
  101963. * Binds the view projection matrix to the effect
  101964. * @param effect defines the effect to bind the view projection matrix to
  101965. */
  101966. bindViewProjection(effect: Effect): void;
  101967. /**
  101968. * Processes to execute after binding the material to a mesh
  101969. * @param mesh defines the rendered mesh
  101970. */
  101971. protected _afterBind(mesh?: Mesh): void;
  101972. /**
  101973. * Unbinds the material from the mesh
  101974. */
  101975. unbind(): void;
  101976. /**
  101977. * Gets the active textures from the material
  101978. * @returns an array of textures
  101979. */
  101980. getActiveTextures(): BaseTexture[];
  101981. /**
  101982. * Specifies if the material uses a texture
  101983. * @param texture defines the texture to check against the material
  101984. * @returns a boolean specifying if the material uses the texture
  101985. */
  101986. hasTexture(texture: BaseTexture): boolean;
  101987. /**
  101988. * Makes a duplicate of the material, and gives it a new name
  101989. * @param name defines the new name for the duplicated material
  101990. * @returns the cloned material
  101991. */
  101992. clone(name: string): Nullable<Material>;
  101993. /**
  101994. * Gets the meshes bound to the material
  101995. * @returns an array of meshes bound to the material
  101996. */
  101997. getBindedMeshes(): AbstractMesh[];
  101998. /**
  101999. * Force shader compilation
  102000. * @param mesh defines the mesh associated with this material
  102001. * @param onCompiled defines a function to execute once the material is compiled
  102002. * @param options defines the options to configure the compilation
  102003. * @param onError defines a function to execute if the material fails compiling
  102004. */
  102005. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102006. /**
  102007. * Force shader compilation
  102008. * @param mesh defines the mesh that will use this material
  102009. * @param options defines additional options for compiling the shaders
  102010. * @returns a promise that resolves when the compilation completes
  102011. */
  102012. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102013. private static readonly _AllDirtyCallBack;
  102014. private static readonly _ImageProcessingDirtyCallBack;
  102015. private static readonly _TextureDirtyCallBack;
  102016. private static readonly _FresnelDirtyCallBack;
  102017. private static readonly _MiscDirtyCallBack;
  102018. private static readonly _LightsDirtyCallBack;
  102019. private static readonly _AttributeDirtyCallBack;
  102020. private static _FresnelAndMiscDirtyCallBack;
  102021. private static _TextureAndMiscDirtyCallBack;
  102022. private static readonly _DirtyCallbackArray;
  102023. private static readonly _RunDirtyCallBacks;
  102024. /**
  102025. * Marks a define in the material to indicate that it needs to be re-computed
  102026. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102027. */
  102028. markAsDirty(flag: number): void;
  102029. /**
  102030. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102031. * @param func defines a function which checks material defines against the submeshes
  102032. */
  102033. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102034. /**
  102035. * Indicates that we need to re-calculated for all submeshes
  102036. */
  102037. protected _markAllSubMeshesAsAllDirty(): void;
  102038. /**
  102039. * Indicates that image processing needs to be re-calculated for all submeshes
  102040. */
  102041. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102042. /**
  102043. * Indicates that textures need to be re-calculated for all submeshes
  102044. */
  102045. protected _markAllSubMeshesAsTexturesDirty(): void;
  102046. /**
  102047. * Indicates that fresnel needs to be re-calculated for all submeshes
  102048. */
  102049. protected _markAllSubMeshesAsFresnelDirty(): void;
  102050. /**
  102051. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102052. */
  102053. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102054. /**
  102055. * Indicates that lights need to be re-calculated for all submeshes
  102056. */
  102057. protected _markAllSubMeshesAsLightsDirty(): void;
  102058. /**
  102059. * Indicates that attributes need to be re-calculated for all submeshes
  102060. */
  102061. protected _markAllSubMeshesAsAttributesDirty(): void;
  102062. /**
  102063. * Indicates that misc needs to be re-calculated for all submeshes
  102064. */
  102065. protected _markAllSubMeshesAsMiscDirty(): void;
  102066. /**
  102067. * Indicates that textures and misc need to be re-calculated for all submeshes
  102068. */
  102069. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102070. /**
  102071. * Disposes the material
  102072. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102073. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102074. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102075. */
  102076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102077. /** @hidden */
  102078. private releaseVertexArrayObject;
  102079. /**
  102080. * Serializes this material
  102081. * @returns the serialized material object
  102082. */
  102083. serialize(): any;
  102084. /**
  102085. * Creates a material from parsed material data
  102086. * @param parsedMaterial defines parsed material data
  102087. * @param scene defines the hosting scene
  102088. * @param rootUrl defines the root URL to use to load textures
  102089. * @returns a new material
  102090. */
  102091. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102092. }
  102093. }
  102094. declare module BABYLON {
  102095. /**
  102096. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102097. * separate meshes. This can be use to improve performances.
  102098. * @see http://doc.babylonjs.com/how_to/multi_materials
  102099. */
  102100. export class MultiMaterial extends Material {
  102101. private _subMaterials;
  102102. /**
  102103. * Gets or Sets the list of Materials used within the multi material.
  102104. * They need to be ordered according to the submeshes order in the associated mesh
  102105. */
  102106. get subMaterials(): Nullable<Material>[];
  102107. set subMaterials(value: Nullable<Material>[]);
  102108. /**
  102109. * Function used to align with Node.getChildren()
  102110. * @returns the list of Materials used within the multi material
  102111. */
  102112. getChildren(): Nullable<Material>[];
  102113. /**
  102114. * Instantiates a new Multi Material
  102115. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102116. * separate meshes. This can be use to improve performances.
  102117. * @see http://doc.babylonjs.com/how_to/multi_materials
  102118. * @param name Define the name in the scene
  102119. * @param scene Define the scene the material belongs to
  102120. */
  102121. constructor(name: string, scene: Scene);
  102122. private _hookArray;
  102123. /**
  102124. * Get one of the submaterial by its index in the submaterials array
  102125. * @param index The index to look the sub material at
  102126. * @returns The Material if the index has been defined
  102127. */
  102128. getSubMaterial(index: number): Nullable<Material>;
  102129. /**
  102130. * Get the list of active textures for the whole sub materials list.
  102131. * @returns All the textures that will be used during the rendering
  102132. */
  102133. getActiveTextures(): BaseTexture[];
  102134. /**
  102135. * Gets the current class name of the material e.g. "MultiMaterial"
  102136. * Mainly use in serialization.
  102137. * @returns the class name
  102138. */
  102139. getClassName(): string;
  102140. /**
  102141. * Checks if the material is ready to render the requested sub mesh
  102142. * @param mesh Define the mesh the submesh belongs to
  102143. * @param subMesh Define the sub mesh to look readyness for
  102144. * @param useInstances Define whether or not the material is used with instances
  102145. * @returns true if ready, otherwise false
  102146. */
  102147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102148. /**
  102149. * Clones the current material and its related sub materials
  102150. * @param name Define the name of the newly cloned material
  102151. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102152. * @returns the cloned material
  102153. */
  102154. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102155. /**
  102156. * Serializes the materials into a JSON representation.
  102157. * @returns the JSON representation
  102158. */
  102159. serialize(): any;
  102160. /**
  102161. * Dispose the material and release its associated resources
  102162. * @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)
  102163. * @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)
  102164. * @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)
  102165. */
  102166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102167. /**
  102168. * Creates a MultiMaterial from parsed MultiMaterial data.
  102169. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102170. * @param scene defines the hosting scene
  102171. * @returns a new MultiMaterial
  102172. */
  102173. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102174. }
  102175. }
  102176. declare module BABYLON {
  102177. /**
  102178. * Defines a subdivision inside a mesh
  102179. */
  102180. export class SubMesh implements ICullable {
  102181. /** the material index to use */
  102182. materialIndex: number;
  102183. /** vertex index start */
  102184. verticesStart: number;
  102185. /** vertices count */
  102186. verticesCount: number;
  102187. /** index start */
  102188. indexStart: number;
  102189. /** indices count */
  102190. indexCount: number;
  102191. /** @hidden */
  102192. _materialDefines: Nullable<MaterialDefines>;
  102193. /** @hidden */
  102194. _materialEffect: Nullable<Effect>;
  102195. /** @hidden */
  102196. _effectOverride: Nullable<Effect>;
  102197. /**
  102198. * Gets material defines used by the effect associated to the sub mesh
  102199. */
  102200. get materialDefines(): Nullable<MaterialDefines>;
  102201. /**
  102202. * Sets material defines used by the effect associated to the sub mesh
  102203. */
  102204. set materialDefines(defines: Nullable<MaterialDefines>);
  102205. /**
  102206. * Gets associated effect
  102207. */
  102208. get effect(): Nullable<Effect>;
  102209. /**
  102210. * Sets associated effect (effect used to render this submesh)
  102211. * @param effect defines the effect to associate with
  102212. * @param defines defines the set of defines used to compile this effect
  102213. */
  102214. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102215. /** @hidden */
  102216. _linesIndexCount: number;
  102217. private _mesh;
  102218. private _renderingMesh;
  102219. private _boundingInfo;
  102220. private _linesIndexBuffer;
  102221. /** @hidden */
  102222. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102223. /** @hidden */
  102224. _trianglePlanes: Plane[];
  102225. /** @hidden */
  102226. _lastColliderTransformMatrix: Nullable<Matrix>;
  102227. /** @hidden */
  102228. _renderId: number;
  102229. /** @hidden */
  102230. _alphaIndex: number;
  102231. /** @hidden */
  102232. _distanceToCamera: number;
  102233. /** @hidden */
  102234. _id: number;
  102235. private _currentMaterial;
  102236. /**
  102237. * Add a new submesh to a mesh
  102238. * @param materialIndex defines the material index to use
  102239. * @param verticesStart defines vertex index start
  102240. * @param verticesCount defines vertices count
  102241. * @param indexStart defines index start
  102242. * @param indexCount defines indices count
  102243. * @param mesh defines the parent mesh
  102244. * @param renderingMesh defines an optional rendering mesh
  102245. * @param createBoundingBox defines if bounding box should be created for this submesh
  102246. * @returns the new submesh
  102247. */
  102248. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102249. /**
  102250. * Creates a new submesh
  102251. * @param materialIndex defines the material index to use
  102252. * @param verticesStart defines vertex index start
  102253. * @param verticesCount defines vertices count
  102254. * @param indexStart defines index start
  102255. * @param indexCount defines indices count
  102256. * @param mesh defines the parent mesh
  102257. * @param renderingMesh defines an optional rendering mesh
  102258. * @param createBoundingBox defines if bounding box should be created for this submesh
  102259. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102260. */
  102261. constructor(
  102262. /** the material index to use */
  102263. materialIndex: number,
  102264. /** vertex index start */
  102265. verticesStart: number,
  102266. /** vertices count */
  102267. verticesCount: number,
  102268. /** index start */
  102269. indexStart: number,
  102270. /** indices count */
  102271. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102272. /**
  102273. * Returns true if this submesh covers the entire parent mesh
  102274. * @ignorenaming
  102275. */
  102276. get IsGlobal(): boolean;
  102277. /**
  102278. * Returns the submesh BoudingInfo object
  102279. * @returns current bounding info (or mesh's one if the submesh is global)
  102280. */
  102281. getBoundingInfo(): BoundingInfo;
  102282. /**
  102283. * Sets the submesh BoundingInfo
  102284. * @param boundingInfo defines the new bounding info to use
  102285. * @returns the SubMesh
  102286. */
  102287. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102288. /**
  102289. * Returns the mesh of the current submesh
  102290. * @return the parent mesh
  102291. */
  102292. getMesh(): AbstractMesh;
  102293. /**
  102294. * Returns the rendering mesh of the submesh
  102295. * @returns the rendering mesh (could be different from parent mesh)
  102296. */
  102297. getRenderingMesh(): Mesh;
  102298. /**
  102299. * Returns the replacement mesh of the submesh
  102300. * @returns the replacement mesh (could be different from parent mesh)
  102301. */
  102302. getReplacementMesh(): Nullable<AbstractMesh>;
  102303. /**
  102304. * Returns the effective mesh of the submesh
  102305. * @returns the effective mesh (could be different from parent mesh)
  102306. */
  102307. getEffectiveMesh(): AbstractMesh;
  102308. /**
  102309. * Returns the submesh material
  102310. * @returns null or the current material
  102311. */
  102312. getMaterial(): Nullable<Material>;
  102313. private _IsMultiMaterial;
  102314. /**
  102315. * Sets a new updated BoundingInfo object to the submesh
  102316. * @param data defines an optional position array to use to determine the bounding info
  102317. * @returns the SubMesh
  102318. */
  102319. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102320. /** @hidden */
  102321. _checkCollision(collider: Collider): boolean;
  102322. /**
  102323. * Updates the submesh BoundingInfo
  102324. * @param world defines the world matrix to use to update the bounding info
  102325. * @returns the submesh
  102326. */
  102327. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102328. /**
  102329. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102330. * @param frustumPlanes defines the frustum planes
  102331. * @returns true if the submesh is intersecting with the frustum
  102332. */
  102333. isInFrustum(frustumPlanes: Plane[]): boolean;
  102334. /**
  102335. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102336. * @param frustumPlanes defines the frustum planes
  102337. * @returns true if the submesh is inside the frustum
  102338. */
  102339. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102340. /**
  102341. * Renders the submesh
  102342. * @param enableAlphaMode defines if alpha needs to be used
  102343. * @returns the submesh
  102344. */
  102345. render(enableAlphaMode: boolean): SubMesh;
  102346. /**
  102347. * @hidden
  102348. */
  102349. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102350. /**
  102351. * Checks if the submesh intersects with a ray
  102352. * @param ray defines the ray to test
  102353. * @returns true is the passed ray intersects the submesh bounding box
  102354. */
  102355. canIntersects(ray: Ray): boolean;
  102356. /**
  102357. * Intersects current submesh with a ray
  102358. * @param ray defines the ray to test
  102359. * @param positions defines mesh's positions array
  102360. * @param indices defines mesh's indices array
  102361. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102362. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102363. * @returns intersection info or null if no intersection
  102364. */
  102365. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102366. /** @hidden */
  102367. private _intersectLines;
  102368. /** @hidden */
  102369. private _intersectUnIndexedLines;
  102370. /** @hidden */
  102371. private _intersectTriangles;
  102372. /** @hidden */
  102373. private _intersectUnIndexedTriangles;
  102374. /** @hidden */
  102375. _rebuild(): void;
  102376. /**
  102377. * Creates a new submesh from the passed mesh
  102378. * @param newMesh defines the new hosting mesh
  102379. * @param newRenderingMesh defines an optional rendering mesh
  102380. * @returns the new submesh
  102381. */
  102382. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102383. /**
  102384. * Release associated resources
  102385. */
  102386. dispose(): void;
  102387. /**
  102388. * Gets the class name
  102389. * @returns the string "SubMesh".
  102390. */
  102391. getClassName(): string;
  102392. /**
  102393. * Creates a new submesh from indices data
  102394. * @param materialIndex the index of the main mesh material
  102395. * @param startIndex the index where to start the copy in the mesh indices array
  102396. * @param indexCount the number of indices to copy then from the startIndex
  102397. * @param mesh the main mesh to create the submesh from
  102398. * @param renderingMesh the optional rendering mesh
  102399. * @returns a new submesh
  102400. */
  102401. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102402. }
  102403. }
  102404. declare module BABYLON {
  102405. /**
  102406. * Class used to represent data loading progression
  102407. */
  102408. export class SceneLoaderFlags {
  102409. private static _ForceFullSceneLoadingForIncremental;
  102410. private static _ShowLoadingScreen;
  102411. private static _CleanBoneMatrixWeights;
  102412. private static _loggingLevel;
  102413. /**
  102414. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102415. */
  102416. static get ForceFullSceneLoadingForIncremental(): boolean;
  102417. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102418. /**
  102419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102420. */
  102421. static get ShowLoadingScreen(): boolean;
  102422. static set ShowLoadingScreen(value: boolean);
  102423. /**
  102424. * Defines the current logging level (while loading the scene)
  102425. * @ignorenaming
  102426. */
  102427. static get loggingLevel(): number;
  102428. static set loggingLevel(value: number);
  102429. /**
  102430. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102431. */
  102432. static get CleanBoneMatrixWeights(): boolean;
  102433. static set CleanBoneMatrixWeights(value: boolean);
  102434. }
  102435. }
  102436. declare module BABYLON {
  102437. /**
  102438. * Class used to store geometry data (vertex buffers + index buffer)
  102439. */
  102440. export class Geometry implements IGetSetVerticesData {
  102441. /**
  102442. * Gets or sets the ID of the geometry
  102443. */
  102444. id: string;
  102445. /**
  102446. * Gets or sets the unique ID of the geometry
  102447. */
  102448. uniqueId: number;
  102449. /**
  102450. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102451. */
  102452. delayLoadState: number;
  102453. /**
  102454. * Gets the file containing the data to load when running in delay load state
  102455. */
  102456. delayLoadingFile: Nullable<string>;
  102457. /**
  102458. * Callback called when the geometry is updated
  102459. */
  102460. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102461. private _scene;
  102462. private _engine;
  102463. private _meshes;
  102464. private _totalVertices;
  102465. /** @hidden */
  102466. _indices: IndicesArray;
  102467. /** @hidden */
  102468. _vertexBuffers: {
  102469. [key: string]: VertexBuffer;
  102470. };
  102471. private _isDisposed;
  102472. private _extend;
  102473. private _boundingBias;
  102474. /** @hidden */
  102475. _delayInfo: Array<string>;
  102476. private _indexBuffer;
  102477. private _indexBufferIsUpdatable;
  102478. /** @hidden */
  102479. _boundingInfo: Nullable<BoundingInfo>;
  102480. /** @hidden */
  102481. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102482. /** @hidden */
  102483. _softwareSkinningFrameId: number;
  102484. private _vertexArrayObjects;
  102485. private _updatable;
  102486. /** @hidden */
  102487. _positions: Nullable<Vector3[]>;
  102488. /**
  102489. * 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
  102490. */
  102491. get boundingBias(): Vector2;
  102492. /**
  102493. * 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
  102494. */
  102495. set boundingBias(value: Vector2);
  102496. /**
  102497. * Static function used to attach a new empty geometry to a mesh
  102498. * @param mesh defines the mesh to attach the geometry to
  102499. * @returns the new Geometry
  102500. */
  102501. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102502. /** Get the list of meshes using this geometry */
  102503. get meshes(): Mesh[];
  102504. /**
  102505. * Creates a new geometry
  102506. * @param id defines the unique ID
  102507. * @param scene defines the hosting scene
  102508. * @param vertexData defines the VertexData used to get geometry data
  102509. * @param updatable defines if geometry must be updatable (false by default)
  102510. * @param mesh defines the mesh that will be associated with the geometry
  102511. */
  102512. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102513. /**
  102514. * Gets the current extend of the geometry
  102515. */
  102516. get extend(): {
  102517. minimum: Vector3;
  102518. maximum: Vector3;
  102519. };
  102520. /**
  102521. * Gets the hosting scene
  102522. * @returns the hosting Scene
  102523. */
  102524. getScene(): Scene;
  102525. /**
  102526. * Gets the hosting engine
  102527. * @returns the hosting Engine
  102528. */
  102529. getEngine(): Engine;
  102530. /**
  102531. * Defines if the geometry is ready to use
  102532. * @returns true if the geometry is ready to be used
  102533. */
  102534. isReady(): boolean;
  102535. /**
  102536. * Gets a value indicating that the geometry should not be serialized
  102537. */
  102538. get doNotSerialize(): boolean;
  102539. /** @hidden */
  102540. _rebuild(): void;
  102541. /**
  102542. * Affects all geometry data in one call
  102543. * @param vertexData defines the geometry data
  102544. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102545. */
  102546. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102547. /**
  102548. * Set specific vertex data
  102549. * @param kind defines the data kind (Position, normal, etc...)
  102550. * @param data defines the vertex data to use
  102551. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102552. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102553. */
  102554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102555. /**
  102556. * Removes a specific vertex data
  102557. * @param kind defines the data kind (Position, normal, etc...)
  102558. */
  102559. removeVerticesData(kind: string): void;
  102560. /**
  102561. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102562. * @param buffer defines the vertex buffer to use
  102563. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102564. */
  102565. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102566. /**
  102567. * Update a specific vertex buffer
  102568. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102569. * It will do nothing if the buffer is not updatable
  102570. * @param kind defines the data kind (Position, normal, etc...)
  102571. * @param data defines the data to use
  102572. * @param offset defines the offset in the target buffer where to store the data
  102573. * @param useBytes set to true if the offset is in bytes
  102574. */
  102575. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102576. /**
  102577. * Update a specific vertex buffer
  102578. * This function will create a new buffer if the current one is not updatable
  102579. * @param kind defines the data kind (Position, normal, etc...)
  102580. * @param data defines the data to use
  102581. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102582. */
  102583. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102584. private _updateBoundingInfo;
  102585. /** @hidden */
  102586. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102587. /**
  102588. * Gets total number of vertices
  102589. * @returns the total number of vertices
  102590. */
  102591. getTotalVertices(): number;
  102592. /**
  102593. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102594. * @param kind defines the data kind (Position, normal, etc...)
  102595. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102597. * @returns a float array containing vertex data
  102598. */
  102599. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102600. /**
  102601. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102602. * @param kind defines the data kind (Position, normal, etc...)
  102603. * @returns true if the vertex buffer with the specified kind is updatable
  102604. */
  102605. isVertexBufferUpdatable(kind: string): boolean;
  102606. /**
  102607. * Gets a specific vertex buffer
  102608. * @param kind defines the data kind (Position, normal, etc...)
  102609. * @returns a VertexBuffer
  102610. */
  102611. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102612. /**
  102613. * Returns all vertex buffers
  102614. * @return an object holding all vertex buffers indexed by kind
  102615. */
  102616. getVertexBuffers(): Nullable<{
  102617. [key: string]: VertexBuffer;
  102618. }>;
  102619. /**
  102620. * Gets a boolean indicating if specific vertex buffer is present
  102621. * @param kind defines the data kind (Position, normal, etc...)
  102622. * @returns true if data is present
  102623. */
  102624. isVerticesDataPresent(kind: string): boolean;
  102625. /**
  102626. * Gets a list of all attached data kinds (Position, normal, etc...)
  102627. * @returns a list of string containing all kinds
  102628. */
  102629. getVerticesDataKinds(): string[];
  102630. /**
  102631. * Update index buffer
  102632. * @param indices defines the indices to store in the index buffer
  102633. * @param offset defines the offset in the target buffer where to store the data
  102634. * @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)
  102635. */
  102636. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102637. /**
  102638. * Creates a new index buffer
  102639. * @param indices defines the indices to store in the index buffer
  102640. * @param totalVertices defines the total number of vertices (could be null)
  102641. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102642. */
  102643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102644. /**
  102645. * Return the total number of indices
  102646. * @returns the total number of indices
  102647. */
  102648. getTotalIndices(): number;
  102649. /**
  102650. * Gets the index buffer array
  102651. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102652. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102653. * @returns the index buffer array
  102654. */
  102655. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102656. /**
  102657. * Gets the index buffer
  102658. * @return the index buffer
  102659. */
  102660. getIndexBuffer(): Nullable<DataBuffer>;
  102661. /** @hidden */
  102662. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102663. /**
  102664. * Release the associated resources for a specific mesh
  102665. * @param mesh defines the source mesh
  102666. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102667. */
  102668. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102669. /**
  102670. * Apply current geometry to a given mesh
  102671. * @param mesh defines the mesh to apply geometry to
  102672. */
  102673. applyToMesh(mesh: Mesh): void;
  102674. private _updateExtend;
  102675. private _applyToMesh;
  102676. private notifyUpdate;
  102677. /**
  102678. * Load the geometry if it was flagged as delay loaded
  102679. * @param scene defines the hosting scene
  102680. * @param onLoaded defines a callback called when the geometry is loaded
  102681. */
  102682. load(scene: Scene, onLoaded?: () => void): void;
  102683. private _queueLoad;
  102684. /**
  102685. * Invert the geometry to move from a right handed system to a left handed one.
  102686. */
  102687. toLeftHanded(): void;
  102688. /** @hidden */
  102689. _resetPointsArrayCache(): void;
  102690. /** @hidden */
  102691. _generatePointsArray(): boolean;
  102692. /**
  102693. * Gets a value indicating if the geometry is disposed
  102694. * @returns true if the geometry was disposed
  102695. */
  102696. isDisposed(): boolean;
  102697. private _disposeVertexArrayObjects;
  102698. /**
  102699. * Free all associated resources
  102700. */
  102701. dispose(): void;
  102702. /**
  102703. * Clone the current geometry into a new geometry
  102704. * @param id defines the unique ID of the new geometry
  102705. * @returns a new geometry object
  102706. */
  102707. copy(id: string): Geometry;
  102708. /**
  102709. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102710. * @return a JSON representation of the current geometry data (without the vertices data)
  102711. */
  102712. serialize(): any;
  102713. private toNumberArray;
  102714. /**
  102715. * Serialize all vertices data into a JSON oject
  102716. * @returns a JSON representation of the current geometry data
  102717. */
  102718. serializeVerticeData(): any;
  102719. /**
  102720. * Extracts a clone of a mesh geometry
  102721. * @param mesh defines the source mesh
  102722. * @param id defines the unique ID of the new geometry object
  102723. * @returns the new geometry object
  102724. */
  102725. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102726. /**
  102727. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102729. * Be aware Math.random() could cause collisions, but:
  102730. * "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"
  102731. * @returns a string containing a new GUID
  102732. */
  102733. static RandomId(): string;
  102734. /** @hidden */
  102735. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102736. private static _CleanMatricesWeights;
  102737. /**
  102738. * Create a new geometry from persisted data (Using .babylon file format)
  102739. * @param parsedVertexData defines the persisted data
  102740. * @param scene defines the hosting scene
  102741. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102742. * @returns the new geometry object
  102743. */
  102744. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /**
  102749. * Define an interface for all classes that will get and set the data on vertices
  102750. */
  102751. export interface IGetSetVerticesData {
  102752. /**
  102753. * Gets a boolean indicating if specific vertex data is present
  102754. * @param kind defines the vertex data kind to use
  102755. * @returns true is data kind is present
  102756. */
  102757. isVerticesDataPresent(kind: string): boolean;
  102758. /**
  102759. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102760. * @param kind defines the data kind (Position, normal, etc...)
  102761. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102762. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102763. * @returns a float array containing vertex data
  102764. */
  102765. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102766. /**
  102767. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102768. * @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.
  102769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102770. * @returns the indices array or an empty array if the mesh has no geometry
  102771. */
  102772. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102773. /**
  102774. * Set specific vertex data
  102775. * @param kind defines the data kind (Position, normal, etc...)
  102776. * @param data defines the vertex data to use
  102777. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102778. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102779. */
  102780. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102781. /**
  102782. * Update a specific associated vertex buffer
  102783. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102784. * - VertexBuffer.PositionKind
  102785. * - VertexBuffer.UVKind
  102786. * - VertexBuffer.UV2Kind
  102787. * - VertexBuffer.UV3Kind
  102788. * - VertexBuffer.UV4Kind
  102789. * - VertexBuffer.UV5Kind
  102790. * - VertexBuffer.UV6Kind
  102791. * - VertexBuffer.ColorKind
  102792. * - VertexBuffer.MatricesIndicesKind
  102793. * - VertexBuffer.MatricesIndicesExtraKind
  102794. * - VertexBuffer.MatricesWeightsKind
  102795. * - VertexBuffer.MatricesWeightsExtraKind
  102796. * @param data defines the data source
  102797. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102798. * @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)
  102799. */
  102800. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102801. /**
  102802. * Creates a new index buffer
  102803. * @param indices defines the indices to store in the index buffer
  102804. * @param totalVertices defines the total number of vertices (could be null)
  102805. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102806. */
  102807. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102808. }
  102809. /**
  102810. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102811. */
  102812. export class VertexData {
  102813. /**
  102814. * Mesh side orientation : usually the external or front surface
  102815. */
  102816. static readonly FRONTSIDE: number;
  102817. /**
  102818. * Mesh side orientation : usually the internal or back surface
  102819. */
  102820. static readonly BACKSIDE: number;
  102821. /**
  102822. * Mesh side orientation : both internal and external or front and back surfaces
  102823. */
  102824. static readonly DOUBLESIDE: number;
  102825. /**
  102826. * Mesh side orientation : by default, `FRONTSIDE`
  102827. */
  102828. static readonly DEFAULTSIDE: number;
  102829. /**
  102830. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102831. */
  102832. positions: Nullable<FloatArray>;
  102833. /**
  102834. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102835. */
  102836. normals: Nullable<FloatArray>;
  102837. /**
  102838. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102839. */
  102840. tangents: Nullable<FloatArray>;
  102841. /**
  102842. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102843. */
  102844. uvs: Nullable<FloatArray>;
  102845. /**
  102846. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102847. */
  102848. uvs2: Nullable<FloatArray>;
  102849. /**
  102850. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102851. */
  102852. uvs3: Nullable<FloatArray>;
  102853. /**
  102854. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102855. */
  102856. uvs4: Nullable<FloatArray>;
  102857. /**
  102858. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102859. */
  102860. uvs5: Nullable<FloatArray>;
  102861. /**
  102862. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102863. */
  102864. uvs6: Nullable<FloatArray>;
  102865. /**
  102866. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102867. */
  102868. colors: Nullable<FloatArray>;
  102869. /**
  102870. * 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).
  102871. */
  102872. matricesIndices: Nullable<FloatArray>;
  102873. /**
  102874. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102875. */
  102876. matricesWeights: Nullable<FloatArray>;
  102877. /**
  102878. * An array extending the number of possible indices
  102879. */
  102880. matricesIndicesExtra: Nullable<FloatArray>;
  102881. /**
  102882. * An array extending the number of possible weights when the number of indices is extended
  102883. */
  102884. matricesWeightsExtra: Nullable<FloatArray>;
  102885. /**
  102886. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102887. */
  102888. indices: Nullable<IndicesArray>;
  102889. /**
  102890. * Uses the passed data array to set the set the values for the specified kind of data
  102891. * @param data a linear array of floating numbers
  102892. * @param kind the type of data that is being set, eg positions, colors etc
  102893. */
  102894. set(data: FloatArray, kind: string): void;
  102895. /**
  102896. * Associates the vertexData to the passed Mesh.
  102897. * Sets it as updatable or not (default `false`)
  102898. * @param mesh the mesh the vertexData is applied to
  102899. * @param updatable when used and having the value true allows new data to update the vertexData
  102900. * @returns the VertexData
  102901. */
  102902. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102903. /**
  102904. * Associates the vertexData to the passed Geometry.
  102905. * Sets it as updatable or not (default `false`)
  102906. * @param geometry the geometry the vertexData is applied to
  102907. * @param updatable when used and having the value true allows new data to update the vertexData
  102908. * @returns VertexData
  102909. */
  102910. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102911. /**
  102912. * Updates the associated mesh
  102913. * @param mesh the mesh to be updated
  102914. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102915. * @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
  102916. * @returns VertexData
  102917. */
  102918. updateMesh(mesh: Mesh): VertexData;
  102919. /**
  102920. * Updates the associated geometry
  102921. * @param geometry the geometry to be updated
  102922. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102923. * @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
  102924. * @returns VertexData.
  102925. */
  102926. updateGeometry(geometry: Geometry): VertexData;
  102927. private _applyTo;
  102928. private _update;
  102929. /**
  102930. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102931. * @param matrix the transforming matrix
  102932. * @returns the VertexData
  102933. */
  102934. transform(matrix: Matrix): VertexData;
  102935. /**
  102936. * Merges the passed VertexData into the current one
  102937. * @param other the VertexData to be merged into the current one
  102938. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102939. * @returns the modified VertexData
  102940. */
  102941. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102942. private _mergeElement;
  102943. private _validate;
  102944. /**
  102945. * Serializes the VertexData
  102946. * @returns a serialized object
  102947. */
  102948. serialize(): any;
  102949. /**
  102950. * Extracts the vertexData from a mesh
  102951. * @param mesh the mesh from which to extract the VertexData
  102952. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102953. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102954. * @returns the object VertexData associated to the passed mesh
  102955. */
  102956. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102957. /**
  102958. * Extracts the vertexData from the geometry
  102959. * @param geometry the geometry from which to extract the VertexData
  102960. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102961. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102962. * @returns the object VertexData associated to the passed mesh
  102963. */
  102964. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102965. private static _ExtractFrom;
  102966. /**
  102967. * Creates the VertexData for a Ribbon
  102968. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102969. * * pathArray array of paths, each of which an array of successive Vector3
  102970. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102971. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102972. * * 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
  102973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102974. * * 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)
  102975. * * 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)
  102976. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102977. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102978. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102979. * @returns the VertexData of the ribbon
  102980. */
  102981. static CreateRibbon(options: {
  102982. pathArray: Vector3[][];
  102983. closeArray?: boolean;
  102984. closePath?: boolean;
  102985. offset?: number;
  102986. sideOrientation?: number;
  102987. frontUVs?: Vector4;
  102988. backUVs?: Vector4;
  102989. invertUV?: boolean;
  102990. uvs?: Vector2[];
  102991. colors?: Color4[];
  102992. }): VertexData;
  102993. /**
  102994. * Creates the VertexData for a box
  102995. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102996. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102997. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102998. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102999. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103000. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103001. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103003. * * 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)
  103004. * * 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)
  103005. * @returns the VertexData of the box
  103006. */
  103007. static CreateBox(options: {
  103008. size?: number;
  103009. width?: number;
  103010. height?: number;
  103011. depth?: number;
  103012. faceUV?: Vector4[];
  103013. faceColors?: Color4[];
  103014. sideOrientation?: number;
  103015. frontUVs?: Vector4;
  103016. backUVs?: Vector4;
  103017. }): VertexData;
  103018. /**
  103019. * Creates the VertexData for a tiled box
  103020. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103022. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103023. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103025. * @returns the VertexData of the box
  103026. */
  103027. static CreateTiledBox(options: {
  103028. pattern?: number;
  103029. width?: number;
  103030. height?: number;
  103031. depth?: number;
  103032. tileSize?: number;
  103033. tileWidth?: number;
  103034. tileHeight?: number;
  103035. alignHorizontal?: number;
  103036. alignVertical?: number;
  103037. faceUV?: Vector4[];
  103038. faceColors?: Color4[];
  103039. sideOrientation?: number;
  103040. }): VertexData;
  103041. /**
  103042. * Creates the VertexData for a tiled plane
  103043. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103044. * * pattern a limited pattern arrangement depending on the number
  103045. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103046. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103047. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103049. * * 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)
  103050. * * 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)
  103051. * @returns the VertexData of the tiled plane
  103052. */
  103053. static CreateTiledPlane(options: {
  103054. pattern?: number;
  103055. tileSize?: number;
  103056. tileWidth?: number;
  103057. tileHeight?: number;
  103058. size?: number;
  103059. width?: number;
  103060. height?: number;
  103061. alignHorizontal?: number;
  103062. alignVertical?: number;
  103063. sideOrientation?: number;
  103064. frontUVs?: Vector4;
  103065. backUVs?: Vector4;
  103066. }): VertexData;
  103067. /**
  103068. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103070. * * segments sets the number of horizontal strips optional, default 32
  103071. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103072. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103073. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103074. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103075. * * 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
  103076. * * 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
  103077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103078. * * 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)
  103079. * * 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)
  103080. * @returns the VertexData of the ellipsoid
  103081. */
  103082. static CreateSphere(options: {
  103083. segments?: number;
  103084. diameter?: number;
  103085. diameterX?: number;
  103086. diameterY?: number;
  103087. diameterZ?: number;
  103088. arc?: number;
  103089. slice?: number;
  103090. sideOrientation?: number;
  103091. frontUVs?: Vector4;
  103092. backUVs?: Vector4;
  103093. }): VertexData;
  103094. /**
  103095. * Creates the VertexData for a cylinder, cone or prism
  103096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103097. * * height sets the height (y direction) of the cylinder, optional, default 2
  103098. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103099. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103100. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103101. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103102. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103103. * * 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
  103104. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103105. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103106. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103107. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103109. * * 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)
  103110. * * 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)
  103111. * @returns the VertexData of the cylinder, cone or prism
  103112. */
  103113. static CreateCylinder(options: {
  103114. height?: number;
  103115. diameterTop?: number;
  103116. diameterBottom?: number;
  103117. diameter?: number;
  103118. tessellation?: number;
  103119. subdivisions?: number;
  103120. arc?: number;
  103121. faceColors?: Color4[];
  103122. faceUV?: Vector4[];
  103123. hasRings?: boolean;
  103124. enclose?: boolean;
  103125. sideOrientation?: number;
  103126. frontUVs?: Vector4;
  103127. backUVs?: Vector4;
  103128. }): VertexData;
  103129. /**
  103130. * Creates the VertexData for a torus
  103131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103132. * * diameter the diameter of the torus, optional default 1
  103133. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103134. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103136. * * 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)
  103137. * * 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)
  103138. * @returns the VertexData of the torus
  103139. */
  103140. static CreateTorus(options: {
  103141. diameter?: number;
  103142. thickness?: number;
  103143. tessellation?: number;
  103144. sideOrientation?: number;
  103145. frontUVs?: Vector4;
  103146. backUVs?: Vector4;
  103147. }): VertexData;
  103148. /**
  103149. * Creates the VertexData of the LineSystem
  103150. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103151. * - lines an array of lines, each line being an array of successive Vector3
  103152. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103153. * @returns the VertexData of the LineSystem
  103154. */
  103155. static CreateLineSystem(options: {
  103156. lines: Vector3[][];
  103157. colors?: Nullable<Color4[][]>;
  103158. }): VertexData;
  103159. /**
  103160. * Create the VertexData for a DashedLines
  103161. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103162. * - points an array successive Vector3
  103163. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103164. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103165. * - dashNb the intended total number of dashes, optional, default 200
  103166. * @returns the VertexData for the DashedLines
  103167. */
  103168. static CreateDashedLines(options: {
  103169. points: Vector3[];
  103170. dashSize?: number;
  103171. gapSize?: number;
  103172. dashNb?: number;
  103173. }): VertexData;
  103174. /**
  103175. * Creates the VertexData for a Ground
  103176. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103177. * - width the width (x direction) of the ground, optional, default 1
  103178. * - height the height (z direction) of the ground, optional, default 1
  103179. * - subdivisions the number of subdivisions per side, optional, default 1
  103180. * @returns the VertexData of the Ground
  103181. */
  103182. static CreateGround(options: {
  103183. width?: number;
  103184. height?: number;
  103185. subdivisions?: number;
  103186. subdivisionsX?: number;
  103187. subdivisionsY?: number;
  103188. }): VertexData;
  103189. /**
  103190. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103191. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103192. * * xmin the ground minimum X coordinate, optional, default -1
  103193. * * zmin the ground minimum Z coordinate, optional, default -1
  103194. * * xmax the ground maximum X coordinate, optional, default 1
  103195. * * zmax the ground maximum Z coordinate, optional, default 1
  103196. * * 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}
  103197. * * 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}
  103198. * @returns the VertexData of the TiledGround
  103199. */
  103200. static CreateTiledGround(options: {
  103201. xmin: number;
  103202. zmin: number;
  103203. xmax: number;
  103204. zmax: number;
  103205. subdivisions?: {
  103206. w: number;
  103207. h: number;
  103208. };
  103209. precision?: {
  103210. w: number;
  103211. h: number;
  103212. };
  103213. }): VertexData;
  103214. /**
  103215. * Creates the VertexData of the Ground designed from a heightmap
  103216. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103217. * * width the width (x direction) of the ground
  103218. * * height the height (z direction) of the ground
  103219. * * subdivisions the number of subdivisions per side
  103220. * * minHeight the minimum altitude on the ground, optional, default 0
  103221. * * maxHeight the maximum altitude on the ground, optional default 1
  103222. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103223. * * buffer the array holding the image color data
  103224. * * bufferWidth the width of image
  103225. * * bufferHeight the height of image
  103226. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103227. * @returns the VertexData of the Ground designed from a heightmap
  103228. */
  103229. static CreateGroundFromHeightMap(options: {
  103230. width: number;
  103231. height: number;
  103232. subdivisions: number;
  103233. minHeight: number;
  103234. maxHeight: number;
  103235. colorFilter: Color3;
  103236. buffer: Uint8Array;
  103237. bufferWidth: number;
  103238. bufferHeight: number;
  103239. alphaFilter: number;
  103240. }): VertexData;
  103241. /**
  103242. * Creates the VertexData for a Plane
  103243. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103244. * * size sets the width and height of the plane to the value of size, optional default 1
  103245. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103246. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103248. * * 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)
  103249. * * 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)
  103250. * @returns the VertexData of the box
  103251. */
  103252. static CreatePlane(options: {
  103253. size?: number;
  103254. width?: number;
  103255. height?: number;
  103256. sideOrientation?: number;
  103257. frontUVs?: Vector4;
  103258. backUVs?: Vector4;
  103259. }): VertexData;
  103260. /**
  103261. * Creates the VertexData of the Disc or regular Polygon
  103262. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103263. * * radius the radius of the disc, optional default 0.5
  103264. * * tessellation the number of polygon sides, optional, default 64
  103265. * * 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
  103266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103267. * * 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)
  103268. * * 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)
  103269. * @returns the VertexData of the box
  103270. */
  103271. static CreateDisc(options: {
  103272. radius?: number;
  103273. tessellation?: number;
  103274. arc?: number;
  103275. sideOrientation?: number;
  103276. frontUVs?: Vector4;
  103277. backUVs?: Vector4;
  103278. }): VertexData;
  103279. /**
  103280. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103281. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103282. * @param polygon a mesh built from polygonTriangulation.build()
  103283. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103284. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103285. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103286. * @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)
  103287. * @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)
  103288. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103289. * @returns the VertexData of the Polygon
  103290. */
  103291. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103292. /**
  103293. * Creates the VertexData of the IcoSphere
  103294. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103295. * * radius the radius of the IcoSphere, optional default 1
  103296. * * radiusX allows stretching in the x direction, optional, default radius
  103297. * * radiusY allows stretching in the y direction, optional, default radius
  103298. * * radiusZ allows stretching in the z direction, optional, default radius
  103299. * * flat when true creates a flat shaded mesh, optional, default true
  103300. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103302. * * 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)
  103303. * * 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)
  103304. * @returns the VertexData of the IcoSphere
  103305. */
  103306. static CreateIcoSphere(options: {
  103307. radius?: number;
  103308. radiusX?: number;
  103309. radiusY?: number;
  103310. radiusZ?: number;
  103311. flat?: boolean;
  103312. subdivisions?: number;
  103313. sideOrientation?: number;
  103314. frontUVs?: Vector4;
  103315. backUVs?: Vector4;
  103316. }): VertexData;
  103317. /**
  103318. * Creates the VertexData for a Polyhedron
  103319. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103320. * * type provided types are:
  103321. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103322. * * 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)
  103323. * * size the size of the IcoSphere, optional default 1
  103324. * * sizeX allows stretching in the x direction, optional, default size
  103325. * * sizeY allows stretching in the y direction, optional, default size
  103326. * * sizeZ allows stretching in the z direction, optional, default size
  103327. * * 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
  103328. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103329. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103330. * * flat when true creates a flat shaded mesh, optional, default true
  103331. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103333. * * 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)
  103334. * * 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)
  103335. * @returns the VertexData of the Polyhedron
  103336. */
  103337. static CreatePolyhedron(options: {
  103338. type?: number;
  103339. size?: number;
  103340. sizeX?: number;
  103341. sizeY?: number;
  103342. sizeZ?: number;
  103343. custom?: any;
  103344. faceUV?: Vector4[];
  103345. faceColors?: Color4[];
  103346. flat?: boolean;
  103347. sideOrientation?: number;
  103348. frontUVs?: Vector4;
  103349. backUVs?: Vector4;
  103350. }): VertexData;
  103351. /**
  103352. * Creates the VertexData for a TorusKnot
  103353. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103354. * * radius the radius of the torus knot, optional, default 2
  103355. * * tube the thickness of the tube, optional, default 0.5
  103356. * * radialSegments the number of sides on each tube segments, optional, default 32
  103357. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103358. * * p the number of windings around the z axis, optional, default 2
  103359. * * q the number of windings around the x axis, optional, default 3
  103360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103361. * * 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)
  103362. * * 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)
  103363. * @returns the VertexData of the Torus Knot
  103364. */
  103365. static CreateTorusKnot(options: {
  103366. radius?: number;
  103367. tube?: number;
  103368. radialSegments?: number;
  103369. tubularSegments?: number;
  103370. p?: number;
  103371. q?: number;
  103372. sideOrientation?: number;
  103373. frontUVs?: Vector4;
  103374. backUVs?: Vector4;
  103375. }): VertexData;
  103376. /**
  103377. * Compute normals for given positions and indices
  103378. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103379. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103380. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103381. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103382. * * facetNormals : optional array of facet normals (vector3)
  103383. * * facetPositions : optional array of facet positions (vector3)
  103384. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103385. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103386. * * bInfo : optional bounding info, required for facetPartitioning computation
  103387. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103388. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103389. * * useRightHandedSystem: optional boolean to for right handed system computation
  103390. * * depthSort : optional boolean to enable the facet depth sort computation
  103391. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103392. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103393. */
  103394. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103395. facetNormals?: any;
  103396. facetPositions?: any;
  103397. facetPartitioning?: any;
  103398. ratio?: number;
  103399. bInfo?: any;
  103400. bbSize?: Vector3;
  103401. subDiv?: any;
  103402. useRightHandedSystem?: boolean;
  103403. depthSort?: boolean;
  103404. distanceTo?: Vector3;
  103405. depthSortedFacets?: any;
  103406. }): void;
  103407. /** @hidden */
  103408. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103409. /**
  103410. * Applies VertexData created from the imported parameters to the geometry
  103411. * @param parsedVertexData the parsed data from an imported file
  103412. * @param geometry the geometry to apply the VertexData to
  103413. */
  103414. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103415. }
  103416. }
  103417. declare module BABYLON {
  103418. /**
  103419. * Defines a target to use with MorphTargetManager
  103420. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103421. */
  103422. export class MorphTarget implements IAnimatable {
  103423. /** defines the name of the target */
  103424. name: string;
  103425. /**
  103426. * Gets or sets the list of animations
  103427. */
  103428. animations: Animation[];
  103429. private _scene;
  103430. private _positions;
  103431. private _normals;
  103432. private _tangents;
  103433. private _uvs;
  103434. private _influence;
  103435. private _uniqueId;
  103436. /**
  103437. * Observable raised when the influence changes
  103438. */
  103439. onInfluenceChanged: Observable<boolean>;
  103440. /** @hidden */
  103441. _onDataLayoutChanged: Observable<void>;
  103442. /**
  103443. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103444. */
  103445. get influence(): number;
  103446. set influence(influence: number);
  103447. /**
  103448. * Gets or sets the id of the morph Target
  103449. */
  103450. id: string;
  103451. private _animationPropertiesOverride;
  103452. /**
  103453. * Gets or sets the animation properties override
  103454. */
  103455. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103456. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103457. /**
  103458. * Creates a new MorphTarget
  103459. * @param name defines the name of the target
  103460. * @param influence defines the influence to use
  103461. * @param scene defines the scene the morphtarget belongs to
  103462. */
  103463. constructor(
  103464. /** defines the name of the target */
  103465. name: string, influence?: number, scene?: Nullable<Scene>);
  103466. /**
  103467. * Gets the unique ID of this manager
  103468. */
  103469. get uniqueId(): number;
  103470. /**
  103471. * Gets a boolean defining if the target contains position data
  103472. */
  103473. get hasPositions(): boolean;
  103474. /**
  103475. * Gets a boolean defining if the target contains normal data
  103476. */
  103477. get hasNormals(): boolean;
  103478. /**
  103479. * Gets a boolean defining if the target contains tangent data
  103480. */
  103481. get hasTangents(): boolean;
  103482. /**
  103483. * Gets a boolean defining if the target contains texture coordinates data
  103484. */
  103485. get hasUVs(): boolean;
  103486. /**
  103487. * Affects position data to this target
  103488. * @param data defines the position data to use
  103489. */
  103490. setPositions(data: Nullable<FloatArray>): void;
  103491. /**
  103492. * Gets the position data stored in this target
  103493. * @returns a FloatArray containing the position data (or null if not present)
  103494. */
  103495. getPositions(): Nullable<FloatArray>;
  103496. /**
  103497. * Affects normal data to this target
  103498. * @param data defines the normal data to use
  103499. */
  103500. setNormals(data: Nullable<FloatArray>): void;
  103501. /**
  103502. * Gets the normal data stored in this target
  103503. * @returns a FloatArray containing the normal data (or null if not present)
  103504. */
  103505. getNormals(): Nullable<FloatArray>;
  103506. /**
  103507. * Affects tangent data to this target
  103508. * @param data defines the tangent data to use
  103509. */
  103510. setTangents(data: Nullable<FloatArray>): void;
  103511. /**
  103512. * Gets the tangent data stored in this target
  103513. * @returns a FloatArray containing the tangent data (or null if not present)
  103514. */
  103515. getTangents(): Nullable<FloatArray>;
  103516. /**
  103517. * Affects texture coordinates data to this target
  103518. * @param data defines the texture coordinates data to use
  103519. */
  103520. setUVs(data: Nullable<FloatArray>): void;
  103521. /**
  103522. * Gets the texture coordinates data stored in this target
  103523. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103524. */
  103525. getUVs(): Nullable<FloatArray>;
  103526. /**
  103527. * Clone the current target
  103528. * @returns a new MorphTarget
  103529. */
  103530. clone(): MorphTarget;
  103531. /**
  103532. * Serializes the current target into a Serialization object
  103533. * @returns the serialized object
  103534. */
  103535. serialize(): any;
  103536. /**
  103537. * Returns the string "MorphTarget"
  103538. * @returns "MorphTarget"
  103539. */
  103540. getClassName(): string;
  103541. /**
  103542. * Creates a new target from serialized data
  103543. * @param serializationObject defines the serialized data to use
  103544. * @returns a new MorphTarget
  103545. */
  103546. static Parse(serializationObject: any): MorphTarget;
  103547. /**
  103548. * Creates a MorphTarget from mesh data
  103549. * @param mesh defines the source mesh
  103550. * @param name defines the name to use for the new target
  103551. * @param influence defines the influence to attach to the target
  103552. * @returns a new MorphTarget
  103553. */
  103554. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103555. }
  103556. }
  103557. declare module BABYLON {
  103558. /**
  103559. * This class is used to deform meshes using morphing between different targets
  103560. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103561. */
  103562. export class MorphTargetManager {
  103563. private _targets;
  103564. private _targetInfluenceChangedObservers;
  103565. private _targetDataLayoutChangedObservers;
  103566. private _activeTargets;
  103567. private _scene;
  103568. private _influences;
  103569. private _supportsNormals;
  103570. private _supportsTangents;
  103571. private _supportsUVs;
  103572. private _vertexCount;
  103573. private _uniqueId;
  103574. private _tempInfluences;
  103575. /**
  103576. * Gets or sets a boolean indicating if normals must be morphed
  103577. */
  103578. enableNormalMorphing: boolean;
  103579. /**
  103580. * Gets or sets a boolean indicating if tangents must be morphed
  103581. */
  103582. enableTangentMorphing: boolean;
  103583. /**
  103584. * Gets or sets a boolean indicating if UV must be morphed
  103585. */
  103586. enableUVMorphing: boolean;
  103587. /**
  103588. * Creates a new MorphTargetManager
  103589. * @param scene defines the current scene
  103590. */
  103591. constructor(scene?: Nullable<Scene>);
  103592. /**
  103593. * Gets the unique ID of this manager
  103594. */
  103595. get uniqueId(): number;
  103596. /**
  103597. * Gets the number of vertices handled by this manager
  103598. */
  103599. get vertexCount(): number;
  103600. /**
  103601. * Gets a boolean indicating if this manager supports morphing of normals
  103602. */
  103603. get supportsNormals(): boolean;
  103604. /**
  103605. * Gets a boolean indicating if this manager supports morphing of tangents
  103606. */
  103607. get supportsTangents(): boolean;
  103608. /**
  103609. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103610. */
  103611. get supportsUVs(): boolean;
  103612. /**
  103613. * Gets the number of targets stored in this manager
  103614. */
  103615. get numTargets(): number;
  103616. /**
  103617. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103618. */
  103619. get numInfluencers(): number;
  103620. /**
  103621. * Gets the list of influences (one per target)
  103622. */
  103623. get influences(): Float32Array;
  103624. /**
  103625. * Gets the active target at specified index. An active target is a target with an influence > 0
  103626. * @param index defines the index to check
  103627. * @returns the requested target
  103628. */
  103629. getActiveTarget(index: number): MorphTarget;
  103630. /**
  103631. * Gets the target at specified index
  103632. * @param index defines the index to check
  103633. * @returns the requested target
  103634. */
  103635. getTarget(index: number): MorphTarget;
  103636. /**
  103637. * Add a new target to this manager
  103638. * @param target defines the target to add
  103639. */
  103640. addTarget(target: MorphTarget): void;
  103641. /**
  103642. * Removes a target from the manager
  103643. * @param target defines the target to remove
  103644. */
  103645. removeTarget(target: MorphTarget): void;
  103646. /**
  103647. * Clone the current manager
  103648. * @returns a new MorphTargetManager
  103649. */
  103650. clone(): MorphTargetManager;
  103651. /**
  103652. * Serializes the current manager into a Serialization object
  103653. * @returns the serialized object
  103654. */
  103655. serialize(): any;
  103656. private _syncActiveTargets;
  103657. /**
  103658. * Syncrhonize the targets with all the meshes using this morph target manager
  103659. */
  103660. synchronize(): void;
  103661. /**
  103662. * Creates a new MorphTargetManager from serialized data
  103663. * @param serializationObject defines the serialized data
  103664. * @param scene defines the hosting scene
  103665. * @returns the new MorphTargetManager
  103666. */
  103667. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103668. }
  103669. }
  103670. declare module BABYLON {
  103671. /**
  103672. * Class used to represent a specific level of detail of a mesh
  103673. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103674. */
  103675. export class MeshLODLevel {
  103676. /** Defines the distance where this level should start being displayed */
  103677. distance: number;
  103678. /** Defines the mesh to use to render this level */
  103679. mesh: Nullable<Mesh>;
  103680. /**
  103681. * Creates a new LOD level
  103682. * @param distance defines the distance where this level should star being displayed
  103683. * @param mesh defines the mesh to use to render this level
  103684. */
  103685. constructor(
  103686. /** Defines the distance where this level should start being displayed */
  103687. distance: number,
  103688. /** Defines the mesh to use to render this level */
  103689. mesh: Nullable<Mesh>);
  103690. }
  103691. }
  103692. declare module BABYLON {
  103693. /**
  103694. * Helper class used to generate a canvas to manipulate images
  103695. */
  103696. export class CanvasGenerator {
  103697. /**
  103698. * Create a new canvas (or offscreen canvas depending on the context)
  103699. * @param width defines the expected width
  103700. * @param height defines the expected height
  103701. * @return a new canvas or offscreen canvas
  103702. */
  103703. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  103704. }
  103705. }
  103706. declare module BABYLON {
  103707. /**
  103708. * Mesh representing the gorund
  103709. */
  103710. export class GroundMesh extends Mesh {
  103711. /** If octree should be generated */
  103712. generateOctree: boolean;
  103713. private _heightQuads;
  103714. /** @hidden */
  103715. _subdivisionsX: number;
  103716. /** @hidden */
  103717. _subdivisionsY: number;
  103718. /** @hidden */
  103719. _width: number;
  103720. /** @hidden */
  103721. _height: number;
  103722. /** @hidden */
  103723. _minX: number;
  103724. /** @hidden */
  103725. _maxX: number;
  103726. /** @hidden */
  103727. _minZ: number;
  103728. /** @hidden */
  103729. _maxZ: number;
  103730. constructor(name: string, scene: Scene);
  103731. /**
  103732. * "GroundMesh"
  103733. * @returns "GroundMesh"
  103734. */
  103735. getClassName(): string;
  103736. /**
  103737. * The minimum of x and y subdivisions
  103738. */
  103739. get subdivisions(): number;
  103740. /**
  103741. * X subdivisions
  103742. */
  103743. get subdivisionsX(): number;
  103744. /**
  103745. * Y subdivisions
  103746. */
  103747. get subdivisionsY(): number;
  103748. /**
  103749. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103750. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103751. * @param chunksCount the number of subdivisions for x and y
  103752. * @param octreeBlocksSize (Default: 32)
  103753. */
  103754. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103755. /**
  103756. * Returns a height (y) value in the Worl system :
  103757. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103758. * @param x x coordinate
  103759. * @param z z coordinate
  103760. * @returns the ground y position if (x, z) are outside the ground surface.
  103761. */
  103762. getHeightAtCoordinates(x: number, z: number): number;
  103763. /**
  103764. * Returns a normalized vector (Vector3) orthogonal to the ground
  103765. * at the ground coordinates (x, z) expressed in the World system.
  103766. * @param x x coordinate
  103767. * @param z z coordinate
  103768. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103769. */
  103770. getNormalAtCoordinates(x: number, z: number): Vector3;
  103771. /**
  103772. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103773. * at the ground coordinates (x, z) expressed in the World system.
  103774. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103775. * @param x x coordinate
  103776. * @param z z coordinate
  103777. * @param ref vector to store the result
  103778. * @returns the GroundMesh.
  103779. */
  103780. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103781. /**
  103782. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103783. * if the ground has been updated.
  103784. * This can be used in the render loop.
  103785. * @returns the GroundMesh.
  103786. */
  103787. updateCoordinateHeights(): GroundMesh;
  103788. private _getFacetAt;
  103789. private _initHeightQuads;
  103790. private _computeHeightQuads;
  103791. /**
  103792. * Serializes this ground mesh
  103793. * @param serializationObject object to write serialization to
  103794. */
  103795. serialize(serializationObject: any): void;
  103796. /**
  103797. * Parses a serialized ground mesh
  103798. * @param parsedMesh the serialized mesh
  103799. * @param scene the scene to create the ground mesh in
  103800. * @returns the created ground mesh
  103801. */
  103802. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103803. }
  103804. }
  103805. declare module BABYLON {
  103806. /**
  103807. * Interface for Physics-Joint data
  103808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103809. */
  103810. export interface PhysicsJointData {
  103811. /**
  103812. * The main pivot of the joint
  103813. */
  103814. mainPivot?: Vector3;
  103815. /**
  103816. * The connected pivot of the joint
  103817. */
  103818. connectedPivot?: Vector3;
  103819. /**
  103820. * The main axis of the joint
  103821. */
  103822. mainAxis?: Vector3;
  103823. /**
  103824. * The connected axis of the joint
  103825. */
  103826. connectedAxis?: Vector3;
  103827. /**
  103828. * The collision of the joint
  103829. */
  103830. collision?: boolean;
  103831. /**
  103832. * Native Oimo/Cannon/Energy data
  103833. */
  103834. nativeParams?: any;
  103835. }
  103836. /**
  103837. * This is a holder class for the physics joint created by the physics plugin
  103838. * It holds a set of functions to control the underlying joint
  103839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103840. */
  103841. export class PhysicsJoint {
  103842. /**
  103843. * The type of the physics joint
  103844. */
  103845. type: number;
  103846. /**
  103847. * The data for the physics joint
  103848. */
  103849. jointData: PhysicsJointData;
  103850. private _physicsJoint;
  103851. protected _physicsPlugin: IPhysicsEnginePlugin;
  103852. /**
  103853. * Initializes the physics joint
  103854. * @param type The type of the physics joint
  103855. * @param jointData The data for the physics joint
  103856. */
  103857. constructor(
  103858. /**
  103859. * The type of the physics joint
  103860. */
  103861. type: number,
  103862. /**
  103863. * The data for the physics joint
  103864. */
  103865. jointData: PhysicsJointData);
  103866. /**
  103867. * Gets the physics joint
  103868. */
  103869. get physicsJoint(): any;
  103870. /**
  103871. * Sets the physics joint
  103872. */
  103873. set physicsJoint(newJoint: any);
  103874. /**
  103875. * Sets the physics plugin
  103876. */
  103877. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103878. /**
  103879. * Execute a function that is physics-plugin specific.
  103880. * @param {Function} func the function that will be executed.
  103881. * It accepts two parameters: the physics world and the physics joint
  103882. */
  103883. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103884. /**
  103885. * Distance-Joint type
  103886. */
  103887. static DistanceJoint: number;
  103888. /**
  103889. * Hinge-Joint type
  103890. */
  103891. static HingeJoint: number;
  103892. /**
  103893. * Ball-and-Socket joint type
  103894. */
  103895. static BallAndSocketJoint: number;
  103896. /**
  103897. * Wheel-Joint type
  103898. */
  103899. static WheelJoint: number;
  103900. /**
  103901. * Slider-Joint type
  103902. */
  103903. static SliderJoint: number;
  103904. /**
  103905. * Prismatic-Joint type
  103906. */
  103907. static PrismaticJoint: number;
  103908. /**
  103909. * Universal-Joint type
  103910. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103911. */
  103912. static UniversalJoint: number;
  103913. /**
  103914. * Hinge-Joint 2 type
  103915. */
  103916. static Hinge2Joint: number;
  103917. /**
  103918. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103919. */
  103920. static PointToPointJoint: number;
  103921. /**
  103922. * Spring-Joint type
  103923. */
  103924. static SpringJoint: number;
  103925. /**
  103926. * Lock-Joint type
  103927. */
  103928. static LockJoint: number;
  103929. }
  103930. /**
  103931. * A class representing a physics distance joint
  103932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103933. */
  103934. export class DistanceJoint extends PhysicsJoint {
  103935. /**
  103936. *
  103937. * @param jointData The data for the Distance-Joint
  103938. */
  103939. constructor(jointData: DistanceJointData);
  103940. /**
  103941. * Update the predefined distance.
  103942. * @param maxDistance The maximum preferred distance
  103943. * @param minDistance The minimum preferred distance
  103944. */
  103945. updateDistance(maxDistance: number, minDistance?: number): void;
  103946. }
  103947. /**
  103948. * Represents a Motor-Enabled Joint
  103949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103950. */
  103951. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103952. /**
  103953. * Initializes the Motor-Enabled Joint
  103954. * @param type The type of the joint
  103955. * @param jointData The physica joint data for the joint
  103956. */
  103957. constructor(type: number, jointData: PhysicsJointData);
  103958. /**
  103959. * Set the motor values.
  103960. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103961. * @param force the force to apply
  103962. * @param maxForce max force for this motor.
  103963. */
  103964. setMotor(force?: number, maxForce?: number): void;
  103965. /**
  103966. * Set the motor's limits.
  103967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103968. * @param upperLimit The upper limit of the motor
  103969. * @param lowerLimit The lower limit of the motor
  103970. */
  103971. setLimit(upperLimit: number, lowerLimit?: number): void;
  103972. }
  103973. /**
  103974. * This class represents a single physics Hinge-Joint
  103975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103976. */
  103977. export class HingeJoint extends MotorEnabledJoint {
  103978. /**
  103979. * Initializes the Hinge-Joint
  103980. * @param jointData The joint data for the Hinge-Joint
  103981. */
  103982. constructor(jointData: PhysicsJointData);
  103983. /**
  103984. * Set the motor values.
  103985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103986. * @param {number} force the force to apply
  103987. * @param {number} maxForce max force for this motor.
  103988. */
  103989. setMotor(force?: number, maxForce?: number): void;
  103990. /**
  103991. * Set the motor's limits.
  103992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103993. * @param upperLimit The upper limit of the motor
  103994. * @param lowerLimit The lower limit of the motor
  103995. */
  103996. setLimit(upperLimit: number, lowerLimit?: number): void;
  103997. }
  103998. /**
  103999. * This class represents a dual hinge physics joint (same as wheel joint)
  104000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104001. */
  104002. export class Hinge2Joint extends MotorEnabledJoint {
  104003. /**
  104004. * Initializes the Hinge2-Joint
  104005. * @param jointData The joint data for the Hinge2-Joint
  104006. */
  104007. constructor(jointData: PhysicsJointData);
  104008. /**
  104009. * Set the motor values.
  104010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104011. * @param {number} targetSpeed the speed the motor is to reach
  104012. * @param {number} maxForce max force for this motor.
  104013. * @param {motorIndex} the motor's index, 0 or 1.
  104014. */
  104015. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104016. /**
  104017. * Set the motor limits.
  104018. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104019. * @param {number} upperLimit the upper limit
  104020. * @param {number} lowerLimit lower limit
  104021. * @param {motorIndex} the motor's index, 0 or 1.
  104022. */
  104023. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104024. }
  104025. /**
  104026. * Interface for a motor enabled joint
  104027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104028. */
  104029. export interface IMotorEnabledJoint {
  104030. /**
  104031. * Physics joint
  104032. */
  104033. physicsJoint: any;
  104034. /**
  104035. * Sets the motor of the motor-enabled joint
  104036. * @param force The force of the motor
  104037. * @param maxForce The maximum force of the motor
  104038. * @param motorIndex The index of the motor
  104039. */
  104040. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104041. /**
  104042. * Sets the limit of the motor
  104043. * @param upperLimit The upper limit of the motor
  104044. * @param lowerLimit The lower limit of the motor
  104045. * @param motorIndex The index of the motor
  104046. */
  104047. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104048. }
  104049. /**
  104050. * Joint data for a Distance-Joint
  104051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104052. */
  104053. export interface DistanceJointData extends PhysicsJointData {
  104054. /**
  104055. * Max distance the 2 joint objects can be apart
  104056. */
  104057. maxDistance: number;
  104058. }
  104059. /**
  104060. * Joint data from a spring joint
  104061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104062. */
  104063. export interface SpringJointData extends PhysicsJointData {
  104064. /**
  104065. * Length of the spring
  104066. */
  104067. length: number;
  104068. /**
  104069. * Stiffness of the spring
  104070. */
  104071. stiffness: number;
  104072. /**
  104073. * Damping of the spring
  104074. */
  104075. damping: number;
  104076. /** this callback will be called when applying the force to the impostors. */
  104077. forceApplicationCallback: () => void;
  104078. }
  104079. }
  104080. declare module BABYLON {
  104081. /**
  104082. * Holds the data for the raycast result
  104083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104084. */
  104085. export class PhysicsRaycastResult {
  104086. private _hasHit;
  104087. private _hitDistance;
  104088. private _hitNormalWorld;
  104089. private _hitPointWorld;
  104090. private _rayFromWorld;
  104091. private _rayToWorld;
  104092. /**
  104093. * Gets if there was a hit
  104094. */
  104095. get hasHit(): boolean;
  104096. /**
  104097. * Gets the distance from the hit
  104098. */
  104099. get hitDistance(): number;
  104100. /**
  104101. * Gets the hit normal/direction in the world
  104102. */
  104103. get hitNormalWorld(): Vector3;
  104104. /**
  104105. * Gets the hit point in the world
  104106. */
  104107. get hitPointWorld(): Vector3;
  104108. /**
  104109. * Gets the ray "start point" of the ray in the world
  104110. */
  104111. get rayFromWorld(): Vector3;
  104112. /**
  104113. * Gets the ray "end point" of the ray in the world
  104114. */
  104115. get rayToWorld(): Vector3;
  104116. /**
  104117. * Sets the hit data (normal & point in world space)
  104118. * @param hitNormalWorld defines the normal in world space
  104119. * @param hitPointWorld defines the point in world space
  104120. */
  104121. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104122. /**
  104123. * Sets the distance from the start point to the hit point
  104124. * @param distance
  104125. */
  104126. setHitDistance(distance: number): void;
  104127. /**
  104128. * Calculates the distance manually
  104129. */
  104130. calculateHitDistance(): void;
  104131. /**
  104132. * Resets all the values to default
  104133. * @param from The from point on world space
  104134. * @param to The to point on world space
  104135. */
  104136. reset(from?: Vector3, to?: Vector3): void;
  104137. }
  104138. /**
  104139. * Interface for the size containing width and height
  104140. */
  104141. interface IXYZ {
  104142. /**
  104143. * X
  104144. */
  104145. x: number;
  104146. /**
  104147. * Y
  104148. */
  104149. y: number;
  104150. /**
  104151. * Z
  104152. */
  104153. z: number;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * Interface used to describe a physics joint
  104159. */
  104160. export interface PhysicsImpostorJoint {
  104161. /** Defines the main impostor to which the joint is linked */
  104162. mainImpostor: PhysicsImpostor;
  104163. /** Defines the impostor that is connected to the main impostor using this joint */
  104164. connectedImpostor: PhysicsImpostor;
  104165. /** Defines the joint itself */
  104166. joint: PhysicsJoint;
  104167. }
  104168. /** @hidden */
  104169. export interface IPhysicsEnginePlugin {
  104170. world: any;
  104171. name: string;
  104172. setGravity(gravity: Vector3): void;
  104173. setTimeStep(timeStep: number): void;
  104174. getTimeStep(): number;
  104175. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104176. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104177. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104179. removePhysicsBody(impostor: PhysicsImpostor): void;
  104180. generateJoint(joint: PhysicsImpostorJoint): void;
  104181. removeJoint(joint: PhysicsImpostorJoint): void;
  104182. isSupported(): boolean;
  104183. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104184. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104185. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104186. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104187. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104188. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104189. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104190. getBodyMass(impostor: PhysicsImpostor): number;
  104191. getBodyFriction(impostor: PhysicsImpostor): number;
  104192. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104193. getBodyRestitution(impostor: PhysicsImpostor): number;
  104194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104195. getBodyPressure?(impostor: PhysicsImpostor): number;
  104196. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104197. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104198. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104199. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104200. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104201. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104202. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104203. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104204. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104205. sleepBody(impostor: PhysicsImpostor): void;
  104206. wakeUpBody(impostor: PhysicsImpostor): void;
  104207. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104209. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104211. getRadius(impostor: PhysicsImpostor): number;
  104212. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104213. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104214. dispose(): void;
  104215. }
  104216. /**
  104217. * Interface used to define a physics engine
  104218. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104219. */
  104220. export interface IPhysicsEngine {
  104221. /**
  104222. * Gets the gravity vector used by the simulation
  104223. */
  104224. gravity: Vector3;
  104225. /**
  104226. * Sets the gravity vector used by the simulation
  104227. * @param gravity defines the gravity vector to use
  104228. */
  104229. setGravity(gravity: Vector3): void;
  104230. /**
  104231. * Set the time step of the physics engine.
  104232. * Default is 1/60.
  104233. * To slow it down, enter 1/600 for example.
  104234. * To speed it up, 1/30
  104235. * @param newTimeStep the new timestep to apply to this world.
  104236. */
  104237. setTimeStep(newTimeStep: number): void;
  104238. /**
  104239. * Get the time step of the physics engine.
  104240. * @returns the current time step
  104241. */
  104242. getTimeStep(): number;
  104243. /**
  104244. * Set the sub time step of the physics engine.
  104245. * Default is 0 meaning there is no sub steps
  104246. * To increase physics resolution precision, set a small value (like 1 ms)
  104247. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104248. */
  104249. setSubTimeStep(subTimeStep: number): void;
  104250. /**
  104251. * Get the sub time step of the physics engine.
  104252. * @returns the current sub time step
  104253. */
  104254. getSubTimeStep(): number;
  104255. /**
  104256. * Release all resources
  104257. */
  104258. dispose(): void;
  104259. /**
  104260. * Gets the name of the current physics plugin
  104261. * @returns the name of the plugin
  104262. */
  104263. getPhysicsPluginName(): string;
  104264. /**
  104265. * Adding a new impostor for the impostor tracking.
  104266. * This will be done by the impostor itself.
  104267. * @param impostor the impostor to add
  104268. */
  104269. addImpostor(impostor: PhysicsImpostor): void;
  104270. /**
  104271. * Remove an impostor from the engine.
  104272. * This impostor and its mesh will not longer be updated by the physics engine.
  104273. * @param impostor the impostor to remove
  104274. */
  104275. removeImpostor(impostor: PhysicsImpostor): void;
  104276. /**
  104277. * Add a joint to the physics engine
  104278. * @param mainImpostor defines the main impostor to which the joint is added.
  104279. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104280. * @param joint defines the joint that will connect both impostors.
  104281. */
  104282. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104283. /**
  104284. * Removes a joint from the simulation
  104285. * @param mainImpostor defines the impostor used with the joint
  104286. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104287. * @param joint defines the joint to remove
  104288. */
  104289. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104290. /**
  104291. * Gets the current plugin used to run the simulation
  104292. * @returns current plugin
  104293. */
  104294. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104295. /**
  104296. * Gets the list of physic impostors
  104297. * @returns an array of PhysicsImpostor
  104298. */
  104299. getImpostors(): Array<PhysicsImpostor>;
  104300. /**
  104301. * Gets the impostor for a physics enabled object
  104302. * @param object defines the object impersonated by the impostor
  104303. * @returns the PhysicsImpostor or null if not found
  104304. */
  104305. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104306. /**
  104307. * Gets the impostor for a physics body object
  104308. * @param body defines physics body used by the impostor
  104309. * @returns the PhysicsImpostor or null if not found
  104310. */
  104311. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104312. /**
  104313. * Does a raycast in the physics world
  104314. * @param from when should the ray start?
  104315. * @param to when should the ray end?
  104316. * @returns PhysicsRaycastResult
  104317. */
  104318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104319. /**
  104320. * Called by the scene. No need to call it.
  104321. * @param delta defines the timespam between frames
  104322. */
  104323. _step(delta: number): void;
  104324. }
  104325. }
  104326. declare module BABYLON {
  104327. /**
  104328. * The interface for the physics imposter parameters
  104329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104330. */
  104331. export interface PhysicsImpostorParameters {
  104332. /**
  104333. * The mass of the physics imposter
  104334. */
  104335. mass: number;
  104336. /**
  104337. * The friction of the physics imposter
  104338. */
  104339. friction?: number;
  104340. /**
  104341. * The coefficient of restitution of the physics imposter
  104342. */
  104343. restitution?: number;
  104344. /**
  104345. * The native options of the physics imposter
  104346. */
  104347. nativeOptions?: any;
  104348. /**
  104349. * Specifies if the parent should be ignored
  104350. */
  104351. ignoreParent?: boolean;
  104352. /**
  104353. * Specifies if bi-directional transformations should be disabled
  104354. */
  104355. disableBidirectionalTransformation?: boolean;
  104356. /**
  104357. * The pressure inside the physics imposter, soft object only
  104358. */
  104359. pressure?: number;
  104360. /**
  104361. * The stiffness the physics imposter, soft object only
  104362. */
  104363. stiffness?: number;
  104364. /**
  104365. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104366. */
  104367. velocityIterations?: number;
  104368. /**
  104369. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104370. */
  104371. positionIterations?: number;
  104372. /**
  104373. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104374. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104375. * Add to fix multiple points
  104376. */
  104377. fixedPoints?: number;
  104378. /**
  104379. * The collision margin around a soft object
  104380. */
  104381. margin?: number;
  104382. /**
  104383. * The collision margin around a soft object
  104384. */
  104385. damping?: number;
  104386. /**
  104387. * The path for a rope based on an extrusion
  104388. */
  104389. path?: any;
  104390. /**
  104391. * The shape of an extrusion used for a rope based on an extrusion
  104392. */
  104393. shape?: any;
  104394. }
  104395. /**
  104396. * Interface for a physics-enabled object
  104397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104398. */
  104399. export interface IPhysicsEnabledObject {
  104400. /**
  104401. * The position of the physics-enabled object
  104402. */
  104403. position: Vector3;
  104404. /**
  104405. * The rotation of the physics-enabled object
  104406. */
  104407. rotationQuaternion: Nullable<Quaternion>;
  104408. /**
  104409. * The scale of the physics-enabled object
  104410. */
  104411. scaling: Vector3;
  104412. /**
  104413. * The rotation of the physics-enabled object
  104414. */
  104415. rotation?: Vector3;
  104416. /**
  104417. * The parent of the physics-enabled object
  104418. */
  104419. parent?: any;
  104420. /**
  104421. * The bounding info of the physics-enabled object
  104422. * @returns The bounding info of the physics-enabled object
  104423. */
  104424. getBoundingInfo(): BoundingInfo;
  104425. /**
  104426. * Computes the world matrix
  104427. * @param force Specifies if the world matrix should be computed by force
  104428. * @returns A world matrix
  104429. */
  104430. computeWorldMatrix(force: boolean): Matrix;
  104431. /**
  104432. * Gets the world matrix
  104433. * @returns A world matrix
  104434. */
  104435. getWorldMatrix?(): Matrix;
  104436. /**
  104437. * Gets the child meshes
  104438. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104439. * @returns An array of abstract meshes
  104440. */
  104441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104442. /**
  104443. * Gets the vertex data
  104444. * @param kind The type of vertex data
  104445. * @returns A nullable array of numbers, or a float32 array
  104446. */
  104447. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104448. /**
  104449. * Gets the indices from the mesh
  104450. * @returns A nullable array of index arrays
  104451. */
  104452. getIndices?(): Nullable<IndicesArray>;
  104453. /**
  104454. * Gets the scene from the mesh
  104455. * @returns the indices array or null
  104456. */
  104457. getScene?(): Scene;
  104458. /**
  104459. * Gets the absolute position from the mesh
  104460. * @returns the absolute position
  104461. */
  104462. getAbsolutePosition(): Vector3;
  104463. /**
  104464. * Gets the absolute pivot point from the mesh
  104465. * @returns the absolute pivot point
  104466. */
  104467. getAbsolutePivotPoint(): Vector3;
  104468. /**
  104469. * Rotates the mesh
  104470. * @param axis The axis of rotation
  104471. * @param amount The amount of rotation
  104472. * @param space The space of the rotation
  104473. * @returns The rotation transform node
  104474. */
  104475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104476. /**
  104477. * Translates the mesh
  104478. * @param axis The axis of translation
  104479. * @param distance The distance of translation
  104480. * @param space The space of the translation
  104481. * @returns The transform node
  104482. */
  104483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104484. /**
  104485. * Sets the absolute position of the mesh
  104486. * @param absolutePosition The absolute position of the mesh
  104487. * @returns The transform node
  104488. */
  104489. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104490. /**
  104491. * Gets the class name of the mesh
  104492. * @returns The class name
  104493. */
  104494. getClassName(): string;
  104495. }
  104496. /**
  104497. * Represents a physics imposter
  104498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104499. */
  104500. export class PhysicsImpostor {
  104501. /**
  104502. * The physics-enabled object used as the physics imposter
  104503. */
  104504. object: IPhysicsEnabledObject;
  104505. /**
  104506. * The type of the physics imposter
  104507. */
  104508. type: number;
  104509. private _options;
  104510. private _scene?;
  104511. /**
  104512. * The default object size of the imposter
  104513. */
  104514. static DEFAULT_OBJECT_SIZE: Vector3;
  104515. /**
  104516. * The identity quaternion of the imposter
  104517. */
  104518. static IDENTITY_QUATERNION: Quaternion;
  104519. /** @hidden */
  104520. _pluginData: any;
  104521. private _physicsEngine;
  104522. private _physicsBody;
  104523. private _bodyUpdateRequired;
  104524. private _onBeforePhysicsStepCallbacks;
  104525. private _onAfterPhysicsStepCallbacks;
  104526. /** @hidden */
  104527. _onPhysicsCollideCallbacks: Array<{
  104528. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104529. otherImpostors: Array<PhysicsImpostor>;
  104530. }>;
  104531. private _deltaPosition;
  104532. private _deltaRotation;
  104533. private _deltaRotationConjugated;
  104534. /** @hidden */
  104535. _isFromLine: boolean;
  104536. private _parent;
  104537. private _isDisposed;
  104538. private static _tmpVecs;
  104539. private static _tmpQuat;
  104540. /**
  104541. * Specifies if the physics imposter is disposed
  104542. */
  104543. get isDisposed(): boolean;
  104544. /**
  104545. * Gets the mass of the physics imposter
  104546. */
  104547. get mass(): number;
  104548. set mass(value: number);
  104549. /**
  104550. * Gets the coefficient of friction
  104551. */
  104552. get friction(): number;
  104553. /**
  104554. * Sets the coefficient of friction
  104555. */
  104556. set friction(value: number);
  104557. /**
  104558. * Gets the coefficient of restitution
  104559. */
  104560. get restitution(): number;
  104561. /**
  104562. * Sets the coefficient of restitution
  104563. */
  104564. set restitution(value: number);
  104565. /**
  104566. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104567. */
  104568. get pressure(): number;
  104569. /**
  104570. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104571. */
  104572. set pressure(value: number);
  104573. /**
  104574. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104575. */
  104576. get stiffness(): number;
  104577. /**
  104578. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104579. */
  104580. set stiffness(value: number);
  104581. /**
  104582. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104583. */
  104584. get velocityIterations(): number;
  104585. /**
  104586. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104587. */
  104588. set velocityIterations(value: number);
  104589. /**
  104590. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104591. */
  104592. get positionIterations(): number;
  104593. /**
  104594. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104595. */
  104596. set positionIterations(value: number);
  104597. /**
  104598. * The unique id of the physics imposter
  104599. * set by the physics engine when adding this impostor to the array
  104600. */
  104601. uniqueId: number;
  104602. /**
  104603. * @hidden
  104604. */
  104605. soft: boolean;
  104606. /**
  104607. * @hidden
  104608. */
  104609. segments: number;
  104610. private _joints;
  104611. /**
  104612. * Initializes the physics imposter
  104613. * @param object The physics-enabled object used as the physics imposter
  104614. * @param type The type of the physics imposter
  104615. * @param _options The options for the physics imposter
  104616. * @param _scene The Babylon scene
  104617. */
  104618. constructor(
  104619. /**
  104620. * The physics-enabled object used as the physics imposter
  104621. */
  104622. object: IPhysicsEnabledObject,
  104623. /**
  104624. * The type of the physics imposter
  104625. */
  104626. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104627. /**
  104628. * This function will completly initialize this impostor.
  104629. * It will create a new body - but only if this mesh has no parent.
  104630. * If it has, this impostor will not be used other than to define the impostor
  104631. * of the child mesh.
  104632. * @hidden
  104633. */
  104634. _init(): void;
  104635. private _getPhysicsParent;
  104636. /**
  104637. * Should a new body be generated.
  104638. * @returns boolean specifying if body initialization is required
  104639. */
  104640. isBodyInitRequired(): boolean;
  104641. /**
  104642. * Sets the updated scaling
  104643. * @param updated Specifies if the scaling is updated
  104644. */
  104645. setScalingUpdated(): void;
  104646. /**
  104647. * Force a regeneration of this or the parent's impostor's body.
  104648. * Use under cautious - This will remove all joints already implemented.
  104649. */
  104650. forceUpdate(): void;
  104651. /**
  104652. * Gets the body that holds this impostor. Either its own, or its parent.
  104653. */
  104654. get physicsBody(): any;
  104655. /**
  104656. * Get the parent of the physics imposter
  104657. * @returns Physics imposter or null
  104658. */
  104659. get parent(): Nullable<PhysicsImpostor>;
  104660. /**
  104661. * Sets the parent of the physics imposter
  104662. */
  104663. set parent(value: Nullable<PhysicsImpostor>);
  104664. /**
  104665. * Set the physics body. Used mainly by the physics engine/plugin
  104666. */
  104667. set physicsBody(physicsBody: any);
  104668. /**
  104669. * Resets the update flags
  104670. */
  104671. resetUpdateFlags(): void;
  104672. /**
  104673. * Gets the object extend size
  104674. * @returns the object extend size
  104675. */
  104676. getObjectExtendSize(): Vector3;
  104677. /**
  104678. * Gets the object center
  104679. * @returns The object center
  104680. */
  104681. getObjectCenter(): Vector3;
  104682. /**
  104683. * Get a specific parameter from the options parameters
  104684. * @param paramName The object parameter name
  104685. * @returns The object parameter
  104686. */
  104687. getParam(paramName: string): any;
  104688. /**
  104689. * Sets a specific parameter in the options given to the physics plugin
  104690. * @param paramName The parameter name
  104691. * @param value The value of the parameter
  104692. */
  104693. setParam(paramName: string, value: number): void;
  104694. /**
  104695. * Specifically change the body's mass option. Won't recreate the physics body object
  104696. * @param mass The mass of the physics imposter
  104697. */
  104698. setMass(mass: number): void;
  104699. /**
  104700. * Gets the linear velocity
  104701. * @returns linear velocity or null
  104702. */
  104703. getLinearVelocity(): Nullable<Vector3>;
  104704. /**
  104705. * Sets the linear velocity
  104706. * @param velocity linear velocity or null
  104707. */
  104708. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104709. /**
  104710. * Gets the angular velocity
  104711. * @returns angular velocity or null
  104712. */
  104713. getAngularVelocity(): Nullable<Vector3>;
  104714. /**
  104715. * Sets the angular velocity
  104716. * @param velocity The velocity or null
  104717. */
  104718. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104719. /**
  104720. * Execute a function with the physics plugin native code
  104721. * Provide a function the will have two variables - the world object and the physics body object
  104722. * @param func The function to execute with the physics plugin native code
  104723. */
  104724. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104725. /**
  104726. * Register a function that will be executed before the physics world is stepping forward
  104727. * @param func The function to execute before the physics world is stepped forward
  104728. */
  104729. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104730. /**
  104731. * Unregister a function that will be executed before the physics world is stepping forward
  104732. * @param func The function to execute before the physics world is stepped forward
  104733. */
  104734. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104735. /**
  104736. * Register a function that will be executed after the physics step
  104737. * @param func The function to execute after physics step
  104738. */
  104739. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104740. /**
  104741. * Unregisters a function that will be executed after the physics step
  104742. * @param func The function to execute after physics step
  104743. */
  104744. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104745. /**
  104746. * register a function that will be executed when this impostor collides against a different body
  104747. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104748. * @param func Callback that is executed on collision
  104749. */
  104750. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104751. /**
  104752. * Unregisters the physics imposter on contact
  104753. * @param collideAgainst The physics object to collide against
  104754. * @param func Callback to execute on collision
  104755. */
  104756. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104757. private _tmpQuat;
  104758. private _tmpQuat2;
  104759. /**
  104760. * Get the parent rotation
  104761. * @returns The parent rotation
  104762. */
  104763. getParentsRotation(): Quaternion;
  104764. /**
  104765. * this function is executed by the physics engine.
  104766. */
  104767. beforeStep: () => void;
  104768. /**
  104769. * this function is executed by the physics engine
  104770. */
  104771. afterStep: () => void;
  104772. /**
  104773. * Legacy collision detection event support
  104774. */
  104775. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104776. /**
  104777. * event and body object due to cannon's event-based architecture.
  104778. */
  104779. onCollide: (e: {
  104780. body: any;
  104781. }) => void;
  104782. /**
  104783. * Apply a force
  104784. * @param force The force to apply
  104785. * @param contactPoint The contact point for the force
  104786. * @returns The physics imposter
  104787. */
  104788. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104789. /**
  104790. * Apply an impulse
  104791. * @param force The impulse force
  104792. * @param contactPoint The contact point for the impulse force
  104793. * @returns The physics imposter
  104794. */
  104795. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104796. /**
  104797. * A help function to create a joint
  104798. * @param otherImpostor A physics imposter used to create a joint
  104799. * @param jointType The type of joint
  104800. * @param jointData The data for the joint
  104801. * @returns The physics imposter
  104802. */
  104803. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104804. /**
  104805. * Add a joint to this impostor with a different impostor
  104806. * @param otherImpostor A physics imposter used to add a joint
  104807. * @param joint The joint to add
  104808. * @returns The physics imposter
  104809. */
  104810. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104811. /**
  104812. * Add an anchor to a cloth impostor
  104813. * @param otherImpostor rigid impostor to anchor to
  104814. * @param width ratio across width from 0 to 1
  104815. * @param height ratio up height from 0 to 1
  104816. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104817. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104818. * @returns impostor the soft imposter
  104819. */
  104820. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104821. /**
  104822. * Add a hook to a rope impostor
  104823. * @param otherImpostor rigid impostor to anchor to
  104824. * @param length ratio across rope from 0 to 1
  104825. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104826. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104827. * @returns impostor the rope imposter
  104828. */
  104829. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104830. /**
  104831. * Will keep this body still, in a sleep mode.
  104832. * @returns the physics imposter
  104833. */
  104834. sleep(): PhysicsImpostor;
  104835. /**
  104836. * Wake the body up.
  104837. * @returns The physics imposter
  104838. */
  104839. wakeUp(): PhysicsImpostor;
  104840. /**
  104841. * Clones the physics imposter
  104842. * @param newObject The physics imposter clones to this physics-enabled object
  104843. * @returns A nullable physics imposter
  104844. */
  104845. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104846. /**
  104847. * Disposes the physics imposter
  104848. */
  104849. dispose(): void;
  104850. /**
  104851. * Sets the delta position
  104852. * @param position The delta position amount
  104853. */
  104854. setDeltaPosition(position: Vector3): void;
  104855. /**
  104856. * Sets the delta rotation
  104857. * @param rotation The delta rotation amount
  104858. */
  104859. setDeltaRotation(rotation: Quaternion): void;
  104860. /**
  104861. * Gets the box size of the physics imposter and stores the result in the input parameter
  104862. * @param result Stores the box size
  104863. * @returns The physics imposter
  104864. */
  104865. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104866. /**
  104867. * Gets the radius of the physics imposter
  104868. * @returns Radius of the physics imposter
  104869. */
  104870. getRadius(): number;
  104871. /**
  104872. * Sync a bone with this impostor
  104873. * @param bone The bone to sync to the impostor.
  104874. * @param boneMesh The mesh that the bone is influencing.
  104875. * @param jointPivot The pivot of the joint / bone in local space.
  104876. * @param distToJoint Optional distance from the impostor to the joint.
  104877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104878. */
  104879. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104880. /**
  104881. * Sync impostor to a bone
  104882. * @param bone The bone that the impostor will be synced to.
  104883. * @param boneMesh The mesh that the bone is influencing.
  104884. * @param jointPivot The pivot of the joint / bone in local space.
  104885. * @param distToJoint Optional distance from the impostor to the joint.
  104886. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104887. * @param boneAxis Optional vector3 axis the bone is aligned with
  104888. */
  104889. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104890. /**
  104891. * No-Imposter type
  104892. */
  104893. static NoImpostor: number;
  104894. /**
  104895. * Sphere-Imposter type
  104896. */
  104897. static SphereImpostor: number;
  104898. /**
  104899. * Box-Imposter type
  104900. */
  104901. static BoxImpostor: number;
  104902. /**
  104903. * Plane-Imposter type
  104904. */
  104905. static PlaneImpostor: number;
  104906. /**
  104907. * Mesh-imposter type
  104908. */
  104909. static MeshImpostor: number;
  104910. /**
  104911. * Capsule-Impostor type (Ammo.js plugin only)
  104912. */
  104913. static CapsuleImpostor: number;
  104914. /**
  104915. * Cylinder-Imposter type
  104916. */
  104917. static CylinderImpostor: number;
  104918. /**
  104919. * Particle-Imposter type
  104920. */
  104921. static ParticleImpostor: number;
  104922. /**
  104923. * Heightmap-Imposter type
  104924. */
  104925. static HeightmapImpostor: number;
  104926. /**
  104927. * ConvexHull-Impostor type (Ammo.js plugin only)
  104928. */
  104929. static ConvexHullImpostor: number;
  104930. /**
  104931. * Custom-Imposter type (Ammo.js plugin only)
  104932. */
  104933. static CustomImpostor: number;
  104934. /**
  104935. * Rope-Imposter type
  104936. */
  104937. static RopeImpostor: number;
  104938. /**
  104939. * Cloth-Imposter type
  104940. */
  104941. static ClothImpostor: number;
  104942. /**
  104943. * Softbody-Imposter type
  104944. */
  104945. static SoftbodyImpostor: number;
  104946. }
  104947. }
  104948. declare module BABYLON {
  104949. /**
  104950. * @hidden
  104951. **/
  104952. export class _CreationDataStorage {
  104953. closePath?: boolean;
  104954. closeArray?: boolean;
  104955. idx: number[];
  104956. dashSize: number;
  104957. gapSize: number;
  104958. path3D: Path3D;
  104959. pathArray: Vector3[][];
  104960. arc: number;
  104961. radius: number;
  104962. cap: number;
  104963. tessellation: number;
  104964. }
  104965. /**
  104966. * @hidden
  104967. **/
  104968. class _InstanceDataStorage {
  104969. visibleInstances: any;
  104970. batchCache: _InstancesBatch;
  104971. instancesBufferSize: number;
  104972. instancesBuffer: Nullable<Buffer>;
  104973. instancesData: Float32Array;
  104974. overridenInstanceCount: number;
  104975. isFrozen: boolean;
  104976. previousBatch: Nullable<_InstancesBatch>;
  104977. hardwareInstancedRendering: boolean;
  104978. sideOrientation: number;
  104979. manualUpdate: boolean;
  104980. }
  104981. /**
  104982. * @hidden
  104983. **/
  104984. export class _InstancesBatch {
  104985. mustReturn: boolean;
  104986. visibleInstances: Nullable<InstancedMesh[]>[];
  104987. renderSelf: boolean[];
  104988. hardwareInstancedRendering: boolean[];
  104989. }
  104990. /**
  104991. * @hidden
  104992. **/
  104993. class _ThinInstanceDataStorage {
  104994. instancesCount: number;
  104995. matrixBuffer: Nullable<Buffer>;
  104996. matrixBufferSize: number;
  104997. matrixData: Nullable<Float32Array>;
  104998. boundingVectors: Array<Vector3>;
  104999. }
  105000. /**
  105001. * Class used to represent renderable models
  105002. */
  105003. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105004. /**
  105005. * Mesh side orientation : usually the external or front surface
  105006. */
  105007. static readonly FRONTSIDE: number;
  105008. /**
  105009. * Mesh side orientation : usually the internal or back surface
  105010. */
  105011. static readonly BACKSIDE: number;
  105012. /**
  105013. * Mesh side orientation : both internal and external or front and back surfaces
  105014. */
  105015. static readonly DOUBLESIDE: number;
  105016. /**
  105017. * Mesh side orientation : by default, `FRONTSIDE`
  105018. */
  105019. static readonly DEFAULTSIDE: number;
  105020. /**
  105021. * Mesh cap setting : no cap
  105022. */
  105023. static readonly NO_CAP: number;
  105024. /**
  105025. * Mesh cap setting : one cap at the beginning of the mesh
  105026. */
  105027. static readonly CAP_START: number;
  105028. /**
  105029. * Mesh cap setting : one cap at the end of the mesh
  105030. */
  105031. static readonly CAP_END: number;
  105032. /**
  105033. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105034. */
  105035. static readonly CAP_ALL: number;
  105036. /**
  105037. * Mesh pattern setting : no flip or rotate
  105038. */
  105039. static readonly NO_FLIP: number;
  105040. /**
  105041. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105042. */
  105043. static readonly FLIP_TILE: number;
  105044. /**
  105045. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105046. */
  105047. static readonly ROTATE_TILE: number;
  105048. /**
  105049. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105050. */
  105051. static readonly FLIP_ROW: number;
  105052. /**
  105053. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105054. */
  105055. static readonly ROTATE_ROW: number;
  105056. /**
  105057. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105058. */
  105059. static readonly FLIP_N_ROTATE_TILE: number;
  105060. /**
  105061. * Mesh pattern setting : rotate pattern and rotate
  105062. */
  105063. static readonly FLIP_N_ROTATE_ROW: number;
  105064. /**
  105065. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105066. */
  105067. static readonly CENTER: number;
  105068. /**
  105069. * Mesh tile positioning : part tiles on left
  105070. */
  105071. static readonly LEFT: number;
  105072. /**
  105073. * Mesh tile positioning : part tiles on right
  105074. */
  105075. static readonly RIGHT: number;
  105076. /**
  105077. * Mesh tile positioning : part tiles on top
  105078. */
  105079. static readonly TOP: number;
  105080. /**
  105081. * Mesh tile positioning : part tiles on bottom
  105082. */
  105083. static readonly BOTTOM: number;
  105084. /**
  105085. * Gets the default side orientation.
  105086. * @param orientation the orientation to value to attempt to get
  105087. * @returns the default orientation
  105088. * @hidden
  105089. */
  105090. static _GetDefaultSideOrientation(orientation?: number): number;
  105091. private _internalMeshDataInfo;
  105092. /**
  105093. * An event triggered before rendering the mesh
  105094. */
  105095. get onBeforeRenderObservable(): Observable<Mesh>;
  105096. /**
  105097. * An event triggered before binding the mesh
  105098. */
  105099. get onBeforeBindObservable(): Observable<Mesh>;
  105100. /**
  105101. * An event triggered after rendering the mesh
  105102. */
  105103. get onAfterRenderObservable(): Observable<Mesh>;
  105104. /**
  105105. * An event triggered before drawing the mesh
  105106. */
  105107. get onBeforeDrawObservable(): Observable<Mesh>;
  105108. private _onBeforeDrawObserver;
  105109. /**
  105110. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105111. */
  105112. set onBeforeDraw(callback: () => void);
  105113. get hasInstances(): boolean;
  105114. get hasThinInstances(): boolean;
  105115. /**
  105116. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105117. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105118. */
  105119. delayLoadState: number;
  105120. /**
  105121. * Gets the list of instances created from this mesh
  105122. * it is not supposed to be modified manually.
  105123. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105124. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105125. */
  105126. instances: InstancedMesh[];
  105127. /**
  105128. * Gets the file containing delay loading data for this mesh
  105129. */
  105130. delayLoadingFile: string;
  105131. /** @hidden */
  105132. _binaryInfo: any;
  105133. /**
  105134. * User defined function used to change how LOD level selection is done
  105135. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  105136. */
  105137. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105138. /**
  105139. * Gets or sets the morph target manager
  105140. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105141. */
  105142. get morphTargetManager(): Nullable<MorphTargetManager>;
  105143. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105144. /** @hidden */
  105145. _creationDataStorage: Nullable<_CreationDataStorage>;
  105146. /** @hidden */
  105147. _geometry: Nullable<Geometry>;
  105148. /** @hidden */
  105149. _delayInfo: Array<string>;
  105150. /** @hidden */
  105151. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105152. /** @hidden */
  105153. _instanceDataStorage: _InstanceDataStorage;
  105154. /** @hidden */
  105155. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105156. private _effectiveMaterial;
  105157. /** @hidden */
  105158. _shouldGenerateFlatShading: boolean;
  105159. /** @hidden */
  105160. _originalBuilderSideOrientation: number;
  105161. /**
  105162. * Use this property to change the original side orientation defined at construction time
  105163. */
  105164. overrideMaterialSideOrientation: Nullable<number>;
  105165. /**
  105166. * Gets the source mesh (the one used to clone this one from)
  105167. */
  105168. get source(): Nullable<Mesh>;
  105169. /**
  105170. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105171. */
  105172. get isUnIndexed(): boolean;
  105173. set isUnIndexed(value: boolean);
  105174. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105175. get worldMatrixInstancedBuffer(): Float32Array;
  105176. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105177. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105178. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105179. /**
  105180. * @constructor
  105181. * @param name The value used by scene.getMeshByName() to do a lookup.
  105182. * @param scene The scene to add this mesh to.
  105183. * @param parent The parent of this mesh, if it has one
  105184. * @param source An optional Mesh from which geometry is shared, cloned.
  105185. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105186. * When false, achieved by calling a clone(), also passing False.
  105187. * This will make creation of children, recursive.
  105188. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105189. */
  105190. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105191. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105192. doNotInstantiate: boolean;
  105193. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105194. /**
  105195. * Gets the class name
  105196. * @returns the string "Mesh".
  105197. */
  105198. getClassName(): string;
  105199. /** @hidden */
  105200. get _isMesh(): boolean;
  105201. /**
  105202. * Returns a description of this mesh
  105203. * @param fullDetails define if full details about this mesh must be used
  105204. * @returns a descriptive string representing this mesh
  105205. */
  105206. toString(fullDetails?: boolean): string;
  105207. /** @hidden */
  105208. _unBindEffect(): void;
  105209. /**
  105210. * Gets a boolean indicating if this mesh has LOD
  105211. */
  105212. get hasLODLevels(): boolean;
  105213. /**
  105214. * Gets the list of MeshLODLevel associated with the current mesh
  105215. * @returns an array of MeshLODLevel
  105216. */
  105217. getLODLevels(): MeshLODLevel[];
  105218. private _sortLODLevels;
  105219. /**
  105220. * Add a mesh as LOD level triggered at the given distance.
  105221. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105222. * @param distance The distance from the center of the object to show this level
  105223. * @param mesh The mesh to be added as LOD level (can be null)
  105224. * @return This mesh (for chaining)
  105225. */
  105226. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105227. /**
  105228. * Returns the LOD level mesh at the passed distance or null if not found.
  105229. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105230. * @param distance The distance from the center of the object to show this level
  105231. * @returns a Mesh or `null`
  105232. */
  105233. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105234. /**
  105235. * Remove a mesh from the LOD array
  105236. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105237. * @param mesh defines the mesh to be removed
  105238. * @return This mesh (for chaining)
  105239. */
  105240. removeLODLevel(mesh: Mesh): Mesh;
  105241. /**
  105242. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105243. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105244. * @param camera defines the camera to use to compute distance
  105245. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105246. * @return This mesh (for chaining)
  105247. */
  105248. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105249. /**
  105250. * Gets the mesh internal Geometry object
  105251. */
  105252. get geometry(): Nullable<Geometry>;
  105253. /**
  105254. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105255. * @returns the total number of vertices
  105256. */
  105257. getTotalVertices(): number;
  105258. /**
  105259. * Returns the content of an associated vertex buffer
  105260. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105261. * - VertexBuffer.PositionKind
  105262. * - VertexBuffer.UVKind
  105263. * - VertexBuffer.UV2Kind
  105264. * - VertexBuffer.UV3Kind
  105265. * - VertexBuffer.UV4Kind
  105266. * - VertexBuffer.UV5Kind
  105267. * - VertexBuffer.UV6Kind
  105268. * - VertexBuffer.ColorKind
  105269. * - VertexBuffer.MatricesIndicesKind
  105270. * - VertexBuffer.MatricesIndicesExtraKind
  105271. * - VertexBuffer.MatricesWeightsKind
  105272. * - VertexBuffer.MatricesWeightsExtraKind
  105273. * @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
  105274. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105275. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105276. */
  105277. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105278. /**
  105279. * Returns the mesh VertexBuffer object from the requested `kind`
  105280. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105281. * - VertexBuffer.PositionKind
  105282. * - VertexBuffer.NormalKind
  105283. * - VertexBuffer.UVKind
  105284. * - VertexBuffer.UV2Kind
  105285. * - VertexBuffer.UV3Kind
  105286. * - VertexBuffer.UV4Kind
  105287. * - VertexBuffer.UV5Kind
  105288. * - VertexBuffer.UV6Kind
  105289. * - VertexBuffer.ColorKind
  105290. * - VertexBuffer.MatricesIndicesKind
  105291. * - VertexBuffer.MatricesIndicesExtraKind
  105292. * - VertexBuffer.MatricesWeightsKind
  105293. * - VertexBuffer.MatricesWeightsExtraKind
  105294. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105295. */
  105296. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105297. /**
  105298. * Tests if a specific vertex buffer is associated with this mesh
  105299. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105300. * - VertexBuffer.PositionKind
  105301. * - VertexBuffer.NormalKind
  105302. * - VertexBuffer.UVKind
  105303. * - VertexBuffer.UV2Kind
  105304. * - VertexBuffer.UV3Kind
  105305. * - VertexBuffer.UV4Kind
  105306. * - VertexBuffer.UV5Kind
  105307. * - VertexBuffer.UV6Kind
  105308. * - VertexBuffer.ColorKind
  105309. * - VertexBuffer.MatricesIndicesKind
  105310. * - VertexBuffer.MatricesIndicesExtraKind
  105311. * - VertexBuffer.MatricesWeightsKind
  105312. * - VertexBuffer.MatricesWeightsExtraKind
  105313. * @returns a boolean
  105314. */
  105315. isVerticesDataPresent(kind: string): boolean;
  105316. /**
  105317. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105318. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105319. * - VertexBuffer.PositionKind
  105320. * - VertexBuffer.UVKind
  105321. * - VertexBuffer.UV2Kind
  105322. * - VertexBuffer.UV3Kind
  105323. * - VertexBuffer.UV4Kind
  105324. * - VertexBuffer.UV5Kind
  105325. * - VertexBuffer.UV6Kind
  105326. * - VertexBuffer.ColorKind
  105327. * - VertexBuffer.MatricesIndicesKind
  105328. * - VertexBuffer.MatricesIndicesExtraKind
  105329. * - VertexBuffer.MatricesWeightsKind
  105330. * - VertexBuffer.MatricesWeightsExtraKind
  105331. * @returns a boolean
  105332. */
  105333. isVertexBufferUpdatable(kind: string): boolean;
  105334. /**
  105335. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105336. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105337. * - VertexBuffer.PositionKind
  105338. * - VertexBuffer.NormalKind
  105339. * - VertexBuffer.UVKind
  105340. * - VertexBuffer.UV2Kind
  105341. * - VertexBuffer.UV3Kind
  105342. * - VertexBuffer.UV4Kind
  105343. * - VertexBuffer.UV5Kind
  105344. * - VertexBuffer.UV6Kind
  105345. * - VertexBuffer.ColorKind
  105346. * - VertexBuffer.MatricesIndicesKind
  105347. * - VertexBuffer.MatricesIndicesExtraKind
  105348. * - VertexBuffer.MatricesWeightsKind
  105349. * - VertexBuffer.MatricesWeightsExtraKind
  105350. * @returns an array of strings
  105351. */
  105352. getVerticesDataKinds(): string[];
  105353. /**
  105354. * Returns a positive integer : the total number of indices in this mesh geometry.
  105355. * @returns the numner of indices or zero if the mesh has no geometry.
  105356. */
  105357. getTotalIndices(): number;
  105358. /**
  105359. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105360. * @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.
  105361. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105362. * @returns the indices array or an empty array if the mesh has no geometry
  105363. */
  105364. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105365. get isBlocked(): boolean;
  105366. /**
  105367. * Determine if the current mesh is ready to be rendered
  105368. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105369. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105370. * @returns true if all associated assets are ready (material, textures, shaders)
  105371. */
  105372. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105373. /**
  105374. * 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.
  105375. */
  105376. get areNormalsFrozen(): boolean;
  105377. /**
  105378. * 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.
  105379. * @returns the current mesh
  105380. */
  105381. freezeNormals(): Mesh;
  105382. /**
  105383. * 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
  105384. * @returns the current mesh
  105385. */
  105386. unfreezeNormals(): Mesh;
  105387. /**
  105388. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105389. */
  105390. set overridenInstanceCount(count: number);
  105391. /** @hidden */
  105392. _preActivate(): Mesh;
  105393. /** @hidden */
  105394. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105395. /** @hidden */
  105396. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105397. protected _afterComputeWorldMatrix(): void;
  105398. /** @hidden */
  105399. _postActivate(): void;
  105400. /**
  105401. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105402. * This means the mesh underlying bounding box and sphere are recomputed.
  105403. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105404. * @returns the current mesh
  105405. */
  105406. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105407. /** @hidden */
  105408. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105409. /**
  105410. * This function will subdivide the mesh into multiple submeshes
  105411. * @param count defines the expected number of submeshes
  105412. */
  105413. subdivide(count: number): void;
  105414. /**
  105415. * Copy a FloatArray into a specific associated vertex buffer
  105416. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105417. * - VertexBuffer.PositionKind
  105418. * - VertexBuffer.UVKind
  105419. * - VertexBuffer.UV2Kind
  105420. * - VertexBuffer.UV3Kind
  105421. * - VertexBuffer.UV4Kind
  105422. * - VertexBuffer.UV5Kind
  105423. * - VertexBuffer.UV6Kind
  105424. * - VertexBuffer.ColorKind
  105425. * - VertexBuffer.MatricesIndicesKind
  105426. * - VertexBuffer.MatricesIndicesExtraKind
  105427. * - VertexBuffer.MatricesWeightsKind
  105428. * - VertexBuffer.MatricesWeightsExtraKind
  105429. * @param data defines the data source
  105430. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105431. * @param stride defines the data stride size (can be null)
  105432. * @returns the current mesh
  105433. */
  105434. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105435. /**
  105436. * Delete a vertex buffer associated with this mesh
  105437. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105438. * - VertexBuffer.PositionKind
  105439. * - VertexBuffer.UVKind
  105440. * - VertexBuffer.UV2Kind
  105441. * - VertexBuffer.UV3Kind
  105442. * - VertexBuffer.UV4Kind
  105443. * - VertexBuffer.UV5Kind
  105444. * - VertexBuffer.UV6Kind
  105445. * - VertexBuffer.ColorKind
  105446. * - VertexBuffer.MatricesIndicesKind
  105447. * - VertexBuffer.MatricesIndicesExtraKind
  105448. * - VertexBuffer.MatricesWeightsKind
  105449. * - VertexBuffer.MatricesWeightsExtraKind
  105450. */
  105451. removeVerticesData(kind: string): void;
  105452. /**
  105453. * Flags an associated vertex buffer as updatable
  105454. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105455. * - VertexBuffer.PositionKind
  105456. * - VertexBuffer.UVKind
  105457. * - VertexBuffer.UV2Kind
  105458. * - VertexBuffer.UV3Kind
  105459. * - VertexBuffer.UV4Kind
  105460. * - VertexBuffer.UV5Kind
  105461. * - VertexBuffer.UV6Kind
  105462. * - VertexBuffer.ColorKind
  105463. * - VertexBuffer.MatricesIndicesKind
  105464. * - VertexBuffer.MatricesIndicesExtraKind
  105465. * - VertexBuffer.MatricesWeightsKind
  105466. * - VertexBuffer.MatricesWeightsExtraKind
  105467. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105468. */
  105469. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105470. /**
  105471. * Sets the mesh global Vertex Buffer
  105472. * @param buffer defines the buffer to use
  105473. * @returns the current mesh
  105474. */
  105475. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105476. /**
  105477. * Update a specific associated vertex buffer
  105478. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105479. * - VertexBuffer.PositionKind
  105480. * - VertexBuffer.UVKind
  105481. * - VertexBuffer.UV2Kind
  105482. * - VertexBuffer.UV3Kind
  105483. * - VertexBuffer.UV4Kind
  105484. * - VertexBuffer.UV5Kind
  105485. * - VertexBuffer.UV6Kind
  105486. * - VertexBuffer.ColorKind
  105487. * - VertexBuffer.MatricesIndicesKind
  105488. * - VertexBuffer.MatricesIndicesExtraKind
  105489. * - VertexBuffer.MatricesWeightsKind
  105490. * - VertexBuffer.MatricesWeightsExtraKind
  105491. * @param data defines the data source
  105492. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105493. * @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)
  105494. * @returns the current mesh
  105495. */
  105496. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105497. /**
  105498. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105499. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105500. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105501. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105502. * @returns the current mesh
  105503. */
  105504. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105505. /**
  105506. * Creates a un-shared specific occurence of the geometry for the mesh.
  105507. * @returns the current mesh
  105508. */
  105509. makeGeometryUnique(): Mesh;
  105510. /**
  105511. * Set the index buffer of this mesh
  105512. * @param indices defines the source data
  105513. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105514. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105515. * @returns the current mesh
  105516. */
  105517. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105518. /**
  105519. * Update the current index buffer
  105520. * @param indices defines the source data
  105521. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105522. * @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)
  105523. * @returns the current mesh
  105524. */
  105525. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105526. /**
  105527. * Invert the geometry to move from a right handed system to a left handed one.
  105528. * @returns the current mesh
  105529. */
  105530. toLeftHanded(): Mesh;
  105531. /** @hidden */
  105532. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105533. /** @hidden */
  105534. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105535. /**
  105536. * Registers for this mesh a javascript function called just before the rendering process
  105537. * @param func defines the function to call before rendering this mesh
  105538. * @returns the current mesh
  105539. */
  105540. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105541. /**
  105542. * Disposes a previously registered javascript function called before the rendering
  105543. * @param func defines the function to remove
  105544. * @returns the current mesh
  105545. */
  105546. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105547. /**
  105548. * Registers for this mesh a javascript function called just after the rendering is complete
  105549. * @param func defines the function to call after rendering this mesh
  105550. * @returns the current mesh
  105551. */
  105552. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105553. /**
  105554. * Disposes a previously registered javascript function called after the rendering.
  105555. * @param func defines the function to remove
  105556. * @returns the current mesh
  105557. */
  105558. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105559. /** @hidden */
  105560. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105561. /** @hidden */
  105562. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105563. /** @hidden */
  105564. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105565. /** @hidden */
  105566. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105567. /** @hidden */
  105568. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105569. /** @hidden */
  105570. _rebuild(): void;
  105571. /** @hidden */
  105572. _freeze(): void;
  105573. /** @hidden */
  105574. _unFreeze(): void;
  105575. /**
  105576. * 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
  105577. * @param subMesh defines the subMesh to render
  105578. * @param enableAlphaMode defines if alpha mode can be changed
  105579. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105580. * @returns the current mesh
  105581. */
  105582. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105583. private _onBeforeDraw;
  105584. /**
  105585. * Renormalize the mesh and patch it up if there are no weights
  105586. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105587. * However in the case of zero weights then we set just a single influence to 1.
  105588. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105589. */
  105590. cleanMatrixWeights(): void;
  105591. private normalizeSkinFourWeights;
  105592. private normalizeSkinWeightsAndExtra;
  105593. /**
  105594. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105595. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105596. * the user know there was an issue with importing the mesh
  105597. * @returns a validation object with skinned, valid and report string
  105598. */
  105599. validateSkinning(): {
  105600. skinned: boolean;
  105601. valid: boolean;
  105602. report: string;
  105603. };
  105604. /** @hidden */
  105605. _checkDelayState(): Mesh;
  105606. private _queueLoad;
  105607. /**
  105608. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105609. * A mesh is in the frustum if its bounding box intersects the frustum
  105610. * @param frustumPlanes defines the frustum to test
  105611. * @returns true if the mesh is in the frustum planes
  105612. */
  105613. isInFrustum(frustumPlanes: Plane[]): boolean;
  105614. /**
  105615. * Sets the mesh material by the material or multiMaterial `id` property
  105616. * @param id is a string identifying the material or the multiMaterial
  105617. * @returns the current mesh
  105618. */
  105619. setMaterialByID(id: string): Mesh;
  105620. /**
  105621. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105622. * @returns an array of IAnimatable
  105623. */
  105624. getAnimatables(): IAnimatable[];
  105625. /**
  105626. * Modifies the mesh geometry according to the passed transformation matrix.
  105627. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105628. * The mesh normals are modified using the same transformation.
  105629. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105630. * @param transform defines the transform matrix to use
  105631. * @see http://doc.babylonjs.com/resources/baking_transformations
  105632. * @returns the current mesh
  105633. */
  105634. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105635. /**
  105636. * Modifies the mesh geometry according to its own current World Matrix.
  105637. * The mesh World Matrix is then reset.
  105638. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105639. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105640. * @see http://doc.babylonjs.com/resources/baking_transformations
  105641. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105642. * @returns the current mesh
  105643. */
  105644. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105645. /** @hidden */
  105646. get _positions(): Nullable<Vector3[]>;
  105647. /** @hidden */
  105648. _resetPointsArrayCache(): Mesh;
  105649. /** @hidden */
  105650. _generatePointsArray(): boolean;
  105651. /**
  105652. * Returns a new Mesh object generated from the current mesh properties.
  105653. * This method must not get confused with createInstance()
  105654. * @param name is a string, the name given to the new mesh
  105655. * @param newParent can be any Node object (default `null`)
  105656. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105657. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105658. * @returns a new mesh
  105659. */
  105660. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105661. /**
  105662. * Releases resources associated with this mesh.
  105663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105665. */
  105666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105667. /** @hidden */
  105668. _disposeInstanceSpecificData(): void;
  105669. /** @hidden */
  105670. _disposeThinInstanceSpecificData(): void;
  105671. /**
  105672. * Modifies the mesh geometry according to a displacement map.
  105673. * 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.
  105674. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105675. * @param url is a string, the URL from the image file is to be downloaded.
  105676. * @param minHeight is the lower limit of the displacement.
  105677. * @param maxHeight is the upper limit of the displacement.
  105678. * @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.
  105679. * @param uvOffset is an optional vector2 used to offset UV.
  105680. * @param uvScale is an optional vector2 used to scale UV.
  105681. * @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.
  105682. * @returns the Mesh.
  105683. */
  105684. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105685. /**
  105686. * Modifies the mesh geometry according to a displacementMap buffer.
  105687. * 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.
  105688. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105689. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105690. * @param heightMapWidth is the width of the buffer image.
  105691. * @param heightMapHeight is the height of the buffer image.
  105692. * @param minHeight is the lower limit of the displacement.
  105693. * @param maxHeight is the upper limit of the displacement.
  105694. * @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.
  105695. * @param uvOffset is an optional vector2 used to offset UV.
  105696. * @param uvScale is an optional vector2 used to scale UV.
  105697. * @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.
  105698. * @returns the Mesh.
  105699. */
  105700. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105701. /**
  105702. * Modify the mesh to get a flat shading rendering.
  105703. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105704. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105705. * @returns current mesh
  105706. */
  105707. convertToFlatShadedMesh(): Mesh;
  105708. /**
  105709. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105710. * In other words, more vertices, no more indices and a single bigger VBO.
  105711. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105712. * @returns current mesh
  105713. */
  105714. convertToUnIndexedMesh(): Mesh;
  105715. /**
  105716. * Inverses facet orientations.
  105717. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105718. * @param flipNormals will also inverts the normals
  105719. * @returns current mesh
  105720. */
  105721. flipFaces(flipNormals?: boolean): Mesh;
  105722. /**
  105723. * Increase the number of facets and hence vertices in a mesh
  105724. * Vertex normals are interpolated from existing vertex normals
  105725. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105726. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105727. */
  105728. increaseVertices(numberPerEdge: number): void;
  105729. /**
  105730. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105731. * This will undo any application of covertToFlatShadedMesh
  105732. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105733. */
  105734. forceSharedVertices(): void;
  105735. /** @hidden */
  105736. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105737. /** @hidden */
  105738. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105739. /**
  105740. * Creates a new InstancedMesh object from the mesh model.
  105741. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105742. * @param name defines the name of the new instance
  105743. * @returns a new InstancedMesh
  105744. */
  105745. createInstance(name: string): InstancedMesh;
  105746. /**
  105747. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105748. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105749. * @returns the current mesh
  105750. */
  105751. synchronizeInstances(): Mesh;
  105752. /**
  105753. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105754. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105755. * This should be used together with the simplification to avoid disappearing triangles.
  105756. * @param successCallback an optional success callback to be called after the optimization finished.
  105757. * @returns the current mesh
  105758. */
  105759. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105760. /**
  105761. * Serialize current mesh
  105762. * @param serializationObject defines the object which will receive the serialization data
  105763. */
  105764. serialize(serializationObject: any): void;
  105765. /** @hidden */
  105766. _syncGeometryWithMorphTargetManager(): void;
  105767. /** @hidden */
  105768. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105769. /**
  105770. * Returns a new Mesh object parsed from the source provided.
  105771. * @param parsedMesh is the source
  105772. * @param scene defines the hosting scene
  105773. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105774. * @returns a new Mesh
  105775. */
  105776. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105777. /**
  105778. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105779. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105780. * @param name defines the name of the mesh to create
  105781. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105782. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105783. * @param closePath creates a seam between the first and the last points of each path of the path array
  105784. * @param offset is taken in account only if the `pathArray` is containing a single path
  105785. * @param scene defines the hosting scene
  105786. * @param updatable defines if the mesh must be flagged as updatable
  105787. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105788. * @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)
  105789. * @returns a new Mesh
  105790. */
  105791. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105792. /**
  105793. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105794. * @param name defines the name of the mesh to create
  105795. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105796. * @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
  105797. * @param scene defines the hosting scene
  105798. * @param updatable defines if the mesh must be flagged as updatable
  105799. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105800. * @returns a new Mesh
  105801. */
  105802. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105803. /**
  105804. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105805. * @param name defines the name of the mesh to create
  105806. * @param size sets the size (float) of each box side (default 1)
  105807. * @param scene defines the hosting scene
  105808. * @param updatable defines if the mesh must be flagged as updatable
  105809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105810. * @returns a new Mesh
  105811. */
  105812. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105813. /**
  105814. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105815. * @param name defines the name of the mesh to create
  105816. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105817. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105818. * @param scene defines the hosting scene
  105819. * @param updatable defines if the mesh must be flagged as updatable
  105820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105821. * @returns a new Mesh
  105822. */
  105823. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105824. /**
  105825. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105826. * @param name defines the name of the mesh to create
  105827. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105828. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105829. * @param scene defines the hosting scene
  105830. * @returns a new Mesh
  105831. */
  105832. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105833. /**
  105834. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105835. * @param name defines the name of the mesh to create
  105836. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105837. * @param diameterTop set the top cap diameter (floats, default 1)
  105838. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105839. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105840. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105841. * @param scene defines the hosting scene
  105842. * @param updatable defines if the mesh must be flagged as updatable
  105843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105844. * @returns a new Mesh
  105845. */
  105846. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105847. /**
  105848. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105849. * @param name defines the name of the mesh to create
  105850. * @param diameter sets the diameter size (float) of the torus (default 1)
  105851. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105852. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105853. * @param scene defines the hosting scene
  105854. * @param updatable defines if the mesh must be flagged as updatable
  105855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105856. * @returns a new Mesh
  105857. */
  105858. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105859. /**
  105860. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105861. * @param name defines the name of the mesh to create
  105862. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105863. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105864. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105865. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105866. * @param p the number of windings on X axis (positive integers, default 2)
  105867. * @param q the number of windings on Y axis (positive integers, default 3)
  105868. * @param scene defines the hosting scene
  105869. * @param updatable defines if the mesh must be flagged as updatable
  105870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105871. * @returns a new Mesh
  105872. */
  105873. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105874. /**
  105875. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105876. * @param name defines the name of the mesh to create
  105877. * @param points is an array successive Vector3
  105878. * @param scene defines the hosting scene
  105879. * @param updatable defines if the mesh must be flagged as updatable
  105880. * @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).
  105881. * @returns a new Mesh
  105882. */
  105883. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105884. /**
  105885. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105886. * @param name defines the name of the mesh to create
  105887. * @param points is an array successive Vector3
  105888. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105889. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105890. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105891. * @param scene defines the hosting scene
  105892. * @param updatable defines if the mesh must be flagged as updatable
  105893. * @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)
  105894. * @returns a new Mesh
  105895. */
  105896. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105897. /**
  105898. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105899. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105900. * 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.
  105901. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105902. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105903. * Remember you can only change the shape positions, not their number when updating a polygon.
  105904. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105905. * @param name defines the name of the mesh to create
  105906. * @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
  105907. * @param scene defines the hosting scene
  105908. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105909. * @param updatable defines if the mesh must be flagged as updatable
  105910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105911. * @param earcutInjection can be used to inject your own earcut reference
  105912. * @returns a new Mesh
  105913. */
  105914. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105915. /**
  105916. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105917. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105918. * @param name defines the name of the mesh to create
  105919. * @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
  105920. * @param depth defines the height of extrusion
  105921. * @param scene defines the hosting scene
  105922. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105923. * @param updatable defines if the mesh must be flagged as updatable
  105924. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105925. * @param earcutInjection can be used to inject your own earcut reference
  105926. * @returns a new Mesh
  105927. */
  105928. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105929. /**
  105930. * Creates an extruded shape mesh.
  105931. * 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
  105932. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105933. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105934. * @param name defines the name of the mesh to create
  105935. * @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
  105936. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105937. * @param scale is the value to scale the shape
  105938. * @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
  105939. * @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
  105940. * @param scene defines the hosting scene
  105941. * @param updatable defines if the mesh must be flagged as updatable
  105942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105943. * @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)
  105944. * @returns a new Mesh
  105945. */
  105946. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105947. /**
  105948. * Creates an custom extruded shape mesh.
  105949. * The custom extrusion is a parametric shape.
  105950. * It has no predefined shape. Its final shape will depend on the input parameters.
  105951. * Please consider using the same method from the MeshBuilder class instead
  105952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105953. * @param name defines the name of the mesh to create
  105954. * @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
  105955. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105956. * @param scaleFunction is a custom Javascript function called on each path point
  105957. * @param rotationFunction is a custom Javascript function called on each path point
  105958. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105959. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105960. * @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
  105961. * @param scene defines the hosting scene
  105962. * @param updatable defines if the mesh must be flagged as updatable
  105963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105964. * @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)
  105965. * @returns a new Mesh
  105966. */
  105967. 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;
  105968. /**
  105969. * Creates lathe mesh.
  105970. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105971. * Please consider using the same method from the MeshBuilder class instead
  105972. * @param name defines the name of the mesh to create
  105973. * @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
  105974. * @param radius is the radius value of the lathe
  105975. * @param tessellation is the side number of the lathe.
  105976. * @param scene defines the hosting scene
  105977. * @param updatable defines if the mesh must be flagged as updatable
  105978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105979. * @returns a new Mesh
  105980. */
  105981. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105982. /**
  105983. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105984. * @param name defines the name of the mesh to create
  105985. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105986. * @param scene defines the hosting scene
  105987. * @param updatable defines if the mesh must be flagged as updatable
  105988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105989. * @returns a new Mesh
  105990. */
  105991. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105992. /**
  105993. * Creates a ground mesh.
  105994. * Please consider using the same method from the MeshBuilder class instead
  105995. * @param name defines the name of the mesh to create
  105996. * @param width set the width of the ground
  105997. * @param height set the height of the ground
  105998. * @param subdivisions sets the number of subdivisions per side
  105999. * @param scene defines the hosting scene
  106000. * @param updatable defines if the mesh must be flagged as updatable
  106001. * @returns a new Mesh
  106002. */
  106003. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106004. /**
  106005. * Creates a tiled ground mesh.
  106006. * Please consider using the same method from the MeshBuilder class instead
  106007. * @param name defines the name of the mesh to create
  106008. * @param xmin set the ground minimum X coordinate
  106009. * @param zmin set the ground minimum Y coordinate
  106010. * @param xmax set the ground maximum X coordinate
  106011. * @param zmax set the ground maximum Z coordinate
  106012. * @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
  106013. * @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
  106014. * @param scene defines the hosting scene
  106015. * @param updatable defines if the mesh must be flagged as updatable
  106016. * @returns a new Mesh
  106017. */
  106018. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106019. w: number;
  106020. h: number;
  106021. }, precision: {
  106022. w: number;
  106023. h: number;
  106024. }, scene: Scene, updatable?: boolean): Mesh;
  106025. /**
  106026. * Creates a ground mesh from a height map.
  106027. * Please consider using the same method from the MeshBuilder class instead
  106028. * @see http://doc.babylonjs.com/babylon101/height_map
  106029. * @param name defines the name of the mesh to create
  106030. * @param url sets the URL of the height map image resource
  106031. * @param width set the ground width size
  106032. * @param height set the ground height size
  106033. * @param subdivisions sets the number of subdivision per side
  106034. * @param minHeight is the minimum altitude on the ground
  106035. * @param maxHeight is the maximum altitude on the ground
  106036. * @param scene defines the hosting scene
  106037. * @param updatable defines if the mesh must be flagged as updatable
  106038. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106039. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106040. * @returns a new Mesh
  106041. */
  106042. 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;
  106043. /**
  106044. * Creates a tube mesh.
  106045. * The tube is a parametric shape.
  106046. * It has no predefined shape. Its final shape will depend on the input parameters.
  106047. * Please consider using the same method from the MeshBuilder class instead
  106048. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  106049. * @param name defines the name of the mesh to create
  106050. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106051. * @param radius sets the tube radius size
  106052. * @param tessellation is the number of sides on the tubular surface
  106053. * @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
  106054. * @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
  106055. * @param scene defines the hosting scene
  106056. * @param updatable defines if the mesh must be flagged as updatable
  106057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106058. * @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)
  106059. * @returns a new Mesh
  106060. */
  106061. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106062. (i: number, distance: number): number;
  106063. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106064. /**
  106065. * Creates a polyhedron mesh.
  106066. * Please consider using the same method from the MeshBuilder class instead.
  106067. * * 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
  106068. * * The parameter `size` (positive float, default 1) sets the polygon size
  106069. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106070. * * 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`
  106071. * * 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
  106072. * * 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)`)
  106073. * * 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
  106074. * * 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
  106075. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106076. * * If you create a double-sided mesh, you can choose what parts of 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
  106077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106078. * @param name defines the name of the mesh to create
  106079. * @param options defines the options used to create the mesh
  106080. * @param scene defines the hosting scene
  106081. * @returns a new Mesh
  106082. */
  106083. static CreatePolyhedron(name: string, options: {
  106084. type?: number;
  106085. size?: number;
  106086. sizeX?: number;
  106087. sizeY?: number;
  106088. sizeZ?: number;
  106089. custom?: any;
  106090. faceUV?: Vector4[];
  106091. faceColors?: Color4[];
  106092. updatable?: boolean;
  106093. sideOrientation?: number;
  106094. }, scene: Scene): Mesh;
  106095. /**
  106096. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106097. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106098. * * 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`)
  106099. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106100. * * 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
  106101. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106102. * * If you create a double-sided mesh, you can choose what parts of 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
  106103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106104. * @param name defines the name of the mesh
  106105. * @param options defines the options used to create the mesh
  106106. * @param scene defines the hosting scene
  106107. * @returns a new Mesh
  106108. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106109. */
  106110. static CreateIcoSphere(name: string, options: {
  106111. radius?: number;
  106112. flat?: boolean;
  106113. subdivisions?: number;
  106114. sideOrientation?: number;
  106115. updatable?: boolean;
  106116. }, scene: Scene): Mesh;
  106117. /**
  106118. * Creates a decal mesh.
  106119. * Please consider using the same method from the MeshBuilder class instead.
  106120. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106121. * @param name defines the name of the mesh
  106122. * @param sourceMesh defines the mesh receiving the decal
  106123. * @param position sets the position of the decal in world coordinates
  106124. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106125. * @param size sets the decal scaling
  106126. * @param angle sets the angle to rotate the decal
  106127. * @returns a new Mesh
  106128. */
  106129. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106130. /**
  106131. * Prepare internal position array for software CPU skinning
  106132. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106133. */
  106134. setPositionsForCPUSkinning(): Float32Array;
  106135. /**
  106136. * Prepare internal normal array for software CPU skinning
  106137. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106138. */
  106139. setNormalsForCPUSkinning(): Float32Array;
  106140. /**
  106141. * Updates the vertex buffer by applying transformation from the bones
  106142. * @param skeleton defines the skeleton to apply to current mesh
  106143. * @returns the current mesh
  106144. */
  106145. applySkeleton(skeleton: Skeleton): Mesh;
  106146. /**
  106147. * 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
  106148. * @param meshes defines the list of meshes to scan
  106149. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106150. */
  106151. static MinMax(meshes: AbstractMesh[]): {
  106152. min: Vector3;
  106153. max: Vector3;
  106154. };
  106155. /**
  106156. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106157. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106158. * @returns a vector3
  106159. */
  106160. static Center(meshesOrMinMaxVector: {
  106161. min: Vector3;
  106162. max: Vector3;
  106163. } | AbstractMesh[]): Vector3;
  106164. /**
  106165. * Merge the array of meshes into a single mesh for performance reasons.
  106166. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106167. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106168. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106169. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106170. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106171. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106172. * @returns a new mesh
  106173. */
  106174. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106175. /** @hidden */
  106176. addInstance(instance: InstancedMesh): void;
  106177. /** @hidden */
  106178. removeInstance(instance: InstancedMesh): void;
  106179. }
  106180. }
  106181. declare module BABYLON {
  106182. /**
  106183. * This is the base class of all the camera used in the application.
  106184. * @see http://doc.babylonjs.com/features/cameras
  106185. */
  106186. export class Camera extends Node {
  106187. /** @hidden */
  106188. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106189. /**
  106190. * This is the default projection mode used by the cameras.
  106191. * It helps recreating a feeling of perspective and better appreciate depth.
  106192. * This is the best way to simulate real life cameras.
  106193. */
  106194. static readonly PERSPECTIVE_CAMERA: number;
  106195. /**
  106196. * This helps creating camera with an orthographic mode.
  106197. * 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.
  106198. */
  106199. static readonly ORTHOGRAPHIC_CAMERA: number;
  106200. /**
  106201. * This is the default FOV mode for perspective cameras.
  106202. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106203. */
  106204. static readonly FOVMODE_VERTICAL_FIXED: number;
  106205. /**
  106206. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106207. */
  106208. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106209. /**
  106210. * This specifies ther is no need for a camera rig.
  106211. * Basically only one eye is rendered corresponding to the camera.
  106212. */
  106213. static readonly RIG_MODE_NONE: number;
  106214. /**
  106215. * Simulates a camera Rig with one blue eye and one red eye.
  106216. * This can be use with 3d blue and red glasses.
  106217. */
  106218. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106219. /**
  106220. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106221. */
  106222. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106223. /**
  106224. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106225. */
  106226. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106227. /**
  106228. * Defines that both eyes of the camera will be rendered over under each other.
  106229. */
  106230. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106231. /**
  106232. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106233. */
  106234. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106235. /**
  106236. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106237. */
  106238. static readonly RIG_MODE_VR: number;
  106239. /**
  106240. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106241. */
  106242. static readonly RIG_MODE_WEBVR: number;
  106243. /**
  106244. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106245. */
  106246. static readonly RIG_MODE_CUSTOM: number;
  106247. /**
  106248. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106249. */
  106250. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106251. /**
  106252. * Define the input manager associated with the camera.
  106253. */
  106254. inputs: CameraInputsManager<Camera>;
  106255. /** @hidden */
  106256. _position: Vector3;
  106257. /**
  106258. * Define the current local position of the camera in the scene
  106259. */
  106260. get position(): Vector3;
  106261. set position(newPosition: Vector3);
  106262. /**
  106263. * The vector the camera should consider as up.
  106264. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106265. */
  106266. upVector: Vector3;
  106267. /**
  106268. * Define the current limit on the left side for an orthographic camera
  106269. * In scene unit
  106270. */
  106271. orthoLeft: Nullable<number>;
  106272. /**
  106273. * Define the current limit on the right side for an orthographic camera
  106274. * In scene unit
  106275. */
  106276. orthoRight: Nullable<number>;
  106277. /**
  106278. * Define the current limit on the bottom side for an orthographic camera
  106279. * In scene unit
  106280. */
  106281. orthoBottom: Nullable<number>;
  106282. /**
  106283. * Define the current limit on the top side for an orthographic camera
  106284. * In scene unit
  106285. */
  106286. orthoTop: Nullable<number>;
  106287. /**
  106288. * Field Of View is set in Radians. (default is 0.8)
  106289. */
  106290. fov: number;
  106291. /**
  106292. * Define the minimum distance the camera can see from.
  106293. * This is important to note that the depth buffer are not infinite and the closer it starts
  106294. * the more your scene might encounter depth fighting issue.
  106295. */
  106296. minZ: number;
  106297. /**
  106298. * Define the maximum distance the camera can see to.
  106299. * This is important to note that the depth buffer are not infinite and the further it end
  106300. * the more your scene might encounter depth fighting issue.
  106301. */
  106302. maxZ: number;
  106303. /**
  106304. * Define the default inertia of the camera.
  106305. * This helps giving a smooth feeling to the camera movement.
  106306. */
  106307. inertia: number;
  106308. /**
  106309. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106310. */
  106311. mode: number;
  106312. /**
  106313. * Define whether the camera is intermediate.
  106314. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106315. */
  106316. isIntermediate: boolean;
  106317. /**
  106318. * Define the viewport of the camera.
  106319. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106320. */
  106321. viewport: Viewport;
  106322. /**
  106323. * Restricts the camera to viewing objects with the same layerMask.
  106324. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106325. */
  106326. layerMask: number;
  106327. /**
  106328. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106329. */
  106330. fovMode: number;
  106331. /**
  106332. * Rig mode of the camera.
  106333. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106334. * This is normally controlled byt the camera themselves as internal use.
  106335. */
  106336. cameraRigMode: number;
  106337. /**
  106338. * Defines the distance between both "eyes" in case of a RIG
  106339. */
  106340. interaxialDistance: number;
  106341. /**
  106342. * Defines if stereoscopic rendering is done side by side or over under.
  106343. */
  106344. isStereoscopicSideBySide: boolean;
  106345. /**
  106346. * 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
  106347. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106348. * else in the scene. (Eg. security camera)
  106349. *
  106350. * 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)
  106351. */
  106352. customRenderTargets: RenderTargetTexture[];
  106353. /**
  106354. * When set, the camera will render to this render target instead of the default canvas
  106355. *
  106356. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106357. */
  106358. outputRenderTarget: Nullable<RenderTargetTexture>;
  106359. /**
  106360. * Observable triggered when the camera view matrix has changed.
  106361. */
  106362. onViewMatrixChangedObservable: Observable<Camera>;
  106363. /**
  106364. * Observable triggered when the camera Projection matrix has changed.
  106365. */
  106366. onProjectionMatrixChangedObservable: Observable<Camera>;
  106367. /**
  106368. * Observable triggered when the inputs have been processed.
  106369. */
  106370. onAfterCheckInputsObservable: Observable<Camera>;
  106371. /**
  106372. * Observable triggered when reset has been called and applied to the camera.
  106373. */
  106374. onRestoreStateObservable: Observable<Camera>;
  106375. /**
  106376. * Is this camera a part of a rig system?
  106377. */
  106378. isRigCamera: boolean;
  106379. /**
  106380. * If isRigCamera set to true this will be set with the parent camera.
  106381. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106382. */
  106383. rigParent?: Camera;
  106384. /** @hidden */
  106385. _cameraRigParams: any;
  106386. /** @hidden */
  106387. _rigCameras: Camera[];
  106388. /** @hidden */
  106389. _rigPostProcess: Nullable<PostProcess>;
  106390. protected _webvrViewMatrix: Matrix;
  106391. /** @hidden */
  106392. _skipRendering: boolean;
  106393. /** @hidden */
  106394. _projectionMatrix: Matrix;
  106395. /** @hidden */
  106396. _postProcesses: Nullable<PostProcess>[];
  106397. /** @hidden */
  106398. _activeMeshes: SmartArray<AbstractMesh>;
  106399. protected _globalPosition: Vector3;
  106400. /** @hidden */
  106401. _computedViewMatrix: Matrix;
  106402. private _doNotComputeProjectionMatrix;
  106403. private _transformMatrix;
  106404. private _frustumPlanes;
  106405. private _refreshFrustumPlanes;
  106406. private _storedFov;
  106407. private _stateStored;
  106408. /**
  106409. * Instantiates a new camera object.
  106410. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106411. * @see http://doc.babylonjs.com/features/cameras
  106412. * @param name Defines the name of the camera in the scene
  106413. * @param position Defines the position of the camera
  106414. * @param scene Defines the scene the camera belongs too
  106415. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106416. */
  106417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106418. /**
  106419. * Store current camera state (fov, position, etc..)
  106420. * @returns the camera
  106421. */
  106422. storeState(): Camera;
  106423. /**
  106424. * Restores the camera state values if it has been stored. You must call storeState() first
  106425. */
  106426. protected _restoreStateValues(): boolean;
  106427. /**
  106428. * Restored camera state. You must call storeState() first.
  106429. * @returns true if restored and false otherwise
  106430. */
  106431. restoreState(): boolean;
  106432. /**
  106433. * Gets the class name of the camera.
  106434. * @returns the class name
  106435. */
  106436. getClassName(): string;
  106437. /** @hidden */
  106438. readonly _isCamera: boolean;
  106439. /**
  106440. * Gets a string representation of the camera useful for debug purpose.
  106441. * @param fullDetails Defines that a more verboe level of logging is required
  106442. * @returns the string representation
  106443. */
  106444. toString(fullDetails?: boolean): string;
  106445. /**
  106446. * Gets the current world space position of the camera.
  106447. */
  106448. get globalPosition(): Vector3;
  106449. /**
  106450. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106451. * @returns the active meshe list
  106452. */
  106453. getActiveMeshes(): SmartArray<AbstractMesh>;
  106454. /**
  106455. * Check whether a mesh is part of the current active mesh list of the camera
  106456. * @param mesh Defines the mesh to check
  106457. * @returns true if active, false otherwise
  106458. */
  106459. isActiveMesh(mesh: Mesh): boolean;
  106460. /**
  106461. * Is this camera ready to be used/rendered
  106462. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106463. * @return true if the camera is ready
  106464. */
  106465. isReady(completeCheck?: boolean): boolean;
  106466. /** @hidden */
  106467. _initCache(): void;
  106468. /** @hidden */
  106469. _updateCache(ignoreParentClass?: boolean): void;
  106470. /** @hidden */
  106471. _isSynchronized(): boolean;
  106472. /** @hidden */
  106473. _isSynchronizedViewMatrix(): boolean;
  106474. /** @hidden */
  106475. _isSynchronizedProjectionMatrix(): boolean;
  106476. /**
  106477. * Attach the input controls to a specific dom element to get the input from.
  106478. * @param element Defines the element the controls should be listened from
  106479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106480. */
  106481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106482. /**
  106483. * Detach the current controls from the specified dom element.
  106484. * @param element Defines the element to stop listening the inputs from
  106485. */
  106486. detachControl(element: HTMLElement): void;
  106487. /**
  106488. * Update the camera state according to the different inputs gathered during the frame.
  106489. */
  106490. update(): void;
  106491. /** @hidden */
  106492. _checkInputs(): void;
  106493. /** @hidden */
  106494. get rigCameras(): Camera[];
  106495. /**
  106496. * Gets the post process used by the rig cameras
  106497. */
  106498. get rigPostProcess(): Nullable<PostProcess>;
  106499. /**
  106500. * Internal, gets the first post proces.
  106501. * @returns the first post process to be run on this camera.
  106502. */
  106503. _getFirstPostProcess(): Nullable<PostProcess>;
  106504. private _cascadePostProcessesToRigCams;
  106505. /**
  106506. * Attach a post process to the camera.
  106507. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106508. * @param postProcess The post process to attach to the camera
  106509. * @param insertAt The position of the post process in case several of them are in use in the scene
  106510. * @returns the position the post process has been inserted at
  106511. */
  106512. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106513. /**
  106514. * Detach a post process to the camera.
  106515. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106516. * @param postProcess The post process to detach from the camera
  106517. */
  106518. detachPostProcess(postProcess: PostProcess): void;
  106519. /**
  106520. * Gets the current world matrix of the camera
  106521. */
  106522. getWorldMatrix(): Matrix;
  106523. /** @hidden */
  106524. _getViewMatrix(): Matrix;
  106525. /**
  106526. * Gets the current view matrix of the camera.
  106527. * @param force forces the camera to recompute the matrix without looking at the cached state
  106528. * @returns the view matrix
  106529. */
  106530. getViewMatrix(force?: boolean): Matrix;
  106531. /**
  106532. * Freeze the projection matrix.
  106533. * It will prevent the cache check of the camera projection compute and can speed up perf
  106534. * if no parameter of the camera are meant to change
  106535. * @param projection Defines manually a projection if necessary
  106536. */
  106537. freezeProjectionMatrix(projection?: Matrix): void;
  106538. /**
  106539. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106540. */
  106541. unfreezeProjectionMatrix(): void;
  106542. /**
  106543. * Gets the current projection matrix of the camera.
  106544. * @param force forces the camera to recompute the matrix without looking at the cached state
  106545. * @returns the projection matrix
  106546. */
  106547. getProjectionMatrix(force?: boolean): Matrix;
  106548. /**
  106549. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106550. * @returns a Matrix
  106551. */
  106552. getTransformationMatrix(): Matrix;
  106553. private _updateFrustumPlanes;
  106554. /**
  106555. * Checks if a cullable object (mesh...) is in the camera frustum
  106556. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106557. * @param target The object to check
  106558. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106559. * @returns true if the object is in frustum otherwise false
  106560. */
  106561. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106562. /**
  106563. * Checks if a cullable object (mesh...) is in the camera frustum
  106564. * Unlike isInFrustum this cheks the full bounding box
  106565. * @param target The object to check
  106566. * @returns true if the object is in frustum otherwise false
  106567. */
  106568. isCompletelyInFrustum(target: ICullable): boolean;
  106569. /**
  106570. * Gets a ray in the forward direction from the camera.
  106571. * @param length Defines the length of the ray to create
  106572. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106573. * @param origin Defines the start point of the ray which defaults to the camera position
  106574. * @returns the forward ray
  106575. */
  106576. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106577. /**
  106578. * Releases resources associated with this node.
  106579. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106580. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106581. */
  106582. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106583. /** @hidden */
  106584. _isLeftCamera: boolean;
  106585. /**
  106586. * Gets the left camera of a rig setup in case of Rigged Camera
  106587. */
  106588. get isLeftCamera(): boolean;
  106589. /** @hidden */
  106590. _isRightCamera: boolean;
  106591. /**
  106592. * Gets the right camera of a rig setup in case of Rigged Camera
  106593. */
  106594. get isRightCamera(): boolean;
  106595. /**
  106596. * Gets the left camera of a rig setup in case of Rigged Camera
  106597. */
  106598. get leftCamera(): Nullable<FreeCamera>;
  106599. /**
  106600. * Gets the right camera of a rig setup in case of Rigged Camera
  106601. */
  106602. get rightCamera(): Nullable<FreeCamera>;
  106603. /**
  106604. * Gets the left camera target of a rig setup in case of Rigged Camera
  106605. * @returns the target position
  106606. */
  106607. getLeftTarget(): Nullable<Vector3>;
  106608. /**
  106609. * Gets the right camera target of a rig setup in case of Rigged Camera
  106610. * @returns the target position
  106611. */
  106612. getRightTarget(): Nullable<Vector3>;
  106613. /**
  106614. * @hidden
  106615. */
  106616. setCameraRigMode(mode: number, rigParams: any): void;
  106617. /** @hidden */
  106618. static _setStereoscopicRigMode(camera: Camera): void;
  106619. /** @hidden */
  106620. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106621. /** @hidden */
  106622. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106623. /** @hidden */
  106624. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106625. /** @hidden */
  106626. _getVRProjectionMatrix(): Matrix;
  106627. protected _updateCameraRotationMatrix(): void;
  106628. protected _updateWebVRCameraRotationMatrix(): void;
  106629. /**
  106630. * This function MUST be overwritten by the different WebVR cameras available.
  106631. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106632. * @hidden
  106633. */
  106634. _getWebVRProjectionMatrix(): Matrix;
  106635. /**
  106636. * This function MUST be overwritten by the different WebVR cameras available.
  106637. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106638. * @hidden
  106639. */
  106640. _getWebVRViewMatrix(): Matrix;
  106641. /** @hidden */
  106642. setCameraRigParameter(name: string, value: any): void;
  106643. /**
  106644. * needs to be overridden by children so sub has required properties to be copied
  106645. * @hidden
  106646. */
  106647. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106648. /**
  106649. * May need to be overridden by children
  106650. * @hidden
  106651. */
  106652. _updateRigCameras(): void;
  106653. /** @hidden */
  106654. _setupInputs(): void;
  106655. /**
  106656. * Serialiaze the camera setup to a json represention
  106657. * @returns the JSON representation
  106658. */
  106659. serialize(): any;
  106660. /**
  106661. * Clones the current camera.
  106662. * @param name The cloned camera name
  106663. * @returns the cloned camera
  106664. */
  106665. clone(name: string): Camera;
  106666. /**
  106667. * Gets the direction of the camera relative to a given local axis.
  106668. * @param localAxis Defines the reference axis to provide a relative direction.
  106669. * @return the direction
  106670. */
  106671. getDirection(localAxis: Vector3): Vector3;
  106672. /**
  106673. * Returns the current camera absolute rotation
  106674. */
  106675. get absoluteRotation(): Quaternion;
  106676. /**
  106677. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106678. * @param localAxis Defines the reference axis to provide a relative direction.
  106679. * @param result Defines the vector to store the result in
  106680. */
  106681. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106682. /**
  106683. * Gets a camera constructor for a given camera type
  106684. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106685. * @param name The name of the camera the result will be able to instantiate
  106686. * @param scene The scene the result will construct the camera in
  106687. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106688. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106689. * @returns a factory method to construc the camera
  106690. */
  106691. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106692. /**
  106693. * Compute the world matrix of the camera.
  106694. * @returns the camera world matrix
  106695. */
  106696. computeWorldMatrix(): Matrix;
  106697. /**
  106698. * Parse a JSON and creates the camera from the parsed information
  106699. * @param parsedCamera The JSON to parse
  106700. * @param scene The scene to instantiate the camera in
  106701. * @returns the newly constructed camera
  106702. */
  106703. static Parse(parsedCamera: any, scene: Scene): Camera;
  106704. }
  106705. }
  106706. declare module BABYLON {
  106707. /**
  106708. * Class containing static functions to help procedurally build meshes
  106709. */
  106710. export class DiscBuilder {
  106711. /**
  106712. * Creates a plane polygonal mesh. By default, this is a disc
  106713. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106714. * * 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
  106715. * * 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
  106716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106719. * @param name defines the name of the mesh
  106720. * @param options defines the options used to create the mesh
  106721. * @param scene defines the hosting scene
  106722. * @returns the plane polygonal mesh
  106723. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106724. */
  106725. static CreateDisc(name: string, options: {
  106726. radius?: number;
  106727. tessellation?: number;
  106728. arc?: number;
  106729. updatable?: boolean;
  106730. sideOrientation?: number;
  106731. frontUVs?: Vector4;
  106732. backUVs?: Vector4;
  106733. }, scene?: Nullable<Scene>): Mesh;
  106734. }
  106735. }
  106736. declare module BABYLON {
  106737. /**
  106738. * Options to be used when creating a FresnelParameters.
  106739. */
  106740. export type IFresnelParametersCreationOptions = {
  106741. /**
  106742. * Define the color used on edges (grazing angle)
  106743. */
  106744. leftColor?: Color3;
  106745. /**
  106746. * Define the color used on center
  106747. */
  106748. rightColor?: Color3;
  106749. /**
  106750. * Define bias applied to computed fresnel term
  106751. */
  106752. bias?: number;
  106753. /**
  106754. * Defined the power exponent applied to fresnel term
  106755. */
  106756. power?: number;
  106757. /**
  106758. * Define if the fresnel effect is enable or not.
  106759. */
  106760. isEnabled?: boolean;
  106761. };
  106762. /**
  106763. * Serialized format for FresnelParameters.
  106764. */
  106765. export type IFresnelParametersSerialized = {
  106766. /**
  106767. * Define the color used on edges (grazing angle) [as an array]
  106768. */
  106769. leftColor: number[];
  106770. /**
  106771. * Define the color used on center [as an array]
  106772. */
  106773. rightColor: number[];
  106774. /**
  106775. * Define bias applied to computed fresnel term
  106776. */
  106777. bias: number;
  106778. /**
  106779. * Defined the power exponent applied to fresnel term
  106780. */
  106781. power?: number;
  106782. /**
  106783. * Define if the fresnel effect is enable or not.
  106784. */
  106785. isEnabled: boolean;
  106786. };
  106787. /**
  106788. * This represents all the required information to add a fresnel effect on a material:
  106789. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106790. */
  106791. export class FresnelParameters {
  106792. private _isEnabled;
  106793. /**
  106794. * Define if the fresnel effect is enable or not.
  106795. */
  106796. get isEnabled(): boolean;
  106797. set isEnabled(value: boolean);
  106798. /**
  106799. * Define the color used on edges (grazing angle)
  106800. */
  106801. leftColor: Color3;
  106802. /**
  106803. * Define the color used on center
  106804. */
  106805. rightColor: Color3;
  106806. /**
  106807. * Define bias applied to computed fresnel term
  106808. */
  106809. bias: number;
  106810. /**
  106811. * Defined the power exponent applied to fresnel term
  106812. */
  106813. power: number;
  106814. /**
  106815. * Creates a new FresnelParameters object.
  106816. *
  106817. * @param options provide your own settings to optionally to override defaults
  106818. */
  106819. constructor(options?: IFresnelParametersCreationOptions);
  106820. /**
  106821. * Clones the current fresnel and its valuues
  106822. * @returns a clone fresnel configuration
  106823. */
  106824. clone(): FresnelParameters;
  106825. /**
  106826. * Determines equality between FresnelParameters objects
  106827. * @param otherFresnelParameters defines the second operand
  106828. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106829. */
  106830. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106831. /**
  106832. * Serializes the current fresnel parameters to a JSON representation.
  106833. * @return the JSON serialization
  106834. */
  106835. serialize(): IFresnelParametersSerialized;
  106836. /**
  106837. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106838. * @param parsedFresnelParameters Define the JSON representation
  106839. * @returns the parsed parameters
  106840. */
  106841. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106842. }
  106843. }
  106844. declare module BABYLON {
  106845. /**
  106846. * This groups all the flags used to control the materials channel.
  106847. */
  106848. export class MaterialFlags {
  106849. private static _DiffuseTextureEnabled;
  106850. /**
  106851. * Are diffuse textures enabled in the application.
  106852. */
  106853. static get DiffuseTextureEnabled(): boolean;
  106854. static set DiffuseTextureEnabled(value: boolean);
  106855. private static _DetailTextureEnabled;
  106856. /**
  106857. * Are detail textures enabled in the application.
  106858. */
  106859. static get DetailTextureEnabled(): boolean;
  106860. static set DetailTextureEnabled(value: boolean);
  106861. private static _AmbientTextureEnabled;
  106862. /**
  106863. * Are ambient textures enabled in the application.
  106864. */
  106865. static get AmbientTextureEnabled(): boolean;
  106866. static set AmbientTextureEnabled(value: boolean);
  106867. private static _OpacityTextureEnabled;
  106868. /**
  106869. * Are opacity textures enabled in the application.
  106870. */
  106871. static get OpacityTextureEnabled(): boolean;
  106872. static set OpacityTextureEnabled(value: boolean);
  106873. private static _ReflectionTextureEnabled;
  106874. /**
  106875. * Are reflection textures enabled in the application.
  106876. */
  106877. static get ReflectionTextureEnabled(): boolean;
  106878. static set ReflectionTextureEnabled(value: boolean);
  106879. private static _EmissiveTextureEnabled;
  106880. /**
  106881. * Are emissive textures enabled in the application.
  106882. */
  106883. static get EmissiveTextureEnabled(): boolean;
  106884. static set EmissiveTextureEnabled(value: boolean);
  106885. private static _SpecularTextureEnabled;
  106886. /**
  106887. * Are specular textures enabled in the application.
  106888. */
  106889. static get SpecularTextureEnabled(): boolean;
  106890. static set SpecularTextureEnabled(value: boolean);
  106891. private static _BumpTextureEnabled;
  106892. /**
  106893. * Are bump textures enabled in the application.
  106894. */
  106895. static get BumpTextureEnabled(): boolean;
  106896. static set BumpTextureEnabled(value: boolean);
  106897. private static _LightmapTextureEnabled;
  106898. /**
  106899. * Are lightmap textures enabled in the application.
  106900. */
  106901. static get LightmapTextureEnabled(): boolean;
  106902. static set LightmapTextureEnabled(value: boolean);
  106903. private static _RefractionTextureEnabled;
  106904. /**
  106905. * Are refraction textures enabled in the application.
  106906. */
  106907. static get RefractionTextureEnabled(): boolean;
  106908. static set RefractionTextureEnabled(value: boolean);
  106909. private static _ColorGradingTextureEnabled;
  106910. /**
  106911. * Are color grading textures enabled in the application.
  106912. */
  106913. static get ColorGradingTextureEnabled(): boolean;
  106914. static set ColorGradingTextureEnabled(value: boolean);
  106915. private static _FresnelEnabled;
  106916. /**
  106917. * Are fresnels enabled in the application.
  106918. */
  106919. static get FresnelEnabled(): boolean;
  106920. static set FresnelEnabled(value: boolean);
  106921. private static _ClearCoatTextureEnabled;
  106922. /**
  106923. * Are clear coat textures enabled in the application.
  106924. */
  106925. static get ClearCoatTextureEnabled(): boolean;
  106926. static set ClearCoatTextureEnabled(value: boolean);
  106927. private static _ClearCoatBumpTextureEnabled;
  106928. /**
  106929. * Are clear coat bump textures enabled in the application.
  106930. */
  106931. static get ClearCoatBumpTextureEnabled(): boolean;
  106932. static set ClearCoatBumpTextureEnabled(value: boolean);
  106933. private static _ClearCoatTintTextureEnabled;
  106934. /**
  106935. * Are clear coat tint textures enabled in the application.
  106936. */
  106937. static get ClearCoatTintTextureEnabled(): boolean;
  106938. static set ClearCoatTintTextureEnabled(value: boolean);
  106939. private static _SheenTextureEnabled;
  106940. /**
  106941. * Are sheen textures enabled in the application.
  106942. */
  106943. static get SheenTextureEnabled(): boolean;
  106944. static set SheenTextureEnabled(value: boolean);
  106945. private static _AnisotropicTextureEnabled;
  106946. /**
  106947. * Are anisotropic textures enabled in the application.
  106948. */
  106949. static get AnisotropicTextureEnabled(): boolean;
  106950. static set AnisotropicTextureEnabled(value: boolean);
  106951. private static _ThicknessTextureEnabled;
  106952. /**
  106953. * Are thickness textures enabled in the application.
  106954. */
  106955. static get ThicknessTextureEnabled(): boolean;
  106956. static set ThicknessTextureEnabled(value: boolean);
  106957. }
  106958. }
  106959. declare module BABYLON {
  106960. /** @hidden */
  106961. export var defaultFragmentDeclaration: {
  106962. name: string;
  106963. shader: string;
  106964. };
  106965. }
  106966. declare module BABYLON {
  106967. /** @hidden */
  106968. export var defaultUboDeclaration: {
  106969. name: string;
  106970. shader: string;
  106971. };
  106972. }
  106973. declare module BABYLON {
  106974. /** @hidden */
  106975. export var lightFragmentDeclaration: {
  106976. name: string;
  106977. shader: string;
  106978. };
  106979. }
  106980. declare module BABYLON {
  106981. /** @hidden */
  106982. export var lightUboDeclaration: {
  106983. name: string;
  106984. shader: string;
  106985. };
  106986. }
  106987. declare module BABYLON {
  106988. /** @hidden */
  106989. export var lightsFragmentFunctions: {
  106990. name: string;
  106991. shader: string;
  106992. };
  106993. }
  106994. declare module BABYLON {
  106995. /** @hidden */
  106996. export var shadowsFragmentFunctions: {
  106997. name: string;
  106998. shader: string;
  106999. };
  107000. }
  107001. declare module BABYLON {
  107002. /** @hidden */
  107003. export var fresnelFunction: {
  107004. name: string;
  107005. shader: string;
  107006. };
  107007. }
  107008. declare module BABYLON {
  107009. /** @hidden */
  107010. export var bumpFragmentMainFunctions: {
  107011. name: string;
  107012. shader: string;
  107013. };
  107014. }
  107015. declare module BABYLON {
  107016. /** @hidden */
  107017. export var bumpFragmentFunctions: {
  107018. name: string;
  107019. shader: string;
  107020. };
  107021. }
  107022. declare module BABYLON {
  107023. /** @hidden */
  107024. export var logDepthDeclaration: {
  107025. name: string;
  107026. shader: string;
  107027. };
  107028. }
  107029. declare module BABYLON {
  107030. /** @hidden */
  107031. export var bumpFragment: {
  107032. name: string;
  107033. shader: string;
  107034. };
  107035. }
  107036. declare module BABYLON {
  107037. /** @hidden */
  107038. export var depthPrePass: {
  107039. name: string;
  107040. shader: string;
  107041. };
  107042. }
  107043. declare module BABYLON {
  107044. /** @hidden */
  107045. export var lightFragment: {
  107046. name: string;
  107047. shader: string;
  107048. };
  107049. }
  107050. declare module BABYLON {
  107051. /** @hidden */
  107052. export var logDepthFragment: {
  107053. name: string;
  107054. shader: string;
  107055. };
  107056. }
  107057. declare module BABYLON {
  107058. /** @hidden */
  107059. export var defaultPixelShader: {
  107060. name: string;
  107061. shader: string;
  107062. };
  107063. }
  107064. declare module BABYLON {
  107065. /** @hidden */
  107066. export var defaultVertexDeclaration: {
  107067. name: string;
  107068. shader: string;
  107069. };
  107070. }
  107071. declare module BABYLON {
  107072. /** @hidden */
  107073. export var bumpVertexDeclaration: {
  107074. name: string;
  107075. shader: string;
  107076. };
  107077. }
  107078. declare module BABYLON {
  107079. /** @hidden */
  107080. export var bumpVertex: {
  107081. name: string;
  107082. shader: string;
  107083. };
  107084. }
  107085. declare module BABYLON {
  107086. /** @hidden */
  107087. export var fogVertex: {
  107088. name: string;
  107089. shader: string;
  107090. };
  107091. }
  107092. declare module BABYLON {
  107093. /** @hidden */
  107094. export var shadowsVertex: {
  107095. name: string;
  107096. shader: string;
  107097. };
  107098. }
  107099. declare module BABYLON {
  107100. /** @hidden */
  107101. export var pointCloudVertex: {
  107102. name: string;
  107103. shader: string;
  107104. };
  107105. }
  107106. declare module BABYLON {
  107107. /** @hidden */
  107108. export var logDepthVertex: {
  107109. name: string;
  107110. shader: string;
  107111. };
  107112. }
  107113. declare module BABYLON {
  107114. /** @hidden */
  107115. export var defaultVertexShader: {
  107116. name: string;
  107117. shader: string;
  107118. };
  107119. }
  107120. declare module BABYLON {
  107121. /**
  107122. * @hidden
  107123. */
  107124. export interface IMaterialDetailMapDefines {
  107125. DETAIL: boolean;
  107126. DETAILDIRECTUV: number;
  107127. DETAIL_NORMALBLENDMETHOD: number;
  107128. /** @hidden */
  107129. _areTexturesDirty: boolean;
  107130. }
  107131. /**
  107132. * Define the code related to the detail map parameters of a material
  107133. *
  107134. * Inspired from:
  107135. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  107136. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107137. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107138. */
  107139. export class DetailMapConfiguration {
  107140. private _texture;
  107141. /**
  107142. * The detail texture of the material.
  107143. */
  107144. texture: Nullable<BaseTexture>;
  107145. /**
  107146. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107147. * Bigger values mean stronger blending
  107148. */
  107149. diffuseBlendLevel: number;
  107150. /**
  107151. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107152. * Bigger values mean stronger blending. Only used with PBR materials
  107153. */
  107154. roughnessBlendLevel: number;
  107155. /**
  107156. * Defines how strong the bump effect from the detail map is
  107157. * Bigger values mean stronger effect
  107158. */
  107159. bumpLevel: number;
  107160. private _normalBlendMethod;
  107161. /**
  107162. * The method used to blend the bump and detail normals together
  107163. */
  107164. normalBlendMethod: number;
  107165. private _isEnabled;
  107166. /**
  107167. * Enable or disable the detail map on this material
  107168. */
  107169. isEnabled: boolean;
  107170. /** @hidden */
  107171. private _internalMarkAllSubMeshesAsTexturesDirty;
  107172. /** @hidden */
  107173. _markAllSubMeshesAsTexturesDirty(): void;
  107174. /**
  107175. * Instantiate a new detail map
  107176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107177. */
  107178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107179. /**
  107180. * Gets whether the submesh is ready to be used or not.
  107181. * @param defines the list of "defines" to update.
  107182. * @param scene defines the scene the material belongs to.
  107183. * @returns - boolean indicating that the submesh is ready or not.
  107184. */
  107185. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107186. /**
  107187. * Update the defines for detail map usage
  107188. * @param defines the list of "defines" to update.
  107189. * @param scene defines the scene the material belongs to.
  107190. */
  107191. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107192. /**
  107193. * Binds the material data.
  107194. * @param uniformBuffer defines the Uniform buffer to fill in.
  107195. * @param scene defines the scene the material belongs to.
  107196. * @param isFrozen defines whether the material is frozen or not.
  107197. */
  107198. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107199. /**
  107200. * Checks to see if a texture is used in the material.
  107201. * @param texture - Base texture to use.
  107202. * @returns - Boolean specifying if a texture is used in the material.
  107203. */
  107204. hasTexture(texture: BaseTexture): boolean;
  107205. /**
  107206. * Returns an array of the actively used textures.
  107207. * @param activeTextures Array of BaseTextures
  107208. */
  107209. getActiveTextures(activeTextures: BaseTexture[]): void;
  107210. /**
  107211. * Returns the animatable textures.
  107212. * @param animatables Array of animatable textures.
  107213. */
  107214. getAnimatables(animatables: IAnimatable[]): void;
  107215. /**
  107216. * Disposes the resources of the material.
  107217. * @param forceDisposeTextures - Forces the disposal of all textures.
  107218. */
  107219. dispose(forceDisposeTextures?: boolean): void;
  107220. /**
  107221. * Get the current class name useful for serialization or dynamic coding.
  107222. * @returns "DetailMap"
  107223. */
  107224. getClassName(): string;
  107225. /**
  107226. * Add the required uniforms to the current list.
  107227. * @param uniforms defines the current uniform list.
  107228. */
  107229. static AddUniforms(uniforms: string[]): void;
  107230. /**
  107231. * Add the required samplers to the current list.
  107232. * @param samplers defines the current sampler list.
  107233. */
  107234. static AddSamplers(samplers: string[]): void;
  107235. /**
  107236. * Add the required uniforms to the current buffer.
  107237. * @param uniformBuffer defines the current uniform buffer.
  107238. */
  107239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107240. /**
  107241. * Makes a duplicate of the current instance into another one.
  107242. * @param detailMap define the instance where to copy the info
  107243. */
  107244. copyTo(detailMap: DetailMapConfiguration): void;
  107245. /**
  107246. * Serializes this detail map instance
  107247. * @returns - An object with the serialized instance.
  107248. */
  107249. serialize(): any;
  107250. /**
  107251. * Parses a detail map setting from a serialized object.
  107252. * @param source - Serialized object.
  107253. * @param scene Defines the scene we are parsing for
  107254. * @param rootUrl Defines the rootUrl to load from
  107255. */
  107256. parse(source: any, scene: Scene, rootUrl: string): void;
  107257. }
  107258. }
  107259. declare module BABYLON {
  107260. /** @hidden */
  107261. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107262. MAINUV1: boolean;
  107263. MAINUV2: boolean;
  107264. DIFFUSE: boolean;
  107265. DIFFUSEDIRECTUV: number;
  107266. DETAIL: boolean;
  107267. DETAILDIRECTUV: number;
  107268. DETAIL_NORMALBLENDMETHOD: number;
  107269. AMBIENT: boolean;
  107270. AMBIENTDIRECTUV: number;
  107271. OPACITY: boolean;
  107272. OPACITYDIRECTUV: number;
  107273. OPACITYRGB: boolean;
  107274. REFLECTION: boolean;
  107275. EMISSIVE: boolean;
  107276. EMISSIVEDIRECTUV: number;
  107277. SPECULAR: boolean;
  107278. SPECULARDIRECTUV: number;
  107279. BUMP: boolean;
  107280. BUMPDIRECTUV: number;
  107281. PARALLAX: boolean;
  107282. PARALLAXOCCLUSION: boolean;
  107283. SPECULAROVERALPHA: boolean;
  107284. CLIPPLANE: boolean;
  107285. CLIPPLANE2: boolean;
  107286. CLIPPLANE3: boolean;
  107287. CLIPPLANE4: boolean;
  107288. CLIPPLANE5: boolean;
  107289. CLIPPLANE6: boolean;
  107290. ALPHATEST: boolean;
  107291. DEPTHPREPASS: boolean;
  107292. ALPHAFROMDIFFUSE: boolean;
  107293. POINTSIZE: boolean;
  107294. FOG: boolean;
  107295. SPECULARTERM: boolean;
  107296. DIFFUSEFRESNEL: boolean;
  107297. OPACITYFRESNEL: boolean;
  107298. REFLECTIONFRESNEL: boolean;
  107299. REFRACTIONFRESNEL: boolean;
  107300. EMISSIVEFRESNEL: boolean;
  107301. FRESNEL: boolean;
  107302. NORMAL: boolean;
  107303. UV1: boolean;
  107304. UV2: boolean;
  107305. VERTEXCOLOR: boolean;
  107306. VERTEXALPHA: boolean;
  107307. NUM_BONE_INFLUENCERS: number;
  107308. BonesPerMesh: number;
  107309. BONETEXTURE: boolean;
  107310. INSTANCES: boolean;
  107311. THIN_INSTANCES: boolean;
  107312. GLOSSINESS: boolean;
  107313. ROUGHNESS: boolean;
  107314. EMISSIVEASILLUMINATION: boolean;
  107315. LINKEMISSIVEWITHDIFFUSE: boolean;
  107316. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107317. LIGHTMAP: boolean;
  107318. LIGHTMAPDIRECTUV: number;
  107319. OBJECTSPACE_NORMALMAP: boolean;
  107320. USELIGHTMAPASSHADOWMAP: boolean;
  107321. REFLECTIONMAP_3D: boolean;
  107322. REFLECTIONMAP_SPHERICAL: boolean;
  107323. REFLECTIONMAP_PLANAR: boolean;
  107324. REFLECTIONMAP_CUBIC: boolean;
  107325. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107326. REFLECTIONMAP_PROJECTION: boolean;
  107327. REFLECTIONMAP_SKYBOX: boolean;
  107328. REFLECTIONMAP_EXPLICIT: boolean;
  107329. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107330. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107331. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107332. INVERTCUBICMAP: boolean;
  107333. LOGARITHMICDEPTH: boolean;
  107334. REFRACTION: boolean;
  107335. REFRACTIONMAP_3D: boolean;
  107336. REFLECTIONOVERALPHA: boolean;
  107337. TWOSIDEDLIGHTING: boolean;
  107338. SHADOWFLOAT: boolean;
  107339. MORPHTARGETS: boolean;
  107340. MORPHTARGETS_NORMAL: boolean;
  107341. MORPHTARGETS_TANGENT: boolean;
  107342. MORPHTARGETS_UV: boolean;
  107343. NUM_MORPH_INFLUENCERS: number;
  107344. NONUNIFORMSCALING: boolean;
  107345. PREMULTIPLYALPHA: boolean;
  107346. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107347. ALPHABLEND: boolean;
  107348. RGBDLIGHTMAP: boolean;
  107349. RGBDREFLECTION: boolean;
  107350. RGBDREFRACTION: boolean;
  107351. IMAGEPROCESSING: boolean;
  107352. VIGNETTE: boolean;
  107353. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107354. VIGNETTEBLENDMODEOPAQUE: boolean;
  107355. TONEMAPPING: boolean;
  107356. TONEMAPPING_ACES: boolean;
  107357. CONTRAST: boolean;
  107358. COLORCURVES: boolean;
  107359. COLORGRADING: boolean;
  107360. COLORGRADING3D: boolean;
  107361. SAMPLER3DGREENDEPTH: boolean;
  107362. SAMPLER3DBGRMAP: boolean;
  107363. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107364. MULTIVIEW: boolean;
  107365. /**
  107366. * If the reflection texture on this material is in linear color space
  107367. * @hidden
  107368. */
  107369. IS_REFLECTION_LINEAR: boolean;
  107370. /**
  107371. * If the refraction texture on this material is in linear color space
  107372. * @hidden
  107373. */
  107374. IS_REFRACTION_LINEAR: boolean;
  107375. EXPOSURE: boolean;
  107376. constructor();
  107377. setReflectionMode(modeToEnable: string): void;
  107378. }
  107379. /**
  107380. * This is the default material used in Babylon. It is the best trade off between quality
  107381. * and performances.
  107382. * @see http://doc.babylonjs.com/babylon101/materials
  107383. */
  107384. export class StandardMaterial extends PushMaterial {
  107385. private _diffuseTexture;
  107386. /**
  107387. * The basic texture of the material as viewed under a light.
  107388. */
  107389. diffuseTexture: Nullable<BaseTexture>;
  107390. private _ambientTexture;
  107391. /**
  107392. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107393. */
  107394. ambientTexture: Nullable<BaseTexture>;
  107395. private _opacityTexture;
  107396. /**
  107397. * Define the transparency of the material from a texture.
  107398. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107399. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107400. */
  107401. opacityTexture: Nullable<BaseTexture>;
  107402. private _reflectionTexture;
  107403. /**
  107404. * Define the texture used to display the reflection.
  107405. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107406. */
  107407. reflectionTexture: Nullable<BaseTexture>;
  107408. private _emissiveTexture;
  107409. /**
  107410. * Define texture of the material as if self lit.
  107411. * This will be mixed in the final result even in the absence of light.
  107412. */
  107413. emissiveTexture: Nullable<BaseTexture>;
  107414. private _specularTexture;
  107415. /**
  107416. * Define how the color and intensity of the highlight given by the light in the material.
  107417. */
  107418. specularTexture: Nullable<BaseTexture>;
  107419. private _bumpTexture;
  107420. /**
  107421. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107422. * 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.
  107423. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107424. */
  107425. bumpTexture: Nullable<BaseTexture>;
  107426. private _lightmapTexture;
  107427. /**
  107428. * Complex lighting can be computationally expensive to compute at runtime.
  107429. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107430. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107431. */
  107432. lightmapTexture: Nullable<BaseTexture>;
  107433. private _refractionTexture;
  107434. /**
  107435. * Define the texture used to display the refraction.
  107436. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107437. */
  107438. refractionTexture: Nullable<BaseTexture>;
  107439. /**
  107440. * The color of the material lit by the environmental background lighting.
  107441. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107442. */
  107443. ambientColor: Color3;
  107444. /**
  107445. * The basic color of the material as viewed under a light.
  107446. */
  107447. diffuseColor: Color3;
  107448. /**
  107449. * Define how the color and intensity of the highlight given by the light in the material.
  107450. */
  107451. specularColor: Color3;
  107452. /**
  107453. * Define the color of the material as if self lit.
  107454. * This will be mixed in the final result even in the absence of light.
  107455. */
  107456. emissiveColor: Color3;
  107457. /**
  107458. * Defines how sharp are the highlights in the material.
  107459. * The bigger the value the sharper giving a more glossy feeling to the result.
  107460. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107461. */
  107462. specularPower: number;
  107463. private _useAlphaFromDiffuseTexture;
  107464. /**
  107465. * Does the transparency come from the diffuse texture alpha channel.
  107466. */
  107467. useAlphaFromDiffuseTexture: boolean;
  107468. private _useEmissiveAsIllumination;
  107469. /**
  107470. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107471. */
  107472. useEmissiveAsIllumination: boolean;
  107473. private _linkEmissiveWithDiffuse;
  107474. /**
  107475. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107476. * the emissive level when the final color is close to one.
  107477. */
  107478. linkEmissiveWithDiffuse: boolean;
  107479. private _useSpecularOverAlpha;
  107480. /**
  107481. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107482. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107483. */
  107484. useSpecularOverAlpha: boolean;
  107485. private _useReflectionOverAlpha;
  107486. /**
  107487. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107488. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107489. */
  107490. useReflectionOverAlpha: boolean;
  107491. private _disableLighting;
  107492. /**
  107493. * Does lights from the scene impacts this material.
  107494. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107495. */
  107496. disableLighting: boolean;
  107497. private _useObjectSpaceNormalMap;
  107498. /**
  107499. * Allows using an object space normal map (instead of tangent space).
  107500. */
  107501. useObjectSpaceNormalMap: boolean;
  107502. private _useParallax;
  107503. /**
  107504. * Is parallax enabled or not.
  107505. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107506. */
  107507. useParallax: boolean;
  107508. private _useParallaxOcclusion;
  107509. /**
  107510. * Is parallax occlusion enabled or not.
  107511. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107512. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107513. */
  107514. useParallaxOcclusion: boolean;
  107515. /**
  107516. * 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.
  107517. */
  107518. parallaxScaleBias: number;
  107519. private _roughness;
  107520. /**
  107521. * Helps to define how blurry the reflections should appears in the material.
  107522. */
  107523. roughness: number;
  107524. /**
  107525. * In case of refraction, define the value of the index of refraction.
  107526. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107527. */
  107528. indexOfRefraction: number;
  107529. /**
  107530. * Invert the refraction texture alongside the y axis.
  107531. * It can be useful with procedural textures or probe for instance.
  107532. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107533. */
  107534. invertRefractionY: boolean;
  107535. /**
  107536. * Defines the alpha limits in alpha test mode.
  107537. */
  107538. alphaCutOff: number;
  107539. private _useLightmapAsShadowmap;
  107540. /**
  107541. * In case of light mapping, define whether the map contains light or shadow informations.
  107542. */
  107543. useLightmapAsShadowmap: boolean;
  107544. private _diffuseFresnelParameters;
  107545. /**
  107546. * Define the diffuse fresnel parameters of the material.
  107547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107548. */
  107549. diffuseFresnelParameters: FresnelParameters;
  107550. private _opacityFresnelParameters;
  107551. /**
  107552. * Define the opacity fresnel parameters of the material.
  107553. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107554. */
  107555. opacityFresnelParameters: FresnelParameters;
  107556. private _reflectionFresnelParameters;
  107557. /**
  107558. * Define the reflection fresnel parameters of the material.
  107559. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107560. */
  107561. reflectionFresnelParameters: FresnelParameters;
  107562. private _refractionFresnelParameters;
  107563. /**
  107564. * Define the refraction fresnel parameters of the material.
  107565. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107566. */
  107567. refractionFresnelParameters: FresnelParameters;
  107568. private _emissiveFresnelParameters;
  107569. /**
  107570. * Define the emissive fresnel parameters of the material.
  107571. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107572. */
  107573. emissiveFresnelParameters: FresnelParameters;
  107574. private _useReflectionFresnelFromSpecular;
  107575. /**
  107576. * If true automatically deducts the fresnels values from the material specularity.
  107577. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107578. */
  107579. useReflectionFresnelFromSpecular: boolean;
  107580. private _useGlossinessFromSpecularMapAlpha;
  107581. /**
  107582. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107583. */
  107584. useGlossinessFromSpecularMapAlpha: boolean;
  107585. private _maxSimultaneousLights;
  107586. /**
  107587. * Defines the maximum number of lights that can be used in the material
  107588. */
  107589. maxSimultaneousLights: number;
  107590. private _invertNormalMapX;
  107591. /**
  107592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107593. */
  107594. invertNormalMapX: boolean;
  107595. private _invertNormalMapY;
  107596. /**
  107597. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107598. */
  107599. invertNormalMapY: boolean;
  107600. private _twoSidedLighting;
  107601. /**
  107602. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107603. */
  107604. twoSidedLighting: boolean;
  107605. /**
  107606. * Default configuration related to image processing available in the standard Material.
  107607. */
  107608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107609. /**
  107610. * Gets the image processing configuration used either in this material.
  107611. */
  107612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107613. /**
  107614. * Sets the Default image processing configuration used either in the this material.
  107615. *
  107616. * If sets to null, the scene one is in use.
  107617. */
  107618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107619. /**
  107620. * Keep track of the image processing observer to allow dispose and replace.
  107621. */
  107622. private _imageProcessingObserver;
  107623. /**
  107624. * Attaches a new image processing configuration to the Standard Material.
  107625. * @param configuration
  107626. */
  107627. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107628. /**
  107629. * Gets wether the color curves effect is enabled.
  107630. */
  107631. get cameraColorCurvesEnabled(): boolean;
  107632. /**
  107633. * Sets wether the color curves effect is enabled.
  107634. */
  107635. set cameraColorCurvesEnabled(value: boolean);
  107636. /**
  107637. * Gets wether the color grading effect is enabled.
  107638. */
  107639. get cameraColorGradingEnabled(): boolean;
  107640. /**
  107641. * Gets wether the color grading effect is enabled.
  107642. */
  107643. set cameraColorGradingEnabled(value: boolean);
  107644. /**
  107645. * Gets wether tonemapping is enabled or not.
  107646. */
  107647. get cameraToneMappingEnabled(): boolean;
  107648. /**
  107649. * Sets wether tonemapping is enabled or not
  107650. */
  107651. set cameraToneMappingEnabled(value: boolean);
  107652. /**
  107653. * The camera exposure used on this material.
  107654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107655. * This corresponds to a photographic exposure.
  107656. */
  107657. get cameraExposure(): number;
  107658. /**
  107659. * The camera exposure used on this material.
  107660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107661. * This corresponds to a photographic exposure.
  107662. */
  107663. set cameraExposure(value: number);
  107664. /**
  107665. * Gets The camera contrast used on this material.
  107666. */
  107667. get cameraContrast(): number;
  107668. /**
  107669. * Sets The camera contrast used on this material.
  107670. */
  107671. set cameraContrast(value: number);
  107672. /**
  107673. * Gets the Color Grading 2D Lookup Texture.
  107674. */
  107675. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107676. /**
  107677. * Sets the Color Grading 2D Lookup Texture.
  107678. */
  107679. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107680. /**
  107681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107683. * 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;
  107684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107685. */
  107686. get cameraColorCurves(): Nullable<ColorCurves>;
  107687. /**
  107688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107690. * 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;
  107691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107692. */
  107693. set cameraColorCurves(value: Nullable<ColorCurves>);
  107694. /**
  107695. * Defines the detail map parameters for the material.
  107696. */
  107697. readonly detailMap: DetailMapConfiguration;
  107698. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107699. protected _worldViewProjectionMatrix: Matrix;
  107700. protected _globalAmbientColor: Color3;
  107701. protected _useLogarithmicDepth: boolean;
  107702. protected _rebuildInParallel: boolean;
  107703. /**
  107704. * Instantiates a new standard material.
  107705. * This is the default material used in Babylon. It is the best trade off between quality
  107706. * and performances.
  107707. * @see http://doc.babylonjs.com/babylon101/materials
  107708. * @param name Define the name of the material in the scene
  107709. * @param scene Define the scene the material belong to
  107710. */
  107711. constructor(name: string, scene: Scene);
  107712. /**
  107713. * Gets a boolean indicating that current material needs to register RTT
  107714. */
  107715. get hasRenderTargetTextures(): boolean;
  107716. /**
  107717. * Gets the current class name of the material e.g. "StandardMaterial"
  107718. * Mainly use in serialization.
  107719. * @returns the class name
  107720. */
  107721. getClassName(): string;
  107722. /**
  107723. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107724. * You can try switching to logarithmic depth.
  107725. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107726. */
  107727. get useLogarithmicDepth(): boolean;
  107728. set useLogarithmicDepth(value: boolean);
  107729. /**
  107730. * Specifies if the material will require alpha blending
  107731. * @returns a boolean specifying if alpha blending is needed
  107732. */
  107733. needAlphaBlending(): boolean;
  107734. /**
  107735. * Specifies if this material should be rendered in alpha test mode
  107736. * @returns a boolean specifying if an alpha test is needed.
  107737. */
  107738. needAlphaTesting(): boolean;
  107739. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107740. /**
  107741. * Get the texture used for alpha test purpose.
  107742. * @returns the diffuse texture in case of the standard material.
  107743. */
  107744. getAlphaTestTexture(): Nullable<BaseTexture>;
  107745. /**
  107746. * Get if the submesh is ready to be used and all its information available.
  107747. * Child classes can use it to update shaders
  107748. * @param mesh defines the mesh to check
  107749. * @param subMesh defines which submesh to check
  107750. * @param useInstances specifies that instances should be used
  107751. * @returns a boolean indicating that the submesh is ready or not
  107752. */
  107753. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107754. /**
  107755. * Builds the material UBO layouts.
  107756. * Used internally during the effect preparation.
  107757. */
  107758. buildUniformLayout(): void;
  107759. /**
  107760. * Unbinds the material from the mesh
  107761. */
  107762. unbind(): void;
  107763. /**
  107764. * Binds the submesh to this material by preparing the effect and shader to draw
  107765. * @param world defines the world transformation matrix
  107766. * @param mesh defines the mesh containing the submesh
  107767. * @param subMesh defines the submesh to bind the material to
  107768. */
  107769. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107770. /**
  107771. * Get the list of animatables in the material.
  107772. * @returns the list of animatables object used in the material
  107773. */
  107774. getAnimatables(): IAnimatable[];
  107775. /**
  107776. * Gets the active textures from the material
  107777. * @returns an array of textures
  107778. */
  107779. getActiveTextures(): BaseTexture[];
  107780. /**
  107781. * Specifies if the material uses a texture
  107782. * @param texture defines the texture to check against the material
  107783. * @returns a boolean specifying if the material uses the texture
  107784. */
  107785. hasTexture(texture: BaseTexture): boolean;
  107786. /**
  107787. * Disposes the material
  107788. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107789. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107790. */
  107791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107792. /**
  107793. * Makes a duplicate of the material, and gives it a new name
  107794. * @param name defines the new name for the duplicated material
  107795. * @returns the cloned material
  107796. */
  107797. clone(name: string): StandardMaterial;
  107798. /**
  107799. * Serializes this material in a JSON representation
  107800. * @returns the serialized material object
  107801. */
  107802. serialize(): any;
  107803. /**
  107804. * Creates a standard material from parsed material data
  107805. * @param source defines the JSON representation of the material
  107806. * @param scene defines the hosting scene
  107807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107808. * @returns a new standard material
  107809. */
  107810. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107811. /**
  107812. * Are diffuse textures enabled in the application.
  107813. */
  107814. static get DiffuseTextureEnabled(): boolean;
  107815. static set DiffuseTextureEnabled(value: boolean);
  107816. /**
  107817. * Are detail textures enabled in the application.
  107818. */
  107819. static get DetailTextureEnabled(): boolean;
  107820. static set DetailTextureEnabled(value: boolean);
  107821. /**
  107822. * Are ambient textures enabled in the application.
  107823. */
  107824. static get AmbientTextureEnabled(): boolean;
  107825. static set AmbientTextureEnabled(value: boolean);
  107826. /**
  107827. * Are opacity textures enabled in the application.
  107828. */
  107829. static get OpacityTextureEnabled(): boolean;
  107830. static set OpacityTextureEnabled(value: boolean);
  107831. /**
  107832. * Are reflection textures enabled in the application.
  107833. */
  107834. static get ReflectionTextureEnabled(): boolean;
  107835. static set ReflectionTextureEnabled(value: boolean);
  107836. /**
  107837. * Are emissive textures enabled in the application.
  107838. */
  107839. static get EmissiveTextureEnabled(): boolean;
  107840. static set EmissiveTextureEnabled(value: boolean);
  107841. /**
  107842. * Are specular textures enabled in the application.
  107843. */
  107844. static get SpecularTextureEnabled(): boolean;
  107845. static set SpecularTextureEnabled(value: boolean);
  107846. /**
  107847. * Are bump textures enabled in the application.
  107848. */
  107849. static get BumpTextureEnabled(): boolean;
  107850. static set BumpTextureEnabled(value: boolean);
  107851. /**
  107852. * Are lightmap textures enabled in the application.
  107853. */
  107854. static get LightmapTextureEnabled(): boolean;
  107855. static set LightmapTextureEnabled(value: boolean);
  107856. /**
  107857. * Are refraction textures enabled in the application.
  107858. */
  107859. static get RefractionTextureEnabled(): boolean;
  107860. static set RefractionTextureEnabled(value: boolean);
  107861. /**
  107862. * Are color grading textures enabled in the application.
  107863. */
  107864. static get ColorGradingTextureEnabled(): boolean;
  107865. static set ColorGradingTextureEnabled(value: boolean);
  107866. /**
  107867. * Are fresnels enabled in the application.
  107868. */
  107869. static get FresnelEnabled(): boolean;
  107870. static set FresnelEnabled(value: boolean);
  107871. }
  107872. }
  107873. declare module BABYLON {
  107874. /**
  107875. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107876. *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.
  107877. * The SPS is also a particle system. It provides some methods to manage the particles.
  107878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107879. *
  107880. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107881. */
  107882. export class SolidParticleSystem implements IDisposable {
  107883. /**
  107884. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107885. * Example : var p = SPS.particles[i];
  107886. */
  107887. particles: SolidParticle[];
  107888. /**
  107889. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107890. */
  107891. nbParticles: number;
  107892. /**
  107893. * If the particles must ever face the camera (default false). Useful for planar particles.
  107894. */
  107895. billboard: boolean;
  107896. /**
  107897. * Recompute normals when adding a shape
  107898. */
  107899. recomputeNormals: boolean;
  107900. /**
  107901. * This a counter ofr your own usage. It's not set by any SPS functions.
  107902. */
  107903. counter: number;
  107904. /**
  107905. * The SPS name. This name is also given to the underlying mesh.
  107906. */
  107907. name: string;
  107908. /**
  107909. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107910. */
  107911. mesh: Mesh;
  107912. /**
  107913. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107914. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107915. */
  107916. vars: any;
  107917. /**
  107918. * This array is populated when the SPS is set as 'pickable'.
  107919. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107920. * Each element of this array is an object `{idx: int, faceId: int}`.
  107921. * `idx` is the picked particle index in the `SPS.particles` array
  107922. * `faceId` is the picked face index counted within this particle.
  107923. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107924. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107925. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107926. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107927. */
  107928. pickedParticles: {
  107929. idx: number;
  107930. faceId: number;
  107931. }[];
  107932. /**
  107933. * This array is populated when the SPS is set as 'pickable'
  107934. * Each key of this array is a submesh index.
  107935. * Each element of this array is a second array defined like this :
  107936. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107937. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107938. * `idx` is the picked particle index in the `SPS.particles` array
  107939. * `faceId` is the picked face index counted within this particle.
  107940. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107941. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107942. */
  107943. pickedBySubMesh: {
  107944. idx: number;
  107945. faceId: number;
  107946. }[][];
  107947. /**
  107948. * This array is populated when `enableDepthSort` is set to true.
  107949. * Each element of this array is an instance of the class DepthSortedParticle.
  107950. */
  107951. depthSortedParticles: DepthSortedParticle[];
  107952. /**
  107953. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107954. * @hidden
  107955. */
  107956. _bSphereOnly: boolean;
  107957. /**
  107958. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107959. * @hidden
  107960. */
  107961. _bSphereRadiusFactor: number;
  107962. private _scene;
  107963. private _positions;
  107964. private _indices;
  107965. private _normals;
  107966. private _colors;
  107967. private _uvs;
  107968. private _indices32;
  107969. private _positions32;
  107970. private _normals32;
  107971. private _fixedNormal32;
  107972. private _colors32;
  107973. private _uvs32;
  107974. private _index;
  107975. private _updatable;
  107976. private _pickable;
  107977. private _isVisibilityBoxLocked;
  107978. private _alwaysVisible;
  107979. private _depthSort;
  107980. private _expandable;
  107981. private _shapeCounter;
  107982. private _copy;
  107983. private _color;
  107984. private _computeParticleColor;
  107985. private _computeParticleTexture;
  107986. private _computeParticleRotation;
  107987. private _computeParticleVertex;
  107988. private _computeBoundingBox;
  107989. private _depthSortParticles;
  107990. private _camera;
  107991. private _mustUnrotateFixedNormals;
  107992. private _particlesIntersect;
  107993. private _needs32Bits;
  107994. private _isNotBuilt;
  107995. private _lastParticleId;
  107996. private _idxOfId;
  107997. private _multimaterialEnabled;
  107998. private _useModelMaterial;
  107999. private _indicesByMaterial;
  108000. private _materialIndexes;
  108001. private _depthSortFunction;
  108002. private _materialSortFunction;
  108003. private _materials;
  108004. private _multimaterial;
  108005. private _materialIndexesById;
  108006. private _defaultMaterial;
  108007. private _autoUpdateSubMeshes;
  108008. private _tmpVertex;
  108009. /**
  108010. * Creates a SPS (Solid Particle System) object.
  108011. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108012. * @param scene (Scene) is the scene in which the SPS is added.
  108013. * @param options defines the options of the sps e.g.
  108014. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108015. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108016. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108017. * * 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.
  108018. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108019. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108020. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108021. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108022. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108023. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108024. */
  108025. constructor(name: string, scene: Scene, options?: {
  108026. updatable?: boolean;
  108027. isPickable?: boolean;
  108028. enableDepthSort?: boolean;
  108029. particleIntersection?: boolean;
  108030. boundingSphereOnly?: boolean;
  108031. bSphereRadiusFactor?: number;
  108032. expandable?: boolean;
  108033. useModelMaterial?: boolean;
  108034. enableMultiMaterial?: boolean;
  108035. });
  108036. /**
  108037. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108038. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108039. * @returns the created mesh
  108040. */
  108041. buildMesh(): Mesh;
  108042. /**
  108043. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108044. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108045. * Thus the particles generated from `digest()` have their property `position` set yet.
  108046. * @param mesh ( Mesh ) is the mesh to be digested
  108047. * @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
  108048. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108049. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108050. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108051. * @returns the current SPS
  108052. */
  108053. digest(mesh: Mesh, options?: {
  108054. facetNb?: number;
  108055. number?: number;
  108056. delta?: number;
  108057. storage?: [];
  108058. }): SolidParticleSystem;
  108059. /**
  108060. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108061. * @hidden
  108062. */
  108063. private _unrotateFixedNormals;
  108064. /**
  108065. * Resets the temporary working copy particle
  108066. * @hidden
  108067. */
  108068. private _resetCopy;
  108069. /**
  108070. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108071. * @param p the current index in the positions array to be updated
  108072. * @param ind the current index in the indices array
  108073. * @param shape a Vector3 array, the shape geometry
  108074. * @param positions the positions array to be updated
  108075. * @param meshInd the shape indices array
  108076. * @param indices the indices array to be updated
  108077. * @param meshUV the shape uv array
  108078. * @param uvs the uv array to be updated
  108079. * @param meshCol the shape color array
  108080. * @param colors the color array to be updated
  108081. * @param meshNor the shape normals array
  108082. * @param normals the normals array to be updated
  108083. * @param idx the particle index
  108084. * @param idxInShape the particle index in its shape
  108085. * @param options the addShape() method passed options
  108086. * @model the particle model
  108087. * @hidden
  108088. */
  108089. private _meshBuilder;
  108090. /**
  108091. * Returns a shape Vector3 array from positions float array
  108092. * @param positions float array
  108093. * @returns a vector3 array
  108094. * @hidden
  108095. */
  108096. private _posToShape;
  108097. /**
  108098. * Returns a shapeUV array from a float uvs (array deep copy)
  108099. * @param uvs as a float array
  108100. * @returns a shapeUV array
  108101. * @hidden
  108102. */
  108103. private _uvsToShapeUV;
  108104. /**
  108105. * Adds a new particle object in the particles array
  108106. * @param idx particle index in particles array
  108107. * @param id particle id
  108108. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108109. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108110. * @param model particle ModelShape object
  108111. * @param shapeId model shape identifier
  108112. * @param idxInShape index of the particle in the current model
  108113. * @param bInfo model bounding info object
  108114. * @param storage target storage array, if any
  108115. * @hidden
  108116. */
  108117. private _addParticle;
  108118. /**
  108119. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108120. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108121. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108122. * @param nb (positive integer) the number of particles to be created from this model
  108123. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108124. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108125. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108126. * @returns the number of shapes in the system
  108127. */
  108128. addShape(mesh: Mesh, nb: number, options?: {
  108129. positionFunction?: any;
  108130. vertexFunction?: any;
  108131. storage?: [];
  108132. }): number;
  108133. /**
  108134. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108135. * @hidden
  108136. */
  108137. private _rebuildParticle;
  108138. /**
  108139. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108140. * @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.
  108141. * @returns the SPS.
  108142. */
  108143. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108144. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108145. * Returns an array with the removed particles.
  108146. * 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.
  108147. * The SPS can't be empty so at least one particle needs to remain in place.
  108148. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108149. * @param start index of the first particle to remove
  108150. * @param end index of the last particle to remove (included)
  108151. * @returns an array populated with the removed particles
  108152. */
  108153. removeParticles(start: number, end: number): SolidParticle[];
  108154. /**
  108155. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108156. * @param solidParticleArray an array populated with Solid Particles objects
  108157. * @returns the SPS
  108158. */
  108159. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108160. /**
  108161. * Creates a new particle and modifies the SPS mesh geometry :
  108162. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108163. * - calls _addParticle() to populate the particle array
  108164. * factorized code from addShape() and insertParticlesFromArray()
  108165. * @param idx particle index in the particles array
  108166. * @param i particle index in its shape
  108167. * @param modelShape particle ModelShape object
  108168. * @param shape shape vertex array
  108169. * @param meshInd shape indices array
  108170. * @param meshUV shape uv array
  108171. * @param meshCol shape color array
  108172. * @param meshNor shape normals array
  108173. * @param bbInfo shape bounding info
  108174. * @param storage target particle storage
  108175. * @options addShape() passed options
  108176. * @hidden
  108177. */
  108178. private _insertNewParticle;
  108179. /**
  108180. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108181. * This method calls `updateParticle()` for each particle of the SPS.
  108182. * For an animated SPS, it is usually called within the render loop.
  108183. * 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.
  108184. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108185. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108186. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108187. * @returns the SPS.
  108188. */
  108189. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108190. /**
  108191. * Disposes the SPS.
  108192. */
  108193. dispose(): void;
  108194. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108195. * idx is the particle index in the SPS
  108196. * faceId is the picked face index counted within this particle.
  108197. * Returns null if the pickInfo can't identify a picked particle.
  108198. * @param pickingInfo (PickingInfo object)
  108199. * @returns {idx: number, faceId: number} or null
  108200. */
  108201. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108202. idx: number;
  108203. faceId: number;
  108204. }>;
  108205. /**
  108206. * Returns a SolidParticle object from its identifier : particle.id
  108207. * @param id (integer) the particle Id
  108208. * @returns the searched particle or null if not found in the SPS.
  108209. */
  108210. getParticleById(id: number): Nullable<SolidParticle>;
  108211. /**
  108212. * Returns a new array populated with the particles having the passed shapeId.
  108213. * @param shapeId (integer) the shape identifier
  108214. * @returns a new solid particle array
  108215. */
  108216. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108217. /**
  108218. * Populates the passed array "ref" with the particles having the passed shapeId.
  108219. * @param shapeId the shape identifier
  108220. * @returns the SPS
  108221. * @param ref
  108222. */
  108223. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108224. /**
  108225. * Computes the required SubMeshes according the materials assigned to the particles.
  108226. * @returns the solid particle system.
  108227. * Does nothing if called before the SPS mesh is built.
  108228. */
  108229. computeSubMeshes(): SolidParticleSystem;
  108230. /**
  108231. * Sorts the solid particles by material when MultiMaterial is enabled.
  108232. * Updates the indices32 array.
  108233. * Updates the indicesByMaterial array.
  108234. * Updates the mesh indices array.
  108235. * @returns the SPS
  108236. * @hidden
  108237. */
  108238. private _sortParticlesByMaterial;
  108239. /**
  108240. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108241. * @hidden
  108242. */
  108243. private _setMaterialIndexesById;
  108244. /**
  108245. * Returns an array with unique values of Materials from the passed array
  108246. * @param array the material array to be checked and filtered
  108247. * @hidden
  108248. */
  108249. private _filterUniqueMaterialId;
  108250. /**
  108251. * Sets a new Standard Material as _defaultMaterial if not already set.
  108252. * @hidden
  108253. */
  108254. private _setDefaultMaterial;
  108255. /**
  108256. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108258. * @returns the SPS.
  108259. */
  108260. refreshVisibleSize(): SolidParticleSystem;
  108261. /**
  108262. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108263. * @param size the size (float) of the visibility box
  108264. * note : this doesn't lock the SPS mesh bounding box.
  108265. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108266. */
  108267. setVisibilityBox(size: number): void;
  108268. /**
  108269. * Gets whether the SPS as always visible or not
  108270. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108271. */
  108272. get isAlwaysVisible(): boolean;
  108273. /**
  108274. * Sets the SPS as always visible or not
  108275. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108276. */
  108277. set isAlwaysVisible(val: boolean);
  108278. /**
  108279. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108281. */
  108282. set isVisibilityBoxLocked(val: boolean);
  108283. /**
  108284. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108286. */
  108287. get isVisibilityBoxLocked(): boolean;
  108288. /**
  108289. * Tells to `setParticles()` to compute the particle rotations or not.
  108290. * Default value : true. The SPS is faster when it's set to false.
  108291. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108292. */
  108293. set computeParticleRotation(val: boolean);
  108294. /**
  108295. * Tells to `setParticles()` to compute the particle colors or not.
  108296. * Default value : true. The SPS is faster when it's set to false.
  108297. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108298. */
  108299. set computeParticleColor(val: boolean);
  108300. set computeParticleTexture(val: boolean);
  108301. /**
  108302. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108303. * Default value : false. The SPS is faster when it's set to false.
  108304. * Note : the particle custom vertex positions aren't stored values.
  108305. */
  108306. set computeParticleVertex(val: boolean);
  108307. /**
  108308. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108309. */
  108310. set computeBoundingBox(val: boolean);
  108311. /**
  108312. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108314. * Default : `true`
  108315. */
  108316. set depthSortParticles(val: boolean);
  108317. /**
  108318. * Gets if `setParticles()` computes the particle rotations or not.
  108319. * Default value : true. The SPS is faster when it's set to false.
  108320. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108321. */
  108322. get computeParticleRotation(): boolean;
  108323. /**
  108324. * Gets if `setParticles()` computes the particle colors or not.
  108325. * Default value : true. The SPS is faster when it's set to false.
  108326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108327. */
  108328. get computeParticleColor(): boolean;
  108329. /**
  108330. * Gets if `setParticles()` computes the particle textures or not.
  108331. * Default value : true. The SPS is faster when it's set to false.
  108332. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108333. */
  108334. get computeParticleTexture(): boolean;
  108335. /**
  108336. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108337. * Default value : false. The SPS is faster when it's set to false.
  108338. * Note : the particle custom vertex positions aren't stored values.
  108339. */
  108340. get computeParticleVertex(): boolean;
  108341. /**
  108342. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108343. */
  108344. get computeBoundingBox(): boolean;
  108345. /**
  108346. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108347. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108348. * Default : `true`
  108349. */
  108350. get depthSortParticles(): boolean;
  108351. /**
  108352. * Gets if the SPS is created as expandable at construction time.
  108353. * Default : `false`
  108354. */
  108355. get expandable(): boolean;
  108356. /**
  108357. * Gets if the SPS supports the Multi Materials
  108358. */
  108359. get multimaterialEnabled(): boolean;
  108360. /**
  108361. * Gets if the SPS uses the model materials for its own multimaterial.
  108362. */
  108363. get useModelMaterial(): boolean;
  108364. /**
  108365. * The SPS used material array.
  108366. */
  108367. get materials(): Material[];
  108368. /**
  108369. * Sets the SPS MultiMaterial from the passed materials.
  108370. * Note : the passed array is internally copied and not used then by reference.
  108371. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108372. */
  108373. setMultiMaterial(materials: Material[]): void;
  108374. /**
  108375. * The SPS computed multimaterial object
  108376. */
  108377. get multimaterial(): MultiMaterial;
  108378. set multimaterial(mm: MultiMaterial);
  108379. /**
  108380. * If the subMeshes must be updated on the next call to setParticles()
  108381. */
  108382. get autoUpdateSubMeshes(): boolean;
  108383. set autoUpdateSubMeshes(val: boolean);
  108384. /**
  108385. * This function does nothing. It may be overwritten to set all the particle first values.
  108386. * The SPS doesn't call this function, you may have to call it by your own.
  108387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108388. */
  108389. initParticles(): void;
  108390. /**
  108391. * This function does nothing. It may be overwritten to recycle a particle.
  108392. * The SPS doesn't call this function, you may have to call it by your own.
  108393. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108394. * @param particle The particle to recycle
  108395. * @returns the recycled particle
  108396. */
  108397. recycleParticle(particle: SolidParticle): SolidParticle;
  108398. /**
  108399. * Updates a particle : this function should be overwritten by the user.
  108400. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108402. * @example : just set a particle position or velocity and recycle conditions
  108403. * @param particle The particle to update
  108404. * @returns the updated particle
  108405. */
  108406. updateParticle(particle: SolidParticle): SolidParticle;
  108407. /**
  108408. * Updates a vertex of a particle : it can be overwritten by the user.
  108409. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108410. * @param particle the current particle
  108411. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108412. * @param pt the index of the current vertex in the particle shape
  108413. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108414. * @example : just set a vertex particle position or color
  108415. * @returns the sps
  108416. */
  108417. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108418. /**
  108419. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108420. * This does nothing and may be overwritten by the user.
  108421. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108422. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108423. * @param update the boolean update value actually passed to setParticles()
  108424. */
  108425. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108426. /**
  108427. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108428. * This will be passed three parameters.
  108429. * This does nothing and may be overwritten by the user.
  108430. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108431. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108432. * @param update the boolean update value actually passed to setParticles()
  108433. */
  108434. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108435. }
  108436. }
  108437. declare module BABYLON {
  108438. /**
  108439. * Represents one particle of a solid particle system.
  108440. */
  108441. export class SolidParticle {
  108442. /**
  108443. * particle global index
  108444. */
  108445. idx: number;
  108446. /**
  108447. * particle identifier
  108448. */
  108449. id: number;
  108450. /**
  108451. * The color of the particle
  108452. */
  108453. color: Nullable<Color4>;
  108454. /**
  108455. * The world space position of the particle.
  108456. */
  108457. position: Vector3;
  108458. /**
  108459. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108460. */
  108461. rotation: Vector3;
  108462. /**
  108463. * The world space rotation quaternion of the particle.
  108464. */
  108465. rotationQuaternion: Nullable<Quaternion>;
  108466. /**
  108467. * The scaling of the particle.
  108468. */
  108469. scaling: Vector3;
  108470. /**
  108471. * The uvs of the particle.
  108472. */
  108473. uvs: Vector4;
  108474. /**
  108475. * The current speed of the particle.
  108476. */
  108477. velocity: Vector3;
  108478. /**
  108479. * The pivot point in the particle local space.
  108480. */
  108481. pivot: Vector3;
  108482. /**
  108483. * Must the particle be translated from its pivot point in its local space ?
  108484. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108485. * Default : false
  108486. */
  108487. translateFromPivot: boolean;
  108488. /**
  108489. * Is the particle active or not ?
  108490. */
  108491. alive: boolean;
  108492. /**
  108493. * Is the particle visible or not ?
  108494. */
  108495. isVisible: boolean;
  108496. /**
  108497. * Index of this particle in the global "positions" array (Internal use)
  108498. * @hidden
  108499. */
  108500. _pos: number;
  108501. /**
  108502. * @hidden Index of this particle in the global "indices" array (Internal use)
  108503. */
  108504. _ind: number;
  108505. /**
  108506. * @hidden ModelShape of this particle (Internal use)
  108507. */
  108508. _model: ModelShape;
  108509. /**
  108510. * ModelShape id of this particle
  108511. */
  108512. shapeId: number;
  108513. /**
  108514. * Index of the particle in its shape id
  108515. */
  108516. idxInShape: number;
  108517. /**
  108518. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108519. */
  108520. _modelBoundingInfo: BoundingInfo;
  108521. /**
  108522. * @hidden Particle BoundingInfo object (Internal use)
  108523. */
  108524. _boundingInfo: BoundingInfo;
  108525. /**
  108526. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108527. */
  108528. _sps: SolidParticleSystem;
  108529. /**
  108530. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108531. */
  108532. _stillInvisible: boolean;
  108533. /**
  108534. * @hidden Last computed particle rotation matrix
  108535. */
  108536. _rotationMatrix: number[];
  108537. /**
  108538. * Parent particle Id, if any.
  108539. * Default null.
  108540. */
  108541. parentId: Nullable<number>;
  108542. /**
  108543. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108544. */
  108545. materialIndex: Nullable<number>;
  108546. /**
  108547. * Custom object or properties.
  108548. */
  108549. props: Nullable<any>;
  108550. /**
  108551. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108552. * The possible values are :
  108553. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108554. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108555. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108557. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108558. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108559. * */
  108560. cullingStrategy: number;
  108561. /**
  108562. * @hidden Internal global position in the SPS.
  108563. */
  108564. _globalPosition: Vector3;
  108565. /**
  108566. * Creates a Solid Particle object.
  108567. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108568. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108569. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108570. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108571. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108572. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108573. * @param shapeId (integer) is the model shape identifier in the SPS.
  108574. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108575. * @param sps defines the sps it is associated to
  108576. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108577. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108578. */
  108579. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108580. /**
  108581. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108582. * @param target the particle target
  108583. * @returns the current particle
  108584. */
  108585. copyToRef(target: SolidParticle): SolidParticle;
  108586. /**
  108587. * Legacy support, changed scale to scaling
  108588. */
  108589. get scale(): Vector3;
  108590. /**
  108591. * Legacy support, changed scale to scaling
  108592. */
  108593. set scale(scale: Vector3);
  108594. /**
  108595. * Legacy support, changed quaternion to rotationQuaternion
  108596. */
  108597. get quaternion(): Nullable<Quaternion>;
  108598. /**
  108599. * Legacy support, changed quaternion to rotationQuaternion
  108600. */
  108601. set quaternion(q: Nullable<Quaternion>);
  108602. /**
  108603. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108604. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108605. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108606. * @returns true if it intersects
  108607. */
  108608. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108609. /**
  108610. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108611. * A particle is in the frustum if its bounding box intersects the frustum
  108612. * @param frustumPlanes defines the frustum to test
  108613. * @returns true if the particle is in the frustum planes
  108614. */
  108615. isInFrustum(frustumPlanes: Plane[]): boolean;
  108616. /**
  108617. * get the rotation matrix of the particle
  108618. * @hidden
  108619. */
  108620. getRotationMatrix(m: Matrix): void;
  108621. }
  108622. /**
  108623. * Represents the shape of the model used by one particle of a solid particle system.
  108624. * SPS internal tool, don't use it manually.
  108625. */
  108626. export class ModelShape {
  108627. /**
  108628. * The shape id
  108629. * @hidden
  108630. */
  108631. shapeID: number;
  108632. /**
  108633. * flat array of model positions (internal use)
  108634. * @hidden
  108635. */
  108636. _shape: Vector3[];
  108637. /**
  108638. * flat array of model UVs (internal use)
  108639. * @hidden
  108640. */
  108641. _shapeUV: number[];
  108642. /**
  108643. * color array of the model
  108644. * @hidden
  108645. */
  108646. _shapeColors: number[];
  108647. /**
  108648. * indices array of the model
  108649. * @hidden
  108650. */
  108651. _indices: number[];
  108652. /**
  108653. * normals array of the model
  108654. * @hidden
  108655. */
  108656. _normals: number[];
  108657. /**
  108658. * length of the shape in the model indices array (internal use)
  108659. * @hidden
  108660. */
  108661. _indicesLength: number;
  108662. /**
  108663. * Custom position function (internal use)
  108664. * @hidden
  108665. */
  108666. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108667. /**
  108668. * Custom vertex function (internal use)
  108669. * @hidden
  108670. */
  108671. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108672. /**
  108673. * Model material (internal use)
  108674. * @hidden
  108675. */
  108676. _material: Nullable<Material>;
  108677. /**
  108678. * 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.
  108679. * SPS internal tool, don't use it manually.
  108680. * @hidden
  108681. */
  108682. 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>);
  108683. }
  108684. /**
  108685. * Represents a Depth Sorted Particle in the solid particle system.
  108686. * @hidden
  108687. */
  108688. export class DepthSortedParticle {
  108689. /**
  108690. * Particle index
  108691. */
  108692. idx: number;
  108693. /**
  108694. * Index of the particle in the "indices" array
  108695. */
  108696. ind: number;
  108697. /**
  108698. * Length of the particle shape in the "indices" array
  108699. */
  108700. indicesLength: number;
  108701. /**
  108702. * Squared distance from the particle to the camera
  108703. */
  108704. sqDistance: number;
  108705. /**
  108706. * Material index when used with MultiMaterials
  108707. */
  108708. materialIndex: number;
  108709. /**
  108710. * Creates a new sorted particle
  108711. * @param materialIndex
  108712. */
  108713. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108714. }
  108715. /**
  108716. * Represents a solid particle vertex
  108717. */
  108718. export class SolidParticleVertex {
  108719. /**
  108720. * Vertex position
  108721. */
  108722. position: Vector3;
  108723. /**
  108724. * Vertex color
  108725. */
  108726. color: Color4;
  108727. /**
  108728. * Vertex UV
  108729. */
  108730. uv: Vector2;
  108731. /**
  108732. * Creates a new solid particle vertex
  108733. */
  108734. constructor();
  108735. /** Vertex x coordinate */
  108736. get x(): number;
  108737. set x(val: number);
  108738. /** Vertex y coordinate */
  108739. get y(): number;
  108740. set y(val: number);
  108741. /** Vertex z coordinate */
  108742. get z(): number;
  108743. set z(val: number);
  108744. }
  108745. }
  108746. declare module BABYLON {
  108747. /**
  108748. * @hidden
  108749. */
  108750. export class _MeshCollisionData {
  108751. _checkCollisions: boolean;
  108752. _collisionMask: number;
  108753. _collisionGroup: number;
  108754. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108755. _collider: Nullable<Collider>;
  108756. _oldPositionForCollisions: Vector3;
  108757. _diffPositionForCollisions: Vector3;
  108758. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108759. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108760. }
  108761. }
  108762. declare module BABYLON {
  108763. /** @hidden */
  108764. class _FacetDataStorage {
  108765. facetPositions: Vector3[];
  108766. facetNormals: Vector3[];
  108767. facetPartitioning: number[][];
  108768. facetNb: number;
  108769. partitioningSubdivisions: number;
  108770. partitioningBBoxRatio: number;
  108771. facetDataEnabled: boolean;
  108772. facetParameters: any;
  108773. bbSize: Vector3;
  108774. subDiv: {
  108775. max: number;
  108776. X: number;
  108777. Y: number;
  108778. Z: number;
  108779. };
  108780. facetDepthSort: boolean;
  108781. facetDepthSortEnabled: boolean;
  108782. depthSortedIndices: IndicesArray;
  108783. depthSortedFacets: {
  108784. ind: number;
  108785. sqDistance: number;
  108786. }[];
  108787. facetDepthSortFunction: (f1: {
  108788. ind: number;
  108789. sqDistance: number;
  108790. }, f2: {
  108791. ind: number;
  108792. sqDistance: number;
  108793. }) => number;
  108794. facetDepthSortFrom: Vector3;
  108795. facetDepthSortOrigin: Vector3;
  108796. invertedMatrix: Matrix;
  108797. }
  108798. /**
  108799. * @hidden
  108800. **/
  108801. class _InternalAbstractMeshDataInfo {
  108802. _hasVertexAlpha: boolean;
  108803. _useVertexColors: boolean;
  108804. _numBoneInfluencers: number;
  108805. _applyFog: boolean;
  108806. _receiveShadows: boolean;
  108807. _facetData: _FacetDataStorage;
  108808. _visibility: number;
  108809. _skeleton: Nullable<Skeleton>;
  108810. _layerMask: number;
  108811. _computeBonesUsingShaders: boolean;
  108812. _isActive: boolean;
  108813. _onlyForInstances: boolean;
  108814. _isActiveIntermediate: boolean;
  108815. _onlyForInstancesIntermediate: boolean;
  108816. _actAsRegularMesh: boolean;
  108817. }
  108818. /**
  108819. * Class used to store all common mesh properties
  108820. */
  108821. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108822. /** No occlusion */
  108823. static OCCLUSION_TYPE_NONE: number;
  108824. /** Occlusion set to optimisitic */
  108825. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108826. /** Occlusion set to strict */
  108827. static OCCLUSION_TYPE_STRICT: number;
  108828. /** Use an accurante occlusion algorithm */
  108829. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108830. /** Use a conservative occlusion algorithm */
  108831. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108833. * Test order :
  108834. * Is the bounding sphere outside the frustum ?
  108835. * If not, are the bounding box vertices outside the frustum ?
  108836. * It not, then the cullable object is in the frustum.
  108837. */
  108838. static readonly CULLINGSTRATEGY_STANDARD: number;
  108839. /** Culling strategy : Bounding Sphere Only.
  108840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108841. * It's also less accurate than the standard because some not visible objects can still be selected.
  108842. * Test : is the bounding sphere outside the frustum ?
  108843. * If not, then the cullable object is in the frustum.
  108844. */
  108845. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108846. /** Culling strategy : Optimistic Inclusion.
  108847. * This in an inclusion test first, then the standard exclusion test.
  108848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108849. * 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.
  108850. * Anyway, it's as accurate as the standard strategy.
  108851. * Test :
  108852. * Is the cullable object bounding sphere center in the frustum ?
  108853. * If not, apply the default culling strategy.
  108854. */
  108855. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108859. * 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.
  108860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108861. * Test :
  108862. * Is the cullable object bounding sphere center in the frustum ?
  108863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108864. */
  108865. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108866. /**
  108867. * No billboard
  108868. */
  108869. static get BILLBOARDMODE_NONE(): number;
  108870. /** Billboard on X axis */
  108871. static get BILLBOARDMODE_X(): number;
  108872. /** Billboard on Y axis */
  108873. static get BILLBOARDMODE_Y(): number;
  108874. /** Billboard on Z axis */
  108875. static get BILLBOARDMODE_Z(): number;
  108876. /** Billboard on all axes */
  108877. static get BILLBOARDMODE_ALL(): number;
  108878. /** Billboard on using position instead of orientation */
  108879. static get BILLBOARDMODE_USE_POSITION(): number;
  108880. /** @hidden */
  108881. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108882. /**
  108883. * The culling strategy to use to check whether the mesh must be rendered or not.
  108884. * This value can be changed at any time and will be used on the next render mesh selection.
  108885. * The possible values are :
  108886. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108887. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108888. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108889. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108890. * Please read each static variable documentation to get details about the culling process.
  108891. * */
  108892. cullingStrategy: number;
  108893. /**
  108894. * Gets the number of facets in the mesh
  108895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108896. */
  108897. get facetNb(): number;
  108898. /**
  108899. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108901. */
  108902. get partitioningSubdivisions(): number;
  108903. set partitioningSubdivisions(nb: number);
  108904. /**
  108905. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108906. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108908. */
  108909. get partitioningBBoxRatio(): number;
  108910. set partitioningBBoxRatio(ratio: number);
  108911. /**
  108912. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108913. * Works only for updatable meshes.
  108914. * Doesn't work with multi-materials
  108915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108916. */
  108917. get mustDepthSortFacets(): boolean;
  108918. set mustDepthSortFacets(sort: boolean);
  108919. /**
  108920. * The location (Vector3) where the facet depth sort must be computed from.
  108921. * By default, the active camera position.
  108922. * Used only when facet depth sort is enabled
  108923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108924. */
  108925. get facetDepthSortFrom(): Vector3;
  108926. set facetDepthSortFrom(location: Vector3);
  108927. /**
  108928. * gets a boolean indicating if facetData is enabled
  108929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108930. */
  108931. get isFacetDataEnabled(): boolean;
  108932. /** @hidden */
  108933. _updateNonUniformScalingState(value: boolean): boolean;
  108934. /**
  108935. * An event triggered when this mesh collides with another one
  108936. */
  108937. onCollideObservable: Observable<AbstractMesh>;
  108938. /** Set a function to call when this mesh collides with another one */
  108939. set onCollide(callback: () => void);
  108940. /**
  108941. * An event triggered when the collision's position changes
  108942. */
  108943. onCollisionPositionChangeObservable: Observable<Vector3>;
  108944. /** Set a function to call when the collision's position changes */
  108945. set onCollisionPositionChange(callback: () => void);
  108946. /**
  108947. * An event triggered when material is changed
  108948. */
  108949. onMaterialChangedObservable: Observable<AbstractMesh>;
  108950. /**
  108951. * Gets or sets the orientation for POV movement & rotation
  108952. */
  108953. definedFacingForward: boolean;
  108954. /** @hidden */
  108955. _occlusionQuery: Nullable<WebGLQuery>;
  108956. /** @hidden */
  108957. _renderingGroup: Nullable<RenderingGroup>;
  108958. /**
  108959. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108960. */
  108961. get visibility(): number;
  108962. /**
  108963. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108964. */
  108965. set visibility(value: number);
  108966. /** Gets or sets the alpha index used to sort transparent meshes
  108967. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108968. */
  108969. alphaIndex: number;
  108970. /**
  108971. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108972. */
  108973. isVisible: boolean;
  108974. /**
  108975. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108976. */
  108977. isPickable: boolean;
  108978. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108979. showSubMeshesBoundingBox: boolean;
  108980. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108982. */
  108983. isBlocker: boolean;
  108984. /**
  108985. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108986. */
  108987. enablePointerMoveEvents: boolean;
  108988. /**
  108989. * Specifies the rendering group id for this mesh (0 by default)
  108990. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108991. */
  108992. renderingGroupId: number;
  108993. private _material;
  108994. /** Gets or sets current material */
  108995. get material(): Nullable<Material>;
  108996. set material(value: Nullable<Material>);
  108997. /**
  108998. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108999. * @see http://doc.babylonjs.com/babylon101/shadows
  109000. */
  109001. get receiveShadows(): boolean;
  109002. set receiveShadows(value: boolean);
  109003. /** Defines color to use when rendering outline */
  109004. outlineColor: Color3;
  109005. /** Define width to use when rendering outline */
  109006. outlineWidth: number;
  109007. /** Defines color to use when rendering overlay */
  109008. overlayColor: Color3;
  109009. /** Defines alpha to use when rendering overlay */
  109010. overlayAlpha: number;
  109011. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109012. get hasVertexAlpha(): boolean;
  109013. set hasVertexAlpha(value: boolean);
  109014. /** 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) */
  109015. get useVertexColors(): boolean;
  109016. set useVertexColors(value: boolean);
  109017. /**
  109018. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109019. */
  109020. get computeBonesUsingShaders(): boolean;
  109021. set computeBonesUsingShaders(value: boolean);
  109022. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109023. get numBoneInfluencers(): number;
  109024. set numBoneInfluencers(value: number);
  109025. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109026. get applyFog(): boolean;
  109027. set applyFog(value: boolean);
  109028. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109029. useOctreeForRenderingSelection: boolean;
  109030. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109031. useOctreeForPicking: boolean;
  109032. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109033. useOctreeForCollisions: boolean;
  109034. /**
  109035. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109036. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109037. */
  109038. get layerMask(): number;
  109039. set layerMask(value: number);
  109040. /**
  109041. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109042. */
  109043. alwaysSelectAsActiveMesh: boolean;
  109044. /**
  109045. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109046. */
  109047. doNotSyncBoundingInfo: boolean;
  109048. /**
  109049. * Gets or sets the current action manager
  109050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109051. */
  109052. actionManager: Nullable<AbstractActionManager>;
  109053. private _meshCollisionData;
  109054. /**
  109055. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109057. */
  109058. ellipsoid: Vector3;
  109059. /**
  109060. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109062. */
  109063. ellipsoidOffset: Vector3;
  109064. /**
  109065. * Gets or sets a collision mask used to mask collisions (default is -1).
  109066. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109067. */
  109068. get collisionMask(): number;
  109069. set collisionMask(mask: number);
  109070. /**
  109071. * Gets or sets the current collision group mask (-1 by default).
  109072. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109073. */
  109074. get collisionGroup(): number;
  109075. set collisionGroup(mask: number);
  109076. /**
  109077. * Gets or sets current surrounding meshes (null by default).
  109078. *
  109079. * By default collision detection is tested against every mesh in the scene.
  109080. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109081. * meshes will be tested for the collision.
  109082. *
  109083. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109084. */
  109085. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109086. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109087. /**
  109088. * Defines edge width used when edgesRenderer is enabled
  109089. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109090. */
  109091. edgesWidth: number;
  109092. /**
  109093. * Defines edge color used when edgesRenderer is enabled
  109094. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109095. */
  109096. edgesColor: Color4;
  109097. /** @hidden */
  109098. _edgesRenderer: Nullable<IEdgesRenderer>;
  109099. /** @hidden */
  109100. _masterMesh: Nullable<AbstractMesh>;
  109101. /** @hidden */
  109102. _boundingInfo: Nullable<BoundingInfo>;
  109103. /** @hidden */
  109104. _renderId: number;
  109105. /**
  109106. * Gets or sets the list of subMeshes
  109107. * @see http://doc.babylonjs.com/how_to/multi_materials
  109108. */
  109109. subMeshes: SubMesh[];
  109110. /** @hidden */
  109111. _intersectionsInProgress: AbstractMesh[];
  109112. /** @hidden */
  109113. _unIndexed: boolean;
  109114. /** @hidden */
  109115. _lightSources: Light[];
  109116. /** Gets the list of lights affecting that mesh */
  109117. get lightSources(): Light[];
  109118. /** @hidden */
  109119. get _positions(): Nullable<Vector3[]>;
  109120. /** @hidden */
  109121. _waitingData: {
  109122. lods: Nullable<any>;
  109123. actions: Nullable<any>;
  109124. freezeWorldMatrix: Nullable<boolean>;
  109125. };
  109126. /** @hidden */
  109127. _bonesTransformMatrices: Nullable<Float32Array>;
  109128. /** @hidden */
  109129. _transformMatrixTexture: Nullable<RawTexture>;
  109130. /**
  109131. * Gets or sets a skeleton to apply skining transformations
  109132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109133. */
  109134. set skeleton(value: Nullable<Skeleton>);
  109135. get skeleton(): Nullable<Skeleton>;
  109136. /**
  109137. * An event triggered when the mesh is rebuilt.
  109138. */
  109139. onRebuildObservable: Observable<AbstractMesh>;
  109140. /**
  109141. * Creates a new AbstractMesh
  109142. * @param name defines the name of the mesh
  109143. * @param scene defines the hosting scene
  109144. */
  109145. constructor(name: string, scene?: Nullable<Scene>);
  109146. /**
  109147. * Returns the string "AbstractMesh"
  109148. * @returns "AbstractMesh"
  109149. */
  109150. getClassName(): string;
  109151. /**
  109152. * Gets a string representation of the current mesh
  109153. * @param fullDetails defines a boolean indicating if full details must be included
  109154. * @returns a string representation of the current mesh
  109155. */
  109156. toString(fullDetails?: boolean): string;
  109157. /**
  109158. * @hidden
  109159. */
  109160. protected _getEffectiveParent(): Nullable<Node>;
  109161. /** @hidden */
  109162. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109163. /** @hidden */
  109164. _rebuild(): void;
  109165. /** @hidden */
  109166. _resyncLightSources(): void;
  109167. /** @hidden */
  109168. _resyncLightSource(light: Light): void;
  109169. /** @hidden */
  109170. _unBindEffect(): void;
  109171. /** @hidden */
  109172. _removeLightSource(light: Light, dispose: boolean): void;
  109173. private _markSubMeshesAsDirty;
  109174. /** @hidden */
  109175. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109176. /** @hidden */
  109177. _markSubMeshesAsAttributesDirty(): void;
  109178. /** @hidden */
  109179. _markSubMeshesAsMiscDirty(): void;
  109180. /**
  109181. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109182. */
  109183. get scaling(): Vector3;
  109184. set scaling(newScaling: Vector3);
  109185. /**
  109186. * Returns true if the mesh is blocked. Implemented by child classes
  109187. */
  109188. get isBlocked(): boolean;
  109189. /**
  109190. * Returns the mesh itself by default. Implemented by child classes
  109191. * @param camera defines the camera to use to pick the right LOD level
  109192. * @returns the currentAbstractMesh
  109193. */
  109194. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109195. /**
  109196. * Returns 0 by default. Implemented by child classes
  109197. * @returns an integer
  109198. */
  109199. getTotalVertices(): number;
  109200. /**
  109201. * Returns a positive integer : the total number of indices in this mesh geometry.
  109202. * @returns the numner of indices or zero if the mesh has no geometry.
  109203. */
  109204. getTotalIndices(): number;
  109205. /**
  109206. * Returns null by default. Implemented by child classes
  109207. * @returns null
  109208. */
  109209. getIndices(): Nullable<IndicesArray>;
  109210. /**
  109211. * Returns the array of the requested vertex data kind. Implemented by child classes
  109212. * @param kind defines the vertex data kind to use
  109213. * @returns null
  109214. */
  109215. getVerticesData(kind: string): Nullable<FloatArray>;
  109216. /**
  109217. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109218. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109219. * Note that a new underlying VertexBuffer object is created each call.
  109220. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109221. * @param kind defines vertex data kind:
  109222. * * VertexBuffer.PositionKind
  109223. * * VertexBuffer.UVKind
  109224. * * VertexBuffer.UV2Kind
  109225. * * VertexBuffer.UV3Kind
  109226. * * VertexBuffer.UV4Kind
  109227. * * VertexBuffer.UV5Kind
  109228. * * VertexBuffer.UV6Kind
  109229. * * VertexBuffer.ColorKind
  109230. * * VertexBuffer.MatricesIndicesKind
  109231. * * VertexBuffer.MatricesIndicesExtraKind
  109232. * * VertexBuffer.MatricesWeightsKind
  109233. * * VertexBuffer.MatricesWeightsExtraKind
  109234. * @param data defines the data source
  109235. * @param updatable defines if the data must be flagged as updatable (or static)
  109236. * @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
  109237. * @returns the current mesh
  109238. */
  109239. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109240. /**
  109241. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109242. * If the mesh has no geometry, it is simply returned as it is.
  109243. * @param kind defines vertex data kind:
  109244. * * VertexBuffer.PositionKind
  109245. * * VertexBuffer.UVKind
  109246. * * VertexBuffer.UV2Kind
  109247. * * VertexBuffer.UV3Kind
  109248. * * VertexBuffer.UV4Kind
  109249. * * VertexBuffer.UV5Kind
  109250. * * VertexBuffer.UV6Kind
  109251. * * VertexBuffer.ColorKind
  109252. * * VertexBuffer.MatricesIndicesKind
  109253. * * VertexBuffer.MatricesIndicesExtraKind
  109254. * * VertexBuffer.MatricesWeightsKind
  109255. * * VertexBuffer.MatricesWeightsExtraKind
  109256. * @param data defines the data source
  109257. * @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
  109258. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109259. * @returns the current mesh
  109260. */
  109261. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109262. /**
  109263. * Sets the mesh indices,
  109264. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109265. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109266. * @param totalVertices Defines the total number of vertices
  109267. * @returns the current mesh
  109268. */
  109269. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109270. /**
  109271. * Gets a boolean indicating if specific vertex data is present
  109272. * @param kind defines the vertex data kind to use
  109273. * @returns true is data kind is present
  109274. */
  109275. isVerticesDataPresent(kind: string): boolean;
  109276. /**
  109277. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109278. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109279. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109280. * @returns a BoundingInfo
  109281. */
  109282. getBoundingInfo(): BoundingInfo;
  109283. /**
  109284. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109285. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109286. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109287. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109288. * @returns the current mesh
  109289. */
  109290. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109291. /**
  109292. * Overwrite the current bounding info
  109293. * @param boundingInfo defines the new bounding info
  109294. * @returns the current mesh
  109295. */
  109296. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109297. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109298. get useBones(): boolean;
  109299. /** @hidden */
  109300. _preActivate(): void;
  109301. /** @hidden */
  109302. _preActivateForIntermediateRendering(renderId: number): void;
  109303. /** @hidden */
  109304. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109305. /** @hidden */
  109306. _postActivate(): void;
  109307. /** @hidden */
  109308. _freeze(): void;
  109309. /** @hidden */
  109310. _unFreeze(): void;
  109311. /**
  109312. * Gets the current world matrix
  109313. * @returns a Matrix
  109314. */
  109315. getWorldMatrix(): Matrix;
  109316. /** @hidden */
  109317. _getWorldMatrixDeterminant(): number;
  109318. /**
  109319. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109320. */
  109321. get isAnInstance(): boolean;
  109322. /**
  109323. * Gets a boolean indicating if this mesh has instances
  109324. */
  109325. get hasInstances(): boolean;
  109326. /**
  109327. * Gets a boolean indicating if this mesh has thin instances
  109328. */
  109329. get hasThinInstances(): boolean;
  109330. /**
  109331. * Perform relative position change from the point of view of behind the front of the mesh.
  109332. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109333. * Supports definition of mesh facing forward or backward
  109334. * @param amountRight defines the distance on the right axis
  109335. * @param amountUp defines the distance on the up axis
  109336. * @param amountForward defines the distance on the forward axis
  109337. * @returns the current mesh
  109338. */
  109339. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109340. /**
  109341. * Calculate relative position change from the point of view of behind the front of the mesh.
  109342. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109343. * Supports definition of mesh facing forward or backward
  109344. * @param amountRight defines the distance on the right axis
  109345. * @param amountUp defines the distance on the up axis
  109346. * @param amountForward defines the distance on the forward axis
  109347. * @returns the new displacement vector
  109348. */
  109349. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109350. /**
  109351. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109352. * Supports definition of mesh facing forward or backward
  109353. * @param flipBack defines the flip
  109354. * @param twirlClockwise defines the twirl
  109355. * @param tiltRight defines the tilt
  109356. * @returns the current mesh
  109357. */
  109358. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109359. /**
  109360. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109361. * Supports definition of mesh facing forward or backward.
  109362. * @param flipBack defines the flip
  109363. * @param twirlClockwise defines the twirl
  109364. * @param tiltRight defines the tilt
  109365. * @returns the new rotation vector
  109366. */
  109367. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109368. /**
  109369. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109370. * This means the mesh underlying bounding box and sphere are recomputed.
  109371. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109372. * @returns the current mesh
  109373. */
  109374. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109375. /** @hidden */
  109376. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109377. /** @hidden */
  109378. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109379. /** @hidden */
  109380. _updateBoundingInfo(): AbstractMesh;
  109381. /** @hidden */
  109382. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109383. /** @hidden */
  109384. protected _afterComputeWorldMatrix(): void;
  109385. /** @hidden */
  109386. get _effectiveMesh(): AbstractMesh;
  109387. /**
  109388. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109389. * A mesh is in the frustum if its bounding box intersects the frustum
  109390. * @param frustumPlanes defines the frustum to test
  109391. * @returns true if the mesh is in the frustum planes
  109392. */
  109393. isInFrustum(frustumPlanes: Plane[]): boolean;
  109394. /**
  109395. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109396. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109397. * @param frustumPlanes defines the frustum to test
  109398. * @returns true if the mesh is completely in the frustum planes
  109399. */
  109400. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109401. /**
  109402. * True if the mesh intersects another mesh or a SolidParticle object
  109403. * @param mesh defines a target mesh or SolidParticle to test
  109404. * @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)
  109405. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109406. * @returns true if there is an intersection
  109407. */
  109408. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109409. /**
  109410. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109411. * @param point defines the point to test
  109412. * @returns true if there is an intersection
  109413. */
  109414. intersectsPoint(point: Vector3): boolean;
  109415. /**
  109416. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109418. */
  109419. get checkCollisions(): boolean;
  109420. set checkCollisions(collisionEnabled: boolean);
  109421. /**
  109422. * Gets Collider object used to compute collisions (not physics)
  109423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109424. */
  109425. get collider(): Nullable<Collider>;
  109426. /**
  109427. * Move the mesh using collision engine
  109428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109429. * @param displacement defines the requested displacement vector
  109430. * @returns the current mesh
  109431. */
  109432. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109433. private _onCollisionPositionChange;
  109434. /** @hidden */
  109435. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109436. /** @hidden */
  109437. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109438. /** @hidden */
  109439. _checkCollision(collider: Collider): AbstractMesh;
  109440. /** @hidden */
  109441. _generatePointsArray(): boolean;
  109442. /**
  109443. * Checks if the passed Ray intersects with the mesh
  109444. * @param ray defines the ray to use
  109445. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109446. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109447. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109448. * @returns the picking info
  109449. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109450. */
  109451. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109452. /**
  109453. * Clones the current mesh
  109454. * @param name defines the mesh name
  109455. * @param newParent defines the new mesh parent
  109456. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109457. * @returns the new mesh
  109458. */
  109459. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109460. /**
  109461. * Disposes all the submeshes of the current meshnp
  109462. * @returns the current mesh
  109463. */
  109464. releaseSubMeshes(): AbstractMesh;
  109465. /**
  109466. * Releases resources associated with this abstract mesh.
  109467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109469. */
  109470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109471. /**
  109472. * Adds the passed mesh as a child to the current mesh
  109473. * @param mesh defines the child mesh
  109474. * @returns the current mesh
  109475. */
  109476. addChild(mesh: AbstractMesh): AbstractMesh;
  109477. /**
  109478. * Removes the passed mesh from the current mesh children list
  109479. * @param mesh defines the child mesh
  109480. * @returns the current mesh
  109481. */
  109482. removeChild(mesh: AbstractMesh): AbstractMesh;
  109483. /** @hidden */
  109484. private _initFacetData;
  109485. /**
  109486. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109487. * This method can be called within the render loop.
  109488. * 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
  109489. * @returns the current mesh
  109490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109491. */
  109492. updateFacetData(): AbstractMesh;
  109493. /**
  109494. * Returns the facetLocalNormals array.
  109495. * The normals are expressed in the mesh local spac
  109496. * @returns an array of Vector3
  109497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109498. */
  109499. getFacetLocalNormals(): Vector3[];
  109500. /**
  109501. * Returns the facetLocalPositions array.
  109502. * The facet positions are expressed in the mesh local space
  109503. * @returns an array of Vector3
  109504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109505. */
  109506. getFacetLocalPositions(): Vector3[];
  109507. /**
  109508. * Returns the facetLocalPartioning array
  109509. * @returns an array of array of numbers
  109510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109511. */
  109512. getFacetLocalPartitioning(): number[][];
  109513. /**
  109514. * Returns the i-th facet position in the world system.
  109515. * This method allocates a new Vector3 per call
  109516. * @param i defines the facet index
  109517. * @returns a new Vector3
  109518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109519. */
  109520. getFacetPosition(i: number): Vector3;
  109521. /**
  109522. * Sets the reference Vector3 with the i-th facet position in the world system
  109523. * @param i defines the facet index
  109524. * @param ref defines the target vector
  109525. * @returns the current mesh
  109526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109527. */
  109528. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109529. /**
  109530. * Returns the i-th facet normal in the world system.
  109531. * This method allocates a new Vector3 per call
  109532. * @param i defines the facet index
  109533. * @returns a new Vector3
  109534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109535. */
  109536. getFacetNormal(i: number): Vector3;
  109537. /**
  109538. * Sets the reference Vector3 with the i-th facet normal in the world system
  109539. * @param i defines the facet index
  109540. * @param ref defines the target vector
  109541. * @returns the current mesh
  109542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109543. */
  109544. getFacetNormalToRef(i: number, ref: Vector3): this;
  109545. /**
  109546. * 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)
  109547. * @param x defines x coordinate
  109548. * @param y defines y coordinate
  109549. * @param z defines z coordinate
  109550. * @returns the array of facet indexes
  109551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109552. */
  109553. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109554. /**
  109555. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109556. * @param projected sets as the (x,y,z) world projection on the facet
  109557. * @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
  109558. * @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
  109559. * @param x defines x coordinate
  109560. * @param y defines y coordinate
  109561. * @param z defines z coordinate
  109562. * @returns the face index if found (or null instead)
  109563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109564. */
  109565. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109566. /**
  109567. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109568. * @param projected sets as the (x,y,z) local projection on the facet
  109569. * @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
  109570. * @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
  109571. * @param x defines x coordinate
  109572. * @param y defines y coordinate
  109573. * @param z defines z coordinate
  109574. * @returns the face index if found (or null instead)
  109575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109576. */
  109577. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109578. /**
  109579. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109580. * @returns the parameters
  109581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109582. */
  109583. getFacetDataParameters(): any;
  109584. /**
  109585. * Disables the feature FacetData and frees the related memory
  109586. * @returns the current mesh
  109587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109588. */
  109589. disableFacetData(): AbstractMesh;
  109590. /**
  109591. * Updates the AbstractMesh indices array
  109592. * @param indices defines the data source
  109593. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109594. * @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)
  109595. * @returns the current mesh
  109596. */
  109597. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109598. /**
  109599. * Creates new normals data for the mesh
  109600. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109601. * @returns the current mesh
  109602. */
  109603. createNormals(updatable: boolean): AbstractMesh;
  109604. /**
  109605. * Align the mesh with a normal
  109606. * @param normal defines the normal to use
  109607. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109608. * @returns the current mesh
  109609. */
  109610. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109611. /** @hidden */
  109612. _checkOcclusionQuery(): boolean;
  109613. /**
  109614. * Disables the mesh edge rendering mode
  109615. * @returns the currentAbstractMesh
  109616. */
  109617. disableEdgesRendering(): AbstractMesh;
  109618. /**
  109619. * Enables the edge rendering mode on the mesh.
  109620. * This mode makes the mesh edges visible
  109621. * @param epsilon defines the maximal distance between two angles to detect a face
  109622. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109623. * @returns the currentAbstractMesh
  109624. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109625. */
  109626. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109627. /**
  109628. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  109629. * @returns an array of particle systems in the scene that use the mesh as an emitter
  109630. */
  109631. getConnectedParticleSystems(): IParticleSystem[];
  109632. }
  109633. }
  109634. declare module BABYLON {
  109635. /**
  109636. * Interface used to define ActionEvent
  109637. */
  109638. export interface IActionEvent {
  109639. /** The mesh or sprite that triggered the action */
  109640. source: any;
  109641. /** The X mouse cursor position at the time of the event */
  109642. pointerX: number;
  109643. /** The Y mouse cursor position at the time of the event */
  109644. pointerY: number;
  109645. /** The mesh that is currently pointed at (can be null) */
  109646. meshUnderPointer: Nullable<AbstractMesh>;
  109647. /** the original (browser) event that triggered the ActionEvent */
  109648. sourceEvent?: any;
  109649. /** additional data for the event */
  109650. additionalData?: any;
  109651. }
  109652. /**
  109653. * ActionEvent is the event being sent when an action is triggered.
  109654. */
  109655. export class ActionEvent implements IActionEvent {
  109656. /** The mesh or sprite that triggered the action */
  109657. source: any;
  109658. /** The X mouse cursor position at the time of the event */
  109659. pointerX: number;
  109660. /** The Y mouse cursor position at the time of the event */
  109661. pointerY: number;
  109662. /** The mesh that is currently pointed at (can be null) */
  109663. meshUnderPointer: Nullable<AbstractMesh>;
  109664. /** the original (browser) event that triggered the ActionEvent */
  109665. sourceEvent?: any;
  109666. /** additional data for the event */
  109667. additionalData?: any;
  109668. /**
  109669. * Creates a new ActionEvent
  109670. * @param source The mesh or sprite that triggered the action
  109671. * @param pointerX The X mouse cursor position at the time of the event
  109672. * @param pointerY The Y mouse cursor position at the time of the event
  109673. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109674. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109675. * @param additionalData additional data for the event
  109676. */
  109677. constructor(
  109678. /** The mesh or sprite that triggered the action */
  109679. source: any,
  109680. /** The X mouse cursor position at the time of the event */
  109681. pointerX: number,
  109682. /** The Y mouse cursor position at the time of the event */
  109683. pointerY: number,
  109684. /** The mesh that is currently pointed at (can be null) */
  109685. meshUnderPointer: Nullable<AbstractMesh>,
  109686. /** the original (browser) event that triggered the ActionEvent */
  109687. sourceEvent?: any,
  109688. /** additional data for the event */
  109689. additionalData?: any);
  109690. /**
  109691. * Helper function to auto-create an ActionEvent from a source mesh.
  109692. * @param source The source mesh that triggered the event
  109693. * @param evt The original (browser) event
  109694. * @param additionalData additional data for the event
  109695. * @returns the new ActionEvent
  109696. */
  109697. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109698. /**
  109699. * Helper function to auto-create an ActionEvent from a source sprite
  109700. * @param source The source sprite that triggered the event
  109701. * @param scene Scene associated with the sprite
  109702. * @param evt The original (browser) event
  109703. * @param additionalData additional data for the event
  109704. * @returns the new ActionEvent
  109705. */
  109706. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109707. /**
  109708. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109709. * @param scene the scene where the event occurred
  109710. * @param evt The original (browser) event
  109711. * @returns the new ActionEvent
  109712. */
  109713. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109714. /**
  109715. * Helper function to auto-create an ActionEvent from a primitive
  109716. * @param prim defines the target primitive
  109717. * @param pointerPos defines the pointer position
  109718. * @param evt The original (browser) event
  109719. * @param additionalData additional data for the event
  109720. * @returns the new ActionEvent
  109721. */
  109722. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109723. }
  109724. }
  109725. declare module BABYLON {
  109726. /**
  109727. * Abstract class used to decouple action Manager from scene and meshes.
  109728. * Do not instantiate.
  109729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109730. */
  109731. export abstract class AbstractActionManager implements IDisposable {
  109732. /** Gets the list of active triggers */
  109733. static Triggers: {
  109734. [key: string]: number;
  109735. };
  109736. /** Gets the cursor to use when hovering items */
  109737. hoverCursor: string;
  109738. /** Gets the list of actions */
  109739. actions: IAction[];
  109740. /**
  109741. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109742. */
  109743. isRecursive: boolean;
  109744. /**
  109745. * Releases all associated resources
  109746. */
  109747. abstract dispose(): void;
  109748. /**
  109749. * Does this action manager has pointer triggers
  109750. */
  109751. abstract get hasPointerTriggers(): boolean;
  109752. /**
  109753. * Does this action manager has pick triggers
  109754. */
  109755. abstract get hasPickTriggers(): boolean;
  109756. /**
  109757. * Process a specific trigger
  109758. * @param trigger defines the trigger to process
  109759. * @param evt defines the event details to be processed
  109760. */
  109761. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109762. /**
  109763. * Does this action manager handles actions of any of the given triggers
  109764. * @param triggers defines the triggers to be tested
  109765. * @return a boolean indicating whether one (or more) of the triggers is handled
  109766. */
  109767. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109768. /**
  109769. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109770. * speed.
  109771. * @param triggerA defines the trigger to be tested
  109772. * @param triggerB defines the trigger to be tested
  109773. * @return a boolean indicating whether one (or more) of the triggers is handled
  109774. */
  109775. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109776. /**
  109777. * Does this action manager handles actions of a given trigger
  109778. * @param trigger defines the trigger to be tested
  109779. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109780. * @return whether the trigger is handled
  109781. */
  109782. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109783. /**
  109784. * Serialize this manager to a JSON object
  109785. * @param name defines the property name to store this manager
  109786. * @returns a JSON representation of this manager
  109787. */
  109788. abstract serialize(name: string): any;
  109789. /**
  109790. * Registers an action to this action manager
  109791. * @param action defines the action to be registered
  109792. * @return the action amended (prepared) after registration
  109793. */
  109794. abstract registerAction(action: IAction): Nullable<IAction>;
  109795. /**
  109796. * Unregisters an action to this action manager
  109797. * @param action defines the action to be unregistered
  109798. * @return a boolean indicating whether the action has been unregistered
  109799. */
  109800. abstract unregisterAction(action: IAction): Boolean;
  109801. /**
  109802. * Does exist one action manager with at least one trigger
  109803. **/
  109804. static get HasTriggers(): boolean;
  109805. /**
  109806. * Does exist one action manager with at least one pick trigger
  109807. **/
  109808. static get HasPickTriggers(): boolean;
  109809. /**
  109810. * Does exist one action manager that handles actions of a given trigger
  109811. * @param trigger defines the trigger to be tested
  109812. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109813. **/
  109814. static HasSpecificTrigger(trigger: number): boolean;
  109815. }
  109816. }
  109817. declare module BABYLON {
  109818. /**
  109819. * Defines how a node can be built from a string name.
  109820. */
  109821. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109822. /**
  109823. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109824. */
  109825. export class Node implements IBehaviorAware<Node> {
  109826. /** @hidden */
  109827. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109828. private static _NodeConstructors;
  109829. /**
  109830. * Add a new node constructor
  109831. * @param type defines the type name of the node to construct
  109832. * @param constructorFunc defines the constructor function
  109833. */
  109834. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109835. /**
  109836. * Returns a node constructor based on type name
  109837. * @param type defines the type name
  109838. * @param name defines the new node name
  109839. * @param scene defines the hosting scene
  109840. * @param options defines optional options to transmit to constructors
  109841. * @returns the new constructor or null
  109842. */
  109843. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109844. /**
  109845. * Gets or sets the name of the node
  109846. */
  109847. name: string;
  109848. /**
  109849. * Gets or sets the id of the node
  109850. */
  109851. id: string;
  109852. /**
  109853. * Gets or sets the unique id of the node
  109854. */
  109855. uniqueId: number;
  109856. /**
  109857. * Gets or sets a string used to store user defined state for the node
  109858. */
  109859. state: string;
  109860. /**
  109861. * Gets or sets an object used to store user defined information for the node
  109862. */
  109863. metadata: any;
  109864. /**
  109865. * For internal use only. Please do not use.
  109866. */
  109867. reservedDataStore: any;
  109868. /**
  109869. * List of inspectable custom properties (used by the Inspector)
  109870. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109871. */
  109872. inspectableCustomProperties: IInspectable[];
  109873. private _doNotSerialize;
  109874. /**
  109875. * Gets or sets a boolean used to define if the node must be serialized
  109876. */
  109877. get doNotSerialize(): boolean;
  109878. set doNotSerialize(value: boolean);
  109879. /** @hidden */
  109880. _isDisposed: boolean;
  109881. /**
  109882. * Gets a list of Animations associated with the node
  109883. */
  109884. animations: Animation[];
  109885. protected _ranges: {
  109886. [name: string]: Nullable<AnimationRange>;
  109887. };
  109888. /**
  109889. * Callback raised when the node is ready to be used
  109890. */
  109891. onReady: Nullable<(node: Node) => void>;
  109892. private _isEnabled;
  109893. private _isParentEnabled;
  109894. private _isReady;
  109895. /** @hidden */
  109896. _currentRenderId: number;
  109897. private _parentUpdateId;
  109898. /** @hidden */
  109899. _childUpdateId: number;
  109900. /** @hidden */
  109901. _waitingParentId: Nullable<string>;
  109902. /** @hidden */
  109903. _scene: Scene;
  109904. /** @hidden */
  109905. _cache: any;
  109906. private _parentNode;
  109907. private _children;
  109908. /** @hidden */
  109909. _worldMatrix: Matrix;
  109910. /** @hidden */
  109911. _worldMatrixDeterminant: number;
  109912. /** @hidden */
  109913. _worldMatrixDeterminantIsDirty: boolean;
  109914. /** @hidden */
  109915. private _sceneRootNodesIndex;
  109916. /**
  109917. * Gets a boolean indicating if the node has been disposed
  109918. * @returns true if the node was disposed
  109919. */
  109920. isDisposed(): boolean;
  109921. /**
  109922. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109923. * @see https://doc.babylonjs.com/how_to/parenting
  109924. */
  109925. set parent(parent: Nullable<Node>);
  109926. get parent(): Nullable<Node>;
  109927. /** @hidden */
  109928. _addToSceneRootNodes(): void;
  109929. /** @hidden */
  109930. _removeFromSceneRootNodes(): void;
  109931. private _animationPropertiesOverride;
  109932. /**
  109933. * Gets or sets the animation properties override
  109934. */
  109935. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109936. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109937. /**
  109938. * Gets a string idenfifying the name of the class
  109939. * @returns "Node" string
  109940. */
  109941. getClassName(): string;
  109942. /** @hidden */
  109943. readonly _isNode: boolean;
  109944. /**
  109945. * An event triggered when the mesh is disposed
  109946. */
  109947. onDisposeObservable: Observable<Node>;
  109948. private _onDisposeObserver;
  109949. /**
  109950. * Sets a callback that will be raised when the node will be disposed
  109951. */
  109952. set onDispose(callback: () => void);
  109953. /**
  109954. * Creates a new Node
  109955. * @param name the name and id to be given to this node
  109956. * @param scene the scene this node will be added to
  109957. */
  109958. constructor(name: string, scene?: Nullable<Scene>);
  109959. /**
  109960. * Gets the scene of the node
  109961. * @returns a scene
  109962. */
  109963. getScene(): Scene;
  109964. /**
  109965. * Gets the engine of the node
  109966. * @returns a Engine
  109967. */
  109968. getEngine(): Engine;
  109969. private _behaviors;
  109970. /**
  109971. * Attach a behavior to the node
  109972. * @see http://doc.babylonjs.com/features/behaviour
  109973. * @param behavior defines the behavior to attach
  109974. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109975. * @returns the current Node
  109976. */
  109977. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109978. /**
  109979. * Remove an attached behavior
  109980. * @see http://doc.babylonjs.com/features/behaviour
  109981. * @param behavior defines the behavior to attach
  109982. * @returns the current Node
  109983. */
  109984. removeBehavior(behavior: Behavior<Node>): Node;
  109985. /**
  109986. * Gets the list of attached behaviors
  109987. * @see http://doc.babylonjs.com/features/behaviour
  109988. */
  109989. get behaviors(): Behavior<Node>[];
  109990. /**
  109991. * Gets an attached behavior by name
  109992. * @param name defines the name of the behavior to look for
  109993. * @see http://doc.babylonjs.com/features/behaviour
  109994. * @returns null if behavior was not found else the requested behavior
  109995. */
  109996. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109997. /**
  109998. * Returns the latest update of the World matrix
  109999. * @returns a Matrix
  110000. */
  110001. getWorldMatrix(): Matrix;
  110002. /** @hidden */
  110003. _getWorldMatrixDeterminant(): number;
  110004. /**
  110005. * Returns directly the latest state of the mesh World matrix.
  110006. * A Matrix is returned.
  110007. */
  110008. get worldMatrixFromCache(): Matrix;
  110009. /** @hidden */
  110010. _initCache(): void;
  110011. /** @hidden */
  110012. updateCache(force?: boolean): void;
  110013. /** @hidden */
  110014. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110015. /** @hidden */
  110016. _updateCache(ignoreParentClass?: boolean): void;
  110017. /** @hidden */
  110018. _isSynchronized(): boolean;
  110019. /** @hidden */
  110020. _markSyncedWithParent(): void;
  110021. /** @hidden */
  110022. isSynchronizedWithParent(): boolean;
  110023. /** @hidden */
  110024. isSynchronized(): boolean;
  110025. /**
  110026. * Is this node ready to be used/rendered
  110027. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110028. * @return true if the node is ready
  110029. */
  110030. isReady(completeCheck?: boolean): boolean;
  110031. /**
  110032. * Is this node enabled?
  110033. * 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
  110034. * @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
  110035. * @return whether this node (and its parent) is enabled
  110036. */
  110037. isEnabled(checkAncestors?: boolean): boolean;
  110038. /** @hidden */
  110039. protected _syncParentEnabledState(): void;
  110040. /**
  110041. * Set the enabled state of this node
  110042. * @param value defines the new enabled state
  110043. */
  110044. setEnabled(value: boolean): void;
  110045. /**
  110046. * Is this node a descendant of the given node?
  110047. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110048. * @param ancestor defines the parent node to inspect
  110049. * @returns a boolean indicating if this node is a descendant of the given node
  110050. */
  110051. isDescendantOf(ancestor: Node): boolean;
  110052. /** @hidden */
  110053. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110054. /**
  110055. * Will return all nodes that have this node as ascendant
  110056. * @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
  110057. * @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
  110058. * @return all children nodes of all types
  110059. */
  110060. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110061. /**
  110062. * Get all child-meshes of this node
  110063. * @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)
  110064. * @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
  110065. * @returns an array of AbstractMesh
  110066. */
  110067. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110068. /**
  110069. * Get all direct children of this node
  110070. * @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
  110071. * @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)
  110072. * @returns an array of Node
  110073. */
  110074. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110075. /** @hidden */
  110076. _setReady(state: boolean): void;
  110077. /**
  110078. * Get an animation by name
  110079. * @param name defines the name of the animation to look for
  110080. * @returns null if not found else the requested animation
  110081. */
  110082. getAnimationByName(name: string): Nullable<Animation>;
  110083. /**
  110084. * Creates an animation range for this node
  110085. * @param name defines the name of the range
  110086. * @param from defines the starting key
  110087. * @param to defines the end key
  110088. */
  110089. createAnimationRange(name: string, from: number, to: number): void;
  110090. /**
  110091. * Delete a specific animation range
  110092. * @param name defines the name of the range to delete
  110093. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110094. */
  110095. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110096. /**
  110097. * Get an animation range by name
  110098. * @param name defines the name of the animation range to look for
  110099. * @returns null if not found else the requested animation range
  110100. */
  110101. getAnimationRange(name: string): Nullable<AnimationRange>;
  110102. /**
  110103. * Gets the list of all animation ranges defined on this node
  110104. * @returns an array
  110105. */
  110106. getAnimationRanges(): Nullable<AnimationRange>[];
  110107. /**
  110108. * Will start the animation sequence
  110109. * @param name defines the range frames for animation sequence
  110110. * @param loop defines if the animation should loop (false by default)
  110111. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110112. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110113. * @returns the object created for this animation. If range does not exist, it will return null
  110114. */
  110115. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110116. /**
  110117. * Serialize animation ranges into a JSON compatible object
  110118. * @returns serialization object
  110119. */
  110120. serializeAnimationRanges(): any;
  110121. /**
  110122. * Computes the world matrix of the node
  110123. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110124. * @returns the world matrix
  110125. */
  110126. computeWorldMatrix(force?: boolean): Matrix;
  110127. /**
  110128. * Releases resources associated with this node.
  110129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110131. */
  110132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110133. /**
  110134. * Parse animation range data from a serialization object and store them into a given node
  110135. * @param node defines where to store the animation ranges
  110136. * @param parsedNode defines the serialization object to read data from
  110137. * @param scene defines the hosting scene
  110138. */
  110139. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110140. /**
  110141. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110142. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110143. * @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
  110144. * @returns the new bounding vectors
  110145. */
  110146. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110147. min: Vector3;
  110148. max: Vector3;
  110149. };
  110150. }
  110151. }
  110152. declare module BABYLON {
  110153. /**
  110154. * @hidden
  110155. */
  110156. export class _IAnimationState {
  110157. key: number;
  110158. repeatCount: number;
  110159. workValue?: any;
  110160. loopMode?: number;
  110161. offsetValue?: any;
  110162. highLimitValue?: any;
  110163. }
  110164. /**
  110165. * Class used to store any kind of animation
  110166. */
  110167. export class Animation {
  110168. /**Name of the animation */
  110169. name: string;
  110170. /**Property to animate */
  110171. targetProperty: string;
  110172. /**The frames per second of the animation */
  110173. framePerSecond: number;
  110174. /**The data type of the animation */
  110175. dataType: number;
  110176. /**The loop mode of the animation */
  110177. loopMode?: number | undefined;
  110178. /**Specifies if blending should be enabled */
  110179. enableBlending?: boolean | undefined;
  110180. /**
  110181. * Use matrix interpolation instead of using direct key value when animating matrices
  110182. */
  110183. static AllowMatricesInterpolation: boolean;
  110184. /**
  110185. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110186. */
  110187. static AllowMatrixDecomposeForInterpolation: boolean;
  110188. /** Define the Url to load snippets */
  110189. static SnippetUrl: string;
  110190. /** Snippet ID if the animation was created from the snippet server */
  110191. snippetId: string;
  110192. /**
  110193. * Stores the key frames of the animation
  110194. */
  110195. private _keys;
  110196. /**
  110197. * Stores the easing function of the animation
  110198. */
  110199. private _easingFunction;
  110200. /**
  110201. * @hidden Internal use only
  110202. */
  110203. _runtimeAnimations: RuntimeAnimation[];
  110204. /**
  110205. * The set of event that will be linked to this animation
  110206. */
  110207. private _events;
  110208. /**
  110209. * Stores an array of target property paths
  110210. */
  110211. targetPropertyPath: string[];
  110212. /**
  110213. * Stores the blending speed of the animation
  110214. */
  110215. blendingSpeed: number;
  110216. /**
  110217. * Stores the animation ranges for the animation
  110218. */
  110219. private _ranges;
  110220. /**
  110221. * @hidden Internal use
  110222. */
  110223. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110224. /**
  110225. * Sets up an animation
  110226. * @param property The property to animate
  110227. * @param animationType The animation type to apply
  110228. * @param framePerSecond The frames per second of the animation
  110229. * @param easingFunction The easing function used in the animation
  110230. * @returns The created animation
  110231. */
  110232. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110233. /**
  110234. * Create and start an animation on a node
  110235. * @param name defines the name of the global animation that will be run on all nodes
  110236. * @param node defines the root node where the animation will take place
  110237. * @param targetProperty defines property to animate
  110238. * @param framePerSecond defines the number of frame per second yo use
  110239. * @param totalFrame defines the number of frames in total
  110240. * @param from defines the initial value
  110241. * @param to defines the final value
  110242. * @param loopMode defines which loop mode you want to use (off by default)
  110243. * @param easingFunction defines the easing function to use (linear by default)
  110244. * @param onAnimationEnd defines the callback to call when animation end
  110245. * @returns the animatable created for this animation
  110246. */
  110247. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110248. /**
  110249. * Create and start an animation on a node and its descendants
  110250. * @param name defines the name of the global animation that will be run on all nodes
  110251. * @param node defines the root node where the animation will take place
  110252. * @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
  110253. * @param targetProperty defines property to animate
  110254. * @param framePerSecond defines the number of frame per second to use
  110255. * @param totalFrame defines the number of frames in total
  110256. * @param from defines the initial value
  110257. * @param to defines the final value
  110258. * @param loopMode defines which loop mode you want to use (off by default)
  110259. * @param easingFunction defines the easing function to use (linear by default)
  110260. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110261. * @returns the list of animatables created for all nodes
  110262. * @example https://www.babylonjs-playground.com/#MH0VLI
  110263. */
  110264. 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[]>;
  110265. /**
  110266. * Creates a new animation, merges it with the existing animations and starts it
  110267. * @param name Name of the animation
  110268. * @param node Node which contains the scene that begins the animations
  110269. * @param targetProperty Specifies which property to animate
  110270. * @param framePerSecond The frames per second of the animation
  110271. * @param totalFrame The total number of frames
  110272. * @param from The frame at the beginning of the animation
  110273. * @param to The frame at the end of the animation
  110274. * @param loopMode Specifies the loop mode of the animation
  110275. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110276. * @param onAnimationEnd Callback to run once the animation is complete
  110277. * @returns Nullable animation
  110278. */
  110279. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110280. /**
  110281. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110282. * @param sourceAnimation defines the Animation containing keyframes to convert
  110283. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110284. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110285. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110286. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110287. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110288. */
  110289. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110290. /**
  110291. * Transition property of an host to the target Value
  110292. * @param property The property to transition
  110293. * @param targetValue The target Value of the property
  110294. * @param host The object where the property to animate belongs
  110295. * @param scene Scene used to run the animation
  110296. * @param frameRate Framerate (in frame/s) to use
  110297. * @param transition The transition type we want to use
  110298. * @param duration The duration of the animation, in milliseconds
  110299. * @param onAnimationEnd Callback trigger at the end of the animation
  110300. * @returns Nullable animation
  110301. */
  110302. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110303. /**
  110304. * Return the array of runtime animations currently using this animation
  110305. */
  110306. get runtimeAnimations(): RuntimeAnimation[];
  110307. /**
  110308. * Specifies if any of the runtime animations are currently running
  110309. */
  110310. get hasRunningRuntimeAnimations(): boolean;
  110311. /**
  110312. * Initializes the animation
  110313. * @param name Name of the animation
  110314. * @param targetProperty Property to animate
  110315. * @param framePerSecond The frames per second of the animation
  110316. * @param dataType The data type of the animation
  110317. * @param loopMode The loop mode of the animation
  110318. * @param enableBlending Specifies if blending should be enabled
  110319. */
  110320. constructor(
  110321. /**Name of the animation */
  110322. name: string,
  110323. /**Property to animate */
  110324. targetProperty: string,
  110325. /**The frames per second of the animation */
  110326. framePerSecond: number,
  110327. /**The data type of the animation */
  110328. dataType: number,
  110329. /**The loop mode of the animation */
  110330. loopMode?: number | undefined,
  110331. /**Specifies if blending should be enabled */
  110332. enableBlending?: boolean | undefined);
  110333. /**
  110334. * Converts the animation to a string
  110335. * @param fullDetails support for multiple levels of logging within scene loading
  110336. * @returns String form of the animation
  110337. */
  110338. toString(fullDetails?: boolean): string;
  110339. /**
  110340. * Add an event to this animation
  110341. * @param event Event to add
  110342. */
  110343. addEvent(event: AnimationEvent): void;
  110344. /**
  110345. * Remove all events found at the given frame
  110346. * @param frame The frame to remove events from
  110347. */
  110348. removeEvents(frame: number): void;
  110349. /**
  110350. * Retrieves all the events from the animation
  110351. * @returns Events from the animation
  110352. */
  110353. getEvents(): AnimationEvent[];
  110354. /**
  110355. * Creates an animation range
  110356. * @param name Name of the animation range
  110357. * @param from Starting frame of the animation range
  110358. * @param to Ending frame of the animation
  110359. */
  110360. createRange(name: string, from: number, to: number): void;
  110361. /**
  110362. * Deletes an animation range by name
  110363. * @param name Name of the animation range to delete
  110364. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110365. */
  110366. deleteRange(name: string, deleteFrames?: boolean): void;
  110367. /**
  110368. * Gets the animation range by name, or null if not defined
  110369. * @param name Name of the animation range
  110370. * @returns Nullable animation range
  110371. */
  110372. getRange(name: string): Nullable<AnimationRange>;
  110373. /**
  110374. * Gets the key frames from the animation
  110375. * @returns The key frames of the animation
  110376. */
  110377. getKeys(): Array<IAnimationKey>;
  110378. /**
  110379. * Gets the highest frame rate of the animation
  110380. * @returns Highest frame rate of the animation
  110381. */
  110382. getHighestFrame(): number;
  110383. /**
  110384. * Gets the easing function of the animation
  110385. * @returns Easing function of the animation
  110386. */
  110387. getEasingFunction(): IEasingFunction;
  110388. /**
  110389. * Sets the easing function of the animation
  110390. * @param easingFunction A custom mathematical formula for animation
  110391. */
  110392. setEasingFunction(easingFunction: EasingFunction): void;
  110393. /**
  110394. * Interpolates a scalar linearly
  110395. * @param startValue Start value of the animation curve
  110396. * @param endValue End value of the animation curve
  110397. * @param gradient Scalar amount to interpolate
  110398. * @returns Interpolated scalar value
  110399. */
  110400. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110401. /**
  110402. * Interpolates a scalar cubically
  110403. * @param startValue Start value of the animation curve
  110404. * @param outTangent End tangent of the animation
  110405. * @param endValue End value of the animation curve
  110406. * @param inTangent Start tangent of the animation curve
  110407. * @param gradient Scalar amount to interpolate
  110408. * @returns Interpolated scalar value
  110409. */
  110410. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110411. /**
  110412. * Interpolates a quaternion using a spherical linear interpolation
  110413. * @param startValue Start value of the animation curve
  110414. * @param endValue End value of the animation curve
  110415. * @param gradient Scalar amount to interpolate
  110416. * @returns Interpolated quaternion value
  110417. */
  110418. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110419. /**
  110420. * Interpolates a quaternion cubically
  110421. * @param startValue Start value of the animation curve
  110422. * @param outTangent End tangent of the animation curve
  110423. * @param endValue End value of the animation curve
  110424. * @param inTangent Start tangent of the animation curve
  110425. * @param gradient Scalar amount to interpolate
  110426. * @returns Interpolated quaternion value
  110427. */
  110428. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110429. /**
  110430. * Interpolates a Vector3 linearl
  110431. * @param startValue Start value of the animation curve
  110432. * @param endValue End value of the animation curve
  110433. * @param gradient Scalar amount to interpolate
  110434. * @returns Interpolated scalar value
  110435. */
  110436. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110437. /**
  110438. * Interpolates a Vector3 cubically
  110439. * @param startValue Start value of the animation curve
  110440. * @param outTangent End tangent of the animation
  110441. * @param endValue End value of the animation curve
  110442. * @param inTangent Start tangent of the animation curve
  110443. * @param gradient Scalar amount to interpolate
  110444. * @returns InterpolatedVector3 value
  110445. */
  110446. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110447. /**
  110448. * Interpolates a Vector2 linearly
  110449. * @param startValue Start value of the animation curve
  110450. * @param endValue End value of the animation curve
  110451. * @param gradient Scalar amount to interpolate
  110452. * @returns Interpolated Vector2 value
  110453. */
  110454. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110455. /**
  110456. * Interpolates a Vector2 cubically
  110457. * @param startValue Start value of the animation curve
  110458. * @param outTangent End tangent of the animation
  110459. * @param endValue End value of the animation curve
  110460. * @param inTangent Start tangent of the animation curve
  110461. * @param gradient Scalar amount to interpolate
  110462. * @returns Interpolated Vector2 value
  110463. */
  110464. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110465. /**
  110466. * Interpolates a size linearly
  110467. * @param startValue Start value of the animation curve
  110468. * @param endValue End value of the animation curve
  110469. * @param gradient Scalar amount to interpolate
  110470. * @returns Interpolated Size value
  110471. */
  110472. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110473. /**
  110474. * Interpolates a Color3 linearly
  110475. * @param startValue Start value of the animation curve
  110476. * @param endValue End value of the animation curve
  110477. * @param gradient Scalar amount to interpolate
  110478. * @returns Interpolated Color3 value
  110479. */
  110480. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110481. /**
  110482. * Interpolates a Color4 linearly
  110483. * @param startValue Start value of the animation curve
  110484. * @param endValue End value of the animation curve
  110485. * @param gradient Scalar amount to interpolate
  110486. * @returns Interpolated Color3 value
  110487. */
  110488. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110489. /**
  110490. * @hidden Internal use only
  110491. */
  110492. _getKeyValue(value: any): any;
  110493. /**
  110494. * @hidden Internal use only
  110495. */
  110496. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110497. /**
  110498. * Defines the function to use to interpolate matrices
  110499. * @param startValue defines the start matrix
  110500. * @param endValue defines the end matrix
  110501. * @param gradient defines the gradient between both matrices
  110502. * @param result defines an optional target matrix where to store the interpolation
  110503. * @returns the interpolated matrix
  110504. */
  110505. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110506. /**
  110507. * Makes a copy of the animation
  110508. * @returns Cloned animation
  110509. */
  110510. clone(): Animation;
  110511. /**
  110512. * Sets the key frames of the animation
  110513. * @param values The animation key frames to set
  110514. */
  110515. setKeys(values: Array<IAnimationKey>): void;
  110516. /**
  110517. * Serializes the animation to an object
  110518. * @returns Serialized object
  110519. */
  110520. serialize(): any;
  110521. /**
  110522. * Float animation type
  110523. */
  110524. static readonly ANIMATIONTYPE_FLOAT: number;
  110525. /**
  110526. * Vector3 animation type
  110527. */
  110528. static readonly ANIMATIONTYPE_VECTOR3: number;
  110529. /**
  110530. * Quaternion animation type
  110531. */
  110532. static readonly ANIMATIONTYPE_QUATERNION: number;
  110533. /**
  110534. * Matrix animation type
  110535. */
  110536. static readonly ANIMATIONTYPE_MATRIX: number;
  110537. /**
  110538. * Color3 animation type
  110539. */
  110540. static readonly ANIMATIONTYPE_COLOR3: number;
  110541. /**
  110542. * Color3 animation type
  110543. */
  110544. static readonly ANIMATIONTYPE_COLOR4: number;
  110545. /**
  110546. * Vector2 animation type
  110547. */
  110548. static readonly ANIMATIONTYPE_VECTOR2: number;
  110549. /**
  110550. * Size animation type
  110551. */
  110552. static readonly ANIMATIONTYPE_SIZE: number;
  110553. /**
  110554. * Relative Loop Mode
  110555. */
  110556. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110557. /**
  110558. * Cycle Loop Mode
  110559. */
  110560. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110561. /**
  110562. * Constant Loop Mode
  110563. */
  110564. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110565. /** @hidden */
  110566. static _UniversalLerp(left: any, right: any, amount: number): any;
  110567. /**
  110568. * Parses an animation object and creates an animation
  110569. * @param parsedAnimation Parsed animation object
  110570. * @returns Animation object
  110571. */
  110572. static Parse(parsedAnimation: any): Animation;
  110573. /**
  110574. * Appends the serialized animations from the source animations
  110575. * @param source Source containing the animations
  110576. * @param destination Target to store the animations
  110577. */
  110578. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110579. /**
  110580. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110581. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110582. * @param url defines the url to load from
  110583. * @returns a promise that will resolve to the new animation or an array of animations
  110584. */
  110585. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110586. /**
  110587. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110588. * @param snippetId defines the snippet to load
  110589. * @returns a promise that will resolve to the new animation or a new array of animations
  110590. */
  110591. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110592. }
  110593. }
  110594. declare module BABYLON {
  110595. /**
  110596. * Interface containing an array of animations
  110597. */
  110598. export interface IAnimatable {
  110599. /**
  110600. * Array of animations
  110601. */
  110602. animations: Nullable<Array<Animation>>;
  110603. }
  110604. }
  110605. declare module BABYLON {
  110606. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110607. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110608. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110609. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110610. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110611. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110612. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110613. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110614. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110615. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110616. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110617. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110618. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110619. /**
  110620. * Decorator used to define property that can be serialized as reference to a camera
  110621. * @param sourceName defines the name of the property to decorate
  110622. */
  110623. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110624. /**
  110625. * Class used to help serialization objects
  110626. */
  110627. export class SerializationHelper {
  110628. /** @hidden */
  110629. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110630. /** @hidden */
  110631. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110632. /** @hidden */
  110633. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110634. /** @hidden */
  110635. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110636. /**
  110637. * Appends the serialized animations from the source animations
  110638. * @param source Source containing the animations
  110639. * @param destination Target to store the animations
  110640. */
  110641. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110642. /**
  110643. * Static function used to serialized a specific entity
  110644. * @param entity defines the entity to serialize
  110645. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110646. * @returns a JSON compatible object representing the serialization of the entity
  110647. */
  110648. static Serialize<T>(entity: T, serializationObject?: any): any;
  110649. /**
  110650. * Creates a new entity from a serialization data object
  110651. * @param creationFunction defines a function used to instanciated the new entity
  110652. * @param source defines the source serialization data
  110653. * @param scene defines the hosting scene
  110654. * @param rootUrl defines the root url for resources
  110655. * @returns a new entity
  110656. */
  110657. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110658. /**
  110659. * Clones an object
  110660. * @param creationFunction defines the function used to instanciate the new object
  110661. * @param source defines the source object
  110662. * @returns the cloned object
  110663. */
  110664. static Clone<T>(creationFunction: () => T, source: T): T;
  110665. /**
  110666. * Instanciates a new object based on a source one (some data will be shared between both object)
  110667. * @param creationFunction defines the function used to instanciate the new object
  110668. * @param source defines the source object
  110669. * @returns the new object
  110670. */
  110671. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110672. }
  110673. }
  110674. declare module BABYLON {
  110675. /**
  110676. * Base class of all the textures in babylon.
  110677. * It groups all the common properties the materials, post process, lights... might need
  110678. * in order to make a correct use of the texture.
  110679. */
  110680. export class BaseTexture implements IAnimatable {
  110681. /**
  110682. * Default anisotropic filtering level for the application.
  110683. * It is set to 4 as a good tradeoff between perf and quality.
  110684. */
  110685. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110686. /**
  110687. * Gets or sets the unique id of the texture
  110688. */
  110689. uniqueId: number;
  110690. /**
  110691. * Define the name of the texture.
  110692. */
  110693. name: string;
  110694. /**
  110695. * Gets or sets an object used to store user defined information.
  110696. */
  110697. metadata: any;
  110698. /**
  110699. * For internal use only. Please do not use.
  110700. */
  110701. reservedDataStore: any;
  110702. private _hasAlpha;
  110703. /**
  110704. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110705. */
  110706. set hasAlpha(value: boolean);
  110707. get hasAlpha(): boolean;
  110708. /**
  110709. * Defines if the alpha value should be determined via the rgb values.
  110710. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110711. */
  110712. getAlphaFromRGB: boolean;
  110713. /**
  110714. * Intensity or strength of the texture.
  110715. * It is commonly used by materials to fine tune the intensity of the texture
  110716. */
  110717. level: number;
  110718. /**
  110719. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110720. * This is part of the texture as textures usually maps to one uv set.
  110721. */
  110722. coordinatesIndex: number;
  110723. private _coordinatesMode;
  110724. /**
  110725. * How a texture is mapped.
  110726. *
  110727. * | Value | Type | Description |
  110728. * | ----- | ----------------------------------- | ----------- |
  110729. * | 0 | EXPLICIT_MODE | |
  110730. * | 1 | SPHERICAL_MODE | |
  110731. * | 2 | PLANAR_MODE | |
  110732. * | 3 | CUBIC_MODE | |
  110733. * | 4 | PROJECTION_MODE | |
  110734. * | 5 | SKYBOX_MODE | |
  110735. * | 6 | INVCUBIC_MODE | |
  110736. * | 7 | EQUIRECTANGULAR_MODE | |
  110737. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110738. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110739. */
  110740. set coordinatesMode(value: number);
  110741. get coordinatesMode(): number;
  110742. /**
  110743. * | Value | Type | Description |
  110744. * | ----- | ------------------ | ----------- |
  110745. * | 0 | CLAMP_ADDRESSMODE | |
  110746. * | 1 | WRAP_ADDRESSMODE | |
  110747. * | 2 | MIRROR_ADDRESSMODE | |
  110748. */
  110749. wrapU: number;
  110750. /**
  110751. * | Value | Type | Description |
  110752. * | ----- | ------------------ | ----------- |
  110753. * | 0 | CLAMP_ADDRESSMODE | |
  110754. * | 1 | WRAP_ADDRESSMODE | |
  110755. * | 2 | MIRROR_ADDRESSMODE | |
  110756. */
  110757. wrapV: number;
  110758. /**
  110759. * | Value | Type | Description |
  110760. * | ----- | ------------------ | ----------- |
  110761. * | 0 | CLAMP_ADDRESSMODE | |
  110762. * | 1 | WRAP_ADDRESSMODE | |
  110763. * | 2 | MIRROR_ADDRESSMODE | |
  110764. */
  110765. wrapR: number;
  110766. /**
  110767. * With compliant hardware and browser (supporting anisotropic filtering)
  110768. * this defines the level of anisotropic filtering in the texture.
  110769. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110770. */
  110771. anisotropicFilteringLevel: number;
  110772. /**
  110773. * Define if the texture is a cube texture or if false a 2d texture.
  110774. */
  110775. get isCube(): boolean;
  110776. set isCube(value: boolean);
  110777. /**
  110778. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110779. */
  110780. get is3D(): boolean;
  110781. set is3D(value: boolean);
  110782. /**
  110783. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110784. */
  110785. get is2DArray(): boolean;
  110786. set is2DArray(value: boolean);
  110787. /**
  110788. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110789. * HDR texture are usually stored in linear space.
  110790. * This only impacts the PBR and Background materials
  110791. */
  110792. gammaSpace: boolean;
  110793. /**
  110794. * Gets or sets whether or not the texture contains RGBD data.
  110795. */
  110796. get isRGBD(): boolean;
  110797. set isRGBD(value: boolean);
  110798. /**
  110799. * Is Z inverted in the texture (useful in a cube texture).
  110800. */
  110801. invertZ: boolean;
  110802. /**
  110803. * Are mip maps generated for this texture or not.
  110804. */
  110805. get noMipmap(): boolean;
  110806. /**
  110807. * @hidden
  110808. */
  110809. lodLevelInAlpha: boolean;
  110810. /**
  110811. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110812. */
  110813. get lodGenerationOffset(): number;
  110814. set lodGenerationOffset(value: number);
  110815. /**
  110816. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110817. */
  110818. get lodGenerationScale(): number;
  110819. set lodGenerationScale(value: number);
  110820. /**
  110821. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110822. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110823. * average roughness values.
  110824. */
  110825. get linearSpecularLOD(): boolean;
  110826. set linearSpecularLOD(value: boolean);
  110827. /**
  110828. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110829. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110830. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110831. */
  110832. get irradianceTexture(): Nullable<BaseTexture>;
  110833. set irradianceTexture(value: Nullable<BaseTexture>);
  110834. /**
  110835. * Define if the texture is a render target.
  110836. */
  110837. isRenderTarget: boolean;
  110838. /**
  110839. * Define the unique id of the texture in the scene.
  110840. */
  110841. get uid(): string;
  110842. /** @hidden */
  110843. _prefiltered: boolean;
  110844. /**
  110845. * Return a string representation of the texture.
  110846. * @returns the texture as a string
  110847. */
  110848. toString(): string;
  110849. /**
  110850. * Get the class name of the texture.
  110851. * @returns "BaseTexture"
  110852. */
  110853. getClassName(): string;
  110854. /**
  110855. * Define the list of animation attached to the texture.
  110856. */
  110857. animations: Animation[];
  110858. /**
  110859. * An event triggered when the texture is disposed.
  110860. */
  110861. onDisposeObservable: Observable<BaseTexture>;
  110862. private _onDisposeObserver;
  110863. /**
  110864. * Callback triggered when the texture has been disposed.
  110865. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110866. */
  110867. set onDispose(callback: () => void);
  110868. /**
  110869. * Define the current state of the loading sequence when in delayed load mode.
  110870. */
  110871. delayLoadState: number;
  110872. private _scene;
  110873. private _engine;
  110874. /** @hidden */
  110875. _texture: Nullable<InternalTexture>;
  110876. private _uid;
  110877. /**
  110878. * Define if the texture is preventinga material to render or not.
  110879. * If not and the texture is not ready, the engine will use a default black texture instead.
  110880. */
  110881. get isBlocking(): boolean;
  110882. /**
  110883. * Instantiates a new BaseTexture.
  110884. * Base class of all the textures in babylon.
  110885. * It groups all the common properties the materials, post process, lights... might need
  110886. * in order to make a correct use of the texture.
  110887. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110888. */
  110889. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110890. /**
  110891. * Get the scene the texture belongs to.
  110892. * @returns the scene or null if undefined
  110893. */
  110894. getScene(): Nullable<Scene>;
  110895. /** @hidden */
  110896. protected _getEngine(): Nullable<ThinEngine>;
  110897. /**
  110898. * Get the texture transform matrix used to offset tile the texture for istance.
  110899. * @returns the transformation matrix
  110900. */
  110901. getTextureMatrix(): Matrix;
  110902. /**
  110903. * Get the texture reflection matrix used to rotate/transform the reflection.
  110904. * @returns the reflection matrix
  110905. */
  110906. getReflectionTextureMatrix(): Matrix;
  110907. /**
  110908. * Get the underlying lower level texture from Babylon.
  110909. * @returns the insternal texture
  110910. */
  110911. getInternalTexture(): Nullable<InternalTexture>;
  110912. /**
  110913. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110914. * @returns true if ready or not blocking
  110915. */
  110916. isReadyOrNotBlocking(): boolean;
  110917. /**
  110918. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110919. * @returns true if fully ready
  110920. */
  110921. isReady(): boolean;
  110922. private _cachedSize;
  110923. /**
  110924. * Get the size of the texture.
  110925. * @returns the texture size.
  110926. */
  110927. getSize(): ISize;
  110928. /**
  110929. * Get the base size of the texture.
  110930. * It can be different from the size if the texture has been resized for POT for instance
  110931. * @returns the base size
  110932. */
  110933. getBaseSize(): ISize;
  110934. /**
  110935. * Update the sampling mode of the texture.
  110936. * Default is Trilinear mode.
  110937. *
  110938. * | Value | Type | Description |
  110939. * | ----- | ------------------ | ----------- |
  110940. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110941. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110942. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110943. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110944. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110945. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110946. * | 7 | NEAREST_LINEAR | |
  110947. * | 8 | NEAREST_NEAREST | |
  110948. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110949. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110950. * | 11 | LINEAR_LINEAR | |
  110951. * | 12 | LINEAR_NEAREST | |
  110952. *
  110953. * > _mag_: magnification filter (close to the viewer)
  110954. * > _min_: minification filter (far from the viewer)
  110955. * > _mip_: filter used between mip map levels
  110956. *@param samplingMode Define the new sampling mode of the texture
  110957. */
  110958. updateSamplingMode(samplingMode: number): void;
  110959. /**
  110960. * Scales the texture if is `canRescale()`
  110961. * @param ratio the resize factor we want to use to rescale
  110962. */
  110963. scale(ratio: number): void;
  110964. /**
  110965. * Get if the texture can rescale.
  110966. */
  110967. get canRescale(): boolean;
  110968. /** @hidden */
  110969. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110970. /** @hidden */
  110971. _rebuild(): void;
  110972. /**
  110973. * Triggers the load sequence in delayed load mode.
  110974. */
  110975. delayLoad(): void;
  110976. /**
  110977. * Clones the texture.
  110978. * @returns the cloned texture
  110979. */
  110980. clone(): Nullable<BaseTexture>;
  110981. /**
  110982. * Get the texture underlying type (INT, FLOAT...)
  110983. */
  110984. get textureType(): number;
  110985. /**
  110986. * Get the texture underlying format (RGB, RGBA...)
  110987. */
  110988. get textureFormat(): number;
  110989. /**
  110990. * Indicates that textures need to be re-calculated for all materials
  110991. */
  110992. protected _markAllSubMeshesAsTexturesDirty(): void;
  110993. /**
  110994. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110995. * This will returns an RGBA array buffer containing either in values (0-255) or
  110996. * float values (0-1) depending of the underlying buffer type.
  110997. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110998. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110999. * @param buffer defines a user defined buffer to fill with data (can be null)
  111000. * @returns The Array buffer containing the pixels data.
  111001. */
  111002. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111003. /**
  111004. * Release and destroy the underlying lower level texture aka internalTexture.
  111005. */
  111006. releaseInternalTexture(): void;
  111007. /** @hidden */
  111008. get _lodTextureHigh(): Nullable<BaseTexture>;
  111009. /** @hidden */
  111010. get _lodTextureMid(): Nullable<BaseTexture>;
  111011. /** @hidden */
  111012. get _lodTextureLow(): Nullable<BaseTexture>;
  111013. /**
  111014. * Dispose the texture and release its associated resources.
  111015. */
  111016. dispose(): void;
  111017. /**
  111018. * Serialize the texture into a JSON representation that can be parsed later on.
  111019. * @returns the JSON representation of the texture
  111020. */
  111021. serialize(): any;
  111022. /**
  111023. * Helper function to be called back once a list of texture contains only ready textures.
  111024. * @param textures Define the list of textures to wait for
  111025. * @param callback Define the callback triggered once the entire list will be ready
  111026. */
  111027. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111028. private static _isScene;
  111029. }
  111030. }
  111031. declare module BABYLON {
  111032. /**
  111033. * Options to be used when creating an effect.
  111034. */
  111035. export interface IEffectCreationOptions {
  111036. /**
  111037. * Atrributes that will be used in the shader.
  111038. */
  111039. attributes: string[];
  111040. /**
  111041. * Uniform varible names that will be set in the shader.
  111042. */
  111043. uniformsNames: string[];
  111044. /**
  111045. * Uniform buffer variable names that will be set in the shader.
  111046. */
  111047. uniformBuffersNames: string[];
  111048. /**
  111049. * Sampler texture variable names that will be set in the shader.
  111050. */
  111051. samplers: string[];
  111052. /**
  111053. * Define statements that will be set in the shader.
  111054. */
  111055. defines: any;
  111056. /**
  111057. * Possible fallbacks for this effect to improve performance when needed.
  111058. */
  111059. fallbacks: Nullable<IEffectFallbacks>;
  111060. /**
  111061. * Callback that will be called when the shader is compiled.
  111062. */
  111063. onCompiled: Nullable<(effect: Effect) => void>;
  111064. /**
  111065. * Callback that will be called if an error occurs during shader compilation.
  111066. */
  111067. onError: Nullable<(effect: Effect, errors: string) => void>;
  111068. /**
  111069. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111070. */
  111071. indexParameters?: any;
  111072. /**
  111073. * Max number of lights that can be used in the shader.
  111074. */
  111075. maxSimultaneousLights?: number;
  111076. /**
  111077. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111078. */
  111079. transformFeedbackVaryings?: Nullable<string[]>;
  111080. /**
  111081. * 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
  111082. */
  111083. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111084. }
  111085. /**
  111086. * Effect containing vertex and fragment shader that can be executed on an object.
  111087. */
  111088. export class Effect implements IDisposable {
  111089. /**
  111090. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111091. */
  111092. static ShadersRepository: string;
  111093. /**
  111094. * Enable logging of the shader code when a compilation error occurs
  111095. */
  111096. static LogShaderCodeOnCompilationError: boolean;
  111097. /**
  111098. * Name of the effect.
  111099. */
  111100. name: any;
  111101. /**
  111102. * String container all the define statements that should be set on the shader.
  111103. */
  111104. defines: string;
  111105. /**
  111106. * Callback that will be called when the shader is compiled.
  111107. */
  111108. onCompiled: Nullable<(effect: Effect) => void>;
  111109. /**
  111110. * Callback that will be called if an error occurs during shader compilation.
  111111. */
  111112. onError: Nullable<(effect: Effect, errors: string) => void>;
  111113. /**
  111114. * Callback that will be called when effect is bound.
  111115. */
  111116. onBind: Nullable<(effect: Effect) => void>;
  111117. /**
  111118. * Unique ID of the effect.
  111119. */
  111120. uniqueId: number;
  111121. /**
  111122. * Observable that will be called when the shader is compiled.
  111123. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111124. */
  111125. onCompileObservable: Observable<Effect>;
  111126. /**
  111127. * Observable that will be called if an error occurs during shader compilation.
  111128. */
  111129. onErrorObservable: Observable<Effect>;
  111130. /** @hidden */
  111131. _onBindObservable: Nullable<Observable<Effect>>;
  111132. /**
  111133. * @hidden
  111134. * Specifies if the effect was previously ready
  111135. */
  111136. _wasPreviouslyReady: boolean;
  111137. /**
  111138. * Observable that will be called when effect is bound.
  111139. */
  111140. get onBindObservable(): Observable<Effect>;
  111141. /** @hidden */
  111142. _bonesComputationForcedToCPU: boolean;
  111143. private static _uniqueIdSeed;
  111144. private _engine;
  111145. private _uniformBuffersNames;
  111146. private _uniformBuffersNamesList;
  111147. private _uniformsNames;
  111148. private _samplerList;
  111149. private _samplers;
  111150. private _isReady;
  111151. private _compilationError;
  111152. private _allFallbacksProcessed;
  111153. private _attributesNames;
  111154. private _attributes;
  111155. private _attributeLocationByName;
  111156. private _uniforms;
  111157. /**
  111158. * Key for the effect.
  111159. * @hidden
  111160. */
  111161. _key: string;
  111162. private _indexParameters;
  111163. private _fallbacks;
  111164. private _vertexSourceCode;
  111165. private _fragmentSourceCode;
  111166. private _vertexSourceCodeOverride;
  111167. private _fragmentSourceCodeOverride;
  111168. private _transformFeedbackVaryings;
  111169. /**
  111170. * Compiled shader to webGL program.
  111171. * @hidden
  111172. */
  111173. _pipelineContext: Nullable<IPipelineContext>;
  111174. private _valueCache;
  111175. private static _baseCache;
  111176. /**
  111177. * Instantiates an effect.
  111178. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111179. * @param baseName Name of the effect.
  111180. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111181. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111182. * @param samplers List of sampler variables that will be passed to the shader.
  111183. * @param engine Engine to be used to render the effect
  111184. * @param defines Define statements to be added to the shader.
  111185. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111186. * @param onCompiled Callback that will be called when the shader is compiled.
  111187. * @param onError Callback that will be called if an error occurs during shader compilation.
  111188. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111189. */
  111190. 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);
  111191. private _useFinalCode;
  111192. /**
  111193. * Unique key for this effect
  111194. */
  111195. get key(): string;
  111196. /**
  111197. * If the effect has been compiled and prepared.
  111198. * @returns if the effect is compiled and prepared.
  111199. */
  111200. isReady(): boolean;
  111201. private _isReadyInternal;
  111202. /**
  111203. * The engine the effect was initialized with.
  111204. * @returns the engine.
  111205. */
  111206. getEngine(): Engine;
  111207. /**
  111208. * The pipeline context for this effect
  111209. * @returns the associated pipeline context
  111210. */
  111211. getPipelineContext(): Nullable<IPipelineContext>;
  111212. /**
  111213. * The set of names of attribute variables for the shader.
  111214. * @returns An array of attribute names.
  111215. */
  111216. getAttributesNames(): string[];
  111217. /**
  111218. * Returns the attribute at the given index.
  111219. * @param index The index of the attribute.
  111220. * @returns The location of the attribute.
  111221. */
  111222. getAttributeLocation(index: number): number;
  111223. /**
  111224. * Returns the attribute based on the name of the variable.
  111225. * @param name of the attribute to look up.
  111226. * @returns the attribute location.
  111227. */
  111228. getAttributeLocationByName(name: string): number;
  111229. /**
  111230. * The number of attributes.
  111231. * @returns the numnber of attributes.
  111232. */
  111233. getAttributesCount(): number;
  111234. /**
  111235. * Gets the index of a uniform variable.
  111236. * @param uniformName of the uniform to look up.
  111237. * @returns the index.
  111238. */
  111239. getUniformIndex(uniformName: string): number;
  111240. /**
  111241. * Returns the attribute based on the name of the variable.
  111242. * @param uniformName of the uniform to look up.
  111243. * @returns the location of the uniform.
  111244. */
  111245. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111246. /**
  111247. * Returns an array of sampler variable names
  111248. * @returns The array of sampler variable names.
  111249. */
  111250. getSamplers(): string[];
  111251. /**
  111252. * Returns an array of uniform variable names
  111253. * @returns The array of uniform variable names.
  111254. */
  111255. getUniformNames(): string[];
  111256. /**
  111257. * Returns an array of uniform buffer variable names
  111258. * @returns The array of uniform buffer variable names.
  111259. */
  111260. getUniformBuffersNames(): string[];
  111261. /**
  111262. * Returns the index parameters used to create the effect
  111263. * @returns The index parameters object
  111264. */
  111265. getIndexParameters(): any;
  111266. /**
  111267. * The error from the last compilation.
  111268. * @returns the error string.
  111269. */
  111270. getCompilationError(): string;
  111271. /**
  111272. * Gets a boolean indicating that all fallbacks were used during compilation
  111273. * @returns true if all fallbacks were used
  111274. */
  111275. allFallbacksProcessed(): boolean;
  111276. /**
  111277. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111278. * @param func The callback to be used.
  111279. */
  111280. executeWhenCompiled(func: (effect: Effect) => void): void;
  111281. private _checkIsReady;
  111282. private _loadShader;
  111283. /**
  111284. * Gets the vertex shader source code of this effect
  111285. */
  111286. get vertexSourceCode(): string;
  111287. /**
  111288. * Gets the fragment shader source code of this effect
  111289. */
  111290. get fragmentSourceCode(): string;
  111291. /**
  111292. * Recompiles the webGL program
  111293. * @param vertexSourceCode The source code for the vertex shader.
  111294. * @param fragmentSourceCode The source code for the fragment shader.
  111295. * @param onCompiled Callback called when completed.
  111296. * @param onError Callback called on error.
  111297. * @hidden
  111298. */
  111299. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111300. /**
  111301. * Prepares the effect
  111302. * @hidden
  111303. */
  111304. _prepareEffect(): void;
  111305. private _getShaderCodeAndErrorLine;
  111306. private _processCompilationErrors;
  111307. /**
  111308. * Checks if the effect is supported. (Must be called after compilation)
  111309. */
  111310. get isSupported(): boolean;
  111311. /**
  111312. * Binds a texture to the engine to be used as output of the shader.
  111313. * @param channel Name of the output variable.
  111314. * @param texture Texture to bind.
  111315. * @hidden
  111316. */
  111317. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111318. /**
  111319. * Sets a texture on the engine to be used in the shader.
  111320. * @param channel Name of the sampler variable.
  111321. * @param texture Texture to set.
  111322. */
  111323. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111324. /**
  111325. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111326. * @param channel Name of the sampler variable.
  111327. * @param texture Texture to set.
  111328. */
  111329. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111330. /**
  111331. * Sets an array of textures on the engine to be used in the shader.
  111332. * @param channel Name of the variable.
  111333. * @param textures Textures to set.
  111334. */
  111335. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111336. /**
  111337. * 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)
  111338. * @param channel Name of the sampler variable.
  111339. * @param postProcess Post process to get the input texture from.
  111340. */
  111341. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111342. /**
  111343. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111344. * 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)
  111345. * @param channel Name of the sampler variable.
  111346. * @param postProcess Post process to get the output texture from.
  111347. */
  111348. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111349. /** @hidden */
  111350. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111351. /** @hidden */
  111352. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111353. /** @hidden */
  111354. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111355. /** @hidden */
  111356. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111357. /**
  111358. * Binds a buffer to a uniform.
  111359. * @param buffer Buffer to bind.
  111360. * @param name Name of the uniform variable to bind to.
  111361. */
  111362. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111363. /**
  111364. * Binds block to a uniform.
  111365. * @param blockName Name of the block to bind.
  111366. * @param index Index to bind.
  111367. */
  111368. bindUniformBlock(blockName: string, index: number): void;
  111369. /**
  111370. * Sets an interger value on a uniform variable.
  111371. * @param uniformName Name of the variable.
  111372. * @param value Value to be set.
  111373. * @returns this effect.
  111374. */
  111375. setInt(uniformName: string, value: number): Effect;
  111376. /**
  111377. * Sets an int array on a uniform variable.
  111378. * @param uniformName Name of the variable.
  111379. * @param array array to be set.
  111380. * @returns this effect.
  111381. */
  111382. setIntArray(uniformName: string, array: Int32Array): Effect;
  111383. /**
  111384. * 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)
  111385. * @param uniformName Name of the variable.
  111386. * @param array array to be set.
  111387. * @returns this effect.
  111388. */
  111389. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111390. /**
  111391. * 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)
  111392. * @param uniformName Name of the variable.
  111393. * @param array array to be set.
  111394. * @returns this effect.
  111395. */
  111396. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111397. /**
  111398. * 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)
  111399. * @param uniformName Name of the variable.
  111400. * @param array array to be set.
  111401. * @returns this effect.
  111402. */
  111403. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111404. /**
  111405. * Sets an float array on a uniform variable.
  111406. * @param uniformName Name of the variable.
  111407. * @param array array to be set.
  111408. * @returns this effect.
  111409. */
  111410. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111411. /**
  111412. * 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)
  111413. * @param uniformName Name of the variable.
  111414. * @param array array to be set.
  111415. * @returns this effect.
  111416. */
  111417. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111418. /**
  111419. * 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)
  111420. * @param uniformName Name of the variable.
  111421. * @param array array to be set.
  111422. * @returns this effect.
  111423. */
  111424. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111425. /**
  111426. * 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)
  111427. * @param uniformName Name of the variable.
  111428. * @param array array to be set.
  111429. * @returns this effect.
  111430. */
  111431. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111432. /**
  111433. * Sets an array on a uniform variable.
  111434. * @param uniformName Name of the variable.
  111435. * @param array array to be set.
  111436. * @returns this effect.
  111437. */
  111438. setArray(uniformName: string, array: number[]): Effect;
  111439. /**
  111440. * 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)
  111441. * @param uniformName Name of the variable.
  111442. * @param array array to be set.
  111443. * @returns this effect.
  111444. */
  111445. setArray2(uniformName: string, array: number[]): Effect;
  111446. /**
  111447. * 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)
  111448. * @param uniformName Name of the variable.
  111449. * @param array array to be set.
  111450. * @returns this effect.
  111451. */
  111452. setArray3(uniformName: string, array: number[]): Effect;
  111453. /**
  111454. * 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)
  111455. * @param uniformName Name of the variable.
  111456. * @param array array to be set.
  111457. * @returns this effect.
  111458. */
  111459. setArray4(uniformName: string, array: number[]): Effect;
  111460. /**
  111461. * Sets matrices on a uniform variable.
  111462. * @param uniformName Name of the variable.
  111463. * @param matrices matrices to be set.
  111464. * @returns this effect.
  111465. */
  111466. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111467. /**
  111468. * Sets matrix on a uniform variable.
  111469. * @param uniformName Name of the variable.
  111470. * @param matrix matrix to be set.
  111471. * @returns this effect.
  111472. */
  111473. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111474. /**
  111475. * 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)
  111476. * @param uniformName Name of the variable.
  111477. * @param matrix matrix to be set.
  111478. * @returns this effect.
  111479. */
  111480. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111481. /**
  111482. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111483. * @param uniformName Name of the variable.
  111484. * @param matrix matrix to be set.
  111485. * @returns this effect.
  111486. */
  111487. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111488. /**
  111489. * Sets a float on a uniform variable.
  111490. * @param uniformName Name of the variable.
  111491. * @param value value to be set.
  111492. * @returns this effect.
  111493. */
  111494. setFloat(uniformName: string, value: number): Effect;
  111495. /**
  111496. * Sets a boolean on a uniform variable.
  111497. * @param uniformName Name of the variable.
  111498. * @param bool value to be set.
  111499. * @returns this effect.
  111500. */
  111501. setBool(uniformName: string, bool: boolean): Effect;
  111502. /**
  111503. * Sets a Vector2 on a uniform variable.
  111504. * @param uniformName Name of the variable.
  111505. * @param vector2 vector2 to be set.
  111506. * @returns this effect.
  111507. */
  111508. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111509. /**
  111510. * Sets a float2 on a uniform variable.
  111511. * @param uniformName Name of the variable.
  111512. * @param x First float in float2.
  111513. * @param y Second float in float2.
  111514. * @returns this effect.
  111515. */
  111516. setFloat2(uniformName: string, x: number, y: number): Effect;
  111517. /**
  111518. * Sets a Vector3 on a uniform variable.
  111519. * @param uniformName Name of the variable.
  111520. * @param vector3 Value to be set.
  111521. * @returns this effect.
  111522. */
  111523. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111524. /**
  111525. * Sets a float3 on a uniform variable.
  111526. * @param uniformName Name of the variable.
  111527. * @param x First float in float3.
  111528. * @param y Second float in float3.
  111529. * @param z Third float in float3.
  111530. * @returns this effect.
  111531. */
  111532. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111533. /**
  111534. * Sets a Vector4 on a uniform variable.
  111535. * @param uniformName Name of the variable.
  111536. * @param vector4 Value to be set.
  111537. * @returns this effect.
  111538. */
  111539. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111540. /**
  111541. * Sets a float4 on a uniform variable.
  111542. * @param uniformName Name of the variable.
  111543. * @param x First float in float4.
  111544. * @param y Second float in float4.
  111545. * @param z Third float in float4.
  111546. * @param w Fourth float in float4.
  111547. * @returns this effect.
  111548. */
  111549. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111550. /**
  111551. * Sets a Color3 on a uniform variable.
  111552. * @param uniformName Name of the variable.
  111553. * @param color3 Value to be set.
  111554. * @returns this effect.
  111555. */
  111556. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111557. /**
  111558. * Sets a Color4 on a uniform variable.
  111559. * @param uniformName Name of the variable.
  111560. * @param color3 Value to be set.
  111561. * @param alpha Alpha value to be set.
  111562. * @returns this effect.
  111563. */
  111564. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111565. /**
  111566. * Sets a Color4 on a uniform variable
  111567. * @param uniformName defines the name of the variable
  111568. * @param color4 defines the value to be set
  111569. * @returns this effect.
  111570. */
  111571. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111572. /** Release all associated resources */
  111573. dispose(): void;
  111574. /**
  111575. * This function will add a new shader to the shader store
  111576. * @param name the name of the shader
  111577. * @param pixelShader optional pixel shader content
  111578. * @param vertexShader optional vertex shader content
  111579. */
  111580. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111581. /**
  111582. * Store of each shader (The can be looked up using effect.key)
  111583. */
  111584. static ShadersStore: {
  111585. [key: string]: string;
  111586. };
  111587. /**
  111588. * Store of each included file for a shader (The can be looked up using effect.key)
  111589. */
  111590. static IncludesShadersStore: {
  111591. [key: string]: string;
  111592. };
  111593. /**
  111594. * Resets the cache of effects.
  111595. */
  111596. static ResetCache(): void;
  111597. }
  111598. }
  111599. declare module BABYLON {
  111600. /**
  111601. * Interface used to describe the capabilities of the engine relatively to the current browser
  111602. */
  111603. export interface EngineCapabilities {
  111604. /** Maximum textures units per fragment shader */
  111605. maxTexturesImageUnits: number;
  111606. /** Maximum texture units per vertex shader */
  111607. maxVertexTextureImageUnits: number;
  111608. /** Maximum textures units in the entire pipeline */
  111609. maxCombinedTexturesImageUnits: number;
  111610. /** Maximum texture size */
  111611. maxTextureSize: number;
  111612. /** Maximum texture samples */
  111613. maxSamples?: number;
  111614. /** Maximum cube texture size */
  111615. maxCubemapTextureSize: number;
  111616. /** Maximum render texture size */
  111617. maxRenderTextureSize: number;
  111618. /** Maximum number of vertex attributes */
  111619. maxVertexAttribs: number;
  111620. /** Maximum number of varyings */
  111621. maxVaryingVectors: number;
  111622. /** Maximum number of uniforms per vertex shader */
  111623. maxVertexUniformVectors: number;
  111624. /** Maximum number of uniforms per fragment shader */
  111625. maxFragmentUniformVectors: number;
  111626. /** Defines if standard derivates (dx/dy) are supported */
  111627. standardDerivatives: boolean;
  111628. /** Defines if s3tc texture compression is supported */
  111629. s3tc?: WEBGL_compressed_texture_s3tc;
  111630. /** Defines if pvrtc texture compression is supported */
  111631. pvrtc: any;
  111632. /** Defines if etc1 texture compression is supported */
  111633. etc1: any;
  111634. /** Defines if etc2 texture compression is supported */
  111635. etc2: any;
  111636. /** Defines if astc texture compression is supported */
  111637. astc: any;
  111638. /** Defines if float textures are supported */
  111639. textureFloat: boolean;
  111640. /** Defines if vertex array objects are supported */
  111641. vertexArrayObject: boolean;
  111642. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111643. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111644. /** Gets the maximum level of anisotropy supported */
  111645. maxAnisotropy: number;
  111646. /** Defines if instancing is supported */
  111647. instancedArrays: boolean;
  111648. /** Defines if 32 bits indices are supported */
  111649. uintIndices: boolean;
  111650. /** Defines if high precision shaders are supported */
  111651. highPrecisionShaderSupported: boolean;
  111652. /** Defines if depth reading in the fragment shader is supported */
  111653. fragmentDepthSupported: boolean;
  111654. /** Defines if float texture linear filtering is supported*/
  111655. textureFloatLinearFiltering: boolean;
  111656. /** Defines if rendering to float textures is supported */
  111657. textureFloatRender: boolean;
  111658. /** Defines if half float textures are supported*/
  111659. textureHalfFloat: boolean;
  111660. /** Defines if half float texture linear filtering is supported*/
  111661. textureHalfFloatLinearFiltering: boolean;
  111662. /** Defines if rendering to half float textures is supported */
  111663. textureHalfFloatRender: boolean;
  111664. /** Defines if textureLOD shader command is supported */
  111665. textureLOD: boolean;
  111666. /** Defines if draw buffers extension is supported */
  111667. drawBuffersExtension: boolean;
  111668. /** Defines if depth textures are supported */
  111669. depthTextureExtension: boolean;
  111670. /** Defines if float color buffer are supported */
  111671. colorBufferFloat: boolean;
  111672. /** Gets disjoint timer query extension (null if not supported) */
  111673. timerQuery?: EXT_disjoint_timer_query;
  111674. /** Defines if timestamp can be used with timer query */
  111675. canUseTimestampForTimerQuery: boolean;
  111676. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111677. multiview?: any;
  111678. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111679. oculusMultiview?: any;
  111680. /** Function used to let the system compiles shaders in background */
  111681. parallelShaderCompile?: {
  111682. COMPLETION_STATUS_KHR: number;
  111683. };
  111684. /** Max number of texture samples for MSAA */
  111685. maxMSAASamples: number;
  111686. /** Defines if the blend min max extension is supported */
  111687. blendMinMax: boolean;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * @hidden
  111693. **/
  111694. export class DepthCullingState {
  111695. private _isDepthTestDirty;
  111696. private _isDepthMaskDirty;
  111697. private _isDepthFuncDirty;
  111698. private _isCullFaceDirty;
  111699. private _isCullDirty;
  111700. private _isZOffsetDirty;
  111701. private _isFrontFaceDirty;
  111702. private _depthTest;
  111703. private _depthMask;
  111704. private _depthFunc;
  111705. private _cull;
  111706. private _cullFace;
  111707. private _zOffset;
  111708. private _frontFace;
  111709. /**
  111710. * Initializes the state.
  111711. */
  111712. constructor();
  111713. get isDirty(): boolean;
  111714. get zOffset(): number;
  111715. set zOffset(value: number);
  111716. get cullFace(): Nullable<number>;
  111717. set cullFace(value: Nullable<number>);
  111718. get cull(): Nullable<boolean>;
  111719. set cull(value: Nullable<boolean>);
  111720. get depthFunc(): Nullable<number>;
  111721. set depthFunc(value: Nullable<number>);
  111722. get depthMask(): boolean;
  111723. set depthMask(value: boolean);
  111724. get depthTest(): boolean;
  111725. set depthTest(value: boolean);
  111726. get frontFace(): Nullable<number>;
  111727. set frontFace(value: Nullable<number>);
  111728. reset(): void;
  111729. apply(gl: WebGLRenderingContext): void;
  111730. }
  111731. }
  111732. declare module BABYLON {
  111733. /**
  111734. * @hidden
  111735. **/
  111736. export class StencilState {
  111737. /** 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 */
  111738. static readonly ALWAYS: number;
  111739. /** Passed to stencilOperation to specify that stencil value must be kept */
  111740. static readonly KEEP: number;
  111741. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111742. static readonly REPLACE: number;
  111743. private _isStencilTestDirty;
  111744. private _isStencilMaskDirty;
  111745. private _isStencilFuncDirty;
  111746. private _isStencilOpDirty;
  111747. private _stencilTest;
  111748. private _stencilMask;
  111749. private _stencilFunc;
  111750. private _stencilFuncRef;
  111751. private _stencilFuncMask;
  111752. private _stencilOpStencilFail;
  111753. private _stencilOpDepthFail;
  111754. private _stencilOpStencilDepthPass;
  111755. get isDirty(): boolean;
  111756. get stencilFunc(): number;
  111757. set stencilFunc(value: number);
  111758. get stencilFuncRef(): number;
  111759. set stencilFuncRef(value: number);
  111760. get stencilFuncMask(): number;
  111761. set stencilFuncMask(value: number);
  111762. get stencilOpStencilFail(): number;
  111763. set stencilOpStencilFail(value: number);
  111764. get stencilOpDepthFail(): number;
  111765. set stencilOpDepthFail(value: number);
  111766. get stencilOpStencilDepthPass(): number;
  111767. set stencilOpStencilDepthPass(value: number);
  111768. get stencilMask(): number;
  111769. set stencilMask(value: number);
  111770. get stencilTest(): boolean;
  111771. set stencilTest(value: boolean);
  111772. constructor();
  111773. reset(): void;
  111774. apply(gl: WebGLRenderingContext): void;
  111775. }
  111776. }
  111777. declare module BABYLON {
  111778. /**
  111779. * @hidden
  111780. **/
  111781. export class AlphaState {
  111782. private _isAlphaBlendDirty;
  111783. private _isBlendFunctionParametersDirty;
  111784. private _isBlendEquationParametersDirty;
  111785. private _isBlendConstantsDirty;
  111786. private _alphaBlend;
  111787. private _blendFunctionParameters;
  111788. private _blendEquationParameters;
  111789. private _blendConstants;
  111790. /**
  111791. * Initializes the state.
  111792. */
  111793. constructor();
  111794. get isDirty(): boolean;
  111795. get alphaBlend(): boolean;
  111796. set alphaBlend(value: boolean);
  111797. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111798. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111799. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111800. reset(): void;
  111801. apply(gl: WebGLRenderingContext): void;
  111802. }
  111803. }
  111804. declare module BABYLON {
  111805. /** @hidden */
  111806. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111807. attributeProcessor(attribute: string): string;
  111808. varyingProcessor(varying: string, isFragment: boolean): string;
  111809. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111810. }
  111811. }
  111812. declare module BABYLON {
  111813. /**
  111814. * Interface for attribute information associated with buffer instanciation
  111815. */
  111816. export interface InstancingAttributeInfo {
  111817. /**
  111818. * Name of the GLSL attribute
  111819. * if attribute index is not specified, this is used to retrieve the index from the effect
  111820. */
  111821. attributeName: string;
  111822. /**
  111823. * Index/offset of the attribute in the vertex shader
  111824. * if not specified, this will be computes from the name.
  111825. */
  111826. index?: number;
  111827. /**
  111828. * size of the attribute, 1, 2, 3 or 4
  111829. */
  111830. attributeSize: number;
  111831. /**
  111832. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111833. */
  111834. offset: number;
  111835. /**
  111836. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111837. * default to 1
  111838. */
  111839. divisor?: number;
  111840. /**
  111841. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111842. * default is FLOAT
  111843. */
  111844. attributeType?: number;
  111845. /**
  111846. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111847. */
  111848. normalized?: boolean;
  111849. }
  111850. }
  111851. declare module BABYLON {
  111852. interface ThinEngine {
  111853. /**
  111854. * Update a video texture
  111855. * @param texture defines the texture to update
  111856. * @param video defines the video element to use
  111857. * @param invertY defines if data must be stored with Y axis inverted
  111858. */
  111859. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111860. }
  111861. }
  111862. declare module BABYLON {
  111863. interface ThinEngine {
  111864. /**
  111865. * Creates a dynamic texture
  111866. * @param width defines the width of the texture
  111867. * @param height defines the height of the texture
  111868. * @param generateMipMaps defines if the engine should generate the mip levels
  111869. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  111870. * @returns the dynamic texture inside an InternalTexture
  111871. */
  111872. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  111873. /**
  111874. * Update the content of a dynamic texture
  111875. * @param texture defines the texture to update
  111876. * @param canvas defines the canvas containing the source
  111877. * @param invertY defines if data must be stored with Y axis inverted
  111878. * @param premulAlpha defines if alpha is stored as premultiplied
  111879. * @param format defines the format of the data
  111880. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111881. */
  111882. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  111883. }
  111884. }
  111885. declare module BABYLON {
  111886. /**
  111887. * Settings for finer control over video usage
  111888. */
  111889. export interface VideoTextureSettings {
  111890. /**
  111891. * Applies `autoplay` to video, if specified
  111892. */
  111893. autoPlay?: boolean;
  111894. /**
  111895. * Applies `loop` to video, if specified
  111896. */
  111897. loop?: boolean;
  111898. /**
  111899. * Automatically updates internal texture from video at every frame in the render loop
  111900. */
  111901. autoUpdateTexture: boolean;
  111902. /**
  111903. * Image src displayed during the video loading or until the user interacts with the video.
  111904. */
  111905. poster?: string;
  111906. }
  111907. /**
  111908. * If you want to display a video in your scene, this is the special texture for that.
  111909. * This special texture works similar to other textures, with the exception of a few parameters.
  111910. * @see https://doc.babylonjs.com/how_to/video_texture
  111911. */
  111912. export class VideoTexture extends Texture {
  111913. /**
  111914. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111915. */
  111916. readonly autoUpdateTexture: boolean;
  111917. /**
  111918. * The video instance used by the texture internally
  111919. */
  111920. readonly video: HTMLVideoElement;
  111921. private _onUserActionRequestedObservable;
  111922. /**
  111923. * Event triggerd when a dom action is required by the user to play the video.
  111924. * This happens due to recent changes in browser policies preventing video to auto start.
  111925. */
  111926. get onUserActionRequestedObservable(): Observable<Texture>;
  111927. private _generateMipMaps;
  111928. private _stillImageCaptured;
  111929. private _displayingPosterTexture;
  111930. private _settings;
  111931. private _createInternalTextureOnEvent;
  111932. private _frameId;
  111933. private _currentSrc;
  111934. /**
  111935. * Creates a video texture.
  111936. * If you want to display a video in your scene, this is the special texture for that.
  111937. * This special texture works similar to other textures, with the exception of a few parameters.
  111938. * @see https://doc.babylonjs.com/how_to/video_texture
  111939. * @param name optional name, will detect from video source, if not defined
  111940. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111941. * @param scene is obviously the current scene.
  111942. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111943. * @param invertY is false by default but can be used to invert video on Y axis
  111944. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111945. * @param settings allows finer control over video usage
  111946. */
  111947. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111948. private _getName;
  111949. private _getVideo;
  111950. private _createInternalTexture;
  111951. private reset;
  111952. /**
  111953. * @hidden Internal method to initiate `update`.
  111954. */
  111955. _rebuild(): void;
  111956. /**
  111957. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111958. */
  111959. update(): void;
  111960. /**
  111961. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111962. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111963. */
  111964. updateTexture(isVisible: boolean): void;
  111965. protected _updateInternalTexture: () => void;
  111966. /**
  111967. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111968. * @param url New url.
  111969. */
  111970. updateURL(url: string): void;
  111971. /**
  111972. * Clones the texture.
  111973. * @returns the cloned texture
  111974. */
  111975. clone(): VideoTexture;
  111976. /**
  111977. * Dispose the texture and release its associated resources.
  111978. */
  111979. dispose(): void;
  111980. /**
  111981. * Creates a video texture straight from a stream.
  111982. * @param scene Define the scene the texture should be created in
  111983. * @param stream Define the stream the texture should be created from
  111984. * @returns The created video texture as a promise
  111985. */
  111986. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111987. /**
  111988. * Creates a video texture straight from your WebCam video feed.
  111989. * @param scene Define the scene the texture should be created in
  111990. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111991. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111992. * @returns The created video texture as a promise
  111993. */
  111994. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111995. minWidth: number;
  111996. maxWidth: number;
  111997. minHeight: number;
  111998. maxHeight: number;
  111999. deviceId: string;
  112000. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112001. /**
  112002. * Creates a video texture straight from your WebCam video feed.
  112003. * @param scene Define the scene the texture should be created in
  112004. * @param onReady Define a callback to triggered once the texture will be ready
  112005. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112006. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112007. */
  112008. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112009. minWidth: number;
  112010. maxWidth: number;
  112011. minHeight: number;
  112012. maxHeight: number;
  112013. deviceId: string;
  112014. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112015. }
  112016. }
  112017. declare module BABYLON {
  112018. /**
  112019. * Defines the interface used by objects working like Scene
  112020. * @hidden
  112021. */
  112022. export interface ISceneLike {
  112023. _addPendingData(data: any): void;
  112024. _removePendingData(data: any): void;
  112025. offlineProvider: IOfflineProvider;
  112026. }
  112027. /** Interface defining initialization parameters for Engine class */
  112028. export interface EngineOptions extends WebGLContextAttributes {
  112029. /**
  112030. * Defines if the engine should no exceed a specified device ratio
  112031. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112032. */
  112033. limitDeviceRatio?: number;
  112034. /**
  112035. * Defines if webvr should be enabled automatically
  112036. * @see http://doc.babylonjs.com/how_to/webvr_camera
  112037. */
  112038. autoEnableWebVR?: boolean;
  112039. /**
  112040. * Defines if webgl2 should be turned off even if supported
  112041. * @see http://doc.babylonjs.com/features/webgl2
  112042. */
  112043. disableWebGL2Support?: boolean;
  112044. /**
  112045. * Defines if webaudio should be initialized as well
  112046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112047. */
  112048. audioEngine?: boolean;
  112049. /**
  112050. * Defines if animations should run using a deterministic lock step
  112051. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112052. */
  112053. deterministicLockstep?: boolean;
  112054. /** Defines the maximum steps to use with deterministic lock step mode */
  112055. lockstepMaxSteps?: number;
  112056. /** Defines the seconds between each deterministic lock step */
  112057. timeStep?: number;
  112058. /**
  112059. * Defines that engine should ignore context lost events
  112060. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112061. */
  112062. doNotHandleContextLost?: boolean;
  112063. /**
  112064. * Defines that engine should ignore modifying touch action attribute and style
  112065. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112066. */
  112067. doNotHandleTouchAction?: boolean;
  112068. /**
  112069. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112070. */
  112071. useHighPrecisionFloats?: boolean;
  112072. /**
  112073. * Make the canvas XR Compatible for XR sessions
  112074. */
  112075. xrCompatible?: boolean;
  112076. }
  112077. /**
  112078. * The base engine class (root of all engines)
  112079. */
  112080. export class ThinEngine {
  112081. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112082. static ExceptionList: ({
  112083. key: string;
  112084. capture: string;
  112085. captureConstraint: number;
  112086. targets: string[];
  112087. } | {
  112088. key: string;
  112089. capture: null;
  112090. captureConstraint: null;
  112091. targets: string[];
  112092. })[];
  112093. /** @hidden */
  112094. static _TextureLoaders: IInternalTextureLoader[];
  112095. /**
  112096. * Returns the current npm package of the sdk
  112097. */
  112098. static get NpmPackage(): string;
  112099. /**
  112100. * Returns the current version of the framework
  112101. */
  112102. static get Version(): string;
  112103. /**
  112104. * Returns a string describing the current engine
  112105. */
  112106. get description(): string;
  112107. /**
  112108. * Gets or sets the epsilon value used by collision engine
  112109. */
  112110. static CollisionsEpsilon: number;
  112111. /**
  112112. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112113. */
  112114. static get ShadersRepository(): string;
  112115. static set ShadersRepository(value: string);
  112116. /** @hidden */
  112117. _shaderProcessor: IShaderProcessor;
  112118. /**
  112119. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112120. */
  112121. forcePOTTextures: boolean;
  112122. /**
  112123. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112124. */
  112125. isFullscreen: boolean;
  112126. /**
  112127. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112128. */
  112129. cullBackFaces: boolean;
  112130. /**
  112131. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112132. */
  112133. renderEvenInBackground: boolean;
  112134. /**
  112135. * Gets or sets a boolean indicating that cache can be kept between frames
  112136. */
  112137. preventCacheWipeBetweenFrames: boolean;
  112138. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112139. validateShaderPrograms: boolean;
  112140. /**
  112141. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112142. * This can provide greater z depth for distant objects.
  112143. */
  112144. useReverseDepthBuffer: boolean;
  112145. /**
  112146. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112147. */
  112148. disableUniformBuffers: boolean;
  112149. /** @hidden */
  112150. _uniformBuffers: UniformBuffer[];
  112151. /**
  112152. * Gets a boolean indicating that the engine supports uniform buffers
  112153. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112154. */
  112155. get supportsUniformBuffers(): boolean;
  112156. /** @hidden */
  112157. _gl: WebGLRenderingContext;
  112158. /** @hidden */
  112159. _webGLVersion: number;
  112160. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112161. protected _windowIsBackground: boolean;
  112162. protected _creationOptions: EngineOptions;
  112163. protected _highPrecisionShadersAllowed: boolean;
  112164. /** @hidden */
  112165. get _shouldUseHighPrecisionShader(): boolean;
  112166. /**
  112167. * Gets a boolean indicating that only power of 2 textures are supported
  112168. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112169. */
  112170. get needPOTTextures(): boolean;
  112171. /** @hidden */
  112172. _badOS: boolean;
  112173. /** @hidden */
  112174. _badDesktopOS: boolean;
  112175. private _hardwareScalingLevel;
  112176. /** @hidden */
  112177. _caps: EngineCapabilities;
  112178. private _isStencilEnable;
  112179. private _glVersion;
  112180. private _glRenderer;
  112181. private _glVendor;
  112182. /** @hidden */
  112183. _videoTextureSupported: boolean;
  112184. protected _renderingQueueLaunched: boolean;
  112185. protected _activeRenderLoops: (() => void)[];
  112186. /**
  112187. * Observable signaled when a context lost event is raised
  112188. */
  112189. onContextLostObservable: Observable<ThinEngine>;
  112190. /**
  112191. * Observable signaled when a context restored event is raised
  112192. */
  112193. onContextRestoredObservable: Observable<ThinEngine>;
  112194. private _onContextLost;
  112195. private _onContextRestored;
  112196. protected _contextWasLost: boolean;
  112197. /** @hidden */
  112198. _doNotHandleContextLost: boolean;
  112199. /**
  112200. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112202. */
  112203. get doNotHandleContextLost(): boolean;
  112204. set doNotHandleContextLost(value: boolean);
  112205. /**
  112206. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112207. */
  112208. disableVertexArrayObjects: boolean;
  112209. /** @hidden */
  112210. protected _colorWrite: boolean;
  112211. /** @hidden */
  112212. protected _colorWriteChanged: boolean;
  112213. /** @hidden */
  112214. protected _depthCullingState: DepthCullingState;
  112215. /** @hidden */
  112216. protected _stencilState: StencilState;
  112217. /** @hidden */
  112218. _alphaState: AlphaState;
  112219. /** @hidden */
  112220. _alphaMode: number;
  112221. /** @hidden */
  112222. _alphaEquation: number;
  112223. /** @hidden */
  112224. _internalTexturesCache: InternalTexture[];
  112225. /** @hidden */
  112226. protected _activeChannel: number;
  112227. private _currentTextureChannel;
  112228. /** @hidden */
  112229. protected _boundTexturesCache: {
  112230. [key: string]: Nullable<InternalTexture>;
  112231. };
  112232. /** @hidden */
  112233. protected _currentEffect: Nullable<Effect>;
  112234. /** @hidden */
  112235. protected _currentProgram: Nullable<WebGLProgram>;
  112236. private _compiledEffects;
  112237. private _vertexAttribArraysEnabled;
  112238. /** @hidden */
  112239. protected _cachedViewport: Nullable<IViewportLike>;
  112240. private _cachedVertexArrayObject;
  112241. /** @hidden */
  112242. protected _cachedVertexBuffers: any;
  112243. /** @hidden */
  112244. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112245. /** @hidden */
  112246. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112247. /** @hidden */
  112248. _currentRenderTarget: Nullable<InternalTexture>;
  112249. private _uintIndicesCurrentlySet;
  112250. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112251. /** @hidden */
  112252. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112253. /** @hidden */
  112254. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112255. private _currentBufferPointers;
  112256. private _currentInstanceLocations;
  112257. private _currentInstanceBuffers;
  112258. private _textureUnits;
  112259. /** @hidden */
  112260. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112261. /** @hidden */
  112262. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112263. /** @hidden */
  112264. _boundRenderFunction: any;
  112265. private _vaoRecordInProgress;
  112266. private _mustWipeVertexAttributes;
  112267. private _emptyTexture;
  112268. private _emptyCubeTexture;
  112269. private _emptyTexture3D;
  112270. private _emptyTexture2DArray;
  112271. /** @hidden */
  112272. _frameHandler: number;
  112273. private _nextFreeTextureSlots;
  112274. private _maxSimultaneousTextures;
  112275. private _activeRequests;
  112276. /** @hidden */
  112277. _transformTextureUrl: Nullable<(url: string) => string>;
  112278. protected get _supportsHardwareTextureRescaling(): boolean;
  112279. private _framebufferDimensionsObject;
  112280. /**
  112281. * sets the object from which width and height will be taken from when getting render width and height
  112282. * Will fallback to the gl object
  112283. * @param dimensions the framebuffer width and height that will be used.
  112284. */
  112285. set framebufferDimensionsObject(dimensions: Nullable<{
  112286. framebufferWidth: number;
  112287. framebufferHeight: number;
  112288. }>);
  112289. /**
  112290. * Gets the current viewport
  112291. */
  112292. get currentViewport(): Nullable<IViewportLike>;
  112293. /**
  112294. * Gets the default empty texture
  112295. */
  112296. get emptyTexture(): InternalTexture;
  112297. /**
  112298. * Gets the default empty 3D texture
  112299. */
  112300. get emptyTexture3D(): InternalTexture;
  112301. /**
  112302. * Gets the default empty 2D array texture
  112303. */
  112304. get emptyTexture2DArray(): InternalTexture;
  112305. /**
  112306. * Gets the default empty cube texture
  112307. */
  112308. get emptyCubeTexture(): InternalTexture;
  112309. /**
  112310. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112311. */
  112312. readonly premultipliedAlpha: boolean;
  112313. /**
  112314. * Observable event triggered before each texture is initialized
  112315. */
  112316. onBeforeTextureInitObservable: Observable<Texture>;
  112317. /**
  112318. * Creates a new engine
  112319. * @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
  112320. * @param antialias defines enable antialiasing (default: false)
  112321. * @param options defines further options to be sent to the getContext() function
  112322. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112323. */
  112324. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112325. private _rebuildInternalTextures;
  112326. private _rebuildEffects;
  112327. /**
  112328. * Gets a boolean indicating if all created effects are ready
  112329. * @returns true if all effects are ready
  112330. */
  112331. areAllEffectsReady(): boolean;
  112332. protected _rebuildBuffers(): void;
  112333. protected _initGLContext(): void;
  112334. /**
  112335. * Gets version of the current webGL context
  112336. */
  112337. get webGLVersion(): number;
  112338. /**
  112339. * Gets a string idenfifying the name of the class
  112340. * @returns "Engine" string
  112341. */
  112342. getClassName(): string;
  112343. /**
  112344. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112345. */
  112346. get isStencilEnable(): boolean;
  112347. /** @hidden */
  112348. _prepareWorkingCanvas(): void;
  112349. /**
  112350. * Reset the texture cache to empty state
  112351. */
  112352. resetTextureCache(): void;
  112353. /**
  112354. * Gets an object containing information about the current webGL context
  112355. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112356. */
  112357. getGlInfo(): {
  112358. vendor: string;
  112359. renderer: string;
  112360. version: string;
  112361. };
  112362. /**
  112363. * Defines the hardware scaling level.
  112364. * By default the hardware scaling level is computed from the window device ratio.
  112365. * 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.
  112366. * @param level defines the level to use
  112367. */
  112368. setHardwareScalingLevel(level: number): void;
  112369. /**
  112370. * Gets the current hardware scaling level.
  112371. * By default the hardware scaling level is computed from the window device ratio.
  112372. * 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.
  112373. * @returns a number indicating the current hardware scaling level
  112374. */
  112375. getHardwareScalingLevel(): number;
  112376. /**
  112377. * Gets the list of loaded textures
  112378. * @returns an array containing all loaded textures
  112379. */
  112380. getLoadedTexturesCache(): InternalTexture[];
  112381. /**
  112382. * Gets the object containing all engine capabilities
  112383. * @returns the EngineCapabilities object
  112384. */
  112385. getCaps(): EngineCapabilities;
  112386. /**
  112387. * stop executing a render loop function and remove it from the execution array
  112388. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112389. */
  112390. stopRenderLoop(renderFunction?: () => void): void;
  112391. /** @hidden */
  112392. _renderLoop(): void;
  112393. /**
  112394. * Gets the HTML canvas attached with the current webGL context
  112395. * @returns a HTML canvas
  112396. */
  112397. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112398. /**
  112399. * Gets host window
  112400. * @returns the host window object
  112401. */
  112402. getHostWindow(): Nullable<Window>;
  112403. /**
  112404. * Gets the current render width
  112405. * @param useScreen defines if screen size must be used (or the current render target if any)
  112406. * @returns a number defining the current render width
  112407. */
  112408. getRenderWidth(useScreen?: boolean): number;
  112409. /**
  112410. * Gets the current render height
  112411. * @param useScreen defines if screen size must be used (or the current render target if any)
  112412. * @returns a number defining the current render height
  112413. */
  112414. getRenderHeight(useScreen?: boolean): number;
  112415. /**
  112416. * Can be used to override the current requestAnimationFrame requester.
  112417. * @hidden
  112418. */
  112419. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112420. /**
  112421. * Register and execute a render loop. The engine can have more than one render function
  112422. * @param renderFunction defines the function to continuously execute
  112423. */
  112424. runRenderLoop(renderFunction: () => void): void;
  112425. /**
  112426. * Clear the current render buffer or the current render target (if any is set up)
  112427. * @param color defines the color to use
  112428. * @param backBuffer defines if the back buffer must be cleared
  112429. * @param depth defines if the depth buffer must be cleared
  112430. * @param stencil defines if the stencil buffer must be cleared
  112431. */
  112432. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112433. private _viewportCached;
  112434. /** @hidden */
  112435. _viewport(x: number, y: number, width: number, height: number): void;
  112436. /**
  112437. * Set the WebGL's viewport
  112438. * @param viewport defines the viewport element to be used
  112439. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112440. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112441. */
  112442. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112443. /**
  112444. * Begin a new frame
  112445. */
  112446. beginFrame(): void;
  112447. /**
  112448. * Enf the current frame
  112449. */
  112450. endFrame(): void;
  112451. /**
  112452. * Resize the view according to the canvas' size
  112453. */
  112454. resize(): void;
  112455. /**
  112456. * Force a specific size of the canvas
  112457. * @param width defines the new canvas' width
  112458. * @param height defines the new canvas' height
  112459. * @returns true if the size was changed
  112460. */
  112461. setSize(width: number, height: number): boolean;
  112462. /**
  112463. * Binds the frame buffer to the specified texture.
  112464. * @param texture The texture to render to or null for the default canvas
  112465. * @param faceIndex The face of the texture to render to in case of cube texture
  112466. * @param requiredWidth The width of the target to render to
  112467. * @param requiredHeight The height of the target to render to
  112468. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112469. * @param lodLevel defines the lod level to bind to the frame buffer
  112470. * @param layer defines the 2d array index to bind to frame buffer to
  112471. */
  112472. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112473. /** @hidden */
  112474. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112475. /**
  112476. * Unbind the current render target texture from the webGL context
  112477. * @param texture defines the render target texture to unbind
  112478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112480. */
  112481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112482. /**
  112483. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112484. */
  112485. flushFramebuffer(): void;
  112486. /**
  112487. * Unbind the current render target and bind the default framebuffer
  112488. */
  112489. restoreDefaultFramebuffer(): void;
  112490. /** @hidden */
  112491. protected _resetVertexBufferBinding(): void;
  112492. /**
  112493. * Creates a vertex buffer
  112494. * @param data the data for the vertex buffer
  112495. * @returns the new WebGL static buffer
  112496. */
  112497. createVertexBuffer(data: DataArray): DataBuffer;
  112498. private _createVertexBuffer;
  112499. /**
  112500. * Creates a dynamic vertex buffer
  112501. * @param data the data for the dynamic vertex buffer
  112502. * @returns the new WebGL dynamic buffer
  112503. */
  112504. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112505. protected _resetIndexBufferBinding(): void;
  112506. /**
  112507. * Creates a new index buffer
  112508. * @param indices defines the content of the index buffer
  112509. * @param updatable defines if the index buffer must be updatable
  112510. * @returns a new webGL buffer
  112511. */
  112512. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112513. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112514. /**
  112515. * Bind a webGL buffer to the webGL context
  112516. * @param buffer defines the buffer to bind
  112517. */
  112518. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112519. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112520. private bindBuffer;
  112521. /**
  112522. * update the bound buffer with the given data
  112523. * @param data defines the data to update
  112524. */
  112525. updateArrayBuffer(data: Float32Array): void;
  112526. private _vertexAttribPointer;
  112527. /** @hidden */
  112528. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112529. private _bindVertexBuffersAttributes;
  112530. /**
  112531. * Records a vertex array object
  112532. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112533. * @param vertexBuffers defines the list of vertex buffers to store
  112534. * @param indexBuffer defines the index buffer to store
  112535. * @param effect defines the effect to store
  112536. * @returns the new vertex array object
  112537. */
  112538. recordVertexArrayObject(vertexBuffers: {
  112539. [key: string]: VertexBuffer;
  112540. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112541. /**
  112542. * Bind a specific vertex array object
  112543. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112544. * @param vertexArrayObject defines the vertex array object to bind
  112545. * @param indexBuffer defines the index buffer to bind
  112546. */
  112547. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112548. /**
  112549. * Bind webGl buffers directly to the webGL context
  112550. * @param vertexBuffer defines the vertex buffer to bind
  112551. * @param indexBuffer defines the index buffer to bind
  112552. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112553. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112554. * @param effect defines the effect associated with the vertex buffer
  112555. */
  112556. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112557. private _unbindVertexArrayObject;
  112558. /**
  112559. * Bind a list of vertex buffers to the webGL context
  112560. * @param vertexBuffers defines the list of vertex buffers to bind
  112561. * @param indexBuffer defines the index buffer to bind
  112562. * @param effect defines the effect associated with the vertex buffers
  112563. */
  112564. bindBuffers(vertexBuffers: {
  112565. [key: string]: Nullable<VertexBuffer>;
  112566. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112567. /**
  112568. * Unbind all instance attributes
  112569. */
  112570. unbindInstanceAttributes(): void;
  112571. /**
  112572. * Release and free the memory of a vertex array object
  112573. * @param vao defines the vertex array object to delete
  112574. */
  112575. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112576. /** @hidden */
  112577. _releaseBuffer(buffer: DataBuffer): boolean;
  112578. protected _deleteBuffer(buffer: DataBuffer): void;
  112579. /**
  112580. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112581. * @param instancesBuffer defines the webGL buffer to update and bind
  112582. * @param data defines the data to store in the buffer
  112583. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112584. */
  112585. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112586. /**
  112587. * Bind the content of a webGL buffer used with instantiation
  112588. * @param instancesBuffer defines the webGL buffer to bind
  112589. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112590. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112591. */
  112592. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112593. /**
  112594. * Disable the instance attribute corresponding to the name in parameter
  112595. * @param name defines the name of the attribute to disable
  112596. */
  112597. disableInstanceAttributeByName(name: string): void;
  112598. /**
  112599. * Disable the instance attribute corresponding to the location in parameter
  112600. * @param attributeLocation defines the attribute location of the attribute to disable
  112601. */
  112602. disableInstanceAttribute(attributeLocation: number): void;
  112603. /**
  112604. * Disable the attribute corresponding to the location in parameter
  112605. * @param attributeLocation defines the attribute location of the attribute to disable
  112606. */
  112607. disableAttributeByIndex(attributeLocation: number): void;
  112608. /**
  112609. * Send a draw order
  112610. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112611. * @param indexStart defines the starting index
  112612. * @param indexCount defines the number of index to draw
  112613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112614. */
  112615. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112616. /**
  112617. * Draw a list of points
  112618. * @param verticesStart defines the index of first vertex to draw
  112619. * @param verticesCount defines the count of vertices to draw
  112620. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112621. */
  112622. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112623. /**
  112624. * Draw a list of unindexed primitives
  112625. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112626. * @param verticesStart defines the index of first vertex to draw
  112627. * @param verticesCount defines the count of vertices to draw
  112628. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112629. */
  112630. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112631. /**
  112632. * Draw a list of indexed primitives
  112633. * @param fillMode defines the primitive to use
  112634. * @param indexStart defines the starting index
  112635. * @param indexCount defines the number of index to draw
  112636. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112637. */
  112638. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112639. /**
  112640. * Draw a list of unindexed primitives
  112641. * @param fillMode defines the primitive to use
  112642. * @param verticesStart defines the index of first vertex to draw
  112643. * @param verticesCount defines the count of vertices to draw
  112644. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112645. */
  112646. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112647. private _drawMode;
  112648. /** @hidden */
  112649. protected _reportDrawCall(): void;
  112650. /** @hidden */
  112651. _releaseEffect(effect: Effect): void;
  112652. /** @hidden */
  112653. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112654. /**
  112655. * Create a new effect (used to store vertex/fragment shaders)
  112656. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112657. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112658. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112659. * @param samplers defines an array of string used to represent textures
  112660. * @param defines defines the string containing the defines to use to compile the shaders
  112661. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112662. * @param onCompiled defines a function to call when the effect creation is successful
  112663. * @param onError defines a function to call when the effect creation has failed
  112664. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112665. * @returns the new Effect
  112666. */
  112667. 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;
  112668. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112669. private _compileShader;
  112670. private _compileRawShader;
  112671. /** @hidden */
  112672. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112673. /**
  112674. * Directly creates a webGL program
  112675. * @param pipelineContext defines the pipeline context to attach to
  112676. * @param vertexCode defines the vertex shader code to use
  112677. * @param fragmentCode defines the fragment shader code to use
  112678. * @param context defines the webGL context to use (if not set, the current one will be used)
  112679. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112680. * @returns the new webGL program
  112681. */
  112682. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112683. /**
  112684. * Creates a webGL program
  112685. * @param pipelineContext defines the pipeline context to attach to
  112686. * @param vertexCode defines the vertex shader code to use
  112687. * @param fragmentCode defines the fragment shader code to use
  112688. * @param defines defines the string containing the defines to use to compile the shaders
  112689. * @param context defines the webGL context to use (if not set, the current one will be used)
  112690. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112691. * @returns the new webGL program
  112692. */
  112693. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112694. /**
  112695. * Creates a new pipeline context
  112696. * @returns the new pipeline
  112697. */
  112698. createPipelineContext(): IPipelineContext;
  112699. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112700. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112701. /** @hidden */
  112702. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112703. /** @hidden */
  112704. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112705. /** @hidden */
  112706. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112707. /**
  112708. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112709. * @param pipelineContext defines the pipeline context to use
  112710. * @param uniformsNames defines the list of uniform names
  112711. * @returns an array of webGL uniform locations
  112712. */
  112713. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112714. /**
  112715. * Gets the lsit of active attributes for a given webGL program
  112716. * @param pipelineContext defines the pipeline context to use
  112717. * @param attributesNames defines the list of attribute names to get
  112718. * @returns an array of indices indicating the offset of each attribute
  112719. */
  112720. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112721. /**
  112722. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112723. * @param effect defines the effect to activate
  112724. */
  112725. enableEffect(effect: Nullable<Effect>): void;
  112726. /**
  112727. * Set the value of an uniform to a number (int)
  112728. * @param uniform defines the webGL uniform location where to store the value
  112729. * @param value defines the int number to store
  112730. */
  112731. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112732. /**
  112733. * Set the value of an uniform to an array of int32
  112734. * @param uniform defines the webGL uniform location where to store the value
  112735. * @param array defines the array of int32 to store
  112736. */
  112737. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112738. /**
  112739. * Set the value of an uniform to an array of int32 (stored as vec2)
  112740. * @param uniform defines the webGL uniform location where to store the value
  112741. * @param array defines the array of int32 to store
  112742. */
  112743. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112744. /**
  112745. * Set the value of an uniform to an array of int32 (stored as vec3)
  112746. * @param uniform defines the webGL uniform location where to store the value
  112747. * @param array defines the array of int32 to store
  112748. */
  112749. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112750. /**
  112751. * Set the value of an uniform to an array of int32 (stored as vec4)
  112752. * @param uniform defines the webGL uniform location where to store the value
  112753. * @param array defines the array of int32 to store
  112754. */
  112755. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112756. /**
  112757. * Set the value of an uniform to an array of number
  112758. * @param uniform defines the webGL uniform location where to store the value
  112759. * @param array defines the array of number to store
  112760. */
  112761. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112762. /**
  112763. * Set the value of an uniform to an array of number (stored as vec2)
  112764. * @param uniform defines the webGL uniform location where to store the value
  112765. * @param array defines the array of number to store
  112766. */
  112767. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112768. /**
  112769. * Set the value of an uniform to an array of number (stored as vec3)
  112770. * @param uniform defines the webGL uniform location where to store the value
  112771. * @param array defines the array of number to store
  112772. */
  112773. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112774. /**
  112775. * Set the value of an uniform to an array of number (stored as vec4)
  112776. * @param uniform defines the webGL uniform location where to store the value
  112777. * @param array defines the array of number to store
  112778. */
  112779. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112780. /**
  112781. * Set the value of an uniform to an array of float32 (stored as matrices)
  112782. * @param uniform defines the webGL uniform location where to store the value
  112783. * @param matrices defines the array of float32 to store
  112784. */
  112785. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112786. /**
  112787. * Set the value of an uniform to a matrix (3x3)
  112788. * @param uniform defines the webGL uniform location where to store the value
  112789. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112790. */
  112791. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112792. /**
  112793. * Set the value of an uniform to a matrix (2x2)
  112794. * @param uniform defines the webGL uniform location where to store the value
  112795. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112796. */
  112797. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112798. /**
  112799. * Set the value of an uniform to a number (float)
  112800. * @param uniform defines the webGL uniform location where to store the value
  112801. * @param value defines the float number to store
  112802. */
  112803. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112804. /**
  112805. * Set the value of an uniform to a vec2
  112806. * @param uniform defines the webGL uniform location where to store the value
  112807. * @param x defines the 1st component of the value
  112808. * @param y defines the 2nd component of the value
  112809. */
  112810. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112811. /**
  112812. * Set the value of an uniform to a vec3
  112813. * @param uniform defines the webGL uniform location where to store the value
  112814. * @param x defines the 1st component of the value
  112815. * @param y defines the 2nd component of the value
  112816. * @param z defines the 3rd component of the value
  112817. */
  112818. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112819. /**
  112820. * Set the value of an uniform to a vec4
  112821. * @param uniform defines the webGL uniform location where to store the value
  112822. * @param x defines the 1st component of the value
  112823. * @param y defines the 2nd component of the value
  112824. * @param z defines the 3rd component of the value
  112825. * @param w defines the 4th component of the value
  112826. */
  112827. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112828. /**
  112829. * Apply all cached states (depth, culling, stencil and alpha)
  112830. */
  112831. applyStates(): void;
  112832. /**
  112833. * Enable or disable color writing
  112834. * @param enable defines the state to set
  112835. */
  112836. setColorWrite(enable: boolean): void;
  112837. /**
  112838. * Gets a boolean indicating if color writing is enabled
  112839. * @returns the current color writing state
  112840. */
  112841. getColorWrite(): boolean;
  112842. /**
  112843. * Gets the depth culling state manager
  112844. */
  112845. get depthCullingState(): DepthCullingState;
  112846. /**
  112847. * Gets the alpha state manager
  112848. */
  112849. get alphaState(): AlphaState;
  112850. /**
  112851. * Gets the stencil state manager
  112852. */
  112853. get stencilState(): StencilState;
  112854. /**
  112855. * Clears the list of texture accessible through engine.
  112856. * This can help preventing texture load conflict due to name collision.
  112857. */
  112858. clearInternalTexturesCache(): void;
  112859. /**
  112860. * Force the entire cache to be cleared
  112861. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112862. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112863. */
  112864. wipeCaches(bruteForce?: boolean): void;
  112865. /** @hidden */
  112866. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112867. min: number;
  112868. mag: number;
  112869. };
  112870. /** @hidden */
  112871. _createTexture(): WebGLTexture;
  112872. /**
  112873. * Usually called from Texture.ts.
  112874. * Passed information to create a WebGLTexture
  112875. * @param url defines a value which contains one of the following:
  112876. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112877. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112878. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112880. * @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)
  112881. * @param scene needed for loading to the correct scene
  112882. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112883. * @param onLoad optional callback to be called upon successful completion
  112884. * @param onError optional callback to be called upon failure
  112885. * @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
  112886. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112887. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112888. * @param forcedExtension defines the extension to use to pick the right loader
  112889. * @param mimeType defines an optional mime type
  112890. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112891. */
  112892. 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;
  112893. /**
  112894. * Loads an image as an HTMLImageElement.
  112895. * @param input url string, ArrayBuffer, or Blob to load
  112896. * @param onLoad callback called when the image successfully loads
  112897. * @param onError callback called when the image fails to load
  112898. * @param offlineProvider offline provider for caching
  112899. * @param mimeType optional mime type
  112900. * @returns the HTMLImageElement of the loaded image
  112901. * @hidden
  112902. */
  112903. 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>;
  112904. /**
  112905. * @hidden
  112906. */
  112907. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112908. private _unpackFlipYCached;
  112909. /**
  112910. * In case you are sharing the context with other applications, it might
  112911. * be interested to not cache the unpack flip y state to ensure a consistent
  112912. * value would be set.
  112913. */
  112914. enableUnpackFlipYCached: boolean;
  112915. /** @hidden */
  112916. _unpackFlipY(value: boolean): void;
  112917. /** @hidden */
  112918. _getUnpackAlignement(): number;
  112919. private _getTextureTarget;
  112920. /**
  112921. * Update the sampling mode of a given texture
  112922. * @param samplingMode defines the required sampling mode
  112923. * @param texture defines the texture to update
  112924. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112925. */
  112926. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112927. /**
  112928. * Update the sampling mode of a given texture
  112929. * @param texture defines the texture to update
  112930. * @param wrapU defines the texture wrap mode of the u coordinates
  112931. * @param wrapV defines the texture wrap mode of the v coordinates
  112932. * @param wrapR defines the texture wrap mode of the r coordinates
  112933. */
  112934. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112935. /** @hidden */
  112936. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112937. width: number;
  112938. height: number;
  112939. layers?: number;
  112940. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112941. /** @hidden */
  112942. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112943. /** @hidden */
  112944. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112945. /**
  112946. * Update a portion of an internal texture
  112947. * @param texture defines the texture to update
  112948. * @param imageData defines the data to store into the texture
  112949. * @param xOffset defines the x coordinates of the update rectangle
  112950. * @param yOffset defines the y coordinates of the update rectangle
  112951. * @param width defines the width of the update rectangle
  112952. * @param height defines the height of the update rectangle
  112953. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112954. * @param lod defines the lod level to update (0 by default)
  112955. */
  112956. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112957. /** @hidden */
  112958. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112959. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112960. private _prepareWebGLTexture;
  112961. /** @hidden */
  112962. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112963. private _getDepthStencilBuffer;
  112964. /** @hidden */
  112965. _releaseFramebufferObjects(texture: InternalTexture): void;
  112966. /** @hidden */
  112967. _releaseTexture(texture: InternalTexture): void;
  112968. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112969. protected _setProgram(program: WebGLProgram): void;
  112970. protected _boundUniforms: {
  112971. [key: number]: WebGLUniformLocation;
  112972. };
  112973. /**
  112974. * Binds an effect to the webGL context
  112975. * @param effect defines the effect to bind
  112976. */
  112977. bindSamplers(effect: Effect): void;
  112978. private _activateCurrentTexture;
  112979. /** @hidden */
  112980. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112981. /** @hidden */
  112982. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112983. /**
  112984. * Unbind all textures from the webGL context
  112985. */
  112986. unbindAllTextures(): void;
  112987. /**
  112988. * Sets a texture to the according uniform.
  112989. * @param channel The texture channel
  112990. * @param uniform The uniform to set
  112991. * @param texture The texture to apply
  112992. */
  112993. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112994. private _bindSamplerUniformToChannel;
  112995. private _getTextureWrapMode;
  112996. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112997. /**
  112998. * Sets an array of texture to the webGL context
  112999. * @param channel defines the channel where the texture array must be set
  113000. * @param uniform defines the associated uniform location
  113001. * @param textures defines the array of textures to bind
  113002. */
  113003. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113004. /** @hidden */
  113005. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113006. private _setTextureParameterFloat;
  113007. private _setTextureParameterInteger;
  113008. /**
  113009. * Unbind all vertex attributes from the webGL context
  113010. */
  113011. unbindAllAttributes(): void;
  113012. /**
  113013. * 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
  113014. */
  113015. releaseEffects(): void;
  113016. /**
  113017. * Dispose and release all associated resources
  113018. */
  113019. dispose(): void;
  113020. /**
  113021. * Attach a new callback raised when context lost event is fired
  113022. * @param callback defines the callback to call
  113023. */
  113024. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113025. /**
  113026. * Attach a new callback raised when context restored event is fired
  113027. * @param callback defines the callback to call
  113028. */
  113029. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113030. /**
  113031. * Get the current error code of the webGL context
  113032. * @returns the error code
  113033. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113034. */
  113035. getError(): number;
  113036. private _canRenderToFloatFramebuffer;
  113037. private _canRenderToHalfFloatFramebuffer;
  113038. private _canRenderToFramebuffer;
  113039. /** @hidden */
  113040. _getWebGLTextureType(type: number): number;
  113041. /** @hidden */
  113042. _getInternalFormat(format: number): number;
  113043. /** @hidden */
  113044. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113045. /** @hidden */
  113046. _getRGBAMultiSampleBufferFormat(type: number): number;
  113047. /** @hidden */
  113048. _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;
  113049. /**
  113050. * Loads a file from a url
  113051. * @param url url to load
  113052. * @param onSuccess callback called when the file successfully loads
  113053. * @param onProgress callback called while file is loading (if the server supports this mode)
  113054. * @param offlineProvider defines the offline provider for caching
  113055. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113056. * @param onError callback called when the file fails to load
  113057. * @returns a file request object
  113058. * @hidden
  113059. */
  113060. 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;
  113061. /**
  113062. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113063. * @param x defines the x coordinate of the rectangle where pixels must be read
  113064. * @param y defines the y coordinate of the rectangle where pixels must be read
  113065. * @param width defines the width of the rectangle where pixels must be read
  113066. * @param height defines the height of the rectangle where pixels must be read
  113067. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113068. * @returns a Uint8Array containing RGBA colors
  113069. */
  113070. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113071. private static _isSupported;
  113072. /**
  113073. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113074. * @returns true if the engine can be created
  113075. * @ignorenaming
  113076. */
  113077. static isSupported(): boolean;
  113078. /**
  113079. * Find the next highest power of two.
  113080. * @param x Number to start search from.
  113081. * @return Next highest power of two.
  113082. */
  113083. static CeilingPOT(x: number): number;
  113084. /**
  113085. * Find the next lowest power of two.
  113086. * @param x Number to start search from.
  113087. * @return Next lowest power of two.
  113088. */
  113089. static FloorPOT(x: number): number;
  113090. /**
  113091. * Find the nearest power of two.
  113092. * @param x Number to start search from.
  113093. * @return Next nearest power of two.
  113094. */
  113095. static NearestPOT(x: number): number;
  113096. /**
  113097. * Get the closest exponent of two
  113098. * @param value defines the value to approximate
  113099. * @param max defines the maximum value to return
  113100. * @param mode defines how to define the closest value
  113101. * @returns closest exponent of two of the given value
  113102. */
  113103. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113104. /**
  113105. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113106. * @param func - the function to be called
  113107. * @param requester - the object that will request the next frame. Falls back to window.
  113108. * @returns frame number
  113109. */
  113110. static QueueNewFrame(func: () => void, requester?: any): number;
  113111. /**
  113112. * Gets host document
  113113. * @returns the host document object
  113114. */
  113115. getHostDocument(): Nullable<Document>;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * Class representing spherical harmonics coefficients to the 3rd degree
  113121. */
  113122. export class SphericalHarmonics {
  113123. /**
  113124. * Defines whether or not the harmonics have been prescaled for rendering.
  113125. */
  113126. preScaled: boolean;
  113127. /**
  113128. * The l0,0 coefficients of the spherical harmonics
  113129. */
  113130. l00: Vector3;
  113131. /**
  113132. * The l1,-1 coefficients of the spherical harmonics
  113133. */
  113134. l1_1: Vector3;
  113135. /**
  113136. * The l1,0 coefficients of the spherical harmonics
  113137. */
  113138. l10: Vector3;
  113139. /**
  113140. * The l1,1 coefficients of the spherical harmonics
  113141. */
  113142. l11: Vector3;
  113143. /**
  113144. * The l2,-2 coefficients of the spherical harmonics
  113145. */
  113146. l2_2: Vector3;
  113147. /**
  113148. * The l2,-1 coefficients of the spherical harmonics
  113149. */
  113150. l2_1: Vector3;
  113151. /**
  113152. * The l2,0 coefficients of the spherical harmonics
  113153. */
  113154. l20: Vector3;
  113155. /**
  113156. * The l2,1 coefficients of the spherical harmonics
  113157. */
  113158. l21: Vector3;
  113159. /**
  113160. * The l2,2 coefficients of the spherical harmonics
  113161. */
  113162. l22: Vector3;
  113163. /**
  113164. * Adds a light to the spherical harmonics
  113165. * @param direction the direction of the light
  113166. * @param color the color of the light
  113167. * @param deltaSolidAngle the delta solid angle of the light
  113168. */
  113169. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113170. /**
  113171. * Scales the spherical harmonics by the given amount
  113172. * @param scale the amount to scale
  113173. */
  113174. scaleInPlace(scale: number): void;
  113175. /**
  113176. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113177. *
  113178. * ```
  113179. * E_lm = A_l * L_lm
  113180. * ```
  113181. *
  113182. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113183. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113184. * the scaling factors are given in equation 9.
  113185. */
  113186. convertIncidentRadianceToIrradiance(): void;
  113187. /**
  113188. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113189. *
  113190. * ```
  113191. * L = (1/pi) * E * rho
  113192. * ```
  113193. *
  113194. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113195. */
  113196. convertIrradianceToLambertianRadiance(): void;
  113197. /**
  113198. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113199. * required operations at run time.
  113200. *
  113201. * This is simply done by scaling back the SH with Ylm constants parameter.
  113202. * The trigonometric part being applied by the shader at run time.
  113203. */
  113204. preScaleForRendering(): void;
  113205. /**
  113206. * Constructs a spherical harmonics from an array.
  113207. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113208. * @returns the spherical harmonics
  113209. */
  113210. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113211. /**
  113212. * Gets the spherical harmonics from polynomial
  113213. * @param polynomial the spherical polynomial
  113214. * @returns the spherical harmonics
  113215. */
  113216. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113217. }
  113218. /**
  113219. * Class representing spherical polynomial coefficients to the 3rd degree
  113220. */
  113221. export class SphericalPolynomial {
  113222. private _harmonics;
  113223. /**
  113224. * The spherical harmonics used to create the polynomials.
  113225. */
  113226. get preScaledHarmonics(): SphericalHarmonics;
  113227. /**
  113228. * The x coefficients of the spherical polynomial
  113229. */
  113230. x: Vector3;
  113231. /**
  113232. * The y coefficients of the spherical polynomial
  113233. */
  113234. y: Vector3;
  113235. /**
  113236. * The z coefficients of the spherical polynomial
  113237. */
  113238. z: Vector3;
  113239. /**
  113240. * The xx coefficients of the spherical polynomial
  113241. */
  113242. xx: Vector3;
  113243. /**
  113244. * The yy coefficients of the spherical polynomial
  113245. */
  113246. yy: Vector3;
  113247. /**
  113248. * The zz coefficients of the spherical polynomial
  113249. */
  113250. zz: Vector3;
  113251. /**
  113252. * The xy coefficients of the spherical polynomial
  113253. */
  113254. xy: Vector3;
  113255. /**
  113256. * The yz coefficients of the spherical polynomial
  113257. */
  113258. yz: Vector3;
  113259. /**
  113260. * The zx coefficients of the spherical polynomial
  113261. */
  113262. zx: Vector3;
  113263. /**
  113264. * Adds an ambient color to the spherical polynomial
  113265. * @param color the color to add
  113266. */
  113267. addAmbient(color: Color3): void;
  113268. /**
  113269. * Scales the spherical polynomial by the given amount
  113270. * @param scale the amount to scale
  113271. */
  113272. scaleInPlace(scale: number): void;
  113273. /**
  113274. * Gets the spherical polynomial from harmonics
  113275. * @param harmonics the spherical harmonics
  113276. * @returns the spherical polynomial
  113277. */
  113278. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113279. /**
  113280. * Constructs a spherical polynomial from an array.
  113281. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113282. * @returns the spherical polynomial
  113283. */
  113284. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113285. }
  113286. }
  113287. declare module BABYLON {
  113288. /**
  113289. * Defines the source of the internal texture
  113290. */
  113291. export enum InternalTextureSource {
  113292. /**
  113293. * The source of the texture data is unknown
  113294. */
  113295. Unknown = 0,
  113296. /**
  113297. * Texture data comes from an URL
  113298. */
  113299. Url = 1,
  113300. /**
  113301. * Texture data is only used for temporary storage
  113302. */
  113303. Temp = 2,
  113304. /**
  113305. * Texture data comes from raw data (ArrayBuffer)
  113306. */
  113307. Raw = 3,
  113308. /**
  113309. * Texture content is dynamic (video or dynamic texture)
  113310. */
  113311. Dynamic = 4,
  113312. /**
  113313. * Texture content is generated by rendering to it
  113314. */
  113315. RenderTarget = 5,
  113316. /**
  113317. * Texture content is part of a multi render target process
  113318. */
  113319. MultiRenderTarget = 6,
  113320. /**
  113321. * Texture data comes from a cube data file
  113322. */
  113323. Cube = 7,
  113324. /**
  113325. * Texture data comes from a raw cube data
  113326. */
  113327. CubeRaw = 8,
  113328. /**
  113329. * Texture data come from a prefiltered cube data file
  113330. */
  113331. CubePrefiltered = 9,
  113332. /**
  113333. * Texture content is raw 3D data
  113334. */
  113335. Raw3D = 10,
  113336. /**
  113337. * Texture content is raw 2D array data
  113338. */
  113339. Raw2DArray = 11,
  113340. /**
  113341. * Texture content is a depth texture
  113342. */
  113343. Depth = 12,
  113344. /**
  113345. * Texture data comes from a raw cube data encoded with RGBD
  113346. */
  113347. CubeRawRGBD = 13
  113348. }
  113349. /**
  113350. * Class used to store data associated with WebGL texture data for the engine
  113351. * This class should not be used directly
  113352. */
  113353. export class InternalTexture {
  113354. /** @hidden */
  113355. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113356. /**
  113357. * Defines if the texture is ready
  113358. */
  113359. isReady: boolean;
  113360. /**
  113361. * Defines if the texture is a cube texture
  113362. */
  113363. isCube: boolean;
  113364. /**
  113365. * Defines if the texture contains 3D data
  113366. */
  113367. is3D: boolean;
  113368. /**
  113369. * Defines if the texture contains 2D array data
  113370. */
  113371. is2DArray: boolean;
  113372. /**
  113373. * Defines if the texture contains multiview data
  113374. */
  113375. isMultiview: boolean;
  113376. /**
  113377. * Gets the URL used to load this texture
  113378. */
  113379. url: string;
  113380. /**
  113381. * Gets the sampling mode of the texture
  113382. */
  113383. samplingMode: number;
  113384. /**
  113385. * Gets a boolean indicating if the texture needs mipmaps generation
  113386. */
  113387. generateMipMaps: boolean;
  113388. /**
  113389. * Gets the number of samples used by the texture (WebGL2+ only)
  113390. */
  113391. samples: number;
  113392. /**
  113393. * Gets the type of the texture (int, float...)
  113394. */
  113395. type: number;
  113396. /**
  113397. * Gets the format of the texture (RGB, RGBA...)
  113398. */
  113399. format: number;
  113400. /**
  113401. * Observable called when the texture is loaded
  113402. */
  113403. onLoadedObservable: Observable<InternalTexture>;
  113404. /**
  113405. * Gets the width of the texture
  113406. */
  113407. width: number;
  113408. /**
  113409. * Gets the height of the texture
  113410. */
  113411. height: number;
  113412. /**
  113413. * Gets the depth of the texture
  113414. */
  113415. depth: number;
  113416. /**
  113417. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113418. */
  113419. baseWidth: number;
  113420. /**
  113421. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113422. */
  113423. baseHeight: number;
  113424. /**
  113425. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113426. */
  113427. baseDepth: number;
  113428. /**
  113429. * Gets a boolean indicating if the texture is inverted on Y axis
  113430. */
  113431. invertY: boolean;
  113432. /** @hidden */
  113433. _invertVScale: boolean;
  113434. /** @hidden */
  113435. _associatedChannel: number;
  113436. /** @hidden */
  113437. _source: InternalTextureSource;
  113438. /** @hidden */
  113439. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113440. /** @hidden */
  113441. _bufferView: Nullable<ArrayBufferView>;
  113442. /** @hidden */
  113443. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113444. /** @hidden */
  113445. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113446. /** @hidden */
  113447. _size: number;
  113448. /** @hidden */
  113449. _extension: string;
  113450. /** @hidden */
  113451. _files: Nullable<string[]>;
  113452. /** @hidden */
  113453. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113454. /** @hidden */
  113455. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113456. /** @hidden */
  113457. _framebuffer: Nullable<WebGLFramebuffer>;
  113458. /** @hidden */
  113459. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113460. /** @hidden */
  113461. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113462. /** @hidden */
  113463. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113464. /** @hidden */
  113465. _attachments: Nullable<number[]>;
  113466. /** @hidden */
  113467. _cachedCoordinatesMode: Nullable<number>;
  113468. /** @hidden */
  113469. _cachedWrapU: Nullable<number>;
  113470. /** @hidden */
  113471. _cachedWrapV: Nullable<number>;
  113472. /** @hidden */
  113473. _cachedWrapR: Nullable<number>;
  113474. /** @hidden */
  113475. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113476. /** @hidden */
  113477. _isDisabled: boolean;
  113478. /** @hidden */
  113479. _compression: Nullable<string>;
  113480. /** @hidden */
  113481. _generateStencilBuffer: boolean;
  113482. /** @hidden */
  113483. _generateDepthBuffer: boolean;
  113484. /** @hidden */
  113485. _comparisonFunction: number;
  113486. /** @hidden */
  113487. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113488. /** @hidden */
  113489. _lodGenerationScale: number;
  113490. /** @hidden */
  113491. _lodGenerationOffset: number;
  113492. /** @hidden */
  113493. _depthStencilTexture: Nullable<InternalTexture>;
  113494. /** @hidden */
  113495. _colorTextureArray: Nullable<WebGLTexture>;
  113496. /** @hidden */
  113497. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113498. /** @hidden */
  113499. _lodTextureHigh: Nullable<BaseTexture>;
  113500. /** @hidden */
  113501. _lodTextureMid: Nullable<BaseTexture>;
  113502. /** @hidden */
  113503. _lodTextureLow: Nullable<BaseTexture>;
  113504. /** @hidden */
  113505. _isRGBD: boolean;
  113506. /** @hidden */
  113507. _linearSpecularLOD: boolean;
  113508. /** @hidden */
  113509. _irradianceTexture: Nullable<BaseTexture>;
  113510. /** @hidden */
  113511. _webGLTexture: Nullable<WebGLTexture>;
  113512. /** @hidden */
  113513. _references: number;
  113514. private _engine;
  113515. /**
  113516. * Gets the Engine the texture belongs to.
  113517. * @returns The babylon engine
  113518. */
  113519. getEngine(): ThinEngine;
  113520. /**
  113521. * Gets the data source type of the texture
  113522. */
  113523. get source(): InternalTextureSource;
  113524. /**
  113525. * Creates a new InternalTexture
  113526. * @param engine defines the engine to use
  113527. * @param source defines the type of data that will be used
  113528. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113529. */
  113530. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113531. /**
  113532. * Increments the number of references (ie. the number of Texture that point to it)
  113533. */
  113534. incrementReferences(): void;
  113535. /**
  113536. * Change the size of the texture (not the size of the content)
  113537. * @param width defines the new width
  113538. * @param height defines the new height
  113539. * @param depth defines the new depth (1 by default)
  113540. */
  113541. updateSize(width: int, height: int, depth?: int): void;
  113542. /** @hidden */
  113543. _rebuild(): void;
  113544. /** @hidden */
  113545. _swapAndDie(target: InternalTexture): void;
  113546. /**
  113547. * Dispose the current allocated resources
  113548. */
  113549. dispose(): void;
  113550. }
  113551. }
  113552. declare module BABYLON {
  113553. /**
  113554. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113556. */
  113557. export class Analyser {
  113558. /**
  113559. * Gets or sets the smoothing
  113560. * @ignorenaming
  113561. */
  113562. SMOOTHING: number;
  113563. /**
  113564. * Gets or sets the FFT table size
  113565. * @ignorenaming
  113566. */
  113567. FFT_SIZE: number;
  113568. /**
  113569. * Gets or sets the bar graph amplitude
  113570. * @ignorenaming
  113571. */
  113572. BARGRAPHAMPLITUDE: number;
  113573. /**
  113574. * Gets or sets the position of the debug canvas
  113575. * @ignorenaming
  113576. */
  113577. DEBUGCANVASPOS: {
  113578. x: number;
  113579. y: number;
  113580. };
  113581. /**
  113582. * Gets or sets the debug canvas size
  113583. * @ignorenaming
  113584. */
  113585. DEBUGCANVASSIZE: {
  113586. width: number;
  113587. height: number;
  113588. };
  113589. private _byteFreqs;
  113590. private _byteTime;
  113591. private _floatFreqs;
  113592. private _webAudioAnalyser;
  113593. private _debugCanvas;
  113594. private _debugCanvasContext;
  113595. private _scene;
  113596. private _registerFunc;
  113597. private _audioEngine;
  113598. /**
  113599. * Creates a new analyser
  113600. * @param scene defines hosting scene
  113601. */
  113602. constructor(scene: Scene);
  113603. /**
  113604. * Get the number of data values you will have to play with for the visualization
  113605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113606. * @returns a number
  113607. */
  113608. getFrequencyBinCount(): number;
  113609. /**
  113610. * Gets the current frequency data as a byte array
  113611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113612. * @returns a Uint8Array
  113613. */
  113614. getByteFrequencyData(): Uint8Array;
  113615. /**
  113616. * Gets the current waveform as a byte array
  113617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113618. * @returns a Uint8Array
  113619. */
  113620. getByteTimeDomainData(): Uint8Array;
  113621. /**
  113622. * Gets the current frequency data as a float array
  113623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113624. * @returns a Float32Array
  113625. */
  113626. getFloatFrequencyData(): Float32Array;
  113627. /**
  113628. * Renders the debug canvas
  113629. */
  113630. drawDebugCanvas(): void;
  113631. /**
  113632. * Stops rendering the debug canvas and removes it
  113633. */
  113634. stopDebugCanvas(): void;
  113635. /**
  113636. * Connects two audio nodes
  113637. * @param inputAudioNode defines first node to connect
  113638. * @param outputAudioNode defines second node to connect
  113639. */
  113640. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113641. /**
  113642. * Releases all associated resources
  113643. */
  113644. dispose(): void;
  113645. }
  113646. }
  113647. declare module BABYLON {
  113648. /**
  113649. * This represents an audio engine and it is responsible
  113650. * to play, synchronize and analyse sounds throughout the application.
  113651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113652. */
  113653. export interface IAudioEngine extends IDisposable {
  113654. /**
  113655. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113656. */
  113657. readonly canUseWebAudio: boolean;
  113658. /**
  113659. * Gets the current AudioContext if available.
  113660. */
  113661. readonly audioContext: Nullable<AudioContext>;
  113662. /**
  113663. * The master gain node defines the global audio volume of your audio engine.
  113664. */
  113665. readonly masterGain: GainNode;
  113666. /**
  113667. * Gets whether or not mp3 are supported by your browser.
  113668. */
  113669. readonly isMP3supported: boolean;
  113670. /**
  113671. * Gets whether or not ogg are supported by your browser.
  113672. */
  113673. readonly isOGGsupported: boolean;
  113674. /**
  113675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113676. * @ignoreNaming
  113677. */
  113678. WarnedWebAudioUnsupported: boolean;
  113679. /**
  113680. * Defines if the audio engine relies on a custom unlocked button.
  113681. * In this case, the embedded button will not be displayed.
  113682. */
  113683. useCustomUnlockedButton: boolean;
  113684. /**
  113685. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113686. */
  113687. readonly unlocked: boolean;
  113688. /**
  113689. * Event raised when audio has been unlocked on the browser.
  113690. */
  113691. onAudioUnlockedObservable: Observable<AudioEngine>;
  113692. /**
  113693. * Event raised when audio has been locked on the browser.
  113694. */
  113695. onAudioLockedObservable: Observable<AudioEngine>;
  113696. /**
  113697. * Flags the audio engine in Locked state.
  113698. * This happens due to new browser policies preventing audio to autoplay.
  113699. */
  113700. lock(): void;
  113701. /**
  113702. * Unlocks the audio engine once a user action has been done on the dom.
  113703. * This is helpful to resume play once browser policies have been satisfied.
  113704. */
  113705. unlock(): void;
  113706. /**
  113707. * Gets the global volume sets on the master gain.
  113708. * @returns the global volume if set or -1 otherwise
  113709. */
  113710. getGlobalVolume(): number;
  113711. /**
  113712. * Sets the global volume of your experience (sets on the master gain).
  113713. * @param newVolume Defines the new global volume of the application
  113714. */
  113715. setGlobalVolume(newVolume: number): void;
  113716. /**
  113717. * Connect the audio engine to an audio analyser allowing some amazing
  113718. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113720. * @param analyser The analyser to connect to the engine
  113721. */
  113722. connectToAnalyser(analyser: Analyser): void;
  113723. }
  113724. /**
  113725. * This represents the default audio engine used in babylon.
  113726. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113728. */
  113729. export class AudioEngine implements IAudioEngine {
  113730. private _audioContext;
  113731. private _audioContextInitialized;
  113732. private _muteButton;
  113733. private _hostElement;
  113734. /**
  113735. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113736. */
  113737. canUseWebAudio: boolean;
  113738. /**
  113739. * The master gain node defines the global audio volume of your audio engine.
  113740. */
  113741. masterGain: GainNode;
  113742. /**
  113743. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113744. * @ignoreNaming
  113745. */
  113746. WarnedWebAudioUnsupported: boolean;
  113747. /**
  113748. * Gets whether or not mp3 are supported by your browser.
  113749. */
  113750. isMP3supported: boolean;
  113751. /**
  113752. * Gets whether or not ogg are supported by your browser.
  113753. */
  113754. isOGGsupported: boolean;
  113755. /**
  113756. * Gets whether audio has been unlocked on the device.
  113757. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113758. * a user interaction has happened.
  113759. */
  113760. unlocked: boolean;
  113761. /**
  113762. * Defines if the audio engine relies on a custom unlocked button.
  113763. * In this case, the embedded button will not be displayed.
  113764. */
  113765. useCustomUnlockedButton: boolean;
  113766. /**
  113767. * Event raised when audio has been unlocked on the browser.
  113768. */
  113769. onAudioUnlockedObservable: Observable<AudioEngine>;
  113770. /**
  113771. * Event raised when audio has been locked on the browser.
  113772. */
  113773. onAudioLockedObservable: Observable<AudioEngine>;
  113774. /**
  113775. * Gets the current AudioContext if available.
  113776. */
  113777. get audioContext(): Nullable<AudioContext>;
  113778. private _connectedAnalyser;
  113779. /**
  113780. * Instantiates a new audio engine.
  113781. *
  113782. * There should be only one per page as some browsers restrict the number
  113783. * of audio contexts you can create.
  113784. * @param hostElement defines the host element where to display the mute icon if necessary
  113785. */
  113786. constructor(hostElement?: Nullable<HTMLElement>);
  113787. /**
  113788. * Flags the audio engine in Locked state.
  113789. * This happens due to new browser policies preventing audio to autoplay.
  113790. */
  113791. lock(): void;
  113792. /**
  113793. * Unlocks the audio engine once a user action has been done on the dom.
  113794. * This is helpful to resume play once browser policies have been satisfied.
  113795. */
  113796. unlock(): void;
  113797. private _resumeAudioContext;
  113798. private _initializeAudioContext;
  113799. private _tryToRun;
  113800. private _triggerRunningState;
  113801. private _triggerSuspendedState;
  113802. private _displayMuteButton;
  113803. private _moveButtonToTopLeft;
  113804. private _onResize;
  113805. private _hideMuteButton;
  113806. /**
  113807. * Destroy and release the resources associated with the audio ccontext.
  113808. */
  113809. dispose(): void;
  113810. /**
  113811. * Gets the global volume sets on the master gain.
  113812. * @returns the global volume if set or -1 otherwise
  113813. */
  113814. getGlobalVolume(): number;
  113815. /**
  113816. * Sets the global volume of your experience (sets on the master gain).
  113817. * @param newVolume Defines the new global volume of the application
  113818. */
  113819. setGlobalVolume(newVolume: number): void;
  113820. /**
  113821. * Connect the audio engine to an audio analyser allowing some amazing
  113822. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113824. * @param analyser The analyser to connect to the engine
  113825. */
  113826. connectToAnalyser(analyser: Analyser): void;
  113827. }
  113828. }
  113829. declare module BABYLON {
  113830. /**
  113831. * Interface used to present a loading screen while loading a scene
  113832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113833. */
  113834. export interface ILoadingScreen {
  113835. /**
  113836. * Function called to display the loading screen
  113837. */
  113838. displayLoadingUI: () => void;
  113839. /**
  113840. * Function called to hide the loading screen
  113841. */
  113842. hideLoadingUI: () => void;
  113843. /**
  113844. * Gets or sets the color to use for the background
  113845. */
  113846. loadingUIBackgroundColor: string;
  113847. /**
  113848. * Gets or sets the text to display while loading
  113849. */
  113850. loadingUIText: string;
  113851. }
  113852. /**
  113853. * Class used for the default loading screen
  113854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113855. */
  113856. export class DefaultLoadingScreen implements ILoadingScreen {
  113857. private _renderingCanvas;
  113858. private _loadingText;
  113859. private _loadingDivBackgroundColor;
  113860. private _loadingDiv;
  113861. private _loadingTextDiv;
  113862. /** Gets or sets the logo url to use for the default loading screen */
  113863. static DefaultLogoUrl: string;
  113864. /** Gets or sets the spinner url to use for the default loading screen */
  113865. static DefaultSpinnerUrl: string;
  113866. /**
  113867. * Creates a new default loading screen
  113868. * @param _renderingCanvas defines the canvas used to render the scene
  113869. * @param _loadingText defines the default text to display
  113870. * @param _loadingDivBackgroundColor defines the default background color
  113871. */
  113872. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113873. /**
  113874. * Function called to display the loading screen
  113875. */
  113876. displayLoadingUI(): void;
  113877. /**
  113878. * Function called to hide the loading screen
  113879. */
  113880. hideLoadingUI(): void;
  113881. /**
  113882. * Gets or sets the text to display while loading
  113883. */
  113884. set loadingUIText(text: string);
  113885. get loadingUIText(): string;
  113886. /**
  113887. * Gets or sets the color to use for the background
  113888. */
  113889. get loadingUIBackgroundColor(): string;
  113890. set loadingUIBackgroundColor(color: string);
  113891. private _resizeLoadingUI;
  113892. }
  113893. }
  113894. declare module BABYLON {
  113895. /**
  113896. * Interface for any object that can request an animation frame
  113897. */
  113898. export interface ICustomAnimationFrameRequester {
  113899. /**
  113900. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113901. */
  113902. renderFunction?: Function;
  113903. /**
  113904. * Called to request the next frame to render to
  113905. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113906. */
  113907. requestAnimationFrame: Function;
  113908. /**
  113909. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113910. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113911. */
  113912. requestID?: number;
  113913. }
  113914. }
  113915. declare module BABYLON {
  113916. /**
  113917. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113918. */
  113919. export class PerformanceMonitor {
  113920. private _enabled;
  113921. private _rollingFrameTime;
  113922. private _lastFrameTimeMs;
  113923. /**
  113924. * constructor
  113925. * @param frameSampleSize The number of samples required to saturate the sliding window
  113926. */
  113927. constructor(frameSampleSize?: number);
  113928. /**
  113929. * Samples current frame
  113930. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113931. */
  113932. sampleFrame(timeMs?: number): void;
  113933. /**
  113934. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113935. */
  113936. get averageFrameTime(): number;
  113937. /**
  113938. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113939. */
  113940. get averageFrameTimeVariance(): number;
  113941. /**
  113942. * Returns the frame time of the most recent frame
  113943. */
  113944. get instantaneousFrameTime(): number;
  113945. /**
  113946. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113947. */
  113948. get averageFPS(): number;
  113949. /**
  113950. * Returns the average framerate in frames per second using the most recent frame time
  113951. */
  113952. get instantaneousFPS(): number;
  113953. /**
  113954. * Returns true if enough samples have been taken to completely fill the sliding window
  113955. */
  113956. get isSaturated(): boolean;
  113957. /**
  113958. * Enables contributions to the sliding window sample set
  113959. */
  113960. enable(): void;
  113961. /**
  113962. * Disables contributions to the sliding window sample set
  113963. * Samples will not be interpolated over the disabled period
  113964. */
  113965. disable(): void;
  113966. /**
  113967. * Returns true if sampling is enabled
  113968. */
  113969. get isEnabled(): boolean;
  113970. /**
  113971. * Resets performance monitor
  113972. */
  113973. reset(): void;
  113974. }
  113975. /**
  113976. * RollingAverage
  113977. *
  113978. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113979. */
  113980. export class RollingAverage {
  113981. /**
  113982. * Current average
  113983. */
  113984. average: number;
  113985. /**
  113986. * Current variance
  113987. */
  113988. variance: number;
  113989. protected _samples: Array<number>;
  113990. protected _sampleCount: number;
  113991. protected _pos: number;
  113992. protected _m2: number;
  113993. /**
  113994. * constructor
  113995. * @param length The number of samples required to saturate the sliding window
  113996. */
  113997. constructor(length: number);
  113998. /**
  113999. * Adds a sample to the sample set
  114000. * @param v The sample value
  114001. */
  114002. add(v: number): void;
  114003. /**
  114004. * Returns previously added values or null if outside of history or outside the sliding window domain
  114005. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114006. * @return Value previously recorded with add() or null if outside of range
  114007. */
  114008. history(i: number): number;
  114009. /**
  114010. * Returns true if enough samples have been taken to completely fill the sliding window
  114011. * @return true if sample-set saturated
  114012. */
  114013. isSaturated(): boolean;
  114014. /**
  114015. * Resets the rolling average (equivalent to 0 samples taken so far)
  114016. */
  114017. reset(): void;
  114018. /**
  114019. * Wraps a value around the sample range boundaries
  114020. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114021. * @return Wrapped position in sample range
  114022. */
  114023. protected _wrapPosition(i: number): number;
  114024. }
  114025. }
  114026. declare module BABYLON {
  114027. /**
  114028. * This class is used to track a performance counter which is number based.
  114029. * The user has access to many properties which give statistics of different nature.
  114030. *
  114031. * The implementer can track two kinds of Performance Counter: time and count.
  114032. * 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.
  114033. * 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.
  114034. */
  114035. export class PerfCounter {
  114036. /**
  114037. * Gets or sets a global boolean to turn on and off all the counters
  114038. */
  114039. static Enabled: boolean;
  114040. /**
  114041. * Returns the smallest value ever
  114042. */
  114043. get min(): number;
  114044. /**
  114045. * Returns the biggest value ever
  114046. */
  114047. get max(): number;
  114048. /**
  114049. * Returns the average value since the performance counter is running
  114050. */
  114051. get average(): number;
  114052. /**
  114053. * Returns the average value of the last second the counter was monitored
  114054. */
  114055. get lastSecAverage(): number;
  114056. /**
  114057. * Returns the current value
  114058. */
  114059. get current(): number;
  114060. /**
  114061. * Gets the accumulated total
  114062. */
  114063. get total(): number;
  114064. /**
  114065. * Gets the total value count
  114066. */
  114067. get count(): number;
  114068. /**
  114069. * Creates a new counter
  114070. */
  114071. constructor();
  114072. /**
  114073. * Call this method to start monitoring a new frame.
  114074. * 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.
  114075. */
  114076. fetchNewFrame(): void;
  114077. /**
  114078. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114079. * @param newCount the count value to add to the monitored count
  114080. * @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.
  114081. */
  114082. addCount(newCount: number, fetchResult: boolean): void;
  114083. /**
  114084. * Start monitoring this performance counter
  114085. */
  114086. beginMonitoring(): void;
  114087. /**
  114088. * Compute the time lapsed since the previous beginMonitoring() call.
  114089. * @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
  114090. */
  114091. endMonitoring(newFrame?: boolean): void;
  114092. private _fetchResult;
  114093. private _startMonitoringTime;
  114094. private _min;
  114095. private _max;
  114096. private _average;
  114097. private _current;
  114098. private _totalValueCount;
  114099. private _totalAccumulated;
  114100. private _lastSecAverage;
  114101. private _lastSecAccumulated;
  114102. private _lastSecTime;
  114103. private _lastSecValueCount;
  114104. }
  114105. }
  114106. declare module BABYLON {
  114107. interface ThinEngine {
  114108. /**
  114109. * Sets alpha constants used by some alpha blending modes
  114110. * @param r defines the red component
  114111. * @param g defines the green component
  114112. * @param b defines the blue component
  114113. * @param a defines the alpha component
  114114. */
  114115. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114116. /**
  114117. * Sets the current alpha mode
  114118. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114119. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114121. */
  114122. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114123. /**
  114124. * Gets the current alpha mode
  114125. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114126. * @returns the current alpha mode
  114127. */
  114128. getAlphaMode(): number;
  114129. /**
  114130. * Sets the current alpha equation
  114131. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114132. */
  114133. setAlphaEquation(equation: number): void;
  114134. /**
  114135. * Gets the current alpha equation.
  114136. * @returns the current alpha equation
  114137. */
  114138. getAlphaEquation(): number;
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. interface ThinEngine {
  114143. /** @hidden */
  114144. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114145. }
  114146. }
  114147. declare module BABYLON {
  114148. /**
  114149. * Defines the interface used by display changed events
  114150. */
  114151. export interface IDisplayChangedEventArgs {
  114152. /** Gets the vrDisplay object (if any) */
  114153. vrDisplay: Nullable<any>;
  114154. /** Gets a boolean indicating if webVR is supported */
  114155. vrSupported: boolean;
  114156. }
  114157. /**
  114158. * Defines the interface used by objects containing a viewport (like a camera)
  114159. */
  114160. interface IViewportOwnerLike {
  114161. /**
  114162. * Gets or sets the viewport
  114163. */
  114164. viewport: IViewportLike;
  114165. }
  114166. /**
  114167. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114168. */
  114169. export class Engine extends ThinEngine {
  114170. /** Defines that alpha blending is disabled */
  114171. static readonly ALPHA_DISABLE: number;
  114172. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114173. static readonly ALPHA_ADD: number;
  114174. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114175. static readonly ALPHA_COMBINE: number;
  114176. /** Defines that alpha blending to DEST - SRC * DEST */
  114177. static readonly ALPHA_SUBTRACT: number;
  114178. /** Defines that alpha blending to SRC * DEST */
  114179. static readonly ALPHA_MULTIPLY: number;
  114180. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114181. static readonly ALPHA_MAXIMIZED: number;
  114182. /** Defines that alpha blending to SRC + DEST */
  114183. static readonly ALPHA_ONEONE: number;
  114184. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114185. static readonly ALPHA_PREMULTIPLIED: number;
  114186. /**
  114187. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114188. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114189. */
  114190. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114191. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114192. static readonly ALPHA_INTERPOLATE: number;
  114193. /**
  114194. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114195. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114196. */
  114197. static readonly ALPHA_SCREENMODE: number;
  114198. /** Defines that the ressource is not delayed*/
  114199. static readonly DELAYLOADSTATE_NONE: number;
  114200. /** Defines that the ressource was successfully delay loaded */
  114201. static readonly DELAYLOADSTATE_LOADED: number;
  114202. /** Defines that the ressource is currently delay loading */
  114203. static readonly DELAYLOADSTATE_LOADING: number;
  114204. /** Defines that the ressource is delayed and has not started loading */
  114205. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114207. static readonly NEVER: number;
  114208. /** 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 */
  114209. static readonly ALWAYS: number;
  114210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114211. static readonly LESS: number;
  114212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114213. static readonly EQUAL: number;
  114214. /** 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 */
  114215. static readonly LEQUAL: number;
  114216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114217. static readonly GREATER: number;
  114218. /** 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 */
  114219. static readonly GEQUAL: number;
  114220. /** 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 */
  114221. static readonly NOTEQUAL: number;
  114222. /** Passed to stencilOperation to specify that stencil value must be kept */
  114223. static readonly KEEP: number;
  114224. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114225. static readonly REPLACE: number;
  114226. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114227. static readonly INCR: number;
  114228. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114229. static readonly DECR: number;
  114230. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114231. static readonly INVERT: number;
  114232. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114233. static readonly INCR_WRAP: number;
  114234. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114235. static readonly DECR_WRAP: number;
  114236. /** Texture is not repeating outside of 0..1 UVs */
  114237. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114238. /** Texture is repeating outside of 0..1 UVs */
  114239. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114240. /** Texture is repeating and mirrored */
  114241. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114242. /** ALPHA */
  114243. static readonly TEXTUREFORMAT_ALPHA: number;
  114244. /** LUMINANCE */
  114245. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114246. /** LUMINANCE_ALPHA */
  114247. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114248. /** RGB */
  114249. static readonly TEXTUREFORMAT_RGB: number;
  114250. /** RGBA */
  114251. static readonly TEXTUREFORMAT_RGBA: number;
  114252. /** RED */
  114253. static readonly TEXTUREFORMAT_RED: number;
  114254. /** RED (2nd reference) */
  114255. static readonly TEXTUREFORMAT_R: number;
  114256. /** RG */
  114257. static readonly TEXTUREFORMAT_RG: number;
  114258. /** RED_INTEGER */
  114259. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114260. /** RED_INTEGER (2nd reference) */
  114261. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114262. /** RG_INTEGER */
  114263. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114264. /** RGB_INTEGER */
  114265. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114266. /** RGBA_INTEGER */
  114267. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114268. /** UNSIGNED_BYTE */
  114269. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114270. /** UNSIGNED_BYTE (2nd reference) */
  114271. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114272. /** FLOAT */
  114273. static readonly TEXTURETYPE_FLOAT: number;
  114274. /** HALF_FLOAT */
  114275. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114276. /** BYTE */
  114277. static readonly TEXTURETYPE_BYTE: number;
  114278. /** SHORT */
  114279. static readonly TEXTURETYPE_SHORT: number;
  114280. /** UNSIGNED_SHORT */
  114281. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114282. /** INT */
  114283. static readonly TEXTURETYPE_INT: number;
  114284. /** UNSIGNED_INT */
  114285. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114286. /** UNSIGNED_SHORT_4_4_4_4 */
  114287. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114288. /** UNSIGNED_SHORT_5_5_5_1 */
  114289. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114290. /** UNSIGNED_SHORT_5_6_5 */
  114291. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114292. /** UNSIGNED_INT_2_10_10_10_REV */
  114293. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114294. /** UNSIGNED_INT_24_8 */
  114295. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114296. /** UNSIGNED_INT_10F_11F_11F_REV */
  114297. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114298. /** UNSIGNED_INT_5_9_9_9_REV */
  114299. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114300. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114301. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114302. /** nearest is mag = nearest and min = nearest and mip = linear */
  114303. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114305. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114306. /** Trilinear is mag = linear and min = linear and mip = linear */
  114307. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114308. /** nearest is mag = nearest and min = nearest and mip = linear */
  114309. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114310. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114311. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114312. /** Trilinear is mag = linear and min = linear and mip = linear */
  114313. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114314. /** mag = nearest and min = nearest and mip = nearest */
  114315. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114316. /** mag = nearest and min = linear and mip = nearest */
  114317. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114318. /** mag = nearest and min = linear and mip = linear */
  114319. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114320. /** mag = nearest and min = linear and mip = none */
  114321. static readonly TEXTURE_NEAREST_LINEAR: number;
  114322. /** mag = nearest and min = nearest and mip = none */
  114323. static readonly TEXTURE_NEAREST_NEAREST: number;
  114324. /** mag = linear and min = nearest and mip = nearest */
  114325. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114326. /** mag = linear and min = nearest and mip = linear */
  114327. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114328. /** mag = linear and min = linear and mip = none */
  114329. static readonly TEXTURE_LINEAR_LINEAR: number;
  114330. /** mag = linear and min = nearest and mip = none */
  114331. static readonly TEXTURE_LINEAR_NEAREST: number;
  114332. /** Explicit coordinates mode */
  114333. static readonly TEXTURE_EXPLICIT_MODE: number;
  114334. /** Spherical coordinates mode */
  114335. static readonly TEXTURE_SPHERICAL_MODE: number;
  114336. /** Planar coordinates mode */
  114337. static readonly TEXTURE_PLANAR_MODE: number;
  114338. /** Cubic coordinates mode */
  114339. static readonly TEXTURE_CUBIC_MODE: number;
  114340. /** Projection coordinates mode */
  114341. static readonly TEXTURE_PROJECTION_MODE: number;
  114342. /** Skybox coordinates mode */
  114343. static readonly TEXTURE_SKYBOX_MODE: number;
  114344. /** Inverse Cubic coordinates mode */
  114345. static readonly TEXTURE_INVCUBIC_MODE: number;
  114346. /** Equirectangular coordinates mode */
  114347. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114348. /** Equirectangular Fixed coordinates mode */
  114349. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114350. /** Equirectangular Fixed Mirrored coordinates mode */
  114351. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114352. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114353. static readonly SCALEMODE_FLOOR: number;
  114354. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114355. static readonly SCALEMODE_NEAREST: number;
  114356. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114357. static readonly SCALEMODE_CEILING: number;
  114358. /**
  114359. * Returns the current npm package of the sdk
  114360. */
  114361. static get NpmPackage(): string;
  114362. /**
  114363. * Returns the current version of the framework
  114364. */
  114365. static get Version(): string;
  114366. /** Gets the list of created engines */
  114367. static get Instances(): Engine[];
  114368. /**
  114369. * Gets the latest created engine
  114370. */
  114371. static get LastCreatedEngine(): Nullable<Engine>;
  114372. /**
  114373. * Gets the latest created scene
  114374. */
  114375. static get LastCreatedScene(): Nullable<Scene>;
  114376. /**
  114377. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114378. * @param flag defines which part of the materials must be marked as dirty
  114379. * @param predicate defines a predicate used to filter which materials should be affected
  114380. */
  114381. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114382. /**
  114383. * Method called to create the default loading screen.
  114384. * This can be overriden in your own app.
  114385. * @param canvas The rendering canvas element
  114386. * @returns The loading screen
  114387. */
  114388. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114389. /**
  114390. * Method called to create the default rescale post process on each engine.
  114391. */
  114392. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114393. /**
  114394. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114395. **/
  114396. enableOfflineSupport: boolean;
  114397. /**
  114398. * 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)
  114399. **/
  114400. disableManifestCheck: boolean;
  114401. /**
  114402. * Gets the list of created scenes
  114403. */
  114404. scenes: Scene[];
  114405. /**
  114406. * Event raised when a new scene is created
  114407. */
  114408. onNewSceneAddedObservable: Observable<Scene>;
  114409. /**
  114410. * Gets the list of created postprocesses
  114411. */
  114412. postProcesses: PostProcess[];
  114413. /**
  114414. * Gets a boolean indicating if the pointer is currently locked
  114415. */
  114416. isPointerLock: boolean;
  114417. /**
  114418. * Observable event triggered each time the rendering canvas is resized
  114419. */
  114420. onResizeObservable: Observable<Engine>;
  114421. /**
  114422. * Observable event triggered each time the canvas loses focus
  114423. */
  114424. onCanvasBlurObservable: Observable<Engine>;
  114425. /**
  114426. * Observable event triggered each time the canvas gains focus
  114427. */
  114428. onCanvasFocusObservable: Observable<Engine>;
  114429. /**
  114430. * Observable event triggered each time the canvas receives pointerout event
  114431. */
  114432. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114433. /**
  114434. * Observable raised when the engine begins a new frame
  114435. */
  114436. onBeginFrameObservable: Observable<Engine>;
  114437. /**
  114438. * If set, will be used to request the next animation frame for the render loop
  114439. */
  114440. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114441. /**
  114442. * Observable raised when the engine ends the current frame
  114443. */
  114444. onEndFrameObservable: Observable<Engine>;
  114445. /**
  114446. * Observable raised when the engine is about to compile a shader
  114447. */
  114448. onBeforeShaderCompilationObservable: Observable<Engine>;
  114449. /**
  114450. * Observable raised when the engine has jsut compiled a shader
  114451. */
  114452. onAfterShaderCompilationObservable: Observable<Engine>;
  114453. /**
  114454. * Gets the audio engine
  114455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114456. * @ignorenaming
  114457. */
  114458. static audioEngine: IAudioEngine;
  114459. /**
  114460. * Default AudioEngine factory responsible of creating the Audio Engine.
  114461. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114462. */
  114463. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114464. /**
  114465. * Default offline support factory responsible of creating a tool used to store data locally.
  114466. * By default, this will create a Database object if the workload has been embedded.
  114467. */
  114468. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114469. private _loadingScreen;
  114470. private _pointerLockRequested;
  114471. private _rescalePostProcess;
  114472. private _deterministicLockstep;
  114473. private _lockstepMaxSteps;
  114474. private _timeStep;
  114475. protected get _supportsHardwareTextureRescaling(): boolean;
  114476. private _fps;
  114477. private _deltaTime;
  114478. /** @hidden */
  114479. _drawCalls: PerfCounter;
  114480. /** 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 */
  114481. canvasTabIndex: number;
  114482. /**
  114483. * Turn this value on if you want to pause FPS computation when in background
  114484. */
  114485. disablePerformanceMonitorInBackground: boolean;
  114486. private _performanceMonitor;
  114487. /**
  114488. * Gets the performance monitor attached to this engine
  114489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114490. */
  114491. get performanceMonitor(): PerformanceMonitor;
  114492. private _onFocus;
  114493. private _onBlur;
  114494. private _onCanvasPointerOut;
  114495. private _onCanvasBlur;
  114496. private _onCanvasFocus;
  114497. private _onFullscreenChange;
  114498. private _onPointerLockChange;
  114499. /**
  114500. * Gets the HTML element used to attach event listeners
  114501. * @returns a HTML element
  114502. */
  114503. getInputElement(): Nullable<HTMLElement>;
  114504. /**
  114505. * Creates a new engine
  114506. * @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
  114507. * @param antialias defines enable antialiasing (default: false)
  114508. * @param options defines further options to be sent to the getContext() function
  114509. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114510. */
  114511. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114512. /**
  114513. * Gets current aspect ratio
  114514. * @param viewportOwner defines the camera to use to get the aspect ratio
  114515. * @param useScreen defines if screen size must be used (or the current render target if any)
  114516. * @returns a number defining the aspect ratio
  114517. */
  114518. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114519. /**
  114520. * Gets current screen aspect ratio
  114521. * @returns a number defining the aspect ratio
  114522. */
  114523. getScreenAspectRatio(): number;
  114524. /**
  114525. * Gets the client rect of the HTML canvas attached with the current webGL context
  114526. * @returns a client rectanglee
  114527. */
  114528. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114529. /**
  114530. * Gets the client rect of the HTML element used for events
  114531. * @returns a client rectanglee
  114532. */
  114533. getInputElementClientRect(): Nullable<ClientRect>;
  114534. /**
  114535. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114536. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114537. * @returns true if engine is in deterministic lock step mode
  114538. */
  114539. isDeterministicLockStep(): boolean;
  114540. /**
  114541. * Gets the max steps when engine is running in deterministic lock step
  114542. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114543. * @returns the max steps
  114544. */
  114545. getLockstepMaxSteps(): number;
  114546. /**
  114547. * Returns the time in ms between steps when using deterministic lock step.
  114548. * @returns time step in (ms)
  114549. */
  114550. getTimeStep(): number;
  114551. /**
  114552. * Force the mipmap generation for the given render target texture
  114553. * @param texture defines the render target texture to use
  114554. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114555. */
  114556. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114557. /** States */
  114558. /**
  114559. * Set various states to the webGL context
  114560. * @param culling defines backface culling state
  114561. * @param zOffset defines the value to apply to zOffset (0 by default)
  114562. * @param force defines if states must be applied even if cache is up to date
  114563. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114564. */
  114565. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114566. /**
  114567. * Set the z offset to apply to current rendering
  114568. * @param value defines the offset to apply
  114569. */
  114570. setZOffset(value: number): void;
  114571. /**
  114572. * Gets the current value of the zOffset
  114573. * @returns the current zOffset state
  114574. */
  114575. getZOffset(): number;
  114576. /**
  114577. * Enable or disable depth buffering
  114578. * @param enable defines the state to set
  114579. */
  114580. setDepthBuffer(enable: boolean): void;
  114581. /**
  114582. * Gets a boolean indicating if depth writing is enabled
  114583. * @returns the current depth writing state
  114584. */
  114585. getDepthWrite(): boolean;
  114586. /**
  114587. * Enable or disable depth writing
  114588. * @param enable defines the state to set
  114589. */
  114590. setDepthWrite(enable: boolean): void;
  114591. /**
  114592. * Gets a boolean indicating if stencil buffer is enabled
  114593. * @returns the current stencil buffer state
  114594. */
  114595. getStencilBuffer(): boolean;
  114596. /**
  114597. * Enable or disable the stencil buffer
  114598. * @param enable defines if the stencil buffer must be enabled or disabled
  114599. */
  114600. setStencilBuffer(enable: boolean): void;
  114601. /**
  114602. * Gets the current stencil mask
  114603. * @returns a number defining the new stencil mask to use
  114604. */
  114605. getStencilMask(): number;
  114606. /**
  114607. * Sets the current stencil mask
  114608. * @param mask defines the new stencil mask to use
  114609. */
  114610. setStencilMask(mask: number): void;
  114611. /**
  114612. * Gets the current stencil function
  114613. * @returns a number defining the stencil function to use
  114614. */
  114615. getStencilFunction(): number;
  114616. /**
  114617. * Gets the current stencil reference value
  114618. * @returns a number defining the stencil reference value to use
  114619. */
  114620. getStencilFunctionReference(): number;
  114621. /**
  114622. * Gets the current stencil mask
  114623. * @returns a number defining the stencil mask to use
  114624. */
  114625. getStencilFunctionMask(): number;
  114626. /**
  114627. * Sets the current stencil function
  114628. * @param stencilFunc defines the new stencil function to use
  114629. */
  114630. setStencilFunction(stencilFunc: number): void;
  114631. /**
  114632. * Sets the current stencil reference
  114633. * @param reference defines the new stencil reference to use
  114634. */
  114635. setStencilFunctionReference(reference: number): void;
  114636. /**
  114637. * Sets the current stencil mask
  114638. * @param mask defines the new stencil mask to use
  114639. */
  114640. setStencilFunctionMask(mask: number): void;
  114641. /**
  114642. * Gets the current stencil operation when stencil fails
  114643. * @returns a number defining stencil operation to use when stencil fails
  114644. */
  114645. getStencilOperationFail(): number;
  114646. /**
  114647. * Gets the current stencil operation when depth fails
  114648. * @returns a number defining stencil operation to use when depth fails
  114649. */
  114650. getStencilOperationDepthFail(): number;
  114651. /**
  114652. * Gets the current stencil operation when stencil passes
  114653. * @returns a number defining stencil operation to use when stencil passes
  114654. */
  114655. getStencilOperationPass(): number;
  114656. /**
  114657. * Sets the stencil operation to use when stencil fails
  114658. * @param operation defines the stencil operation to use when stencil fails
  114659. */
  114660. setStencilOperationFail(operation: number): void;
  114661. /**
  114662. * Sets the stencil operation to use when depth fails
  114663. * @param operation defines the stencil operation to use when depth fails
  114664. */
  114665. setStencilOperationDepthFail(operation: number): void;
  114666. /**
  114667. * Sets the stencil operation to use when stencil passes
  114668. * @param operation defines the stencil operation to use when stencil passes
  114669. */
  114670. setStencilOperationPass(operation: number): void;
  114671. /**
  114672. * Sets a boolean indicating if the dithering state is enabled or disabled
  114673. * @param value defines the dithering state
  114674. */
  114675. setDitheringState(value: boolean): void;
  114676. /**
  114677. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114678. * @param value defines the rasterizer state
  114679. */
  114680. setRasterizerState(value: boolean): void;
  114681. /**
  114682. * Gets the current depth function
  114683. * @returns a number defining the depth function
  114684. */
  114685. getDepthFunction(): Nullable<number>;
  114686. /**
  114687. * Sets the current depth function
  114688. * @param depthFunc defines the function to use
  114689. */
  114690. setDepthFunction(depthFunc: number): void;
  114691. /**
  114692. * Sets the current depth function to GREATER
  114693. */
  114694. setDepthFunctionToGreater(): void;
  114695. /**
  114696. * Sets the current depth function to GEQUAL
  114697. */
  114698. setDepthFunctionToGreaterOrEqual(): void;
  114699. /**
  114700. * Sets the current depth function to LESS
  114701. */
  114702. setDepthFunctionToLess(): void;
  114703. /**
  114704. * Sets the current depth function to LEQUAL
  114705. */
  114706. setDepthFunctionToLessOrEqual(): void;
  114707. private _cachedStencilBuffer;
  114708. private _cachedStencilFunction;
  114709. private _cachedStencilMask;
  114710. private _cachedStencilOperationPass;
  114711. private _cachedStencilOperationFail;
  114712. private _cachedStencilOperationDepthFail;
  114713. private _cachedStencilReference;
  114714. /**
  114715. * Caches the the state of the stencil buffer
  114716. */
  114717. cacheStencilState(): void;
  114718. /**
  114719. * Restores the state of the stencil buffer
  114720. */
  114721. restoreStencilState(): void;
  114722. /**
  114723. * Directly set the WebGL Viewport
  114724. * @param x defines the x coordinate of the viewport (in screen space)
  114725. * @param y defines the y coordinate of the viewport (in screen space)
  114726. * @param width defines the width of the viewport (in screen space)
  114727. * @param height defines the height of the viewport (in screen space)
  114728. * @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
  114729. */
  114730. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114731. /**
  114732. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114733. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114734. * @param y defines the y-coordinate of the corner of the clear rectangle
  114735. * @param width defines the width of the clear rectangle
  114736. * @param height defines the height of the clear rectangle
  114737. * @param clearColor defines the clear color
  114738. */
  114739. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114740. /**
  114741. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114742. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114743. * @param y defines the y-coordinate of the corner of the clear rectangle
  114744. * @param width defines the width of the clear rectangle
  114745. * @param height defines the height of the clear rectangle
  114746. */
  114747. enableScissor(x: number, y: number, width: number, height: number): void;
  114748. /**
  114749. * Disable previously set scissor test rectangle
  114750. */
  114751. disableScissor(): void;
  114752. protected _reportDrawCall(): void;
  114753. /**
  114754. * Initializes a webVR display and starts listening to display change events
  114755. * The onVRDisplayChangedObservable will be notified upon these changes
  114756. * @returns The onVRDisplayChangedObservable
  114757. */
  114758. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114759. /** @hidden */
  114760. _prepareVRComponent(): void;
  114761. /** @hidden */
  114762. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114763. /** @hidden */
  114764. _submitVRFrame(): void;
  114765. /**
  114766. * Call this function to leave webVR mode
  114767. * Will do nothing if webVR is not supported or if there is no webVR device
  114768. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114769. */
  114770. disableVR(): void;
  114771. /**
  114772. * Gets a boolean indicating that the system is in VR mode and is presenting
  114773. * @returns true if VR mode is engaged
  114774. */
  114775. isVRPresenting(): boolean;
  114776. /** @hidden */
  114777. _requestVRFrame(): void;
  114778. /** @hidden */
  114779. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114780. /**
  114781. * Gets the source code of the vertex shader associated with a specific webGL program
  114782. * @param program defines the program to use
  114783. * @returns a string containing the source code of the vertex shader associated with the program
  114784. */
  114785. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114786. /**
  114787. * Gets the source code of the fragment shader associated with a specific webGL program
  114788. * @param program defines the program to use
  114789. * @returns a string containing the source code of the fragment shader associated with the program
  114790. */
  114791. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114792. /**
  114793. * Sets a depth stencil texture from a render target to the according uniform.
  114794. * @param channel The texture channel
  114795. * @param uniform The uniform to set
  114796. * @param texture The render target texture containing the depth stencil texture to apply
  114797. */
  114798. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114799. /**
  114800. * Sets a texture to the webGL context from a postprocess
  114801. * @param channel defines the channel to use
  114802. * @param postProcess defines the source postprocess
  114803. */
  114804. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114805. /**
  114806. * Binds the output of the passed in post process to the texture channel specified
  114807. * @param channel The channel the texture should be bound to
  114808. * @param postProcess The post process which's output should be bound
  114809. */
  114810. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114811. protected _rebuildBuffers(): void;
  114812. /** @hidden */
  114813. _renderFrame(): void;
  114814. _renderLoop(): void;
  114815. /** @hidden */
  114816. _renderViews(): boolean;
  114817. /**
  114818. * Toggle full screen mode
  114819. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114820. */
  114821. switchFullscreen(requestPointerLock: boolean): void;
  114822. /**
  114823. * Enters full screen mode
  114824. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114825. */
  114826. enterFullscreen(requestPointerLock: boolean): void;
  114827. /**
  114828. * Exits full screen mode
  114829. */
  114830. exitFullscreen(): void;
  114831. /**
  114832. * Enters Pointerlock mode
  114833. */
  114834. enterPointerlock(): void;
  114835. /**
  114836. * Exits Pointerlock mode
  114837. */
  114838. exitPointerlock(): void;
  114839. /**
  114840. * Begin a new frame
  114841. */
  114842. beginFrame(): void;
  114843. /**
  114844. * Enf the current frame
  114845. */
  114846. endFrame(): void;
  114847. resize(): void;
  114848. /**
  114849. * Force a specific size of the canvas
  114850. * @param width defines the new canvas' width
  114851. * @param height defines the new canvas' height
  114852. * @returns true if the size was changed
  114853. */
  114854. setSize(width: number, height: number): boolean;
  114855. /**
  114856. * Updates a dynamic vertex buffer.
  114857. * @param vertexBuffer the vertex buffer to update
  114858. * @param data the data used to update the vertex buffer
  114859. * @param byteOffset the byte offset of the data
  114860. * @param byteLength the byte length of the data
  114861. */
  114862. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114863. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114864. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114865. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114866. _releaseTexture(texture: InternalTexture): void;
  114867. /**
  114868. * @hidden
  114869. * Rescales a texture
  114870. * @param source input texutre
  114871. * @param destination destination texture
  114872. * @param scene scene to use to render the resize
  114873. * @param internalFormat format to use when resizing
  114874. * @param onComplete callback to be called when resize has completed
  114875. */
  114876. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114877. /**
  114878. * Gets the current framerate
  114879. * @returns a number representing the framerate
  114880. */
  114881. getFps(): number;
  114882. /**
  114883. * Gets the time spent between current and previous frame
  114884. * @returns a number representing the delta time in ms
  114885. */
  114886. getDeltaTime(): number;
  114887. private _measureFps;
  114888. /** @hidden */
  114889. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114890. /**
  114891. * Update a dynamic index buffer
  114892. * @param indexBuffer defines the target index buffer
  114893. * @param indices defines the data to update
  114894. * @param offset defines the offset in the target index buffer where update should start
  114895. */
  114896. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114897. /**
  114898. * Updates the sample count of a render target texture
  114899. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114900. * @param texture defines the texture to update
  114901. * @param samples defines the sample count to set
  114902. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114903. */
  114904. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114905. /**
  114906. * Updates a depth texture Comparison Mode and Function.
  114907. * If the comparison Function is equal to 0, the mode will be set to none.
  114908. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114909. * @param texture The texture to set the comparison function for
  114910. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114911. */
  114912. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114913. /**
  114914. * Creates a webGL buffer to use with instanciation
  114915. * @param capacity defines the size of the buffer
  114916. * @returns the webGL buffer
  114917. */
  114918. createInstancesBuffer(capacity: number): DataBuffer;
  114919. /**
  114920. * Delete a webGL buffer used with instanciation
  114921. * @param buffer defines the webGL buffer to delete
  114922. */
  114923. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114924. private _clientWaitAsync;
  114925. /** @hidden */
  114926. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114927. dispose(): void;
  114928. private _disableTouchAction;
  114929. /**
  114930. * Display the loading screen
  114931. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114932. */
  114933. displayLoadingUI(): void;
  114934. /**
  114935. * Hide the loading screen
  114936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114937. */
  114938. hideLoadingUI(): void;
  114939. /**
  114940. * Gets the current loading screen object
  114941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114942. */
  114943. get loadingScreen(): ILoadingScreen;
  114944. /**
  114945. * Sets the current loading screen object
  114946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114947. */
  114948. set loadingScreen(loadingScreen: ILoadingScreen);
  114949. /**
  114950. * Sets the current loading screen text
  114951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114952. */
  114953. set loadingUIText(text: string);
  114954. /**
  114955. * Sets the current loading screen background color
  114956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114957. */
  114958. set loadingUIBackgroundColor(color: string);
  114959. /** Pointerlock and fullscreen */
  114960. /**
  114961. * Ask the browser to promote the current element to pointerlock mode
  114962. * @param element defines the DOM element to promote
  114963. */
  114964. static _RequestPointerlock(element: HTMLElement): void;
  114965. /**
  114966. * Asks the browser to exit pointerlock mode
  114967. */
  114968. static _ExitPointerlock(): void;
  114969. /**
  114970. * Ask the browser to promote the current element to fullscreen rendering mode
  114971. * @param element defines the DOM element to promote
  114972. */
  114973. static _RequestFullscreen(element: HTMLElement): void;
  114974. /**
  114975. * Asks the browser to exit fullscreen mode
  114976. */
  114977. static _ExitFullscreen(): void;
  114978. }
  114979. }
  114980. declare module BABYLON {
  114981. /**
  114982. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114983. * during the life time of the application.
  114984. */
  114985. export class EngineStore {
  114986. /** Gets the list of created engines */
  114987. static Instances: Engine[];
  114988. /** @hidden */
  114989. static _LastCreatedScene: Nullable<Scene>;
  114990. /**
  114991. * Gets the latest created engine
  114992. */
  114993. static get LastCreatedEngine(): Nullable<Engine>;
  114994. /**
  114995. * Gets the latest created scene
  114996. */
  114997. static get LastCreatedScene(): Nullable<Scene>;
  114998. /**
  114999. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115000. * @ignorenaming
  115001. */
  115002. static UseFallbackTexture: boolean;
  115003. /**
  115004. * Texture content used if a texture cannot loaded
  115005. * @ignorenaming
  115006. */
  115007. static FallbackTexture: string;
  115008. }
  115009. }
  115010. declare module BABYLON {
  115011. /**
  115012. * Helper class that provides a small promise polyfill
  115013. */
  115014. export class PromisePolyfill {
  115015. /**
  115016. * Static function used to check if the polyfill is required
  115017. * If this is the case then the function will inject the polyfill to window.Promise
  115018. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115019. */
  115020. static Apply(force?: boolean): void;
  115021. }
  115022. }
  115023. declare module BABYLON {
  115024. /**
  115025. * Interface for screenshot methods with describe argument called `size` as object with options
  115026. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115027. */
  115028. export interface IScreenshotSize {
  115029. /**
  115030. * number in pixels for canvas height
  115031. */
  115032. height?: number;
  115033. /**
  115034. * multiplier allowing render at a higher or lower resolution
  115035. * If value is defined then height and width will be ignored and taken from camera
  115036. */
  115037. precision?: number;
  115038. /**
  115039. * number in pixels for canvas width
  115040. */
  115041. width?: number;
  115042. }
  115043. }
  115044. declare module BABYLON {
  115045. interface IColor4Like {
  115046. r: float;
  115047. g: float;
  115048. b: float;
  115049. a: float;
  115050. }
  115051. /**
  115052. * Class containing a set of static utilities functions
  115053. */
  115054. export class Tools {
  115055. /**
  115056. * Gets or sets the base URL to use to load assets
  115057. */
  115058. static get BaseUrl(): string;
  115059. static set BaseUrl(value: string);
  115060. /**
  115061. * Enable/Disable Custom HTTP Request Headers globally.
  115062. * default = false
  115063. * @see CustomRequestHeaders
  115064. */
  115065. static UseCustomRequestHeaders: boolean;
  115066. /**
  115067. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115068. * i.e. when loading files, where the server/service expects an Authorization header
  115069. */
  115070. static CustomRequestHeaders: {
  115071. [key: string]: string;
  115072. };
  115073. /**
  115074. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115075. */
  115076. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115077. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115078. /**
  115079. * Default behaviour for cors in the application.
  115080. * It can be a string if the expected behavior is identical in the entire app.
  115081. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115082. */
  115083. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115084. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115085. /**
  115086. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115087. * @ignorenaming
  115088. */
  115089. static get UseFallbackTexture(): boolean;
  115090. static set UseFallbackTexture(value: boolean);
  115091. /**
  115092. * Use this object to register external classes like custom textures or material
  115093. * to allow the laoders to instantiate them
  115094. */
  115095. static get RegisteredExternalClasses(): {
  115096. [key: string]: Object;
  115097. };
  115098. static set RegisteredExternalClasses(classes: {
  115099. [key: string]: Object;
  115100. });
  115101. /**
  115102. * Texture content used if a texture cannot loaded
  115103. * @ignorenaming
  115104. */
  115105. static get fallbackTexture(): string;
  115106. static set fallbackTexture(value: string);
  115107. /**
  115108. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115109. * @param u defines the coordinate on X axis
  115110. * @param v defines the coordinate on Y axis
  115111. * @param width defines the width of the source data
  115112. * @param height defines the height of the source data
  115113. * @param pixels defines the source byte array
  115114. * @param color defines the output color
  115115. */
  115116. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115117. /**
  115118. * Interpolates between a and b via alpha
  115119. * @param a The lower value (returned when alpha = 0)
  115120. * @param b The upper value (returned when alpha = 1)
  115121. * @param alpha The interpolation-factor
  115122. * @return The mixed value
  115123. */
  115124. static Mix(a: number, b: number, alpha: number): number;
  115125. /**
  115126. * Tries to instantiate a new object from a given class name
  115127. * @param className defines the class name to instantiate
  115128. * @returns the new object or null if the system was not able to do the instantiation
  115129. */
  115130. static Instantiate(className: string): any;
  115131. /**
  115132. * Provides a slice function that will work even on IE
  115133. * @param data defines the array to slice
  115134. * @param start defines the start of the data (optional)
  115135. * @param end defines the end of the data (optional)
  115136. * @returns the new sliced array
  115137. */
  115138. static Slice<T>(data: T, start?: number, end?: number): T;
  115139. /**
  115140. * Polyfill for setImmediate
  115141. * @param action defines the action to execute after the current execution block
  115142. */
  115143. static SetImmediate(action: () => void): void;
  115144. /**
  115145. * Function indicating if a number is an exponent of 2
  115146. * @param value defines the value to test
  115147. * @returns true if the value is an exponent of 2
  115148. */
  115149. static IsExponentOfTwo(value: number): boolean;
  115150. private static _tmpFloatArray;
  115151. /**
  115152. * Returns the nearest 32-bit single precision float representation of a Number
  115153. * @param value A Number. If the parameter is of a different type, it will get converted
  115154. * to a number or to NaN if it cannot be converted
  115155. * @returns number
  115156. */
  115157. static FloatRound(value: number): number;
  115158. /**
  115159. * Extracts the filename from a path
  115160. * @param path defines the path to use
  115161. * @returns the filename
  115162. */
  115163. static GetFilename(path: string): string;
  115164. /**
  115165. * Extracts the "folder" part of a path (everything before the filename).
  115166. * @param uri The URI to extract the info from
  115167. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115168. * @returns The "folder" part of the path
  115169. */
  115170. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115171. /**
  115172. * Extracts text content from a DOM element hierarchy
  115173. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115174. */
  115175. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115176. /**
  115177. * Convert an angle in radians to degrees
  115178. * @param angle defines the angle to convert
  115179. * @returns the angle in degrees
  115180. */
  115181. static ToDegrees(angle: number): number;
  115182. /**
  115183. * Convert an angle in degrees to radians
  115184. * @param angle defines the angle to convert
  115185. * @returns the angle in radians
  115186. */
  115187. static ToRadians(angle: number): number;
  115188. /**
  115189. * Returns an array if obj is not an array
  115190. * @param obj defines the object to evaluate as an array
  115191. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115192. * @returns either obj directly if obj is an array or a new array containing obj
  115193. */
  115194. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115195. /**
  115196. * Gets the pointer prefix to use
  115197. * @param engine defines the engine we are finding the prefix for
  115198. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115199. */
  115200. static GetPointerPrefix(engine: Engine): string;
  115201. /**
  115202. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115203. * @param url define the url we are trying
  115204. * @param element define the dom element where to configure the cors policy
  115205. */
  115206. static SetCorsBehavior(url: string | string[], element: {
  115207. crossOrigin: string | null;
  115208. }): void;
  115209. /**
  115210. * Removes unwanted characters from an url
  115211. * @param url defines the url to clean
  115212. * @returns the cleaned url
  115213. */
  115214. static CleanUrl(url: string): string;
  115215. /**
  115216. * Gets or sets a function used to pre-process url before using them to load assets
  115217. */
  115218. static get PreprocessUrl(): (url: string) => string;
  115219. static set PreprocessUrl(processor: (url: string) => string);
  115220. /**
  115221. * Loads an image as an HTMLImageElement.
  115222. * @param input url string, ArrayBuffer, or Blob to load
  115223. * @param onLoad callback called when the image successfully loads
  115224. * @param onError callback called when the image fails to load
  115225. * @param offlineProvider offline provider for caching
  115226. * @param mimeType optional mime type
  115227. * @returns the HTMLImageElement of the loaded image
  115228. */
  115229. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115230. /**
  115231. * Loads a file from a url
  115232. * @param url url string, ArrayBuffer, or Blob to load
  115233. * @param onSuccess callback called when the file successfully loads
  115234. * @param onProgress callback called while file is loading (if the server supports this mode)
  115235. * @param offlineProvider defines the offline provider for caching
  115236. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115237. * @param onError callback called when the file fails to load
  115238. * @returns a file request object
  115239. */
  115240. 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;
  115241. /**
  115242. * Loads a file from a url
  115243. * @param url the file url to load
  115244. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115245. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115246. */
  115247. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115248. /**
  115249. * Load a script (identified by an url). When the url returns, the
  115250. * content of this file is added into a new script element, attached to the DOM (body element)
  115251. * @param scriptUrl defines the url of the script to laod
  115252. * @param onSuccess defines the callback called when the script is loaded
  115253. * @param onError defines the callback to call if an error occurs
  115254. * @param scriptId defines the id of the script element
  115255. */
  115256. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115257. /**
  115258. * Load an asynchronous script (identified by an url). When the url returns, the
  115259. * content of this file is added into a new script element, attached to the DOM (body element)
  115260. * @param scriptUrl defines the url of the script to laod
  115261. * @param scriptId defines the id of the script element
  115262. * @returns a promise request object
  115263. */
  115264. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115265. /**
  115266. * Loads a file from a blob
  115267. * @param fileToLoad defines the blob to use
  115268. * @param callback defines the callback to call when data is loaded
  115269. * @param progressCallback defines the callback to call during loading process
  115270. * @returns a file request object
  115271. */
  115272. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115273. /**
  115274. * Reads a file from a File object
  115275. * @param file defines the file to load
  115276. * @param onSuccess defines the callback to call when data is loaded
  115277. * @param onProgress defines the callback to call during loading process
  115278. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115279. * @param onError defines the callback to call when an error occurs
  115280. * @returns a file request object
  115281. */
  115282. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115283. /**
  115284. * Creates a data url from a given string content
  115285. * @param content defines the content to convert
  115286. * @returns the new data url link
  115287. */
  115288. static FileAsURL(content: string): string;
  115289. /**
  115290. * Format the given number to a specific decimal format
  115291. * @param value defines the number to format
  115292. * @param decimals defines the number of decimals to use
  115293. * @returns the formatted string
  115294. */
  115295. static Format(value: number, decimals?: number): string;
  115296. /**
  115297. * Tries to copy an object by duplicating every property
  115298. * @param source defines the source object
  115299. * @param destination defines the target object
  115300. * @param doNotCopyList defines a list of properties to avoid
  115301. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115302. */
  115303. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115304. /**
  115305. * Gets a boolean indicating if the given object has no own property
  115306. * @param obj defines the object to test
  115307. * @returns true if object has no own property
  115308. */
  115309. static IsEmpty(obj: any): boolean;
  115310. /**
  115311. * Function used to register events at window level
  115312. * @param windowElement defines the Window object to use
  115313. * @param events defines the events to register
  115314. */
  115315. static RegisterTopRootEvents(windowElement: Window, events: {
  115316. name: string;
  115317. handler: Nullable<(e: FocusEvent) => any>;
  115318. }[]): void;
  115319. /**
  115320. * Function used to unregister events from window level
  115321. * @param windowElement defines the Window object to use
  115322. * @param events defines the events to unregister
  115323. */
  115324. static UnregisterTopRootEvents(windowElement: Window, events: {
  115325. name: string;
  115326. handler: Nullable<(e: FocusEvent) => any>;
  115327. }[]): void;
  115328. /**
  115329. * @ignore
  115330. */
  115331. static _ScreenshotCanvas: HTMLCanvasElement;
  115332. /**
  115333. * Dumps the current bound framebuffer
  115334. * @param width defines the rendering width
  115335. * @param height defines the rendering height
  115336. * @param engine defines the hosting engine
  115337. * @param successCallback defines the callback triggered once the data are available
  115338. * @param mimeType defines the mime type of the result
  115339. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115340. */
  115341. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115342. /**
  115343. * Converts the canvas data to blob.
  115344. * This acts as a polyfill for browsers not supporting the to blob function.
  115345. * @param canvas Defines the canvas to extract the data from
  115346. * @param successCallback Defines the callback triggered once the data are available
  115347. * @param mimeType Defines the mime type of the result
  115348. */
  115349. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115350. /**
  115351. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115352. * @param successCallback defines the callback triggered once the data are available
  115353. * @param mimeType defines the mime type of the result
  115354. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115355. */
  115356. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115357. /**
  115358. * Downloads a blob in the browser
  115359. * @param blob defines the blob to download
  115360. * @param fileName defines the name of the downloaded file
  115361. */
  115362. static Download(blob: Blob, fileName: string): void;
  115363. /**
  115364. * Captures a screenshot of the current rendering
  115365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115366. * @param engine defines the rendering engine
  115367. * @param camera defines the source camera
  115368. * @param size This parameter can be set to a single number or to an object with the
  115369. * following (optional) properties: precision, width, height. If a single number is passed,
  115370. * it will be used for both width and height. If an object is passed, the screenshot size
  115371. * will be derived from the parameters. The precision property is a multiplier allowing
  115372. * rendering at a higher or lower resolution
  115373. * @param successCallback defines the callback receives a single parameter which contains the
  115374. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115375. * src parameter of an <img> to display it
  115376. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115377. * Check your browser for supported MIME types
  115378. */
  115379. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115380. /**
  115381. * Captures a screenshot of the current rendering
  115382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115383. * @param engine defines the rendering engine
  115384. * @param camera defines the source camera
  115385. * @param size This parameter can be set to a single number or to an object with the
  115386. * following (optional) properties: precision, width, height. If a single number is passed,
  115387. * it will be used for both width and height. If an object is passed, the screenshot size
  115388. * will be derived from the parameters. The precision property is a multiplier allowing
  115389. * rendering at a higher or lower resolution
  115390. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115391. * Check your browser for supported MIME types
  115392. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115393. * to the src parameter of an <img> to display it
  115394. */
  115395. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115396. /**
  115397. * Generates an image screenshot from the specified camera.
  115398. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115399. * @param engine The engine to use for rendering
  115400. * @param camera The camera to use for rendering
  115401. * @param size This parameter can be set to a single number or to an object with the
  115402. * following (optional) properties: precision, width, height. If a single number is passed,
  115403. * it will be used for both width and height. If an object is passed, the screenshot size
  115404. * will be derived from the parameters. The precision property is a multiplier allowing
  115405. * rendering at a higher or lower resolution
  115406. * @param successCallback The callback receives a single parameter which contains the
  115407. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115408. * src parameter of an <img> to display it
  115409. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115410. * Check your browser for supported MIME types
  115411. * @param samples Texture samples (default: 1)
  115412. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115413. * @param fileName A name for for the downloaded file.
  115414. */
  115415. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115416. /**
  115417. * Generates an image screenshot from the specified camera.
  115418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115419. * @param engine The engine to use for rendering
  115420. * @param camera The camera to use for rendering
  115421. * @param size This parameter can be set to a single number or to an object with the
  115422. * following (optional) properties: precision, width, height. If a single number is passed,
  115423. * it will be used for both width and height. If an object is passed, the screenshot size
  115424. * will be derived from the parameters. The precision property is a multiplier allowing
  115425. * rendering at a higher or lower resolution
  115426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115427. * Check your browser for supported MIME types
  115428. * @param samples Texture samples (default: 1)
  115429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115430. * @param fileName A name for for the downloaded file.
  115431. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115432. * to the src parameter of an <img> to display it
  115433. */
  115434. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115435. /**
  115436. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115437. * Be aware Math.random() could cause collisions, but:
  115438. * "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"
  115439. * @returns a pseudo random id
  115440. */
  115441. static RandomId(): string;
  115442. /**
  115443. * Test if the given uri is a base64 string
  115444. * @param uri The uri to test
  115445. * @return True if the uri is a base64 string or false otherwise
  115446. */
  115447. static IsBase64(uri: string): boolean;
  115448. /**
  115449. * Decode the given base64 uri.
  115450. * @param uri The uri to decode
  115451. * @return The decoded base64 data.
  115452. */
  115453. static DecodeBase64(uri: string): ArrayBuffer;
  115454. /**
  115455. * Gets the absolute url.
  115456. * @param url the input url
  115457. * @return the absolute url
  115458. */
  115459. static GetAbsoluteUrl(url: string): string;
  115460. /**
  115461. * No log
  115462. */
  115463. static readonly NoneLogLevel: number;
  115464. /**
  115465. * Only message logs
  115466. */
  115467. static readonly MessageLogLevel: number;
  115468. /**
  115469. * Only warning logs
  115470. */
  115471. static readonly WarningLogLevel: number;
  115472. /**
  115473. * Only error logs
  115474. */
  115475. static readonly ErrorLogLevel: number;
  115476. /**
  115477. * All logs
  115478. */
  115479. static readonly AllLogLevel: number;
  115480. /**
  115481. * Gets a value indicating the number of loading errors
  115482. * @ignorenaming
  115483. */
  115484. static get errorsCount(): number;
  115485. /**
  115486. * Callback called when a new log is added
  115487. */
  115488. static OnNewCacheEntry: (entry: string) => void;
  115489. /**
  115490. * Log a message to the console
  115491. * @param message defines the message to log
  115492. */
  115493. static Log(message: string): void;
  115494. /**
  115495. * Write a warning message to the console
  115496. * @param message defines the message to log
  115497. */
  115498. static Warn(message: string): void;
  115499. /**
  115500. * Write an error message to the console
  115501. * @param message defines the message to log
  115502. */
  115503. static Error(message: string): void;
  115504. /**
  115505. * Gets current log cache (list of logs)
  115506. */
  115507. static get LogCache(): string;
  115508. /**
  115509. * Clears the log cache
  115510. */
  115511. static ClearLogCache(): void;
  115512. /**
  115513. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115514. */
  115515. static set LogLevels(level: number);
  115516. /**
  115517. * Checks if the window object exists
  115518. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115519. */
  115520. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115521. /**
  115522. * No performance log
  115523. */
  115524. static readonly PerformanceNoneLogLevel: number;
  115525. /**
  115526. * Use user marks to log performance
  115527. */
  115528. static readonly PerformanceUserMarkLogLevel: number;
  115529. /**
  115530. * Log performance to the console
  115531. */
  115532. static readonly PerformanceConsoleLogLevel: number;
  115533. private static _performance;
  115534. /**
  115535. * Sets the current performance log level
  115536. */
  115537. static set PerformanceLogLevel(level: number);
  115538. private static _StartPerformanceCounterDisabled;
  115539. private static _EndPerformanceCounterDisabled;
  115540. private static _StartUserMark;
  115541. private static _EndUserMark;
  115542. private static _StartPerformanceConsole;
  115543. private static _EndPerformanceConsole;
  115544. /**
  115545. * Starts a performance counter
  115546. */
  115547. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115548. /**
  115549. * Ends a specific performance coutner
  115550. */
  115551. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115552. /**
  115553. * Gets either window.performance.now() if supported or Date.now() else
  115554. */
  115555. static get Now(): number;
  115556. /**
  115557. * This method will return the name of the class used to create the instance of the given object.
  115558. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115559. * @param object the object to get the class name from
  115560. * @param isType defines if the object is actually a type
  115561. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115562. */
  115563. static GetClassName(object: any, isType?: boolean): string;
  115564. /**
  115565. * Gets the first element of an array satisfying a given predicate
  115566. * @param array defines the array to browse
  115567. * @param predicate defines the predicate to use
  115568. * @returns null if not found or the element
  115569. */
  115570. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115571. /**
  115572. * This method will return the name of the full name of the class, including its owning module (if any).
  115573. * 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).
  115574. * @param object the object to get the class name from
  115575. * @param isType defines if the object is actually a type
  115576. * @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.
  115577. * @ignorenaming
  115578. */
  115579. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115580. /**
  115581. * Returns a promise that resolves after the given amount of time.
  115582. * @param delay Number of milliseconds to delay
  115583. * @returns Promise that resolves after the given amount of time
  115584. */
  115585. static DelayAsync(delay: number): Promise<void>;
  115586. /**
  115587. * Utility function to detect if the current user agent is Safari
  115588. * @returns whether or not the current user agent is safari
  115589. */
  115590. static IsSafari(): boolean;
  115591. }
  115592. /**
  115593. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115594. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115595. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115596. * @param name The name of the class, case should be preserved
  115597. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115598. */
  115599. export function className(name: string, module?: string): (target: Object) => void;
  115600. /**
  115601. * An implementation of a loop for asynchronous functions.
  115602. */
  115603. export class AsyncLoop {
  115604. /**
  115605. * Defines the number of iterations for the loop
  115606. */
  115607. iterations: number;
  115608. /**
  115609. * Defines the current index of the loop.
  115610. */
  115611. index: number;
  115612. private _done;
  115613. private _fn;
  115614. private _successCallback;
  115615. /**
  115616. * Constructor.
  115617. * @param iterations the number of iterations.
  115618. * @param func the function to run each iteration
  115619. * @param successCallback the callback that will be called upon succesful execution
  115620. * @param offset starting offset.
  115621. */
  115622. constructor(
  115623. /**
  115624. * Defines the number of iterations for the loop
  115625. */
  115626. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115627. /**
  115628. * Execute the next iteration. Must be called after the last iteration was finished.
  115629. */
  115630. executeNext(): void;
  115631. /**
  115632. * Break the loop and run the success callback.
  115633. */
  115634. breakLoop(): void;
  115635. /**
  115636. * Create and run an async loop.
  115637. * @param iterations the number of iterations.
  115638. * @param fn the function to run each iteration
  115639. * @param successCallback the callback that will be called upon succesful execution
  115640. * @param offset starting offset.
  115641. * @returns the created async loop object
  115642. */
  115643. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115644. /**
  115645. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115646. * @param iterations total number of iterations
  115647. * @param syncedIterations number of synchronous iterations in each async iteration.
  115648. * @param fn the function to call each iteration.
  115649. * @param callback a success call back that will be called when iterating stops.
  115650. * @param breakFunction a break condition (optional)
  115651. * @param timeout timeout settings for the setTimeout function. default - 0.
  115652. * @returns the created async loop object
  115653. */
  115654. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115655. }
  115656. }
  115657. declare module BABYLON {
  115658. /**
  115659. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115660. * The underlying implementation relies on an associative array to ensure the best performances.
  115661. * The value can be anything including 'null' but except 'undefined'
  115662. */
  115663. export class StringDictionary<T> {
  115664. /**
  115665. * This will clear this dictionary and copy the content from the 'source' one.
  115666. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115667. * @param source the dictionary to take the content from and copy to this dictionary
  115668. */
  115669. copyFrom(source: StringDictionary<T>): void;
  115670. /**
  115671. * Get a value based from its key
  115672. * @param key the given key to get the matching value from
  115673. * @return the value if found, otherwise undefined is returned
  115674. */
  115675. get(key: string): T | undefined;
  115676. /**
  115677. * Get a value from its key or add it if it doesn't exist.
  115678. * This method will ensure you that a given key/data will be present in the dictionary.
  115679. * @param key the given key to get the matching value from
  115680. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115681. * The factory will only be invoked if there's no data for the given key.
  115682. * @return the value corresponding to the key.
  115683. */
  115684. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115685. /**
  115686. * Get a value from its key if present in the dictionary otherwise add it
  115687. * @param key the key to get the value from
  115688. * @param val if there's no such key/value pair in the dictionary add it with this value
  115689. * @return the value corresponding to the key
  115690. */
  115691. getOrAdd(key: string, val: T): T;
  115692. /**
  115693. * Check if there's a given key in the dictionary
  115694. * @param key the key to check for
  115695. * @return true if the key is present, false otherwise
  115696. */
  115697. contains(key: string): boolean;
  115698. /**
  115699. * Add a new key and its corresponding value
  115700. * @param key the key to add
  115701. * @param value the value corresponding to the key
  115702. * @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
  115703. */
  115704. add(key: string, value: T): boolean;
  115705. /**
  115706. * Update a specific value associated to a key
  115707. * @param key defines the key to use
  115708. * @param value defines the value to store
  115709. * @returns true if the value was updated (or false if the key was not found)
  115710. */
  115711. set(key: string, value: T): boolean;
  115712. /**
  115713. * Get the element of the given key and remove it from the dictionary
  115714. * @param key defines the key to search
  115715. * @returns the value associated with the key or null if not found
  115716. */
  115717. getAndRemove(key: string): Nullable<T>;
  115718. /**
  115719. * Remove a key/value from the dictionary.
  115720. * @param key the key to remove
  115721. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115722. */
  115723. remove(key: string): boolean;
  115724. /**
  115725. * Clear the whole content of the dictionary
  115726. */
  115727. clear(): void;
  115728. /**
  115729. * Gets the current count
  115730. */
  115731. get count(): number;
  115732. /**
  115733. * Execute a callback on each key/val of the dictionary.
  115734. * Note that you can remove any element in this dictionary in the callback implementation
  115735. * @param callback the callback to execute on a given key/value pair
  115736. */
  115737. forEach(callback: (key: string, val: T) => void): void;
  115738. /**
  115739. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115740. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115741. * Note that you can remove any element in this dictionary in the callback implementation
  115742. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115743. * @returns the first item
  115744. */
  115745. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115746. private _count;
  115747. private _data;
  115748. }
  115749. }
  115750. declare module BABYLON {
  115751. /** @hidden */
  115752. export interface ICollisionCoordinator {
  115753. createCollider(): Collider;
  115754. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115755. init(scene: Scene): void;
  115756. }
  115757. /** @hidden */
  115758. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115759. private _scene;
  115760. private _scaledPosition;
  115761. private _scaledVelocity;
  115762. private _finalPosition;
  115763. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115764. createCollider(): Collider;
  115765. init(scene: Scene): void;
  115766. private _collideWithWorld;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * Class used to manage all inputs for the scene.
  115772. */
  115773. export class InputManager {
  115774. /** The distance in pixel that you have to move to prevent some events */
  115775. static DragMovementThreshold: number;
  115776. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115777. static LongPressDelay: number;
  115778. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115779. static DoubleClickDelay: number;
  115780. /** If you need to check double click without raising a single click at first click, enable this flag */
  115781. static ExclusiveDoubleClickMode: boolean;
  115782. private _wheelEventName;
  115783. private _onPointerMove;
  115784. private _onPointerDown;
  115785. private _onPointerUp;
  115786. private _initClickEvent;
  115787. private _initActionManager;
  115788. private _delayedSimpleClick;
  115789. private _delayedSimpleClickTimeout;
  115790. private _previousDelayedSimpleClickTimeout;
  115791. private _meshPickProceed;
  115792. private _previousButtonPressed;
  115793. private _currentPickResult;
  115794. private _previousPickResult;
  115795. private _totalPointersPressed;
  115796. private _doubleClickOccured;
  115797. private _pointerOverMesh;
  115798. private _pickedDownMesh;
  115799. private _pickedUpMesh;
  115800. private _pointerX;
  115801. private _pointerY;
  115802. private _unTranslatedPointerX;
  115803. private _unTranslatedPointerY;
  115804. private _startingPointerPosition;
  115805. private _previousStartingPointerPosition;
  115806. private _startingPointerTime;
  115807. private _previousStartingPointerTime;
  115808. private _pointerCaptures;
  115809. private _onKeyDown;
  115810. private _onKeyUp;
  115811. private _onCanvasFocusObserver;
  115812. private _onCanvasBlurObserver;
  115813. private _scene;
  115814. /**
  115815. * Creates a new InputManager
  115816. * @param scene defines the hosting scene
  115817. */
  115818. constructor(scene: Scene);
  115819. /**
  115820. * Gets the mesh that is currently under the pointer
  115821. */
  115822. get meshUnderPointer(): Nullable<AbstractMesh>;
  115823. /**
  115824. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115825. */
  115826. get unTranslatedPointer(): Vector2;
  115827. /**
  115828. * Gets or sets the current on-screen X position of the pointer
  115829. */
  115830. get pointerX(): number;
  115831. set pointerX(value: number);
  115832. /**
  115833. * Gets or sets the current on-screen Y position of the pointer
  115834. */
  115835. get pointerY(): number;
  115836. set pointerY(value: number);
  115837. private _updatePointerPosition;
  115838. private _processPointerMove;
  115839. private _setRayOnPointerInfo;
  115840. private _checkPrePointerObservable;
  115841. /**
  115842. * Use this method to simulate a pointer move on a mesh
  115843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115846. */
  115847. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115848. /**
  115849. * Use this method to simulate a pointer down on a mesh
  115850. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115851. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115852. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115853. */
  115854. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115855. private _processPointerDown;
  115856. /** @hidden */
  115857. _isPointerSwiping(): boolean;
  115858. /**
  115859. * Use this method to simulate a pointer up on a mesh
  115860. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115861. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115862. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115863. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115864. */
  115865. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115866. private _processPointerUp;
  115867. /**
  115868. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115869. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115870. * @returns true if the pointer was captured
  115871. */
  115872. isPointerCaptured(pointerId?: number): boolean;
  115873. /**
  115874. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115875. * @param attachUp defines if you want to attach events to pointerup
  115876. * @param attachDown defines if you want to attach events to pointerdown
  115877. * @param attachMove defines if you want to attach events to pointermove
  115878. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115879. */
  115880. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115881. /**
  115882. * Detaches all event handlers
  115883. */
  115884. detachControl(): void;
  115885. /**
  115886. * Force the value of meshUnderPointer
  115887. * @param mesh defines the mesh to use
  115888. */
  115889. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115890. /**
  115891. * Gets the mesh under the pointer
  115892. * @returns a Mesh or null if no mesh is under the pointer
  115893. */
  115894. getPointerOverMesh(): Nullable<AbstractMesh>;
  115895. }
  115896. }
  115897. declare module BABYLON {
  115898. /**
  115899. * This class defines the direct association between an animation and a target
  115900. */
  115901. export class TargetedAnimation {
  115902. /**
  115903. * Animation to perform
  115904. */
  115905. animation: Animation;
  115906. /**
  115907. * Target to animate
  115908. */
  115909. target: any;
  115910. /**
  115911. * Returns the string "TargetedAnimation"
  115912. * @returns "TargetedAnimation"
  115913. */
  115914. getClassName(): string;
  115915. /**
  115916. * Serialize the object
  115917. * @returns the JSON object representing the current entity
  115918. */
  115919. serialize(): any;
  115920. }
  115921. /**
  115922. * Use this class to create coordinated animations on multiple targets
  115923. */
  115924. export class AnimationGroup implements IDisposable {
  115925. /** The name of the animation group */
  115926. name: string;
  115927. private _scene;
  115928. private _targetedAnimations;
  115929. private _animatables;
  115930. private _from;
  115931. private _to;
  115932. private _isStarted;
  115933. private _isPaused;
  115934. private _speedRatio;
  115935. private _loopAnimation;
  115936. private _isAdditive;
  115937. /**
  115938. * Gets or sets the unique id of the node
  115939. */
  115940. uniqueId: number;
  115941. /**
  115942. * This observable will notify when one animation have ended
  115943. */
  115944. onAnimationEndObservable: Observable<TargetedAnimation>;
  115945. /**
  115946. * Observer raised when one animation loops
  115947. */
  115948. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115949. /**
  115950. * Observer raised when all animations have looped
  115951. */
  115952. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115953. /**
  115954. * This observable will notify when all animations have ended.
  115955. */
  115956. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115957. /**
  115958. * This observable will notify when all animations have paused.
  115959. */
  115960. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115961. /**
  115962. * This observable will notify when all animations are playing.
  115963. */
  115964. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115965. /**
  115966. * Gets the first frame
  115967. */
  115968. get from(): number;
  115969. /**
  115970. * Gets the last frame
  115971. */
  115972. get to(): number;
  115973. /**
  115974. * Define if the animations are started
  115975. */
  115976. get isStarted(): boolean;
  115977. /**
  115978. * Gets a value indicating that the current group is playing
  115979. */
  115980. get isPlaying(): boolean;
  115981. /**
  115982. * Gets or sets the speed ratio to use for all animations
  115983. */
  115984. get speedRatio(): number;
  115985. /**
  115986. * Gets or sets the speed ratio to use for all animations
  115987. */
  115988. set speedRatio(value: number);
  115989. /**
  115990. * Gets or sets if all animations should loop or not
  115991. */
  115992. get loopAnimation(): boolean;
  115993. set loopAnimation(value: boolean);
  115994. /**
  115995. * Gets or sets if all animations should be evaluated additively
  115996. */
  115997. get isAdditive(): boolean;
  115998. set isAdditive(value: boolean);
  115999. /**
  116000. * Gets the targeted animations for this animation group
  116001. */
  116002. get targetedAnimations(): Array<TargetedAnimation>;
  116003. /**
  116004. * returning the list of animatables controlled by this animation group.
  116005. */
  116006. get animatables(): Array<Animatable>;
  116007. /**
  116008. * Gets the list of target animations
  116009. */
  116010. get children(): TargetedAnimation[];
  116011. /**
  116012. * Instantiates a new Animation Group.
  116013. * This helps managing several animations at once.
  116014. * @see http://doc.babylonjs.com/how_to/group
  116015. * @param name Defines the name of the group
  116016. * @param scene Defines the scene the group belongs to
  116017. */
  116018. constructor(
  116019. /** The name of the animation group */
  116020. name: string, scene?: Nullable<Scene>);
  116021. /**
  116022. * Add an animation (with its target) in the group
  116023. * @param animation defines the animation we want to add
  116024. * @param target defines the target of the animation
  116025. * @returns the TargetedAnimation object
  116026. */
  116027. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116028. /**
  116029. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116030. * It can add constant keys at begin or end
  116031. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116032. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116033. * @returns the animation group
  116034. */
  116035. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116036. private _animationLoopCount;
  116037. private _animationLoopFlags;
  116038. private _processLoop;
  116039. /**
  116040. * Start all animations on given targets
  116041. * @param loop defines if animations must loop
  116042. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116043. * @param from defines the from key (optional)
  116044. * @param to defines the to key (optional)
  116045. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116046. * @returns the current animation group
  116047. */
  116048. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116049. /**
  116050. * Pause all animations
  116051. * @returns the animation group
  116052. */
  116053. pause(): AnimationGroup;
  116054. /**
  116055. * Play all animations to initial state
  116056. * This function will start() the animations if they were not started or will restart() them if they were paused
  116057. * @param loop defines if animations must loop
  116058. * @returns the animation group
  116059. */
  116060. play(loop?: boolean): AnimationGroup;
  116061. /**
  116062. * Reset all animations to initial state
  116063. * @returns the animation group
  116064. */
  116065. reset(): AnimationGroup;
  116066. /**
  116067. * Restart animations from key 0
  116068. * @returns the animation group
  116069. */
  116070. restart(): AnimationGroup;
  116071. /**
  116072. * Stop all animations
  116073. * @returns the animation group
  116074. */
  116075. stop(): AnimationGroup;
  116076. /**
  116077. * Set animation weight for all animatables
  116078. * @param weight defines the weight to use
  116079. * @return the animationGroup
  116080. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116081. */
  116082. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116083. /**
  116084. * Synchronize and normalize all animatables with a source animatable
  116085. * @param root defines the root animatable to synchronize with
  116086. * @return the animationGroup
  116087. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116088. */
  116089. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116090. /**
  116091. * Goes to a specific frame in this animation group
  116092. * @param frame the frame number to go to
  116093. * @return the animationGroup
  116094. */
  116095. goToFrame(frame: number): AnimationGroup;
  116096. /**
  116097. * Dispose all associated resources
  116098. */
  116099. dispose(): void;
  116100. private _checkAnimationGroupEnded;
  116101. /**
  116102. * Clone the current animation group and returns a copy
  116103. * @param newName defines the name of the new group
  116104. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116105. * @returns the new aniamtion group
  116106. */
  116107. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116108. /**
  116109. * Serializes the animationGroup to an object
  116110. * @returns Serialized object
  116111. */
  116112. serialize(): any;
  116113. /**
  116114. * Returns a new AnimationGroup object parsed from the source provided.
  116115. * @param parsedAnimationGroup defines the source
  116116. * @param scene defines the scene that will receive the animationGroup
  116117. * @returns a new AnimationGroup
  116118. */
  116119. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116120. /**
  116121. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116122. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116123. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116124. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116125. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116126. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116127. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116128. */
  116129. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116130. /**
  116131. * Returns the string "AnimationGroup"
  116132. * @returns "AnimationGroup"
  116133. */
  116134. getClassName(): string;
  116135. /**
  116136. * Creates a detailled string about the object
  116137. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116138. * @returns a string representing the object
  116139. */
  116140. toString(fullDetails?: boolean): string;
  116141. }
  116142. }
  116143. declare module BABYLON {
  116144. /**
  116145. * Define an interface for all classes that will hold resources
  116146. */
  116147. export interface IDisposable {
  116148. /**
  116149. * Releases all held resources
  116150. */
  116151. dispose(): void;
  116152. }
  116153. /** Interface defining initialization parameters for Scene class */
  116154. export interface SceneOptions {
  116155. /**
  116156. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116157. * It will improve performance when the number of geometries becomes important.
  116158. */
  116159. useGeometryUniqueIdsMap?: boolean;
  116160. /**
  116161. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116162. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116163. */
  116164. useMaterialMeshMap?: boolean;
  116165. /**
  116166. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116167. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116168. */
  116169. useClonedMeshMap?: boolean;
  116170. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116171. virtual?: boolean;
  116172. }
  116173. /**
  116174. * Represents a scene to be rendered by the engine.
  116175. * @see http://doc.babylonjs.com/features/scene
  116176. */
  116177. export class Scene extends AbstractScene implements IAnimatable {
  116178. /** The fog is deactivated */
  116179. static readonly FOGMODE_NONE: number;
  116180. /** The fog density is following an exponential function */
  116181. static readonly FOGMODE_EXP: number;
  116182. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116183. static readonly FOGMODE_EXP2: number;
  116184. /** The fog density is following a linear function. */
  116185. static readonly FOGMODE_LINEAR: number;
  116186. /**
  116187. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116189. */
  116190. static MinDeltaTime: number;
  116191. /**
  116192. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116194. */
  116195. static MaxDeltaTime: number;
  116196. /**
  116197. * Factory used to create the default material.
  116198. * @param name The name of the material to create
  116199. * @param scene The scene to create the material for
  116200. * @returns The default material
  116201. */
  116202. static DefaultMaterialFactory(scene: Scene): Material;
  116203. /**
  116204. * Factory used to create the a collision coordinator.
  116205. * @returns The collision coordinator
  116206. */
  116207. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116208. /** @hidden */
  116209. _inputManager: InputManager;
  116210. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116211. cameraToUseForPointers: Nullable<Camera>;
  116212. /** @hidden */
  116213. readonly _isScene: boolean;
  116214. /** @hidden */
  116215. _blockEntityCollection: boolean;
  116216. /**
  116217. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116218. */
  116219. autoClear: boolean;
  116220. /**
  116221. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116222. */
  116223. autoClearDepthAndStencil: boolean;
  116224. /**
  116225. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116226. */
  116227. clearColor: Color4;
  116228. /**
  116229. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116230. */
  116231. ambientColor: Color3;
  116232. /**
  116233. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116234. * It should only be one of the following (if not the default embedded one):
  116235. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116236. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116237. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116238. * The material properties need to be setup according to the type of texture in use.
  116239. */
  116240. environmentBRDFTexture: BaseTexture;
  116241. /** @hidden */
  116242. protected _environmentTexture: Nullable<BaseTexture>;
  116243. /**
  116244. * Texture used in all pbr material as the reflection texture.
  116245. * As in the majority of the scene they are the same (exception for multi room and so on),
  116246. * this is easier to reference from here than from all the materials.
  116247. */
  116248. get environmentTexture(): Nullable<BaseTexture>;
  116249. /**
  116250. * Texture used in all pbr material as the reflection texture.
  116251. * As in the majority of the scene they are the same (exception for multi room and so on),
  116252. * this is easier to set here than in all the materials.
  116253. */
  116254. set environmentTexture(value: Nullable<BaseTexture>);
  116255. /** @hidden */
  116256. protected _environmentIntensity: number;
  116257. /**
  116258. * Intensity of the environment in all pbr material.
  116259. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116260. * As in the majority of the scene they are the same (exception for multi room and so on),
  116261. * this is easier to reference from here than from all the materials.
  116262. */
  116263. get environmentIntensity(): number;
  116264. /**
  116265. * Intensity of the environment in all pbr material.
  116266. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116267. * As in the majority of the scene they are the same (exception for multi room and so on),
  116268. * this is easier to set here than in all the materials.
  116269. */
  116270. set environmentIntensity(value: number);
  116271. /** @hidden */
  116272. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116273. /**
  116274. * Default image processing configuration used either in the rendering
  116275. * Forward main pass or through the imageProcessingPostProcess if present.
  116276. * As in the majority of the scene they are the same (exception for multi camera),
  116277. * this is easier to reference from here than from all the materials and post process.
  116278. *
  116279. * No setter as we it is a shared configuration, you can set the values instead.
  116280. */
  116281. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116282. private _forceWireframe;
  116283. /**
  116284. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116285. */
  116286. set forceWireframe(value: boolean);
  116287. get forceWireframe(): boolean;
  116288. private _skipFrustumClipping;
  116289. /**
  116290. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116291. */
  116292. set skipFrustumClipping(value: boolean);
  116293. get skipFrustumClipping(): boolean;
  116294. private _forcePointsCloud;
  116295. /**
  116296. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116297. */
  116298. set forcePointsCloud(value: boolean);
  116299. get forcePointsCloud(): boolean;
  116300. /**
  116301. * Gets or sets the active clipplane 1
  116302. */
  116303. clipPlane: Nullable<Plane>;
  116304. /**
  116305. * Gets or sets the active clipplane 2
  116306. */
  116307. clipPlane2: Nullable<Plane>;
  116308. /**
  116309. * Gets or sets the active clipplane 3
  116310. */
  116311. clipPlane3: Nullable<Plane>;
  116312. /**
  116313. * Gets or sets the active clipplane 4
  116314. */
  116315. clipPlane4: Nullable<Plane>;
  116316. /**
  116317. * Gets or sets the active clipplane 5
  116318. */
  116319. clipPlane5: Nullable<Plane>;
  116320. /**
  116321. * Gets or sets the active clipplane 6
  116322. */
  116323. clipPlane6: Nullable<Plane>;
  116324. /**
  116325. * Gets or sets a boolean indicating if animations are enabled
  116326. */
  116327. animationsEnabled: boolean;
  116328. private _animationPropertiesOverride;
  116329. /**
  116330. * Gets or sets the animation properties override
  116331. */
  116332. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116333. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116334. /**
  116335. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116336. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116337. */
  116338. useConstantAnimationDeltaTime: boolean;
  116339. /**
  116340. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116341. * Please note that it requires to run a ray cast through the scene on every frame
  116342. */
  116343. constantlyUpdateMeshUnderPointer: boolean;
  116344. /**
  116345. * Defines the HTML cursor to use when hovering over interactive elements
  116346. */
  116347. hoverCursor: string;
  116348. /**
  116349. * Defines the HTML default cursor to use (empty by default)
  116350. */
  116351. defaultCursor: string;
  116352. /**
  116353. * Defines whether cursors are handled by the scene.
  116354. */
  116355. doNotHandleCursors: boolean;
  116356. /**
  116357. * This is used to call preventDefault() on pointer down
  116358. * in order to block unwanted artifacts like system double clicks
  116359. */
  116360. preventDefaultOnPointerDown: boolean;
  116361. /**
  116362. * This is used to call preventDefault() on pointer up
  116363. * in order to block unwanted artifacts like system double clicks
  116364. */
  116365. preventDefaultOnPointerUp: boolean;
  116366. /**
  116367. * Gets or sets user defined metadata
  116368. */
  116369. metadata: any;
  116370. /**
  116371. * For internal use only. Please do not use.
  116372. */
  116373. reservedDataStore: any;
  116374. /**
  116375. * Gets the name of the plugin used to load this scene (null by default)
  116376. */
  116377. loadingPluginName: string;
  116378. /**
  116379. * Use this array to add regular expressions used to disable offline support for specific urls
  116380. */
  116381. disableOfflineSupportExceptionRules: RegExp[];
  116382. /**
  116383. * An event triggered when the scene is disposed.
  116384. */
  116385. onDisposeObservable: Observable<Scene>;
  116386. private _onDisposeObserver;
  116387. /** Sets a function to be executed when this scene is disposed. */
  116388. set onDispose(callback: () => void);
  116389. /**
  116390. * An event triggered before rendering the scene (right after animations and physics)
  116391. */
  116392. onBeforeRenderObservable: Observable<Scene>;
  116393. private _onBeforeRenderObserver;
  116394. /** Sets a function to be executed before rendering this scene */
  116395. set beforeRender(callback: Nullable<() => void>);
  116396. /**
  116397. * An event triggered after rendering the scene
  116398. */
  116399. onAfterRenderObservable: Observable<Scene>;
  116400. /**
  116401. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116402. */
  116403. onAfterRenderCameraObservable: Observable<Camera>;
  116404. private _onAfterRenderObserver;
  116405. /** Sets a function to be executed after rendering this scene */
  116406. set afterRender(callback: Nullable<() => void>);
  116407. /**
  116408. * An event triggered before animating the scene
  116409. */
  116410. onBeforeAnimationsObservable: Observable<Scene>;
  116411. /**
  116412. * An event triggered after animations processing
  116413. */
  116414. onAfterAnimationsObservable: Observable<Scene>;
  116415. /**
  116416. * An event triggered before draw calls are ready to be sent
  116417. */
  116418. onBeforeDrawPhaseObservable: Observable<Scene>;
  116419. /**
  116420. * An event triggered after draw calls have been sent
  116421. */
  116422. onAfterDrawPhaseObservable: Observable<Scene>;
  116423. /**
  116424. * An event triggered when the scene is ready
  116425. */
  116426. onReadyObservable: Observable<Scene>;
  116427. /**
  116428. * An event triggered before rendering a camera
  116429. */
  116430. onBeforeCameraRenderObservable: Observable<Camera>;
  116431. private _onBeforeCameraRenderObserver;
  116432. /** Sets a function to be executed before rendering a camera*/
  116433. set beforeCameraRender(callback: () => void);
  116434. /**
  116435. * An event triggered after rendering a camera
  116436. */
  116437. onAfterCameraRenderObservable: Observable<Camera>;
  116438. private _onAfterCameraRenderObserver;
  116439. /** Sets a function to be executed after rendering a camera*/
  116440. set afterCameraRender(callback: () => void);
  116441. /**
  116442. * An event triggered when active meshes evaluation is about to start
  116443. */
  116444. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116445. /**
  116446. * An event triggered when active meshes evaluation is done
  116447. */
  116448. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116449. /**
  116450. * An event triggered when particles rendering is about to start
  116451. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116452. */
  116453. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116454. /**
  116455. * An event triggered when particles rendering is done
  116456. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116457. */
  116458. onAfterParticlesRenderingObservable: Observable<Scene>;
  116459. /**
  116460. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116461. */
  116462. onDataLoadedObservable: Observable<Scene>;
  116463. /**
  116464. * An event triggered when a camera is created
  116465. */
  116466. onNewCameraAddedObservable: Observable<Camera>;
  116467. /**
  116468. * An event triggered when a camera is removed
  116469. */
  116470. onCameraRemovedObservable: Observable<Camera>;
  116471. /**
  116472. * An event triggered when a light is created
  116473. */
  116474. onNewLightAddedObservable: Observable<Light>;
  116475. /**
  116476. * An event triggered when a light is removed
  116477. */
  116478. onLightRemovedObservable: Observable<Light>;
  116479. /**
  116480. * An event triggered when a geometry is created
  116481. */
  116482. onNewGeometryAddedObservable: Observable<Geometry>;
  116483. /**
  116484. * An event triggered when a geometry is removed
  116485. */
  116486. onGeometryRemovedObservable: Observable<Geometry>;
  116487. /**
  116488. * An event triggered when a transform node is created
  116489. */
  116490. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116491. /**
  116492. * An event triggered when a transform node is removed
  116493. */
  116494. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116495. /**
  116496. * An event triggered when a mesh is created
  116497. */
  116498. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116499. /**
  116500. * An event triggered when a mesh is removed
  116501. */
  116502. onMeshRemovedObservable: Observable<AbstractMesh>;
  116503. /**
  116504. * An event triggered when a skeleton is created
  116505. */
  116506. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116507. /**
  116508. * An event triggered when a skeleton is removed
  116509. */
  116510. onSkeletonRemovedObservable: Observable<Skeleton>;
  116511. /**
  116512. * An event triggered when a material is created
  116513. */
  116514. onNewMaterialAddedObservable: Observable<Material>;
  116515. /**
  116516. * An event triggered when a material is removed
  116517. */
  116518. onMaterialRemovedObservable: Observable<Material>;
  116519. /**
  116520. * An event triggered when a texture is created
  116521. */
  116522. onNewTextureAddedObservable: Observable<BaseTexture>;
  116523. /**
  116524. * An event triggered when a texture is removed
  116525. */
  116526. onTextureRemovedObservable: Observable<BaseTexture>;
  116527. /**
  116528. * An event triggered when render targets are about to be rendered
  116529. * Can happen multiple times per frame.
  116530. */
  116531. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116532. /**
  116533. * An event triggered when render targets were rendered.
  116534. * Can happen multiple times per frame.
  116535. */
  116536. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116537. /**
  116538. * An event triggered before calculating deterministic simulation step
  116539. */
  116540. onBeforeStepObservable: Observable<Scene>;
  116541. /**
  116542. * An event triggered after calculating deterministic simulation step
  116543. */
  116544. onAfterStepObservable: Observable<Scene>;
  116545. /**
  116546. * An event triggered when the activeCamera property is updated
  116547. */
  116548. onActiveCameraChanged: Observable<Scene>;
  116549. /**
  116550. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116551. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116552. * 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)
  116553. */
  116554. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116555. /**
  116556. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116557. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116558. * 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)
  116559. */
  116560. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116561. /**
  116562. * This Observable will when a mesh has been imported into the scene.
  116563. */
  116564. onMeshImportedObservable: Observable<AbstractMesh>;
  116565. /**
  116566. * This Observable will when an animation file has been imported into the scene.
  116567. */
  116568. onAnimationFileImportedObservable: Observable<Scene>;
  116569. /**
  116570. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116571. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116572. */
  116573. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116574. /** @hidden */
  116575. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116576. /**
  116577. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116578. */
  116579. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116580. /**
  116581. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116582. */
  116583. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116584. /**
  116585. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116586. */
  116587. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116588. /** Callback called when a pointer move is detected */
  116589. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116590. /** Callback called when a pointer down is detected */
  116591. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116592. /** Callback called when a pointer up is detected */
  116593. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116594. /** Callback called when a pointer pick is detected */
  116595. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116596. /**
  116597. * 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).
  116598. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116599. */
  116600. onPrePointerObservable: Observable<PointerInfoPre>;
  116601. /**
  116602. * Observable event triggered each time an input event is received from the rendering canvas
  116603. */
  116604. onPointerObservable: Observable<PointerInfo>;
  116605. /**
  116606. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116607. */
  116608. get unTranslatedPointer(): Vector2;
  116609. /**
  116610. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116611. */
  116612. static get DragMovementThreshold(): number;
  116613. static set DragMovementThreshold(value: number);
  116614. /**
  116615. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116616. */
  116617. static get LongPressDelay(): number;
  116618. static set LongPressDelay(value: number);
  116619. /**
  116620. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116621. */
  116622. static get DoubleClickDelay(): number;
  116623. static set DoubleClickDelay(value: number);
  116624. /** If you need to check double click without raising a single click at first click, enable this flag */
  116625. static get ExclusiveDoubleClickMode(): boolean;
  116626. static set ExclusiveDoubleClickMode(value: boolean);
  116627. /** @hidden */
  116628. _mirroredCameraPosition: Nullable<Vector3>;
  116629. /**
  116630. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116631. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116632. */
  116633. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116634. /**
  116635. * Observable event triggered each time an keyboard event is received from the hosting window
  116636. */
  116637. onKeyboardObservable: Observable<KeyboardInfo>;
  116638. private _useRightHandedSystem;
  116639. /**
  116640. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116641. */
  116642. set useRightHandedSystem(value: boolean);
  116643. get useRightHandedSystem(): boolean;
  116644. private _timeAccumulator;
  116645. private _currentStepId;
  116646. private _currentInternalStep;
  116647. /**
  116648. * Sets the step Id used by deterministic lock step
  116649. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116650. * @param newStepId defines the step Id
  116651. */
  116652. setStepId(newStepId: number): void;
  116653. /**
  116654. * Gets the step Id used by deterministic lock step
  116655. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116656. * @returns the step Id
  116657. */
  116658. getStepId(): number;
  116659. /**
  116660. * Gets the internal step used by deterministic lock step
  116661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116662. * @returns the internal step
  116663. */
  116664. getInternalStep(): number;
  116665. private _fogEnabled;
  116666. /**
  116667. * Gets or sets a boolean indicating if fog is enabled on this scene
  116668. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116669. * (Default is true)
  116670. */
  116671. set fogEnabled(value: boolean);
  116672. get fogEnabled(): boolean;
  116673. private _fogMode;
  116674. /**
  116675. * Gets or sets the fog mode to use
  116676. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116677. * | mode | value |
  116678. * | --- | --- |
  116679. * | FOGMODE_NONE | 0 |
  116680. * | FOGMODE_EXP | 1 |
  116681. * | FOGMODE_EXP2 | 2 |
  116682. * | FOGMODE_LINEAR | 3 |
  116683. */
  116684. set fogMode(value: number);
  116685. get fogMode(): number;
  116686. /**
  116687. * Gets or sets the fog color to use
  116688. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116689. * (Default is Color3(0.2, 0.2, 0.3))
  116690. */
  116691. fogColor: Color3;
  116692. /**
  116693. * Gets or sets the fog density to use
  116694. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116695. * (Default is 0.1)
  116696. */
  116697. fogDensity: number;
  116698. /**
  116699. * Gets or sets the fog start distance to use
  116700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116701. * (Default is 0)
  116702. */
  116703. fogStart: number;
  116704. /**
  116705. * Gets or sets the fog end distance to use
  116706. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116707. * (Default is 1000)
  116708. */
  116709. fogEnd: number;
  116710. private _shadowsEnabled;
  116711. /**
  116712. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116713. */
  116714. set shadowsEnabled(value: boolean);
  116715. get shadowsEnabled(): boolean;
  116716. private _lightsEnabled;
  116717. /**
  116718. * Gets or sets a boolean indicating if lights are enabled on this scene
  116719. */
  116720. set lightsEnabled(value: boolean);
  116721. get lightsEnabled(): boolean;
  116722. /** All of the active cameras added to this scene. */
  116723. activeCameras: Camera[];
  116724. /** @hidden */
  116725. _activeCamera: Nullable<Camera>;
  116726. /** Gets or sets the current active camera */
  116727. get activeCamera(): Nullable<Camera>;
  116728. set activeCamera(value: Nullable<Camera>);
  116729. private _defaultMaterial;
  116730. /** The default material used on meshes when no material is affected */
  116731. get defaultMaterial(): Material;
  116732. /** The default material used on meshes when no material is affected */
  116733. set defaultMaterial(value: Material);
  116734. private _texturesEnabled;
  116735. /**
  116736. * Gets or sets a boolean indicating if textures are enabled on this scene
  116737. */
  116738. set texturesEnabled(value: boolean);
  116739. get texturesEnabled(): boolean;
  116740. /**
  116741. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116742. */
  116743. physicsEnabled: boolean;
  116744. /**
  116745. * Gets or sets a boolean indicating if particles are enabled on this scene
  116746. */
  116747. particlesEnabled: boolean;
  116748. /**
  116749. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116750. */
  116751. spritesEnabled: boolean;
  116752. private _skeletonsEnabled;
  116753. /**
  116754. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116755. */
  116756. set skeletonsEnabled(value: boolean);
  116757. get skeletonsEnabled(): boolean;
  116758. /**
  116759. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116760. */
  116761. lensFlaresEnabled: boolean;
  116762. /**
  116763. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116765. */
  116766. collisionsEnabled: boolean;
  116767. private _collisionCoordinator;
  116768. /** @hidden */
  116769. get collisionCoordinator(): ICollisionCoordinator;
  116770. /**
  116771. * Defines the gravity applied to this scene (used only for collisions)
  116772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116773. */
  116774. gravity: Vector3;
  116775. /**
  116776. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116777. */
  116778. postProcessesEnabled: boolean;
  116779. /**
  116780. * The list of postprocesses added to the scene
  116781. */
  116782. postProcesses: PostProcess[];
  116783. /**
  116784. * Gets the current postprocess manager
  116785. */
  116786. postProcessManager: PostProcessManager;
  116787. /**
  116788. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116789. */
  116790. renderTargetsEnabled: boolean;
  116791. /**
  116792. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116793. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116794. */
  116795. dumpNextRenderTargets: boolean;
  116796. /**
  116797. * The list of user defined render targets added to the scene
  116798. */
  116799. customRenderTargets: RenderTargetTexture[];
  116800. /**
  116801. * Defines if texture loading must be delayed
  116802. * If true, textures will only be loaded when they need to be rendered
  116803. */
  116804. useDelayedTextureLoading: boolean;
  116805. /**
  116806. * Gets the list of meshes imported to the scene through SceneLoader
  116807. */
  116808. importedMeshesFiles: String[];
  116809. /**
  116810. * Gets or sets a boolean indicating if probes are enabled on this scene
  116811. */
  116812. probesEnabled: boolean;
  116813. /**
  116814. * Gets or sets the current offline provider to use to store scene data
  116815. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116816. */
  116817. offlineProvider: IOfflineProvider;
  116818. /**
  116819. * Gets or sets the action manager associated with the scene
  116820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116821. */
  116822. actionManager: AbstractActionManager;
  116823. private _meshesForIntersections;
  116824. /**
  116825. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116826. */
  116827. proceduralTexturesEnabled: boolean;
  116828. private _engine;
  116829. private _totalVertices;
  116830. /** @hidden */
  116831. _activeIndices: PerfCounter;
  116832. /** @hidden */
  116833. _activeParticles: PerfCounter;
  116834. /** @hidden */
  116835. _activeBones: PerfCounter;
  116836. private _animationRatio;
  116837. /** @hidden */
  116838. _animationTimeLast: number;
  116839. /** @hidden */
  116840. _animationTime: number;
  116841. /**
  116842. * Gets or sets a general scale for animation speed
  116843. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116844. */
  116845. animationTimeScale: number;
  116846. /** @hidden */
  116847. _cachedMaterial: Nullable<Material>;
  116848. /** @hidden */
  116849. _cachedEffect: Nullable<Effect>;
  116850. /** @hidden */
  116851. _cachedVisibility: Nullable<number>;
  116852. private _renderId;
  116853. private _frameId;
  116854. private _executeWhenReadyTimeoutId;
  116855. private _intermediateRendering;
  116856. private _viewUpdateFlag;
  116857. private _projectionUpdateFlag;
  116858. /** @hidden */
  116859. _toBeDisposed: Nullable<IDisposable>[];
  116860. private _activeRequests;
  116861. /** @hidden */
  116862. _pendingData: any[];
  116863. private _isDisposed;
  116864. /**
  116865. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116866. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116867. */
  116868. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116869. private _activeMeshes;
  116870. private _processedMaterials;
  116871. private _renderTargets;
  116872. /** @hidden */
  116873. _activeParticleSystems: SmartArray<IParticleSystem>;
  116874. private _activeSkeletons;
  116875. private _softwareSkinnedMeshes;
  116876. private _renderingManager;
  116877. /** @hidden */
  116878. _activeAnimatables: Animatable[];
  116879. private _transformMatrix;
  116880. private _sceneUbo;
  116881. /** @hidden */
  116882. _viewMatrix: Matrix;
  116883. private _projectionMatrix;
  116884. /** @hidden */
  116885. _forcedViewPosition: Nullable<Vector3>;
  116886. /** @hidden */
  116887. _frustumPlanes: Plane[];
  116888. /**
  116889. * Gets the list of frustum planes (built from the active camera)
  116890. */
  116891. get frustumPlanes(): Plane[];
  116892. /**
  116893. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116894. * This is useful if there are more lights that the maximum simulteanous authorized
  116895. */
  116896. requireLightSorting: boolean;
  116897. /** @hidden */
  116898. readonly useMaterialMeshMap: boolean;
  116899. /** @hidden */
  116900. readonly useClonedMeshMap: boolean;
  116901. private _externalData;
  116902. private _uid;
  116903. /**
  116904. * @hidden
  116905. * Backing store of defined scene components.
  116906. */
  116907. _components: ISceneComponent[];
  116908. /**
  116909. * @hidden
  116910. * Backing store of defined scene components.
  116911. */
  116912. _serializableComponents: ISceneSerializableComponent[];
  116913. /**
  116914. * List of components to register on the next registration step.
  116915. */
  116916. private _transientComponents;
  116917. /**
  116918. * Registers the transient components if needed.
  116919. */
  116920. private _registerTransientComponents;
  116921. /**
  116922. * @hidden
  116923. * Add a component to the scene.
  116924. * Note that the ccomponent could be registered on th next frame if this is called after
  116925. * the register component stage.
  116926. * @param component Defines the component to add to the scene
  116927. */
  116928. _addComponent(component: ISceneComponent): void;
  116929. /**
  116930. * @hidden
  116931. * Gets a component from the scene.
  116932. * @param name defines the name of the component to retrieve
  116933. * @returns the component or null if not present
  116934. */
  116935. _getComponent(name: string): Nullable<ISceneComponent>;
  116936. /**
  116937. * @hidden
  116938. * Defines the actions happening before camera updates.
  116939. */
  116940. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116941. /**
  116942. * @hidden
  116943. * Defines the actions happening before clear the canvas.
  116944. */
  116945. _beforeClearStage: Stage<SimpleStageAction>;
  116946. /**
  116947. * @hidden
  116948. * Defines the actions when collecting render targets for the frame.
  116949. */
  116950. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116951. /**
  116952. * @hidden
  116953. * Defines the actions happening for one camera in the frame.
  116954. */
  116955. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116956. /**
  116957. * @hidden
  116958. * Defines the actions happening during the per mesh ready checks.
  116959. */
  116960. _isReadyForMeshStage: Stage<MeshStageAction>;
  116961. /**
  116962. * @hidden
  116963. * Defines the actions happening before evaluate active mesh checks.
  116964. */
  116965. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116966. /**
  116967. * @hidden
  116968. * Defines the actions happening during the evaluate sub mesh checks.
  116969. */
  116970. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116971. /**
  116972. * @hidden
  116973. * Defines the actions happening during the active mesh stage.
  116974. */
  116975. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116976. /**
  116977. * @hidden
  116978. * Defines the actions happening during the per camera render target step.
  116979. */
  116980. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116981. /**
  116982. * @hidden
  116983. * Defines the actions happening just before the active camera is drawing.
  116984. */
  116985. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116986. /**
  116987. * @hidden
  116988. * Defines the actions happening just before a render target is drawing.
  116989. */
  116990. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116991. /**
  116992. * @hidden
  116993. * Defines the actions happening just before a rendering group is drawing.
  116994. */
  116995. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116996. /**
  116997. * @hidden
  116998. * Defines the actions happening just before a mesh is drawing.
  116999. */
  117000. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117001. /**
  117002. * @hidden
  117003. * Defines the actions happening just after a mesh has been drawn.
  117004. */
  117005. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117006. /**
  117007. * @hidden
  117008. * Defines the actions happening just after a rendering group has been drawn.
  117009. */
  117010. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117011. /**
  117012. * @hidden
  117013. * Defines the actions happening just after the active camera has been drawn.
  117014. */
  117015. _afterCameraDrawStage: Stage<CameraStageAction>;
  117016. /**
  117017. * @hidden
  117018. * Defines the actions happening just after a render target has been drawn.
  117019. */
  117020. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117021. /**
  117022. * @hidden
  117023. * Defines the actions happening just after rendering all cameras and computing intersections.
  117024. */
  117025. _afterRenderStage: Stage<SimpleStageAction>;
  117026. /**
  117027. * @hidden
  117028. * Defines the actions happening when a pointer move event happens.
  117029. */
  117030. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117031. /**
  117032. * @hidden
  117033. * Defines the actions happening when a pointer down event happens.
  117034. */
  117035. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117036. /**
  117037. * @hidden
  117038. * Defines the actions happening when a pointer up event happens.
  117039. */
  117040. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117041. /**
  117042. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117043. */
  117044. private geometriesByUniqueId;
  117045. /**
  117046. * Creates a new Scene
  117047. * @param engine defines the engine to use to render this scene
  117048. * @param options defines the scene options
  117049. */
  117050. constructor(engine: Engine, options?: SceneOptions);
  117051. /**
  117052. * Gets a string idenfifying the name of the class
  117053. * @returns "Scene" string
  117054. */
  117055. getClassName(): string;
  117056. private _defaultMeshCandidates;
  117057. /**
  117058. * @hidden
  117059. */
  117060. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117061. private _defaultSubMeshCandidates;
  117062. /**
  117063. * @hidden
  117064. */
  117065. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117066. /**
  117067. * Sets the default candidate providers for the scene.
  117068. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117069. * and getCollidingSubMeshCandidates to their default function
  117070. */
  117071. setDefaultCandidateProviders(): void;
  117072. /**
  117073. * Gets the mesh that is currently under the pointer
  117074. */
  117075. get meshUnderPointer(): Nullable<AbstractMesh>;
  117076. /**
  117077. * Gets or sets the current on-screen X position of the pointer
  117078. */
  117079. get pointerX(): number;
  117080. set pointerX(value: number);
  117081. /**
  117082. * Gets or sets the current on-screen Y position of the pointer
  117083. */
  117084. get pointerY(): number;
  117085. set pointerY(value: number);
  117086. /**
  117087. * Gets the cached material (ie. the latest rendered one)
  117088. * @returns the cached material
  117089. */
  117090. getCachedMaterial(): Nullable<Material>;
  117091. /**
  117092. * Gets the cached effect (ie. the latest rendered one)
  117093. * @returns the cached effect
  117094. */
  117095. getCachedEffect(): Nullable<Effect>;
  117096. /**
  117097. * Gets the cached visibility state (ie. the latest rendered one)
  117098. * @returns the cached visibility state
  117099. */
  117100. getCachedVisibility(): Nullable<number>;
  117101. /**
  117102. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117103. * @param material defines the current material
  117104. * @param effect defines the current effect
  117105. * @param visibility defines the current visibility state
  117106. * @returns true if one parameter is not cached
  117107. */
  117108. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117109. /**
  117110. * Gets the engine associated with the scene
  117111. * @returns an Engine
  117112. */
  117113. getEngine(): Engine;
  117114. /**
  117115. * Gets the total number of vertices rendered per frame
  117116. * @returns the total number of vertices rendered per frame
  117117. */
  117118. getTotalVertices(): number;
  117119. /**
  117120. * Gets the performance counter for total vertices
  117121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117122. */
  117123. get totalVerticesPerfCounter(): PerfCounter;
  117124. /**
  117125. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117126. * @returns the total number of active indices rendered per frame
  117127. */
  117128. getActiveIndices(): number;
  117129. /**
  117130. * Gets the performance counter for active indices
  117131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117132. */
  117133. get totalActiveIndicesPerfCounter(): PerfCounter;
  117134. /**
  117135. * Gets the total number of active particles rendered per frame
  117136. * @returns the total number of active particles rendered per frame
  117137. */
  117138. getActiveParticles(): number;
  117139. /**
  117140. * Gets the performance counter for active particles
  117141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117142. */
  117143. get activeParticlesPerfCounter(): PerfCounter;
  117144. /**
  117145. * Gets the total number of active bones rendered per frame
  117146. * @returns the total number of active bones rendered per frame
  117147. */
  117148. getActiveBones(): number;
  117149. /**
  117150. * Gets the performance counter for active bones
  117151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117152. */
  117153. get activeBonesPerfCounter(): PerfCounter;
  117154. /**
  117155. * Gets the array of active meshes
  117156. * @returns an array of AbstractMesh
  117157. */
  117158. getActiveMeshes(): SmartArray<AbstractMesh>;
  117159. /**
  117160. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117161. * @returns a number
  117162. */
  117163. getAnimationRatio(): number;
  117164. /**
  117165. * Gets an unique Id for the current render phase
  117166. * @returns a number
  117167. */
  117168. getRenderId(): number;
  117169. /**
  117170. * Gets an unique Id for the current frame
  117171. * @returns a number
  117172. */
  117173. getFrameId(): number;
  117174. /** Call this function if you want to manually increment the render Id*/
  117175. incrementRenderId(): void;
  117176. private _createUbo;
  117177. /**
  117178. * Use this method to simulate a pointer move on a mesh
  117179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117182. * @returns the current scene
  117183. */
  117184. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117185. /**
  117186. * Use this method to simulate a pointer down on a mesh
  117187. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117188. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117189. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117190. * @returns the current scene
  117191. */
  117192. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117193. /**
  117194. * Use this method to simulate a pointer up on a mesh
  117195. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117196. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117197. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117198. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117199. * @returns the current scene
  117200. */
  117201. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117202. /**
  117203. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117204. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117205. * @returns true if the pointer was captured
  117206. */
  117207. isPointerCaptured(pointerId?: number): boolean;
  117208. /**
  117209. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117210. * @param attachUp defines if you want to attach events to pointerup
  117211. * @param attachDown defines if you want to attach events to pointerdown
  117212. * @param attachMove defines if you want to attach events to pointermove
  117213. */
  117214. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117215. /** Detaches all event handlers*/
  117216. detachControl(): void;
  117217. /**
  117218. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117219. * Delay loaded resources are not taking in account
  117220. * @return true if all required resources are ready
  117221. */
  117222. isReady(): boolean;
  117223. /** Resets all cached information relative to material (including effect and visibility) */
  117224. resetCachedMaterial(): void;
  117225. /**
  117226. * Registers a function to be called before every frame render
  117227. * @param func defines the function to register
  117228. */
  117229. registerBeforeRender(func: () => void): void;
  117230. /**
  117231. * Unregisters a function called before every frame render
  117232. * @param func defines the function to unregister
  117233. */
  117234. unregisterBeforeRender(func: () => void): void;
  117235. /**
  117236. * Registers a function to be called after every frame render
  117237. * @param func defines the function to register
  117238. */
  117239. registerAfterRender(func: () => void): void;
  117240. /**
  117241. * Unregisters a function called after every frame render
  117242. * @param func defines the function to unregister
  117243. */
  117244. unregisterAfterRender(func: () => void): void;
  117245. private _executeOnceBeforeRender;
  117246. /**
  117247. * The provided function will run before render once and will be disposed afterwards.
  117248. * A timeout delay can be provided so that the function will be executed in N ms.
  117249. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117250. * @param func The function to be executed.
  117251. * @param timeout optional delay in ms
  117252. */
  117253. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117254. /** @hidden */
  117255. _addPendingData(data: any): void;
  117256. /** @hidden */
  117257. _removePendingData(data: any): void;
  117258. /**
  117259. * Returns the number of items waiting to be loaded
  117260. * @returns the number of items waiting to be loaded
  117261. */
  117262. getWaitingItemsCount(): number;
  117263. /**
  117264. * Returns a boolean indicating if the scene is still loading data
  117265. */
  117266. get isLoading(): boolean;
  117267. /**
  117268. * Registers a function to be executed when the scene is ready
  117269. * @param {Function} func - the function to be executed
  117270. */
  117271. executeWhenReady(func: () => void): void;
  117272. /**
  117273. * Returns a promise that resolves when the scene is ready
  117274. * @returns A promise that resolves when the scene is ready
  117275. */
  117276. whenReadyAsync(): Promise<void>;
  117277. /** @hidden */
  117278. _checkIsReady(): void;
  117279. /**
  117280. * Gets all animatable attached to the scene
  117281. */
  117282. get animatables(): Animatable[];
  117283. /**
  117284. * Resets the last animation time frame.
  117285. * Useful to override when animations start running when loading a scene for the first time.
  117286. */
  117287. resetLastAnimationTimeFrame(): void;
  117288. /**
  117289. * Gets the current view matrix
  117290. * @returns a Matrix
  117291. */
  117292. getViewMatrix(): Matrix;
  117293. /**
  117294. * Gets the current projection matrix
  117295. * @returns a Matrix
  117296. */
  117297. getProjectionMatrix(): Matrix;
  117298. /**
  117299. * Gets the current transform matrix
  117300. * @returns a Matrix made of View * Projection
  117301. */
  117302. getTransformMatrix(): Matrix;
  117303. /**
  117304. * Sets the current transform matrix
  117305. * @param viewL defines the View matrix to use
  117306. * @param projectionL defines the Projection matrix to use
  117307. * @param viewR defines the right View matrix to use (if provided)
  117308. * @param projectionR defines the right Projection matrix to use (if provided)
  117309. */
  117310. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117311. /**
  117312. * Gets the uniform buffer used to store scene data
  117313. * @returns a UniformBuffer
  117314. */
  117315. getSceneUniformBuffer(): UniformBuffer;
  117316. /**
  117317. * Gets an unique (relatively to the current scene) Id
  117318. * @returns an unique number for the scene
  117319. */
  117320. getUniqueId(): number;
  117321. /**
  117322. * Add a mesh to the list of scene's meshes
  117323. * @param newMesh defines the mesh to add
  117324. * @param recursive if all child meshes should also be added to the scene
  117325. */
  117326. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117327. /**
  117328. * Remove a mesh for the list of scene's meshes
  117329. * @param toRemove defines the mesh to remove
  117330. * @param recursive if all child meshes should also be removed from the scene
  117331. * @returns the index where the mesh was in the mesh list
  117332. */
  117333. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117334. /**
  117335. * Add a transform node to the list of scene's transform nodes
  117336. * @param newTransformNode defines the transform node to add
  117337. */
  117338. addTransformNode(newTransformNode: TransformNode): void;
  117339. /**
  117340. * Remove a transform node for the list of scene's transform nodes
  117341. * @param toRemove defines the transform node to remove
  117342. * @returns the index where the transform node was in the transform node list
  117343. */
  117344. removeTransformNode(toRemove: TransformNode): number;
  117345. /**
  117346. * Remove a skeleton for the list of scene's skeletons
  117347. * @param toRemove defines the skeleton to remove
  117348. * @returns the index where the skeleton was in the skeleton list
  117349. */
  117350. removeSkeleton(toRemove: Skeleton): number;
  117351. /**
  117352. * Remove a morph target for the list of scene's morph targets
  117353. * @param toRemove defines the morph target to remove
  117354. * @returns the index where the morph target was in the morph target list
  117355. */
  117356. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117357. /**
  117358. * Remove a light for the list of scene's lights
  117359. * @param toRemove defines the light to remove
  117360. * @returns the index where the light was in the light list
  117361. */
  117362. removeLight(toRemove: Light): number;
  117363. /**
  117364. * Remove a camera for the list of scene's cameras
  117365. * @param toRemove defines the camera to remove
  117366. * @returns the index where the camera was in the camera list
  117367. */
  117368. removeCamera(toRemove: Camera): number;
  117369. /**
  117370. * Remove a particle system for the list of scene's particle systems
  117371. * @param toRemove defines the particle system to remove
  117372. * @returns the index where the particle system was in the particle system list
  117373. */
  117374. removeParticleSystem(toRemove: IParticleSystem): number;
  117375. /**
  117376. * Remove a animation for the list of scene's animations
  117377. * @param toRemove defines the animation to remove
  117378. * @returns the index where the animation was in the animation list
  117379. */
  117380. removeAnimation(toRemove: Animation): number;
  117381. /**
  117382. * Will stop the animation of the given target
  117383. * @param target - the target
  117384. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117385. * @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)
  117386. */
  117387. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117388. /**
  117389. * Removes the given animation group from this scene.
  117390. * @param toRemove The animation group to remove
  117391. * @returns The index of the removed animation group
  117392. */
  117393. removeAnimationGroup(toRemove: AnimationGroup): number;
  117394. /**
  117395. * Removes the given multi-material from this scene.
  117396. * @param toRemove The multi-material to remove
  117397. * @returns The index of the removed multi-material
  117398. */
  117399. removeMultiMaterial(toRemove: MultiMaterial): number;
  117400. /**
  117401. * Removes the given material from this scene.
  117402. * @param toRemove The material to remove
  117403. * @returns The index of the removed material
  117404. */
  117405. removeMaterial(toRemove: Material): number;
  117406. /**
  117407. * Removes the given action manager from this scene.
  117408. * @param toRemove The action manager to remove
  117409. * @returns The index of the removed action manager
  117410. */
  117411. removeActionManager(toRemove: AbstractActionManager): number;
  117412. /**
  117413. * Removes the given texture from this scene.
  117414. * @param toRemove The texture to remove
  117415. * @returns The index of the removed texture
  117416. */
  117417. removeTexture(toRemove: BaseTexture): number;
  117418. /**
  117419. * Adds the given light to this scene
  117420. * @param newLight The light to add
  117421. */
  117422. addLight(newLight: Light): void;
  117423. /**
  117424. * Sorts the list list based on light priorities
  117425. */
  117426. sortLightsByPriority(): void;
  117427. /**
  117428. * Adds the given camera to this scene
  117429. * @param newCamera The camera to add
  117430. */
  117431. addCamera(newCamera: Camera): void;
  117432. /**
  117433. * Adds the given skeleton to this scene
  117434. * @param newSkeleton The skeleton to add
  117435. */
  117436. addSkeleton(newSkeleton: Skeleton): void;
  117437. /**
  117438. * Adds the given particle system to this scene
  117439. * @param newParticleSystem The particle system to add
  117440. */
  117441. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117442. /**
  117443. * Adds the given animation to this scene
  117444. * @param newAnimation The animation to add
  117445. */
  117446. addAnimation(newAnimation: Animation): void;
  117447. /**
  117448. * Adds the given animation group to this scene.
  117449. * @param newAnimationGroup The animation group to add
  117450. */
  117451. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117452. /**
  117453. * Adds the given multi-material to this scene
  117454. * @param newMultiMaterial The multi-material to add
  117455. */
  117456. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117457. /**
  117458. * Adds the given material to this scene
  117459. * @param newMaterial The material to add
  117460. */
  117461. addMaterial(newMaterial: Material): void;
  117462. /**
  117463. * Adds the given morph target to this scene
  117464. * @param newMorphTargetManager The morph target to add
  117465. */
  117466. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117467. /**
  117468. * Adds the given geometry to this scene
  117469. * @param newGeometry The geometry to add
  117470. */
  117471. addGeometry(newGeometry: Geometry): void;
  117472. /**
  117473. * Adds the given action manager to this scene
  117474. * @param newActionManager The action manager to add
  117475. */
  117476. addActionManager(newActionManager: AbstractActionManager): void;
  117477. /**
  117478. * Adds the given texture to this scene.
  117479. * @param newTexture The texture to add
  117480. */
  117481. addTexture(newTexture: BaseTexture): void;
  117482. /**
  117483. * Switch active camera
  117484. * @param newCamera defines the new active camera
  117485. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117486. */
  117487. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117488. /**
  117489. * sets the active camera of the scene using its ID
  117490. * @param id defines the camera's ID
  117491. * @return the new active camera or null if none found.
  117492. */
  117493. setActiveCameraByID(id: string): Nullable<Camera>;
  117494. /**
  117495. * sets the active camera of the scene using its name
  117496. * @param name defines the camera's name
  117497. * @returns the new active camera or null if none found.
  117498. */
  117499. setActiveCameraByName(name: string): Nullable<Camera>;
  117500. /**
  117501. * get an animation group using its name
  117502. * @param name defines the material's name
  117503. * @return the animation group or null if none found.
  117504. */
  117505. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117506. /**
  117507. * Get a material using its unique id
  117508. * @param uniqueId defines the material's unique id
  117509. * @return the material or null if none found.
  117510. */
  117511. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117512. /**
  117513. * get a material using its id
  117514. * @param id defines the material's ID
  117515. * @return the material or null if none found.
  117516. */
  117517. getMaterialByID(id: string): Nullable<Material>;
  117518. /**
  117519. * Gets a the last added material using a given id
  117520. * @param id defines the material's ID
  117521. * @return the last material with the given id or null if none found.
  117522. */
  117523. getLastMaterialByID(id: string): Nullable<Material>;
  117524. /**
  117525. * Gets a material using its name
  117526. * @param name defines the material's name
  117527. * @return the material or null if none found.
  117528. */
  117529. getMaterialByName(name: string): Nullable<Material>;
  117530. /**
  117531. * Get a texture using its unique id
  117532. * @param uniqueId defines the texture's unique id
  117533. * @return the texture or null if none found.
  117534. */
  117535. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117536. /**
  117537. * Gets a camera using its id
  117538. * @param id defines the id to look for
  117539. * @returns the camera or null if not found
  117540. */
  117541. getCameraByID(id: string): Nullable<Camera>;
  117542. /**
  117543. * Gets a camera using its unique id
  117544. * @param uniqueId defines the unique id to look for
  117545. * @returns the camera or null if not found
  117546. */
  117547. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117548. /**
  117549. * Gets a camera using its name
  117550. * @param name defines the camera's name
  117551. * @return the camera or null if none found.
  117552. */
  117553. getCameraByName(name: string): Nullable<Camera>;
  117554. /**
  117555. * Gets a bone using its id
  117556. * @param id defines the bone's id
  117557. * @return the bone or null if not found
  117558. */
  117559. getBoneByID(id: string): Nullable<Bone>;
  117560. /**
  117561. * Gets a bone using its id
  117562. * @param name defines the bone's name
  117563. * @return the bone or null if not found
  117564. */
  117565. getBoneByName(name: string): Nullable<Bone>;
  117566. /**
  117567. * Gets a light node using its name
  117568. * @param name defines the the light's name
  117569. * @return the light or null if none found.
  117570. */
  117571. getLightByName(name: string): Nullable<Light>;
  117572. /**
  117573. * Gets a light node using its id
  117574. * @param id defines the light's id
  117575. * @return the light or null if none found.
  117576. */
  117577. getLightByID(id: string): Nullable<Light>;
  117578. /**
  117579. * Gets a light node using its scene-generated unique ID
  117580. * @param uniqueId defines the light's unique id
  117581. * @return the light or null if none found.
  117582. */
  117583. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117584. /**
  117585. * Gets a particle system by id
  117586. * @param id defines the particle system id
  117587. * @return the corresponding system or null if none found
  117588. */
  117589. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117590. /**
  117591. * Gets a geometry using its ID
  117592. * @param id defines the geometry's id
  117593. * @return the geometry or null if none found.
  117594. */
  117595. getGeometryByID(id: string): Nullable<Geometry>;
  117596. private _getGeometryByUniqueID;
  117597. /**
  117598. * Add a new geometry to this scene
  117599. * @param geometry defines the geometry to be added to the scene.
  117600. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117601. * @return a boolean defining if the geometry was added or not
  117602. */
  117603. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117604. /**
  117605. * Removes an existing geometry
  117606. * @param geometry defines the geometry to be removed from the scene
  117607. * @return a boolean defining if the geometry was removed or not
  117608. */
  117609. removeGeometry(geometry: Geometry): boolean;
  117610. /**
  117611. * Gets the list of geometries attached to the scene
  117612. * @returns an array of Geometry
  117613. */
  117614. getGeometries(): Geometry[];
  117615. /**
  117616. * Gets the first added mesh found of a given ID
  117617. * @param id defines the id to search for
  117618. * @return the mesh found or null if not found at all
  117619. */
  117620. getMeshByID(id: string): Nullable<AbstractMesh>;
  117621. /**
  117622. * Gets a list of meshes using their id
  117623. * @param id defines the id to search for
  117624. * @returns a list of meshes
  117625. */
  117626. getMeshesByID(id: string): Array<AbstractMesh>;
  117627. /**
  117628. * Gets the first added transform node found of a given ID
  117629. * @param id defines the id to search for
  117630. * @return the found transform node or null if not found at all.
  117631. */
  117632. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117633. /**
  117634. * Gets a transform node with its auto-generated unique id
  117635. * @param uniqueId efines the unique id to search for
  117636. * @return the found transform node or null if not found at all.
  117637. */
  117638. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117639. /**
  117640. * Gets a list of transform nodes using their id
  117641. * @param id defines the id to search for
  117642. * @returns a list of transform nodes
  117643. */
  117644. getTransformNodesByID(id: string): Array<TransformNode>;
  117645. /**
  117646. * Gets a mesh with its auto-generated unique id
  117647. * @param uniqueId defines the unique id to search for
  117648. * @return the found mesh or null if not found at all.
  117649. */
  117650. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117651. /**
  117652. * Gets a the last added mesh using a given id
  117653. * @param id defines the id to search for
  117654. * @return the found mesh or null if not found at all.
  117655. */
  117656. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117657. /**
  117658. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117659. * @param id defines the id to search for
  117660. * @return the found node or null if not found at all
  117661. */
  117662. getLastEntryByID(id: string): Nullable<Node>;
  117663. /**
  117664. * Gets a node (Mesh, Camera, Light) using a given id
  117665. * @param id defines the id to search for
  117666. * @return the found node or null if not found at all
  117667. */
  117668. getNodeByID(id: string): Nullable<Node>;
  117669. /**
  117670. * Gets a node (Mesh, Camera, Light) using a given name
  117671. * @param name defines the name to search for
  117672. * @return the found node or null if not found at all.
  117673. */
  117674. getNodeByName(name: string): Nullable<Node>;
  117675. /**
  117676. * Gets a mesh using a given name
  117677. * @param name defines the name to search for
  117678. * @return the found mesh or null if not found at all.
  117679. */
  117680. getMeshByName(name: string): Nullable<AbstractMesh>;
  117681. /**
  117682. * Gets a transform node using a given name
  117683. * @param name defines the name to search for
  117684. * @return the found transform node or null if not found at all.
  117685. */
  117686. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117687. /**
  117688. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117689. * @param id defines the id to search for
  117690. * @return the found skeleton or null if not found at all.
  117691. */
  117692. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117693. /**
  117694. * Gets a skeleton using a given auto generated unique id
  117695. * @param uniqueId defines the unique id to search for
  117696. * @return the found skeleton or null if not found at all.
  117697. */
  117698. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117699. /**
  117700. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117701. * @param id defines the id to search for
  117702. * @return the found skeleton or null if not found at all.
  117703. */
  117704. getSkeletonById(id: string): Nullable<Skeleton>;
  117705. /**
  117706. * Gets a skeleton using a given name
  117707. * @param name defines the name to search for
  117708. * @return the found skeleton or null if not found at all.
  117709. */
  117710. getSkeletonByName(name: string): Nullable<Skeleton>;
  117711. /**
  117712. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117713. * @param id defines the id to search for
  117714. * @return the found morph target manager or null if not found at all.
  117715. */
  117716. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117717. /**
  117718. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117719. * @param id defines the id to search for
  117720. * @return the found morph target or null if not found at all.
  117721. */
  117722. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117723. /**
  117724. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117725. * @param name defines the name to search for
  117726. * @return the found morph target or null if not found at all.
  117727. */
  117728. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117729. /**
  117730. * Gets a boolean indicating if the given mesh is active
  117731. * @param mesh defines the mesh to look for
  117732. * @returns true if the mesh is in the active list
  117733. */
  117734. isActiveMesh(mesh: AbstractMesh): boolean;
  117735. /**
  117736. * Return a unique id as a string which can serve as an identifier for the scene
  117737. */
  117738. get uid(): string;
  117739. /**
  117740. * Add an externaly attached data from its key.
  117741. * This method call will fail and return false, if such key already exists.
  117742. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117743. * @param key the unique key that identifies the data
  117744. * @param data the data object to associate to the key for this Engine instance
  117745. * @return true if no such key were already present and the data was added successfully, false otherwise
  117746. */
  117747. addExternalData<T>(key: string, data: T): boolean;
  117748. /**
  117749. * Get an externaly attached data from its key
  117750. * @param key the unique key that identifies the data
  117751. * @return the associated data, if present (can be null), or undefined if not present
  117752. */
  117753. getExternalData<T>(key: string): Nullable<T>;
  117754. /**
  117755. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117756. * @param key the unique key that identifies the data
  117757. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117758. * @return the associated data, can be null if the factory returned null.
  117759. */
  117760. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117761. /**
  117762. * Remove an externaly attached data from the Engine instance
  117763. * @param key the unique key that identifies the data
  117764. * @return true if the data was successfully removed, false if it doesn't exist
  117765. */
  117766. removeExternalData(key: string): boolean;
  117767. private _evaluateSubMesh;
  117768. /**
  117769. * Clear the processed materials smart array preventing retention point in material dispose.
  117770. */
  117771. freeProcessedMaterials(): void;
  117772. private _preventFreeActiveMeshesAndRenderingGroups;
  117773. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117774. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117775. * when disposing several meshes in a row or a hierarchy of meshes.
  117776. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117777. */
  117778. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117779. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117780. /**
  117781. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117782. */
  117783. freeActiveMeshes(): void;
  117784. /**
  117785. * Clear the info related to rendering groups preventing retention points during dispose.
  117786. */
  117787. freeRenderingGroups(): void;
  117788. /** @hidden */
  117789. _isInIntermediateRendering(): boolean;
  117790. /**
  117791. * Lambda returning the list of potentially active meshes.
  117792. */
  117793. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117794. /**
  117795. * Lambda returning the list of potentially active sub meshes.
  117796. */
  117797. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117798. /**
  117799. * Lambda returning the list of potentially intersecting sub meshes.
  117800. */
  117801. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117802. /**
  117803. * Lambda returning the list of potentially colliding sub meshes.
  117804. */
  117805. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117806. private _activeMeshesFrozen;
  117807. private _skipEvaluateActiveMeshesCompletely;
  117808. /**
  117809. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117810. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117811. * @returns the current scene
  117812. */
  117813. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117814. /**
  117815. * Use this function to restart evaluating active meshes on every frame
  117816. * @returns the current scene
  117817. */
  117818. unfreezeActiveMeshes(): Scene;
  117819. private _evaluateActiveMeshes;
  117820. private _activeMesh;
  117821. /**
  117822. * Update the transform matrix to update from the current active camera
  117823. * @param force defines a boolean used to force the update even if cache is up to date
  117824. */
  117825. updateTransformMatrix(force?: boolean): void;
  117826. private _bindFrameBuffer;
  117827. /** @hidden */
  117828. _allowPostProcessClearColor: boolean;
  117829. /** @hidden */
  117830. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117831. private _processSubCameras;
  117832. private _checkIntersections;
  117833. /** @hidden */
  117834. _advancePhysicsEngineStep(step: number): void;
  117835. /**
  117836. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117837. */
  117838. getDeterministicFrameTime: () => number;
  117839. /** @hidden */
  117840. _animate(): void;
  117841. /** Execute all animations (for a frame) */
  117842. animate(): void;
  117843. /**
  117844. * Render the scene
  117845. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117846. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117847. */
  117848. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117849. /**
  117850. * Freeze all materials
  117851. * A frozen material will not be updatable but should be faster to render
  117852. */
  117853. freezeMaterials(): void;
  117854. /**
  117855. * Unfreeze all materials
  117856. * A frozen material will not be updatable but should be faster to render
  117857. */
  117858. unfreezeMaterials(): void;
  117859. /**
  117860. * Releases all held ressources
  117861. */
  117862. dispose(): void;
  117863. /**
  117864. * Gets if the scene is already disposed
  117865. */
  117866. get isDisposed(): boolean;
  117867. /**
  117868. * Call this function to reduce memory footprint of the scene.
  117869. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117870. */
  117871. clearCachedVertexData(): void;
  117872. /**
  117873. * This function will remove the local cached buffer data from texture.
  117874. * It will save memory but will prevent the texture from being rebuilt
  117875. */
  117876. cleanCachedTextureBuffer(): void;
  117877. /**
  117878. * Get the world extend vectors with an optional filter
  117879. *
  117880. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117881. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117882. */
  117883. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117884. min: Vector3;
  117885. max: Vector3;
  117886. };
  117887. /**
  117888. * Creates a ray that can be used to pick in the scene
  117889. * @param x defines the x coordinate of the origin (on-screen)
  117890. * @param y defines the y coordinate of the origin (on-screen)
  117891. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117892. * @param camera defines the camera to use for the picking
  117893. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117894. * @returns a Ray
  117895. */
  117896. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117897. /**
  117898. * Creates a ray that can be used to pick in the scene
  117899. * @param x defines the x coordinate of the origin (on-screen)
  117900. * @param y defines the y coordinate of the origin (on-screen)
  117901. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117902. * @param result defines the ray where to store the picking ray
  117903. * @param camera defines the camera to use for the picking
  117904. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117905. * @returns the current scene
  117906. */
  117907. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117908. /**
  117909. * Creates a ray that can be used to pick in the scene
  117910. * @param x defines the x coordinate of the origin (on-screen)
  117911. * @param y defines the y coordinate of the origin (on-screen)
  117912. * @param camera defines the camera to use for the picking
  117913. * @returns a Ray
  117914. */
  117915. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117916. /**
  117917. * Creates a ray that can be used to pick in the scene
  117918. * @param x defines the x coordinate of the origin (on-screen)
  117919. * @param y defines the y coordinate of the origin (on-screen)
  117920. * @param result defines the ray where to store the picking ray
  117921. * @param camera defines the camera to use for the picking
  117922. * @returns the current scene
  117923. */
  117924. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117925. /** Launch a ray to try to pick a mesh in the scene
  117926. * @param x position on screen
  117927. * @param y position on screen
  117928. * @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
  117929. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117930. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117931. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117932. * @returns a PickingInfo
  117933. */
  117934. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117935. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117936. * @param x position on screen
  117937. * @param y position on screen
  117938. * @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
  117939. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117940. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117941. * @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)
  117942. */
  117943. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117944. /** Use the given ray to pick a mesh in the scene
  117945. * @param ray The ray to use to pick meshes
  117946. * @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
  117947. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117949. * @returns a PickingInfo
  117950. */
  117951. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117952. /**
  117953. * Launch a ray to try to pick a mesh in the scene
  117954. * @param x X position on screen
  117955. * @param y Y position on screen
  117956. * @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
  117957. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117959. * @returns an array of PickingInfo
  117960. */
  117961. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117962. /**
  117963. * Launch a ray to try to pick a mesh in the scene
  117964. * @param ray Ray to use
  117965. * @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
  117966. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117967. * @returns an array of PickingInfo
  117968. */
  117969. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117970. /**
  117971. * Force the value of meshUnderPointer
  117972. * @param mesh defines the mesh to use
  117973. */
  117974. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117975. /**
  117976. * Gets the mesh under the pointer
  117977. * @returns a Mesh or null if no mesh is under the pointer
  117978. */
  117979. getPointerOverMesh(): Nullable<AbstractMesh>;
  117980. /** @hidden */
  117981. _rebuildGeometries(): void;
  117982. /** @hidden */
  117983. _rebuildTextures(): void;
  117984. private _getByTags;
  117985. /**
  117986. * Get a list of meshes by tags
  117987. * @param tagsQuery defines the tags query to use
  117988. * @param forEach defines a predicate used to filter results
  117989. * @returns an array of Mesh
  117990. */
  117991. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117992. /**
  117993. * Get a list of cameras by tags
  117994. * @param tagsQuery defines the tags query to use
  117995. * @param forEach defines a predicate used to filter results
  117996. * @returns an array of Camera
  117997. */
  117998. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117999. /**
  118000. * Get a list of lights by tags
  118001. * @param tagsQuery defines the tags query to use
  118002. * @param forEach defines a predicate used to filter results
  118003. * @returns an array of Light
  118004. */
  118005. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118006. /**
  118007. * Get a list of materials by tags
  118008. * @param tagsQuery defines the tags query to use
  118009. * @param forEach defines a predicate used to filter results
  118010. * @returns an array of Material
  118011. */
  118012. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118013. /**
  118014. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118015. * This allowed control for front to back rendering or reversly depending of the special needs.
  118016. *
  118017. * @param renderingGroupId The rendering group id corresponding to its index
  118018. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118019. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118020. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118021. */
  118022. 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;
  118023. /**
  118024. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118025. *
  118026. * @param renderingGroupId The rendering group id corresponding to its index
  118027. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118028. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118029. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118030. */
  118031. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118032. /**
  118033. * Gets the current auto clear configuration for one rendering group of the rendering
  118034. * manager.
  118035. * @param index the rendering group index to get the information for
  118036. * @returns The auto clear setup for the requested rendering group
  118037. */
  118038. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118039. private _blockMaterialDirtyMechanism;
  118040. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118041. get blockMaterialDirtyMechanism(): boolean;
  118042. set blockMaterialDirtyMechanism(value: boolean);
  118043. /**
  118044. * Will flag all materials as dirty to trigger new shader compilation
  118045. * @param flag defines the flag used to specify which material part must be marked as dirty
  118046. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118047. */
  118048. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118049. /** @hidden */
  118050. _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;
  118051. /** @hidden */
  118052. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118053. /** @hidden */
  118054. _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;
  118055. /** @hidden */
  118056. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118057. /** @hidden */
  118058. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118059. /** @hidden */
  118060. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118061. }
  118062. }
  118063. declare module BABYLON {
  118064. /**
  118065. * Set of assets to keep when moving a scene into an asset container.
  118066. */
  118067. export class KeepAssets extends AbstractScene {
  118068. }
  118069. /**
  118070. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118071. */
  118072. export class InstantiatedEntries {
  118073. /**
  118074. * List of new root nodes (eg. nodes with no parent)
  118075. */
  118076. rootNodes: TransformNode[];
  118077. /**
  118078. * List of new skeletons
  118079. */
  118080. skeletons: Skeleton[];
  118081. /**
  118082. * List of new animation groups
  118083. */
  118084. animationGroups: AnimationGroup[];
  118085. }
  118086. /**
  118087. * Container with a set of assets that can be added or removed from a scene.
  118088. */
  118089. export class AssetContainer extends AbstractScene {
  118090. private _wasAddedToScene;
  118091. /**
  118092. * The scene the AssetContainer belongs to.
  118093. */
  118094. scene: Scene;
  118095. /**
  118096. * Instantiates an AssetContainer.
  118097. * @param scene The scene the AssetContainer belongs to.
  118098. */
  118099. constructor(scene: Scene);
  118100. /**
  118101. * Instantiate or clone all meshes and add the new ones to the scene.
  118102. * Skeletons and animation groups will all be cloned
  118103. * @param nameFunction defines an optional function used to get new names for clones
  118104. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118105. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118106. */
  118107. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118108. /**
  118109. * Adds all the assets from the container to the scene.
  118110. */
  118111. addAllToScene(): void;
  118112. /**
  118113. * Removes all the assets in the container from the scene
  118114. */
  118115. removeAllFromScene(): void;
  118116. /**
  118117. * Disposes all the assets in the container
  118118. */
  118119. dispose(): void;
  118120. private _moveAssets;
  118121. /**
  118122. * Removes all the assets contained in the scene and adds them to the container.
  118123. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118124. */
  118125. moveAllFromScene(keepAssets?: KeepAssets): void;
  118126. /**
  118127. * 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.
  118128. * @returns the root mesh
  118129. */
  118130. createRootMesh(): Mesh;
  118131. /**
  118132. * Merge animations (direct and animation groups) from this asset container into a scene
  118133. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118134. * @param animatables set of animatables to retarget to a node from the scene
  118135. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118136. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118137. */
  118138. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118139. }
  118140. }
  118141. declare module BABYLON {
  118142. /**
  118143. * Defines how the parser contract is defined.
  118144. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118145. */
  118146. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118147. /**
  118148. * Defines how the individual parser contract is defined.
  118149. * These parser can parse an individual asset
  118150. */
  118151. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118152. /**
  118153. * Base class of the scene acting as a container for the different elements composing a scene.
  118154. * This class is dynamically extended by the different components of the scene increasing
  118155. * flexibility and reducing coupling
  118156. */
  118157. export abstract class AbstractScene {
  118158. /**
  118159. * Stores the list of available parsers in the application.
  118160. */
  118161. private static _BabylonFileParsers;
  118162. /**
  118163. * Stores the list of available individual parsers in the application.
  118164. */
  118165. private static _IndividualBabylonFileParsers;
  118166. /**
  118167. * Adds a parser in the list of available ones
  118168. * @param name Defines the name of the parser
  118169. * @param parser Defines the parser to add
  118170. */
  118171. static AddParser(name: string, parser: BabylonFileParser): void;
  118172. /**
  118173. * Gets a general parser from the list of avaialble ones
  118174. * @param name Defines the name of the parser
  118175. * @returns the requested parser or null
  118176. */
  118177. static GetParser(name: string): Nullable<BabylonFileParser>;
  118178. /**
  118179. * Adds n individual parser in the list of available ones
  118180. * @param name Defines the name of the parser
  118181. * @param parser Defines the parser to add
  118182. */
  118183. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118184. /**
  118185. * Gets an individual parser from the list of avaialble ones
  118186. * @param name Defines the name of the parser
  118187. * @returns the requested parser or null
  118188. */
  118189. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118190. /**
  118191. * Parser json data and populate both a scene and its associated container object
  118192. * @param jsonData Defines the data to parse
  118193. * @param scene Defines the scene to parse the data for
  118194. * @param container Defines the container attached to the parsing sequence
  118195. * @param rootUrl Defines the root url of the data
  118196. */
  118197. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118198. /**
  118199. * Gets the list of root nodes (ie. nodes with no parent)
  118200. */
  118201. rootNodes: Node[];
  118202. /** All of the cameras added to this scene
  118203. * @see http://doc.babylonjs.com/babylon101/cameras
  118204. */
  118205. cameras: Camera[];
  118206. /**
  118207. * All of the lights added to this scene
  118208. * @see http://doc.babylonjs.com/babylon101/lights
  118209. */
  118210. lights: Light[];
  118211. /**
  118212. * All of the (abstract) meshes added to this scene
  118213. */
  118214. meshes: AbstractMesh[];
  118215. /**
  118216. * The list of skeletons added to the scene
  118217. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118218. */
  118219. skeletons: Skeleton[];
  118220. /**
  118221. * All of the particle systems added to this scene
  118222. * @see http://doc.babylonjs.com/babylon101/particles
  118223. */
  118224. particleSystems: IParticleSystem[];
  118225. /**
  118226. * Gets a list of Animations associated with the scene
  118227. */
  118228. animations: Animation[];
  118229. /**
  118230. * All of the animation groups added to this scene
  118231. * @see http://doc.babylonjs.com/how_to/group
  118232. */
  118233. animationGroups: AnimationGroup[];
  118234. /**
  118235. * All of the multi-materials added to this scene
  118236. * @see http://doc.babylonjs.com/how_to/multi_materials
  118237. */
  118238. multiMaterials: MultiMaterial[];
  118239. /**
  118240. * All of the materials added to this scene
  118241. * In the context of a Scene, it is not supposed to be modified manually.
  118242. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118243. * Note also that the order of the Material within the array is not significant and might change.
  118244. * @see http://doc.babylonjs.com/babylon101/materials
  118245. */
  118246. materials: Material[];
  118247. /**
  118248. * The list of morph target managers added to the scene
  118249. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118250. */
  118251. morphTargetManagers: MorphTargetManager[];
  118252. /**
  118253. * The list of geometries used in the scene.
  118254. */
  118255. geometries: Geometry[];
  118256. /**
  118257. * All of the tranform nodes added to this scene
  118258. * In the context of a Scene, it is not supposed to be modified manually.
  118259. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118260. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118261. * @see http://doc.babylonjs.com/how_to/transformnode
  118262. */
  118263. transformNodes: TransformNode[];
  118264. /**
  118265. * ActionManagers available on the scene.
  118266. */
  118267. actionManagers: AbstractActionManager[];
  118268. /**
  118269. * Textures to keep.
  118270. */
  118271. textures: BaseTexture[];
  118272. /**
  118273. * Environment texture for the scene
  118274. */
  118275. environmentTexture: Nullable<BaseTexture>;
  118276. /**
  118277. * @returns all meshes, lights, cameras, transformNodes and bones
  118278. */
  118279. getNodes(): Array<Node>;
  118280. }
  118281. }
  118282. declare module BABYLON {
  118283. /**
  118284. * Interface used to define options for Sound class
  118285. */
  118286. export interface ISoundOptions {
  118287. /**
  118288. * Does the sound autoplay once loaded.
  118289. */
  118290. autoplay?: boolean;
  118291. /**
  118292. * Does the sound loop after it finishes playing once.
  118293. */
  118294. loop?: boolean;
  118295. /**
  118296. * Sound's volume
  118297. */
  118298. volume?: number;
  118299. /**
  118300. * Is it a spatial sound?
  118301. */
  118302. spatialSound?: boolean;
  118303. /**
  118304. * Maximum distance to hear that sound
  118305. */
  118306. maxDistance?: number;
  118307. /**
  118308. * Uses user defined attenuation function
  118309. */
  118310. useCustomAttenuation?: boolean;
  118311. /**
  118312. * Define the roll off factor of spatial sounds.
  118313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118314. */
  118315. rolloffFactor?: number;
  118316. /**
  118317. * Define the reference distance the sound should be heard perfectly.
  118318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118319. */
  118320. refDistance?: number;
  118321. /**
  118322. * Define the distance attenuation model the sound will follow.
  118323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118324. */
  118325. distanceModel?: string;
  118326. /**
  118327. * Defines the playback speed (1 by default)
  118328. */
  118329. playbackRate?: number;
  118330. /**
  118331. * Defines if the sound is from a streaming source
  118332. */
  118333. streaming?: boolean;
  118334. /**
  118335. * Defines an optional length (in seconds) inside the sound file
  118336. */
  118337. length?: number;
  118338. /**
  118339. * Defines an optional offset (in seconds) inside the sound file
  118340. */
  118341. offset?: number;
  118342. /**
  118343. * If true, URLs will not be required to state the audio file codec to use.
  118344. */
  118345. skipCodecCheck?: boolean;
  118346. }
  118347. /**
  118348. * Defines a sound that can be played in the application.
  118349. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118351. */
  118352. export class Sound {
  118353. /**
  118354. * The name of the sound in the scene.
  118355. */
  118356. name: string;
  118357. /**
  118358. * Does the sound autoplay once loaded.
  118359. */
  118360. autoplay: boolean;
  118361. /**
  118362. * Does the sound loop after it finishes playing once.
  118363. */
  118364. loop: boolean;
  118365. /**
  118366. * Does the sound use a custom attenuation curve to simulate the falloff
  118367. * happening when the source gets further away from the camera.
  118368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118369. */
  118370. useCustomAttenuation: boolean;
  118371. /**
  118372. * The sound track id this sound belongs to.
  118373. */
  118374. soundTrackId: number;
  118375. /**
  118376. * Is this sound currently played.
  118377. */
  118378. isPlaying: boolean;
  118379. /**
  118380. * Is this sound currently paused.
  118381. */
  118382. isPaused: boolean;
  118383. /**
  118384. * Does this sound enables spatial sound.
  118385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118386. */
  118387. spatialSound: boolean;
  118388. /**
  118389. * Define the reference distance the sound should be heard perfectly.
  118390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118391. */
  118392. refDistance: number;
  118393. /**
  118394. * Define the roll off factor of spatial sounds.
  118395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118396. */
  118397. rolloffFactor: number;
  118398. /**
  118399. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118401. */
  118402. maxDistance: number;
  118403. /**
  118404. * Define the distance attenuation model the sound will follow.
  118405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118406. */
  118407. distanceModel: string;
  118408. /**
  118409. * @hidden
  118410. * Back Compat
  118411. **/
  118412. onended: () => any;
  118413. /**
  118414. * Gets or sets an object used to store user defined information for the sound.
  118415. */
  118416. metadata: any;
  118417. /**
  118418. * Observable event when the current playing sound finishes.
  118419. */
  118420. onEndedObservable: Observable<Sound>;
  118421. private _panningModel;
  118422. private _playbackRate;
  118423. private _streaming;
  118424. private _startTime;
  118425. private _startOffset;
  118426. private _position;
  118427. /** @hidden */
  118428. _positionInEmitterSpace: boolean;
  118429. private _localDirection;
  118430. private _volume;
  118431. private _isReadyToPlay;
  118432. private _isDirectional;
  118433. private _readyToPlayCallback;
  118434. private _audioBuffer;
  118435. private _soundSource;
  118436. private _streamingSource;
  118437. private _soundPanner;
  118438. private _soundGain;
  118439. private _inputAudioNode;
  118440. private _outputAudioNode;
  118441. private _coneInnerAngle;
  118442. private _coneOuterAngle;
  118443. private _coneOuterGain;
  118444. private _scene;
  118445. private _connectedTransformNode;
  118446. private _customAttenuationFunction;
  118447. private _registerFunc;
  118448. private _isOutputConnected;
  118449. private _htmlAudioElement;
  118450. private _urlType;
  118451. private _length?;
  118452. private _offset?;
  118453. /** @hidden */
  118454. static _SceneComponentInitialization: (scene: Scene) => void;
  118455. /**
  118456. * Create a sound and attach it to a scene
  118457. * @param name Name of your sound
  118458. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118459. * @param scene defines the scene the sound belongs to
  118460. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118461. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118462. */
  118463. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118464. /**
  118465. * Release the sound and its associated resources
  118466. */
  118467. dispose(): void;
  118468. /**
  118469. * Gets if the sounds is ready to be played or not.
  118470. * @returns true if ready, otherwise false
  118471. */
  118472. isReady(): boolean;
  118473. private _soundLoaded;
  118474. /**
  118475. * Sets the data of the sound from an audiobuffer
  118476. * @param audioBuffer The audioBuffer containing the data
  118477. */
  118478. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118479. /**
  118480. * Updates the current sounds options such as maxdistance, loop...
  118481. * @param options A JSON object containing values named as the object properties
  118482. */
  118483. updateOptions(options: ISoundOptions): void;
  118484. private _createSpatialParameters;
  118485. private _updateSpatialParameters;
  118486. /**
  118487. * Switch the panning model to HRTF:
  118488. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118490. */
  118491. switchPanningModelToHRTF(): void;
  118492. /**
  118493. * Switch the panning model to Equal Power:
  118494. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118496. */
  118497. switchPanningModelToEqualPower(): void;
  118498. private _switchPanningModel;
  118499. /**
  118500. * Connect this sound to a sound track audio node like gain...
  118501. * @param soundTrackAudioNode the sound track audio node to connect to
  118502. */
  118503. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118504. /**
  118505. * Transform this sound into a directional source
  118506. * @param coneInnerAngle Size of the inner cone in degree
  118507. * @param coneOuterAngle Size of the outer cone in degree
  118508. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118509. */
  118510. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118511. /**
  118512. * Gets or sets the inner angle for the directional cone.
  118513. */
  118514. get directionalConeInnerAngle(): number;
  118515. /**
  118516. * Gets or sets the inner angle for the directional cone.
  118517. */
  118518. set directionalConeInnerAngle(value: number);
  118519. /**
  118520. * Gets or sets the outer angle for the directional cone.
  118521. */
  118522. get directionalConeOuterAngle(): number;
  118523. /**
  118524. * Gets or sets the outer angle for the directional cone.
  118525. */
  118526. set directionalConeOuterAngle(value: number);
  118527. /**
  118528. * Sets the position of the emitter if spatial sound is enabled
  118529. * @param newPosition Defines the new posisiton
  118530. */
  118531. setPosition(newPosition: Vector3): void;
  118532. /**
  118533. * Sets the local direction of the emitter if spatial sound is enabled
  118534. * @param newLocalDirection Defines the new local direction
  118535. */
  118536. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118537. private _updateDirection;
  118538. /** @hidden */
  118539. updateDistanceFromListener(): void;
  118540. /**
  118541. * Sets a new custom attenuation function for the sound.
  118542. * @param callback Defines the function used for the attenuation
  118543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118544. */
  118545. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118546. /**
  118547. * Play the sound
  118548. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118549. * @param offset (optional) Start the sound at a specific time in seconds
  118550. * @param length (optional) Sound duration (in seconds)
  118551. */
  118552. play(time?: number, offset?: number, length?: number): void;
  118553. private _onended;
  118554. /**
  118555. * Stop the sound
  118556. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118557. */
  118558. stop(time?: number): void;
  118559. /**
  118560. * Put the sound in pause
  118561. */
  118562. pause(): void;
  118563. /**
  118564. * Sets a dedicated volume for this sounds
  118565. * @param newVolume Define the new volume of the sound
  118566. * @param time Define time for gradual change to new volume
  118567. */
  118568. setVolume(newVolume: number, time?: number): void;
  118569. /**
  118570. * Set the sound play back rate
  118571. * @param newPlaybackRate Define the playback rate the sound should be played at
  118572. */
  118573. setPlaybackRate(newPlaybackRate: number): void;
  118574. /**
  118575. * Gets the volume of the sound.
  118576. * @returns the volume of the sound
  118577. */
  118578. getVolume(): number;
  118579. /**
  118580. * Attach the sound to a dedicated mesh
  118581. * @param transformNode The transform node to connect the sound with
  118582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118583. */
  118584. attachToMesh(transformNode: TransformNode): void;
  118585. /**
  118586. * Detach the sound from the previously attached mesh
  118587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118588. */
  118589. detachFromMesh(): void;
  118590. private _onRegisterAfterWorldMatrixUpdate;
  118591. /**
  118592. * Clone the current sound in the scene.
  118593. * @returns the new sound clone
  118594. */
  118595. clone(): Nullable<Sound>;
  118596. /**
  118597. * Gets the current underlying audio buffer containing the data
  118598. * @returns the audio buffer
  118599. */
  118600. getAudioBuffer(): Nullable<AudioBuffer>;
  118601. /**
  118602. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118603. * @returns the source node
  118604. */
  118605. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118606. /**
  118607. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118608. * @returns the gain node
  118609. */
  118610. getSoundGain(): Nullable<GainNode>;
  118611. /**
  118612. * Serializes the Sound in a JSON representation
  118613. * @returns the JSON representation of the sound
  118614. */
  118615. serialize(): any;
  118616. /**
  118617. * Parse a JSON representation of a sound to innstantiate in a given scene
  118618. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118619. * @param scene Define the scene the new parsed sound should be created in
  118620. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118621. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118622. * @returns the newly parsed sound
  118623. */
  118624. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118625. }
  118626. }
  118627. declare module BABYLON {
  118628. /**
  118629. * This defines an action helpful to play a defined sound on a triggered action.
  118630. */
  118631. export class PlaySoundAction extends Action {
  118632. private _sound;
  118633. /**
  118634. * Instantiate the action
  118635. * @param triggerOptions defines the trigger options
  118636. * @param sound defines the sound to play
  118637. * @param condition defines the trigger related conditions
  118638. */
  118639. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118640. /** @hidden */
  118641. _prepare(): void;
  118642. /**
  118643. * Execute the action and play the sound.
  118644. */
  118645. execute(): void;
  118646. /**
  118647. * Serializes the actions and its related information.
  118648. * @param parent defines the object to serialize in
  118649. * @returns the serialized object
  118650. */
  118651. serialize(parent: any): any;
  118652. }
  118653. /**
  118654. * This defines an action helpful to stop a defined sound on a triggered action.
  118655. */
  118656. export class StopSoundAction extends Action {
  118657. private _sound;
  118658. /**
  118659. * Instantiate the action
  118660. * @param triggerOptions defines the trigger options
  118661. * @param sound defines the sound to stop
  118662. * @param condition defines the trigger related conditions
  118663. */
  118664. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118665. /** @hidden */
  118666. _prepare(): void;
  118667. /**
  118668. * Execute the action and stop the sound.
  118669. */
  118670. execute(): void;
  118671. /**
  118672. * Serializes the actions and its related information.
  118673. * @param parent defines the object to serialize in
  118674. * @returns the serialized object
  118675. */
  118676. serialize(parent: any): any;
  118677. }
  118678. }
  118679. declare module BABYLON {
  118680. /**
  118681. * This defines an action responsible to change the value of a property
  118682. * by interpolating between its current value and the newly set one once triggered.
  118683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118684. */
  118685. export class InterpolateValueAction extends Action {
  118686. /**
  118687. * Defines the path of the property where the value should be interpolated
  118688. */
  118689. propertyPath: string;
  118690. /**
  118691. * Defines the target value at the end of the interpolation.
  118692. */
  118693. value: any;
  118694. /**
  118695. * Defines the time it will take for the property to interpolate to the value.
  118696. */
  118697. duration: number;
  118698. /**
  118699. * Defines if the other scene animations should be stopped when the action has been triggered
  118700. */
  118701. stopOtherAnimations?: boolean;
  118702. /**
  118703. * Defines a callback raised once the interpolation animation has been done.
  118704. */
  118705. onInterpolationDone?: () => void;
  118706. /**
  118707. * Observable triggered once the interpolation animation has been done.
  118708. */
  118709. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118710. private _target;
  118711. private _effectiveTarget;
  118712. private _property;
  118713. /**
  118714. * Instantiate the action
  118715. * @param triggerOptions defines the trigger options
  118716. * @param target defines the object containing the value to interpolate
  118717. * @param propertyPath defines the path to the property in the target object
  118718. * @param value defines the target value at the end of the interpolation
  118719. * @param duration deines the time it will take for the property to interpolate to the value.
  118720. * @param condition defines the trigger related conditions
  118721. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118722. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118723. */
  118724. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118725. /** @hidden */
  118726. _prepare(): void;
  118727. /**
  118728. * Execute the action starts the value interpolation.
  118729. */
  118730. execute(): void;
  118731. /**
  118732. * Serializes the actions and its related information.
  118733. * @param parent defines the object to serialize in
  118734. * @returns the serialized object
  118735. */
  118736. serialize(parent: any): any;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Options allowed during the creation of a sound track.
  118742. */
  118743. export interface ISoundTrackOptions {
  118744. /**
  118745. * The volume the sound track should take during creation
  118746. */
  118747. volume?: number;
  118748. /**
  118749. * Define if the sound track is the main sound track of the scene
  118750. */
  118751. mainTrack?: boolean;
  118752. }
  118753. /**
  118754. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118755. * It will be also used in a future release to apply effects on a specific track.
  118756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118757. */
  118758. export class SoundTrack {
  118759. /**
  118760. * The unique identifier of the sound track in the scene.
  118761. */
  118762. id: number;
  118763. /**
  118764. * The list of sounds included in the sound track.
  118765. */
  118766. soundCollection: Array<Sound>;
  118767. private _outputAudioNode;
  118768. private _scene;
  118769. private _connectedAnalyser;
  118770. private _options;
  118771. private _isInitialized;
  118772. /**
  118773. * Creates a new sound track.
  118774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118775. * @param scene Define the scene the sound track belongs to
  118776. * @param options
  118777. */
  118778. constructor(scene: Scene, options?: ISoundTrackOptions);
  118779. private _initializeSoundTrackAudioGraph;
  118780. /**
  118781. * Release the sound track and its associated resources
  118782. */
  118783. dispose(): void;
  118784. /**
  118785. * Adds a sound to this sound track
  118786. * @param sound define the cound to add
  118787. * @ignoreNaming
  118788. */
  118789. AddSound(sound: Sound): void;
  118790. /**
  118791. * Removes a sound to this sound track
  118792. * @param sound define the cound to remove
  118793. * @ignoreNaming
  118794. */
  118795. RemoveSound(sound: Sound): void;
  118796. /**
  118797. * Set a global volume for the full sound track.
  118798. * @param newVolume Define the new volume of the sound track
  118799. */
  118800. setVolume(newVolume: number): void;
  118801. /**
  118802. * Switch the panning model to HRTF:
  118803. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118805. */
  118806. switchPanningModelToHRTF(): void;
  118807. /**
  118808. * Switch the panning model to Equal Power:
  118809. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118811. */
  118812. switchPanningModelToEqualPower(): void;
  118813. /**
  118814. * Connect the sound track to an audio analyser allowing some amazing
  118815. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118817. * @param analyser The analyser to connect to the engine
  118818. */
  118819. connectToAnalyser(analyser: Analyser): void;
  118820. }
  118821. }
  118822. declare module BABYLON {
  118823. interface AbstractScene {
  118824. /**
  118825. * The list of sounds used in the scene.
  118826. */
  118827. sounds: Nullable<Array<Sound>>;
  118828. }
  118829. interface Scene {
  118830. /**
  118831. * @hidden
  118832. * Backing field
  118833. */
  118834. _mainSoundTrack: SoundTrack;
  118835. /**
  118836. * The main sound track played by the scene.
  118837. * It cotains your primary collection of sounds.
  118838. */
  118839. mainSoundTrack: SoundTrack;
  118840. /**
  118841. * The list of sound tracks added to the scene
  118842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118843. */
  118844. soundTracks: Nullable<Array<SoundTrack>>;
  118845. /**
  118846. * Gets a sound using a given name
  118847. * @param name defines the name to search for
  118848. * @return the found sound or null if not found at all.
  118849. */
  118850. getSoundByName(name: string): Nullable<Sound>;
  118851. /**
  118852. * Gets or sets if audio support is enabled
  118853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118854. */
  118855. audioEnabled: boolean;
  118856. /**
  118857. * Gets or sets if audio will be output to headphones
  118858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118859. */
  118860. headphone: boolean;
  118861. /**
  118862. * Gets or sets custom audio listener position provider
  118863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118864. */
  118865. audioListenerPositionProvider: Nullable<() => Vector3>;
  118866. /**
  118867. * Gets or sets a refresh rate when using 3D audio positioning
  118868. */
  118869. audioPositioningRefreshRate: number;
  118870. }
  118871. /**
  118872. * Defines the sound scene component responsible to manage any sounds
  118873. * in a given scene.
  118874. */
  118875. export class AudioSceneComponent implements ISceneSerializableComponent {
  118876. /**
  118877. * The component name helpfull to identify the component in the list of scene components.
  118878. */
  118879. readonly name: string;
  118880. /**
  118881. * The scene the component belongs to.
  118882. */
  118883. scene: Scene;
  118884. private _audioEnabled;
  118885. /**
  118886. * Gets whether audio is enabled or not.
  118887. * Please use related enable/disable method to switch state.
  118888. */
  118889. get audioEnabled(): boolean;
  118890. private _headphone;
  118891. /**
  118892. * Gets whether audio is outputing to headphone or not.
  118893. * Please use the according Switch methods to change output.
  118894. */
  118895. get headphone(): boolean;
  118896. /**
  118897. * Gets or sets a refresh rate when using 3D audio positioning
  118898. */
  118899. audioPositioningRefreshRate: number;
  118900. private _audioListenerPositionProvider;
  118901. /**
  118902. * Gets the current audio listener position provider
  118903. */
  118904. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118905. /**
  118906. * Sets a custom listener position for all sounds in the scene
  118907. * By default, this is the position of the first active camera
  118908. */
  118909. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118910. /**
  118911. * Creates a new instance of the component for the given scene
  118912. * @param scene Defines the scene to register the component in
  118913. */
  118914. constructor(scene: Scene);
  118915. /**
  118916. * Registers the component in a given scene
  118917. */
  118918. register(): void;
  118919. /**
  118920. * Rebuilds the elements related to this component in case of
  118921. * context lost for instance.
  118922. */
  118923. rebuild(): void;
  118924. /**
  118925. * Serializes the component data to the specified json object
  118926. * @param serializationObject The object to serialize to
  118927. */
  118928. serialize(serializationObject: any): void;
  118929. /**
  118930. * Adds all the elements from the container to the scene
  118931. * @param container the container holding the elements
  118932. */
  118933. addFromContainer(container: AbstractScene): void;
  118934. /**
  118935. * Removes all the elements in the container from the scene
  118936. * @param container contains the elements to remove
  118937. * @param dispose if the removed element should be disposed (default: false)
  118938. */
  118939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118940. /**
  118941. * Disposes the component and the associated ressources.
  118942. */
  118943. dispose(): void;
  118944. /**
  118945. * Disables audio in the associated scene.
  118946. */
  118947. disableAudio(): void;
  118948. /**
  118949. * Enables audio in the associated scene.
  118950. */
  118951. enableAudio(): void;
  118952. /**
  118953. * Switch audio to headphone output.
  118954. */
  118955. switchAudioModeForHeadphones(): void;
  118956. /**
  118957. * Switch audio to normal speakers.
  118958. */
  118959. switchAudioModeForNormalSpeakers(): void;
  118960. private _cachedCameraDirection;
  118961. private _cachedCameraPosition;
  118962. private _lastCheck;
  118963. private _afterRender;
  118964. }
  118965. }
  118966. declare module BABYLON {
  118967. /**
  118968. * Wraps one or more Sound objects and selects one with random weight for playback.
  118969. */
  118970. export class WeightedSound {
  118971. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118972. loop: boolean;
  118973. private _coneInnerAngle;
  118974. private _coneOuterAngle;
  118975. private _volume;
  118976. /** A Sound is currently playing. */
  118977. isPlaying: boolean;
  118978. /** A Sound is currently paused. */
  118979. isPaused: boolean;
  118980. private _sounds;
  118981. private _weights;
  118982. private _currentIndex?;
  118983. /**
  118984. * Creates a new WeightedSound from the list of sounds given.
  118985. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118986. * @param sounds Array of Sounds that will be selected from.
  118987. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118988. */
  118989. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118990. /**
  118991. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118992. */
  118993. get directionalConeInnerAngle(): number;
  118994. /**
  118995. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118996. */
  118997. set directionalConeInnerAngle(value: number);
  118998. /**
  118999. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119000. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119001. */
  119002. get directionalConeOuterAngle(): number;
  119003. /**
  119004. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119005. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119006. */
  119007. set directionalConeOuterAngle(value: number);
  119008. /**
  119009. * Playback volume.
  119010. */
  119011. get volume(): number;
  119012. /**
  119013. * Playback volume.
  119014. */
  119015. set volume(value: number);
  119016. private _onended;
  119017. /**
  119018. * Suspend playback
  119019. */
  119020. pause(): void;
  119021. /**
  119022. * Stop playback
  119023. */
  119024. stop(): void;
  119025. /**
  119026. * Start playback.
  119027. * @param startOffset Position the clip head at a specific time in seconds.
  119028. */
  119029. play(startOffset?: number): void;
  119030. }
  119031. }
  119032. declare module BABYLON {
  119033. /**
  119034. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119036. */
  119037. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119038. /**
  119039. * Gets the name of the behavior.
  119040. */
  119041. get name(): string;
  119042. /**
  119043. * The easing function used by animations
  119044. */
  119045. static EasingFunction: BackEase;
  119046. /**
  119047. * The easing mode used by animations
  119048. */
  119049. static EasingMode: number;
  119050. /**
  119051. * The duration of the animation, in milliseconds
  119052. */
  119053. transitionDuration: number;
  119054. /**
  119055. * Length of the distance animated by the transition when lower radius is reached
  119056. */
  119057. lowerRadiusTransitionRange: number;
  119058. /**
  119059. * Length of the distance animated by the transition when upper radius is reached
  119060. */
  119061. upperRadiusTransitionRange: number;
  119062. private _autoTransitionRange;
  119063. /**
  119064. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119065. */
  119066. get autoTransitionRange(): boolean;
  119067. /**
  119068. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119069. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119070. */
  119071. set autoTransitionRange(value: boolean);
  119072. private _attachedCamera;
  119073. private _onAfterCheckInputsObserver;
  119074. private _onMeshTargetChangedObserver;
  119075. /**
  119076. * Initializes the behavior.
  119077. */
  119078. init(): void;
  119079. /**
  119080. * Attaches the behavior to its arc rotate camera.
  119081. * @param camera Defines the camera to attach the behavior to
  119082. */
  119083. attach(camera: ArcRotateCamera): void;
  119084. /**
  119085. * Detaches the behavior from its current arc rotate camera.
  119086. */
  119087. detach(): void;
  119088. private _radiusIsAnimating;
  119089. private _radiusBounceTransition;
  119090. private _animatables;
  119091. private _cachedWheelPrecision;
  119092. /**
  119093. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119094. * @param radiusLimit The limit to check against.
  119095. * @return Bool to indicate if at limit.
  119096. */
  119097. private _isRadiusAtLimit;
  119098. /**
  119099. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119100. * @param radiusDelta The delta by which to animate to. Can be negative.
  119101. */
  119102. private _applyBoundRadiusAnimation;
  119103. /**
  119104. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119105. */
  119106. protected _clearAnimationLocks(): void;
  119107. /**
  119108. * Stops and removes all animations that have been applied to the camera
  119109. */
  119110. stopAllAnimations(): void;
  119111. }
  119112. }
  119113. declare module BABYLON {
  119114. /**
  119115. * 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.
  119116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119117. */
  119118. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119119. /**
  119120. * Gets the name of the behavior.
  119121. */
  119122. get name(): string;
  119123. private _mode;
  119124. private _radiusScale;
  119125. private _positionScale;
  119126. private _defaultElevation;
  119127. private _elevationReturnTime;
  119128. private _elevationReturnWaitTime;
  119129. private _zoomStopsAnimation;
  119130. private _framingTime;
  119131. /**
  119132. * The easing function used by animations
  119133. */
  119134. static EasingFunction: ExponentialEase;
  119135. /**
  119136. * The easing mode used by animations
  119137. */
  119138. static EasingMode: number;
  119139. /**
  119140. * Sets the current mode used by the behavior
  119141. */
  119142. set mode(mode: number);
  119143. /**
  119144. * Gets current mode used by the behavior.
  119145. */
  119146. get mode(): number;
  119147. /**
  119148. * Sets the scale applied to the radius (1 by default)
  119149. */
  119150. set radiusScale(radius: number);
  119151. /**
  119152. * Gets the scale applied to the radius
  119153. */
  119154. get radiusScale(): number;
  119155. /**
  119156. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119157. */
  119158. set positionScale(scale: number);
  119159. /**
  119160. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119161. */
  119162. get positionScale(): number;
  119163. /**
  119164. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119165. * behaviour is triggered, in radians.
  119166. */
  119167. set defaultElevation(elevation: number);
  119168. /**
  119169. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119170. * behaviour is triggered, in radians.
  119171. */
  119172. get defaultElevation(): number;
  119173. /**
  119174. * Sets the time (in milliseconds) taken to return to the default beta position.
  119175. * Negative value indicates camera should not return to default.
  119176. */
  119177. set elevationReturnTime(speed: number);
  119178. /**
  119179. * Gets the time (in milliseconds) taken to return to the default beta position.
  119180. * Negative value indicates camera should not return to default.
  119181. */
  119182. get elevationReturnTime(): number;
  119183. /**
  119184. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119185. */
  119186. set elevationReturnWaitTime(time: number);
  119187. /**
  119188. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119189. */
  119190. get elevationReturnWaitTime(): number;
  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 transition time when framing the mesh, in milliseconds
  119201. */
  119202. set framingTime(time: number);
  119203. /**
  119204. * Gets the transition time when framing the mesh, in milliseconds
  119205. */
  119206. get framingTime(): number;
  119207. /**
  119208. * Define if the behavior should automatically change the configured
  119209. * camera limits and sensibilities.
  119210. */
  119211. autoCorrectCameraLimitsAndSensibility: boolean;
  119212. private _onPrePointerObservableObserver;
  119213. private _onAfterCheckInputsObserver;
  119214. private _onMeshTargetChangedObserver;
  119215. private _attachedCamera;
  119216. private _isPointerDown;
  119217. private _lastInteractionTime;
  119218. /**
  119219. * Initializes the behavior.
  119220. */
  119221. init(): void;
  119222. /**
  119223. * Attaches the behavior to its arc rotate camera.
  119224. * @param camera Defines the camera to attach the behavior to
  119225. */
  119226. attach(camera: ArcRotateCamera): void;
  119227. /**
  119228. * Detaches the behavior from its current arc rotate camera.
  119229. */
  119230. detach(): void;
  119231. private _animatables;
  119232. private _betaIsAnimating;
  119233. private _betaTransition;
  119234. private _radiusTransition;
  119235. private _vectorTransition;
  119236. /**
  119237. * Targets the given mesh and updates zoom level accordingly.
  119238. * @param mesh The mesh to target.
  119239. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119240. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119241. */
  119242. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119243. /**
  119244. * Targets the given mesh with its children and updates zoom level accordingly.
  119245. * @param mesh The mesh to target.
  119246. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119247. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119248. */
  119249. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119250. /**
  119251. * Targets the given meshes with their children and updates zoom level accordingly.
  119252. * @param meshes The mesh to target.
  119253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119255. */
  119256. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119257. /**
  119258. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119259. * @param minimumWorld Determines the smaller position of the bounding box extend
  119260. * @param maximumWorld Determines the bigger position of the bounding box extend
  119261. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119262. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119263. */
  119264. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119265. /**
  119266. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119267. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119268. * frustum width.
  119269. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119270. * to fully enclose the mesh in the viewing frustum.
  119271. */
  119272. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119273. /**
  119274. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119275. * is automatically returned to its default position (expected to be above ground plane).
  119276. */
  119277. private _maintainCameraAboveGround;
  119278. /**
  119279. * Returns the frustum slope based on the canvas ratio and camera FOV
  119280. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119281. */
  119282. private _getFrustumSlope;
  119283. /**
  119284. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119285. */
  119286. private _clearAnimationLocks;
  119287. /**
  119288. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119289. */
  119290. private _applyUserInteraction;
  119291. /**
  119292. * Stops and removes all animations that have been applied to the camera
  119293. */
  119294. stopAllAnimations(): void;
  119295. /**
  119296. * Gets a value indicating if the user is moving the camera
  119297. */
  119298. get isUserIsMoving(): boolean;
  119299. /**
  119300. * The camera can move all the way towards the mesh.
  119301. */
  119302. static IgnoreBoundsSizeMode: number;
  119303. /**
  119304. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119305. */
  119306. static FitFrustumSidesMode: number;
  119307. }
  119308. }
  119309. declare module BABYLON {
  119310. /**
  119311. * Base class for Camera Pointer Inputs.
  119312. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119313. * for example usage.
  119314. */
  119315. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119316. /**
  119317. * Defines the camera the input is attached to.
  119318. */
  119319. abstract camera: Camera;
  119320. /**
  119321. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119322. */
  119323. protected _altKey: boolean;
  119324. protected _ctrlKey: boolean;
  119325. protected _metaKey: boolean;
  119326. protected _shiftKey: boolean;
  119327. /**
  119328. * Which mouse buttons were pressed at time of last mouse event.
  119329. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119330. */
  119331. protected _buttonsPressed: number;
  119332. /**
  119333. * Defines the buttons associated with the input to handle camera move.
  119334. */
  119335. buttons: number[];
  119336. /**
  119337. * Attach the input controls to a specific dom element to get the input from.
  119338. * @param element Defines the element the controls should be listened from
  119339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119340. */
  119341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119342. /**
  119343. * Detach the current controls from the specified dom element.
  119344. * @param element Defines the element to stop listening the inputs from
  119345. */
  119346. detachControl(element: Nullable<HTMLElement>): void;
  119347. /**
  119348. * Gets the class name of the current input.
  119349. * @returns the class name
  119350. */
  119351. getClassName(): string;
  119352. /**
  119353. * Get the friendly name associated with the input class.
  119354. * @returns the input friendly name
  119355. */
  119356. getSimpleName(): string;
  119357. /**
  119358. * Called on pointer POINTERDOUBLETAP event.
  119359. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119360. */
  119361. protected onDoubleTap(type: string): void;
  119362. /**
  119363. * Called on pointer POINTERMOVE event if only a single touch is active.
  119364. * Override this method to provide functionality.
  119365. */
  119366. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119367. /**
  119368. * Called on pointer POINTERMOVE event if multiple touches are active.
  119369. * Override this method to provide functionality.
  119370. */
  119371. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119372. /**
  119373. * Called on JS contextmenu event.
  119374. * Override this method to provide functionality.
  119375. */
  119376. protected onContextMenu(evt: PointerEvent): void;
  119377. /**
  119378. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119379. * press.
  119380. * Override this method to provide functionality.
  119381. */
  119382. protected onButtonDown(evt: PointerEvent): void;
  119383. /**
  119384. * Called each time a new POINTERUP event occurs. Ie, for each button
  119385. * release.
  119386. * Override this method to provide functionality.
  119387. */
  119388. protected onButtonUp(evt: PointerEvent): void;
  119389. /**
  119390. * Called when window becomes inactive.
  119391. * Override this method to provide functionality.
  119392. */
  119393. protected onLostFocus(): void;
  119394. private _pointerInput;
  119395. private _observer;
  119396. private _onLostFocus;
  119397. private pointA;
  119398. private pointB;
  119399. }
  119400. }
  119401. declare module BABYLON {
  119402. /**
  119403. * Manage the pointers inputs to control an arc rotate camera.
  119404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119405. */
  119406. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119407. /**
  119408. * Defines the camera the input is attached to.
  119409. */
  119410. camera: ArcRotateCamera;
  119411. /**
  119412. * Gets the class name of the current input.
  119413. * @returns the class name
  119414. */
  119415. getClassName(): string;
  119416. /**
  119417. * Defines the buttons associated with the input to handle camera move.
  119418. */
  119419. buttons: number[];
  119420. /**
  119421. * Defines the pointer angular sensibility along the X axis or how fast is
  119422. * the camera rotating.
  119423. */
  119424. angularSensibilityX: number;
  119425. /**
  119426. * Defines the pointer angular sensibility along the Y axis or how fast is
  119427. * the camera rotating.
  119428. */
  119429. angularSensibilityY: number;
  119430. /**
  119431. * Defines the pointer pinch precision or how fast is the camera zooming.
  119432. */
  119433. pinchPrecision: number;
  119434. /**
  119435. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119436. * from 0.
  119437. * It defines the percentage of current camera.radius to use as delta when
  119438. * pinch zoom is used.
  119439. */
  119440. pinchDeltaPercentage: number;
  119441. /**
  119442. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119443. * that any object in the plane at the camera's target point will scale
  119444. * perfectly with finger motion.
  119445. * Overrides pinchDeltaPercentage and pinchPrecision.
  119446. */
  119447. useNaturalPinchZoom: boolean;
  119448. /**
  119449. * Defines the pointer panning sensibility or how fast is the camera moving.
  119450. */
  119451. panningSensibility: number;
  119452. /**
  119453. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119454. */
  119455. multiTouchPanning: boolean;
  119456. /**
  119457. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119458. * zoom (pinch) through multitouch.
  119459. */
  119460. multiTouchPanAndZoom: boolean;
  119461. /**
  119462. * Revers pinch action direction.
  119463. */
  119464. pinchInwards: boolean;
  119465. private _isPanClick;
  119466. private _twoFingerActivityCount;
  119467. private _isPinching;
  119468. /**
  119469. * Called on pointer POINTERMOVE event if only a single touch is active.
  119470. */
  119471. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119472. /**
  119473. * Called on pointer POINTERDOUBLETAP event.
  119474. */
  119475. protected onDoubleTap(type: string): void;
  119476. /**
  119477. * Called on pointer POINTERMOVE event if multiple touches are active.
  119478. */
  119479. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119480. /**
  119481. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119482. * press.
  119483. */
  119484. protected onButtonDown(evt: PointerEvent): void;
  119485. /**
  119486. * Called each time a new POINTERUP event occurs. Ie, for each button
  119487. * release.
  119488. */
  119489. protected onButtonUp(evt: PointerEvent): void;
  119490. /**
  119491. * Called when window becomes inactive.
  119492. */
  119493. protected onLostFocus(): void;
  119494. }
  119495. }
  119496. declare module BABYLON {
  119497. /**
  119498. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119500. */
  119501. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119502. /**
  119503. * Defines the camera the input is attached to.
  119504. */
  119505. camera: ArcRotateCamera;
  119506. /**
  119507. * Defines the list of key codes associated with the up action (increase alpha)
  119508. */
  119509. keysUp: number[];
  119510. /**
  119511. * Defines the list of key codes associated with the down action (decrease alpha)
  119512. */
  119513. keysDown: number[];
  119514. /**
  119515. * Defines the list of key codes associated with the left action (increase beta)
  119516. */
  119517. keysLeft: number[];
  119518. /**
  119519. * Defines the list of key codes associated with the right action (decrease beta)
  119520. */
  119521. keysRight: number[];
  119522. /**
  119523. * Defines the list of key codes associated with the reset action.
  119524. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119525. */
  119526. keysReset: number[];
  119527. /**
  119528. * Defines the panning sensibility of the inputs.
  119529. * (How fast is the camera panning)
  119530. */
  119531. panningSensibility: number;
  119532. /**
  119533. * Defines the zooming sensibility of the inputs.
  119534. * (How fast is the camera zooming)
  119535. */
  119536. zoomingSensibility: number;
  119537. /**
  119538. * Defines whether maintaining the alt key down switch the movement mode from
  119539. * orientation to zoom.
  119540. */
  119541. useAltToZoom: boolean;
  119542. /**
  119543. * Rotation speed of the camera
  119544. */
  119545. angularSpeed: number;
  119546. private _keys;
  119547. private _ctrlPressed;
  119548. private _altPressed;
  119549. private _onCanvasBlurObserver;
  119550. private _onKeyboardObserver;
  119551. private _engine;
  119552. private _scene;
  119553. /**
  119554. * Attach the input controls to a specific dom element to get the input from.
  119555. * @param element Defines the element the controls should be listened from
  119556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119557. */
  119558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119559. /**
  119560. * Detach the current controls from the specified dom element.
  119561. * @param element Defines the element to stop listening the inputs from
  119562. */
  119563. detachControl(element: Nullable<HTMLElement>): void;
  119564. /**
  119565. * Update the current camera state depending on the inputs that have been used this frame.
  119566. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119567. */
  119568. checkInputs(): void;
  119569. /**
  119570. * Gets the class name of the current intput.
  119571. * @returns the class name
  119572. */
  119573. getClassName(): string;
  119574. /**
  119575. * Get the friendly name associated with the input class.
  119576. * @returns the input friendly name
  119577. */
  119578. getSimpleName(): string;
  119579. }
  119580. }
  119581. declare module BABYLON {
  119582. /**
  119583. * Manage the mouse wheel inputs to control an arc rotate camera.
  119584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119585. */
  119586. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119587. /**
  119588. * Defines the camera the input is attached to.
  119589. */
  119590. camera: ArcRotateCamera;
  119591. /**
  119592. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119593. */
  119594. wheelPrecision: number;
  119595. /**
  119596. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119597. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119598. */
  119599. wheelDeltaPercentage: number;
  119600. private _wheel;
  119601. private _observer;
  119602. private computeDeltaFromMouseWheelLegacyEvent;
  119603. /**
  119604. * Attach the input controls to a specific dom element to get the input from.
  119605. * @param element Defines the element the controls should be listened from
  119606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119607. */
  119608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119609. /**
  119610. * Detach the current controls from the specified dom element.
  119611. * @param element Defines the element to stop listening the inputs from
  119612. */
  119613. detachControl(element: Nullable<HTMLElement>): void;
  119614. /**
  119615. * Gets the class name of the current intput.
  119616. * @returns the class name
  119617. */
  119618. getClassName(): string;
  119619. /**
  119620. * Get the friendly name associated with the input class.
  119621. * @returns the input friendly name
  119622. */
  119623. getSimpleName(): string;
  119624. }
  119625. }
  119626. declare module BABYLON {
  119627. /**
  119628. * Default Inputs manager for the ArcRotateCamera.
  119629. * It groups all the default supported inputs for ease of use.
  119630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119631. */
  119632. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119633. /**
  119634. * Instantiates a new ArcRotateCameraInputsManager.
  119635. * @param camera Defines the camera the inputs belong to
  119636. */
  119637. constructor(camera: ArcRotateCamera);
  119638. /**
  119639. * Add mouse wheel input support to the input manager.
  119640. * @returns the current input manager
  119641. */
  119642. addMouseWheel(): ArcRotateCameraInputsManager;
  119643. /**
  119644. * Add pointers input support to the input manager.
  119645. * @returns the current input manager
  119646. */
  119647. addPointers(): ArcRotateCameraInputsManager;
  119648. /**
  119649. * Add keyboard input support to the input manager.
  119650. * @returns the current input manager
  119651. */
  119652. addKeyboard(): ArcRotateCameraInputsManager;
  119653. }
  119654. }
  119655. declare module BABYLON {
  119656. /**
  119657. * This represents an orbital type of camera.
  119658. *
  119659. * 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.
  119660. * 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.
  119661. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119662. */
  119663. export class ArcRotateCamera extends TargetCamera {
  119664. /**
  119665. * Defines the rotation angle of the camera along the longitudinal axis.
  119666. */
  119667. alpha: number;
  119668. /**
  119669. * Defines the rotation angle of the camera along the latitudinal axis.
  119670. */
  119671. beta: number;
  119672. /**
  119673. * Defines the radius of the camera from it s target point.
  119674. */
  119675. radius: number;
  119676. protected _target: Vector3;
  119677. protected _targetHost: Nullable<AbstractMesh>;
  119678. /**
  119679. * Defines the target point of the camera.
  119680. * The camera looks towards it form the radius distance.
  119681. */
  119682. get target(): Vector3;
  119683. set target(value: Vector3);
  119684. /**
  119685. * Define the current local position of the camera in the scene
  119686. */
  119687. get position(): Vector3;
  119688. set position(newPosition: Vector3);
  119689. protected _upVector: Vector3;
  119690. protected _upToYMatrix: Matrix;
  119691. protected _YToUpMatrix: Matrix;
  119692. /**
  119693. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119694. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119695. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119696. */
  119697. set upVector(vec: Vector3);
  119698. get upVector(): Vector3;
  119699. /**
  119700. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119701. */
  119702. setMatUp(): void;
  119703. /**
  119704. * Current inertia value on the longitudinal axis.
  119705. * The bigger this number the longer it will take for the camera to stop.
  119706. */
  119707. inertialAlphaOffset: number;
  119708. /**
  119709. * Current inertia value on the latitudinal axis.
  119710. * The bigger this number the longer it will take for the camera to stop.
  119711. */
  119712. inertialBetaOffset: number;
  119713. /**
  119714. * Current inertia value on the radius axis.
  119715. * The bigger this number the longer it will take for the camera to stop.
  119716. */
  119717. inertialRadiusOffset: number;
  119718. /**
  119719. * Minimum allowed angle on the longitudinal axis.
  119720. * This can help limiting how the Camera is able to move in the scene.
  119721. */
  119722. lowerAlphaLimit: Nullable<number>;
  119723. /**
  119724. * Maximum allowed angle on the longitudinal axis.
  119725. * This can help limiting how the Camera is able to move in the scene.
  119726. */
  119727. upperAlphaLimit: Nullable<number>;
  119728. /**
  119729. * Minimum allowed angle on the latitudinal axis.
  119730. * This can help limiting how the Camera is able to move in the scene.
  119731. */
  119732. lowerBetaLimit: number;
  119733. /**
  119734. * Maximum allowed angle on the latitudinal axis.
  119735. * This can help limiting how the Camera is able to move in the scene.
  119736. */
  119737. upperBetaLimit: number;
  119738. /**
  119739. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119740. * This can help limiting how the Camera is able to move in the scene.
  119741. */
  119742. lowerRadiusLimit: Nullable<number>;
  119743. /**
  119744. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119745. * This can help limiting how the Camera is able to move in the scene.
  119746. */
  119747. upperRadiusLimit: Nullable<number>;
  119748. /**
  119749. * Defines the current inertia value used during panning of the camera along the X axis.
  119750. */
  119751. inertialPanningX: number;
  119752. /**
  119753. * Defines the current inertia value used during panning of the camera along the Y axis.
  119754. */
  119755. inertialPanningY: number;
  119756. /**
  119757. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119758. * Basically if your fingers moves away from more than this distance you will be considered
  119759. * in pinch mode.
  119760. */
  119761. pinchToPanMaxDistance: number;
  119762. /**
  119763. * Defines the maximum distance the camera can pan.
  119764. * This could help keeping the cammera always in your scene.
  119765. */
  119766. panningDistanceLimit: Nullable<number>;
  119767. /**
  119768. * Defines the target of the camera before paning.
  119769. */
  119770. panningOriginTarget: Vector3;
  119771. /**
  119772. * Defines the value of the inertia used during panning.
  119773. * 0 would mean stop inertia and one would mean no decelleration at all.
  119774. */
  119775. panningInertia: number;
  119776. /**
  119777. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119778. */
  119779. get angularSensibilityX(): number;
  119780. set angularSensibilityX(value: number);
  119781. /**
  119782. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119783. */
  119784. get angularSensibilityY(): number;
  119785. set angularSensibilityY(value: number);
  119786. /**
  119787. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119788. */
  119789. get pinchPrecision(): number;
  119790. set pinchPrecision(value: number);
  119791. /**
  119792. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119793. * It will be used instead of pinchDeltaPrecision if different from 0.
  119794. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119795. */
  119796. get pinchDeltaPercentage(): number;
  119797. set pinchDeltaPercentage(value: number);
  119798. /**
  119799. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119800. * and pinch delta percentage.
  119801. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119802. * that any object in the plane at the camera's target point will scale
  119803. * perfectly with finger motion.
  119804. */
  119805. get useNaturalPinchZoom(): boolean;
  119806. set useNaturalPinchZoom(value: boolean);
  119807. /**
  119808. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119809. */
  119810. get panningSensibility(): number;
  119811. set panningSensibility(value: number);
  119812. /**
  119813. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119814. */
  119815. get keysUp(): number[];
  119816. set keysUp(value: number[]);
  119817. /**
  119818. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119819. */
  119820. get keysDown(): number[];
  119821. set keysDown(value: number[]);
  119822. /**
  119823. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119824. */
  119825. get keysLeft(): number[];
  119826. set keysLeft(value: number[]);
  119827. /**
  119828. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119829. */
  119830. get keysRight(): number[];
  119831. set keysRight(value: number[]);
  119832. /**
  119833. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119834. */
  119835. get wheelPrecision(): number;
  119836. set wheelPrecision(value: number);
  119837. /**
  119838. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119839. * It will be used instead of pinchDeltaPrecision if different from 0.
  119840. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119841. */
  119842. get wheelDeltaPercentage(): number;
  119843. set wheelDeltaPercentage(value: number);
  119844. /**
  119845. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119846. */
  119847. zoomOnFactor: number;
  119848. /**
  119849. * Defines a screen offset for the camera position.
  119850. */
  119851. targetScreenOffset: Vector2;
  119852. /**
  119853. * Allows the camera to be completely reversed.
  119854. * If false the camera can not arrive upside down.
  119855. */
  119856. allowUpsideDown: boolean;
  119857. /**
  119858. * Define if double tap/click is used to restore the previously saved state of the camera.
  119859. */
  119860. useInputToRestoreState: boolean;
  119861. /** @hidden */
  119862. _viewMatrix: Matrix;
  119863. /** @hidden */
  119864. _useCtrlForPanning: boolean;
  119865. /** @hidden */
  119866. _panningMouseButton: number;
  119867. /**
  119868. * Defines the input associated to the camera.
  119869. */
  119870. inputs: ArcRotateCameraInputsManager;
  119871. /** @hidden */
  119872. _reset: () => void;
  119873. /**
  119874. * Defines the allowed panning axis.
  119875. */
  119876. panningAxis: Vector3;
  119877. protected _localDirection: Vector3;
  119878. protected _transformedDirection: Vector3;
  119879. private _bouncingBehavior;
  119880. /**
  119881. * Gets the bouncing behavior of the camera if it has been enabled.
  119882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119883. */
  119884. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119885. /**
  119886. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119888. */
  119889. get useBouncingBehavior(): boolean;
  119890. set useBouncingBehavior(value: boolean);
  119891. private _framingBehavior;
  119892. /**
  119893. * Gets the framing behavior of the camera if it has been enabled.
  119894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119895. */
  119896. get framingBehavior(): Nullable<FramingBehavior>;
  119897. /**
  119898. * Defines if the framing behavior of the camera is enabled on the camera.
  119899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119900. */
  119901. get useFramingBehavior(): boolean;
  119902. set useFramingBehavior(value: boolean);
  119903. private _autoRotationBehavior;
  119904. /**
  119905. * Gets the auto rotation behavior of the camera if it has been enabled.
  119906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119907. */
  119908. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119909. /**
  119910. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119911. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119912. */
  119913. get useAutoRotationBehavior(): boolean;
  119914. set useAutoRotationBehavior(value: boolean);
  119915. /**
  119916. * Observable triggered when the mesh target has been changed on the camera.
  119917. */
  119918. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119919. /**
  119920. * Event raised when the camera is colliding with a mesh.
  119921. */
  119922. onCollide: (collidedMesh: AbstractMesh) => void;
  119923. /**
  119924. * Defines whether the camera should check collision with the objects oh the scene.
  119925. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119926. */
  119927. checkCollisions: boolean;
  119928. /**
  119929. * Defines the collision radius of the camera.
  119930. * This simulates a sphere around the camera.
  119931. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119932. */
  119933. collisionRadius: Vector3;
  119934. protected _collider: Collider;
  119935. protected _previousPosition: Vector3;
  119936. protected _collisionVelocity: Vector3;
  119937. protected _newPosition: Vector3;
  119938. protected _previousAlpha: number;
  119939. protected _previousBeta: number;
  119940. protected _previousRadius: number;
  119941. protected _collisionTriggered: boolean;
  119942. protected _targetBoundingCenter: Nullable<Vector3>;
  119943. private _computationVector;
  119944. /**
  119945. * Instantiates a new ArcRotateCamera in a given scene
  119946. * @param name Defines the name of the camera
  119947. * @param alpha Defines the camera rotation along the logitudinal axis
  119948. * @param beta Defines the camera rotation along the latitudinal axis
  119949. * @param radius Defines the camera distance from its target
  119950. * @param target Defines the camera target
  119951. * @param scene Defines the scene the camera belongs to
  119952. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119953. */
  119954. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119955. /** @hidden */
  119956. _initCache(): void;
  119957. /** @hidden */
  119958. _updateCache(ignoreParentClass?: boolean): void;
  119959. protected _getTargetPosition(): Vector3;
  119960. private _storedAlpha;
  119961. private _storedBeta;
  119962. private _storedRadius;
  119963. private _storedTarget;
  119964. private _storedTargetScreenOffset;
  119965. /**
  119966. * Stores the current state of the camera (alpha, beta, radius and target)
  119967. * @returns the camera itself
  119968. */
  119969. storeState(): Camera;
  119970. /**
  119971. * @hidden
  119972. * Restored camera state. You must call storeState() first
  119973. */
  119974. _restoreStateValues(): boolean;
  119975. /** @hidden */
  119976. _isSynchronizedViewMatrix(): boolean;
  119977. /**
  119978. * Attached controls to the current camera.
  119979. * @param element Defines the element the controls should be listened from
  119980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119981. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119982. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119983. */
  119984. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119985. /**
  119986. * Detach the current controls from the camera.
  119987. * The camera will stop reacting to inputs.
  119988. * @param element Defines the element to stop listening the inputs from
  119989. */
  119990. detachControl(element: HTMLElement): void;
  119991. /** @hidden */
  119992. _checkInputs(): void;
  119993. protected _checkLimits(): void;
  119994. /**
  119995. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119996. */
  119997. rebuildAnglesAndRadius(): void;
  119998. /**
  119999. * Use a position to define the current camera related information like alpha, beta and radius
  120000. * @param position Defines the position to set the camera at
  120001. */
  120002. setPosition(position: Vector3): void;
  120003. /**
  120004. * Defines the target the camera should look at.
  120005. * This will automatically adapt alpha beta and radius to fit within the new target.
  120006. * @param target Defines the new target as a Vector or a mesh
  120007. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120008. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120009. */
  120010. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120011. /** @hidden */
  120012. _getViewMatrix(): Matrix;
  120013. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120014. /**
  120015. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120016. * @param meshes Defines the mesh to zoom on
  120017. * @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)
  120018. */
  120019. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120020. /**
  120021. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120022. * The target will be changed but the radius
  120023. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120024. * @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)
  120025. */
  120026. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120027. min: Vector3;
  120028. max: Vector3;
  120029. distance: number;
  120030. }, doNotUpdateMaxZ?: boolean): void;
  120031. /**
  120032. * @override
  120033. * Override Camera.createRigCamera
  120034. */
  120035. createRigCamera(name: string, cameraIndex: number): Camera;
  120036. /**
  120037. * @hidden
  120038. * @override
  120039. * Override Camera._updateRigCameras
  120040. */
  120041. _updateRigCameras(): void;
  120042. /**
  120043. * Destroy the camera and release the current resources hold by it.
  120044. */
  120045. dispose(): void;
  120046. /**
  120047. * Gets the current object class name.
  120048. * @return the class name
  120049. */
  120050. getClassName(): string;
  120051. }
  120052. }
  120053. declare module BABYLON {
  120054. /**
  120055. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120057. */
  120058. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120059. /**
  120060. * Gets the name of the behavior.
  120061. */
  120062. get name(): string;
  120063. private _zoomStopsAnimation;
  120064. private _idleRotationSpeed;
  120065. private _idleRotationWaitTime;
  120066. private _idleRotationSpinupTime;
  120067. /**
  120068. * Sets the flag that indicates if user zooming should stop animation.
  120069. */
  120070. set zoomStopsAnimation(flag: boolean);
  120071. /**
  120072. * Gets the flag that indicates if user zooming should stop animation.
  120073. */
  120074. get zoomStopsAnimation(): boolean;
  120075. /**
  120076. * Sets the default speed at which the camera rotates around the model.
  120077. */
  120078. set idleRotationSpeed(speed: number);
  120079. /**
  120080. * Gets the default speed at which the camera rotates around the model.
  120081. */
  120082. get idleRotationSpeed(): number;
  120083. /**
  120084. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120085. */
  120086. set idleRotationWaitTime(time: number);
  120087. /**
  120088. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120089. */
  120090. get idleRotationWaitTime(): number;
  120091. /**
  120092. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120093. */
  120094. set idleRotationSpinupTime(time: number);
  120095. /**
  120096. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120097. */
  120098. get idleRotationSpinupTime(): number;
  120099. /**
  120100. * Gets a value indicating if the camera is currently rotating because of this behavior
  120101. */
  120102. get rotationInProgress(): boolean;
  120103. private _onPrePointerObservableObserver;
  120104. private _onAfterCheckInputsObserver;
  120105. private _attachedCamera;
  120106. private _isPointerDown;
  120107. private _lastFrameTime;
  120108. private _lastInteractionTime;
  120109. private _cameraRotationSpeed;
  120110. /**
  120111. * Initializes the behavior.
  120112. */
  120113. init(): void;
  120114. /**
  120115. * Attaches the behavior to its arc rotate camera.
  120116. * @param camera Defines the camera to attach the behavior to
  120117. */
  120118. attach(camera: ArcRotateCamera): void;
  120119. /**
  120120. * Detaches the behavior from its current arc rotate camera.
  120121. */
  120122. detach(): void;
  120123. /**
  120124. * Returns true if user is scrolling.
  120125. * @return true if user is scrolling.
  120126. */
  120127. private _userIsZooming;
  120128. private _lastFrameRadius;
  120129. private _shouldAnimationStopForInteraction;
  120130. /**
  120131. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120132. */
  120133. private _applyUserInteraction;
  120134. private _userIsMoving;
  120135. }
  120136. }
  120137. declare module BABYLON {
  120138. /**
  120139. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120140. */
  120141. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120142. private ui;
  120143. /**
  120144. * The name of the behavior
  120145. */
  120146. name: string;
  120147. /**
  120148. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120149. */
  120150. distanceAwayFromFace: number;
  120151. /**
  120152. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120153. */
  120154. distanceAwayFromBottomOfFace: number;
  120155. private _faceVectors;
  120156. private _target;
  120157. private _scene;
  120158. private _onRenderObserver;
  120159. private _tmpMatrix;
  120160. private _tmpVector;
  120161. /**
  120162. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120163. * @param ui The transform node that should be attched to the mesh
  120164. */
  120165. constructor(ui: TransformNode);
  120166. /**
  120167. * Initializes the behavior
  120168. */
  120169. init(): void;
  120170. private _closestFace;
  120171. private _zeroVector;
  120172. private _lookAtTmpMatrix;
  120173. private _lookAtToRef;
  120174. /**
  120175. * Attaches the AttachToBoxBehavior to the passed in mesh
  120176. * @param target The mesh that the specified node will be attached to
  120177. */
  120178. attach(target: Mesh): void;
  120179. /**
  120180. * Detaches the behavior from the mesh
  120181. */
  120182. detach(): void;
  120183. }
  120184. }
  120185. declare module BABYLON {
  120186. /**
  120187. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120188. */
  120189. export class FadeInOutBehavior implements Behavior<Mesh> {
  120190. /**
  120191. * Time in milliseconds to delay before fading in (Default: 0)
  120192. */
  120193. delay: number;
  120194. /**
  120195. * Time in milliseconds for the mesh to fade in (Default: 300)
  120196. */
  120197. fadeInTime: number;
  120198. private _millisecondsPerFrame;
  120199. private _hovered;
  120200. private _hoverValue;
  120201. private _ownerNode;
  120202. /**
  120203. * Instatiates the FadeInOutBehavior
  120204. */
  120205. constructor();
  120206. /**
  120207. * The name of the behavior
  120208. */
  120209. get name(): string;
  120210. /**
  120211. * Initializes the behavior
  120212. */
  120213. init(): void;
  120214. /**
  120215. * Attaches the fade behavior on the passed in mesh
  120216. * @param ownerNode The mesh that will be faded in/out once attached
  120217. */
  120218. attach(ownerNode: Mesh): void;
  120219. /**
  120220. * Detaches the behavior from the mesh
  120221. */
  120222. detach(): void;
  120223. /**
  120224. * Triggers the mesh to begin fading in or out
  120225. * @param value if the object should fade in or out (true to fade in)
  120226. */
  120227. fadeIn(value: boolean): void;
  120228. private _update;
  120229. private _setAllVisibility;
  120230. }
  120231. }
  120232. declare module BABYLON {
  120233. /**
  120234. * Class containing a set of static utilities functions for managing Pivots
  120235. * @hidden
  120236. */
  120237. export class PivotTools {
  120238. private static _PivotCached;
  120239. private static _OldPivotPoint;
  120240. private static _PivotTranslation;
  120241. private static _PivotTmpVector;
  120242. /** @hidden */
  120243. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120244. /** @hidden */
  120245. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120246. }
  120247. }
  120248. declare module BABYLON {
  120249. /**
  120250. * Class containing static functions to help procedurally build meshes
  120251. */
  120252. export class PlaneBuilder {
  120253. /**
  120254. * Creates a plane mesh
  120255. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120256. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120257. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120261. * @param name defines the name of the mesh
  120262. * @param options defines the options used to create the mesh
  120263. * @param scene defines the hosting scene
  120264. * @returns the plane mesh
  120265. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120266. */
  120267. static CreatePlane(name: string, options: {
  120268. size?: number;
  120269. width?: number;
  120270. height?: number;
  120271. sideOrientation?: number;
  120272. frontUVs?: Vector4;
  120273. backUVs?: Vector4;
  120274. updatable?: boolean;
  120275. sourcePlane?: Plane;
  120276. }, scene?: Nullable<Scene>): Mesh;
  120277. }
  120278. }
  120279. declare module BABYLON {
  120280. /**
  120281. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120282. */
  120283. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120284. private static _AnyMouseID;
  120285. /**
  120286. * Abstract mesh the behavior is set on
  120287. */
  120288. attachedNode: AbstractMesh;
  120289. private _dragPlane;
  120290. private _scene;
  120291. private _pointerObserver;
  120292. private _beforeRenderObserver;
  120293. private static _planeScene;
  120294. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120295. /**
  120296. * 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)
  120297. */
  120298. maxDragAngle: number;
  120299. /**
  120300. * @hidden
  120301. */
  120302. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120303. /**
  120304. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120305. */
  120306. currentDraggingPointerID: number;
  120307. /**
  120308. * The last position where the pointer hit the drag plane in world space
  120309. */
  120310. lastDragPosition: Vector3;
  120311. /**
  120312. * If the behavior is currently in a dragging state
  120313. */
  120314. dragging: boolean;
  120315. /**
  120316. * 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)
  120317. */
  120318. dragDeltaRatio: number;
  120319. /**
  120320. * If the drag plane orientation should be updated during the dragging (Default: true)
  120321. */
  120322. updateDragPlane: boolean;
  120323. private _debugMode;
  120324. private _moving;
  120325. /**
  120326. * Fires each time the attached mesh is dragged with the pointer
  120327. * * delta between last drag position and current drag position in world space
  120328. * * dragDistance along the drag axis
  120329. * * dragPlaneNormal normal of the current drag plane used during the drag
  120330. * * dragPlanePoint in world space where the drag intersects the drag plane
  120331. */
  120332. onDragObservable: Observable<{
  120333. delta: Vector3;
  120334. dragPlanePoint: Vector3;
  120335. dragPlaneNormal: Vector3;
  120336. dragDistance: number;
  120337. pointerId: number;
  120338. }>;
  120339. /**
  120340. * Fires each time a drag begins (eg. mouse down on mesh)
  120341. */
  120342. onDragStartObservable: Observable<{
  120343. dragPlanePoint: Vector3;
  120344. pointerId: number;
  120345. }>;
  120346. /**
  120347. * Fires each time a drag ends (eg. mouse release after drag)
  120348. */
  120349. onDragEndObservable: Observable<{
  120350. dragPlanePoint: Vector3;
  120351. pointerId: number;
  120352. }>;
  120353. /**
  120354. * If the attached mesh should be moved when dragged
  120355. */
  120356. moveAttached: boolean;
  120357. /**
  120358. * If the drag behavior will react to drag events (Default: true)
  120359. */
  120360. enabled: boolean;
  120361. /**
  120362. * If pointer events should start and release the drag (Default: true)
  120363. */
  120364. startAndReleaseDragOnPointerEvents: boolean;
  120365. /**
  120366. * If camera controls should be detached during the drag
  120367. */
  120368. detachCameraControls: boolean;
  120369. /**
  120370. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120371. */
  120372. useObjectOrientationForDragging: boolean;
  120373. private _options;
  120374. /**
  120375. * Gets the options used by the behavior
  120376. */
  120377. get options(): {
  120378. dragAxis?: Vector3;
  120379. dragPlaneNormal?: Vector3;
  120380. };
  120381. /**
  120382. * Sets the options used by the behavior
  120383. */
  120384. set options(options: {
  120385. dragAxis?: Vector3;
  120386. dragPlaneNormal?: Vector3;
  120387. });
  120388. /**
  120389. * Creates a pointer drag behavior that can be attached to a mesh
  120390. * @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)
  120391. */
  120392. constructor(options?: {
  120393. dragAxis?: Vector3;
  120394. dragPlaneNormal?: Vector3;
  120395. });
  120396. /**
  120397. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120398. */
  120399. validateDrag: (targetPosition: Vector3) => boolean;
  120400. /**
  120401. * The name of the behavior
  120402. */
  120403. get name(): string;
  120404. /**
  120405. * Initializes the behavior
  120406. */
  120407. init(): void;
  120408. private _tmpVector;
  120409. private _alternatePickedPoint;
  120410. private _worldDragAxis;
  120411. private _targetPosition;
  120412. private _attachedElement;
  120413. /**
  120414. * Attaches the drag behavior the passed in mesh
  120415. * @param ownerNode The mesh that will be dragged around once attached
  120416. * @param predicate Predicate to use for pick filtering
  120417. */
  120418. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120419. /**
  120420. * Force relase the drag action by code.
  120421. */
  120422. releaseDrag(): void;
  120423. private _startDragRay;
  120424. private _lastPointerRay;
  120425. /**
  120426. * Simulates the start of a pointer drag event on the behavior
  120427. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120428. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120429. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120430. */
  120431. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120432. private _startDrag;
  120433. private _dragDelta;
  120434. private _moveDrag;
  120435. private _pickWithRayOnDragPlane;
  120436. private _pointA;
  120437. private _pointB;
  120438. private _pointC;
  120439. private _lineA;
  120440. private _lineB;
  120441. private _localAxis;
  120442. private _lookAt;
  120443. private _updateDragPlanePosition;
  120444. /**
  120445. * Detaches the behavior from the mesh
  120446. */
  120447. detach(): void;
  120448. }
  120449. }
  120450. declare module BABYLON {
  120451. /**
  120452. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120453. */
  120454. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120455. private _dragBehaviorA;
  120456. private _dragBehaviorB;
  120457. private _startDistance;
  120458. private _initialScale;
  120459. private _targetScale;
  120460. private _ownerNode;
  120461. private _sceneRenderObserver;
  120462. /**
  120463. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120464. */
  120465. constructor();
  120466. /**
  120467. * The name of the behavior
  120468. */
  120469. get name(): string;
  120470. /**
  120471. * Initializes the behavior
  120472. */
  120473. init(): void;
  120474. private _getCurrentDistance;
  120475. /**
  120476. * Attaches the scale behavior the passed in mesh
  120477. * @param ownerNode The mesh that will be scaled around once attached
  120478. */
  120479. attach(ownerNode: Mesh): void;
  120480. /**
  120481. * Detaches the behavior from the mesh
  120482. */
  120483. detach(): void;
  120484. }
  120485. }
  120486. declare module BABYLON {
  120487. /**
  120488. * 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
  120489. */
  120490. export class SixDofDragBehavior implements Behavior<Mesh> {
  120491. private static _virtualScene;
  120492. private _ownerNode;
  120493. private _sceneRenderObserver;
  120494. private _scene;
  120495. private _targetPosition;
  120496. private _virtualOriginMesh;
  120497. private _virtualDragMesh;
  120498. private _pointerObserver;
  120499. private _moving;
  120500. private _startingOrientation;
  120501. private _attachedElement;
  120502. /**
  120503. * 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)
  120504. */
  120505. private zDragFactor;
  120506. /**
  120507. * If the object should rotate to face the drag origin
  120508. */
  120509. rotateDraggedObject: boolean;
  120510. /**
  120511. * If the behavior is currently in a dragging state
  120512. */
  120513. dragging: boolean;
  120514. /**
  120515. * 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)
  120516. */
  120517. dragDeltaRatio: number;
  120518. /**
  120519. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120520. */
  120521. currentDraggingPointerID: number;
  120522. /**
  120523. * If camera controls should be detached during the drag
  120524. */
  120525. detachCameraControls: boolean;
  120526. /**
  120527. * Fires each time a drag starts
  120528. */
  120529. onDragStartObservable: Observable<{}>;
  120530. /**
  120531. * Fires each time a drag ends (eg. mouse release after drag)
  120532. */
  120533. onDragEndObservable: Observable<{}>;
  120534. /**
  120535. * 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
  120536. */
  120537. constructor();
  120538. /**
  120539. * The name of the behavior
  120540. */
  120541. get name(): string;
  120542. /**
  120543. * Initializes the behavior
  120544. */
  120545. init(): void;
  120546. /**
  120547. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120548. */
  120549. private get _pointerCamera();
  120550. /**
  120551. * Attaches the scale behavior the passed in mesh
  120552. * @param ownerNode The mesh that will be scaled around once attached
  120553. */
  120554. attach(ownerNode: Mesh): void;
  120555. /**
  120556. * Detaches the behavior from the mesh
  120557. */
  120558. detach(): void;
  120559. }
  120560. }
  120561. declare module BABYLON {
  120562. /**
  120563. * Class used to apply inverse kinematics to bones
  120564. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120565. */
  120566. export class BoneIKController {
  120567. private static _tmpVecs;
  120568. private static _tmpQuat;
  120569. private static _tmpMats;
  120570. /**
  120571. * Gets or sets the target mesh
  120572. */
  120573. targetMesh: AbstractMesh;
  120574. /** Gets or sets the mesh used as pole */
  120575. poleTargetMesh: AbstractMesh;
  120576. /**
  120577. * Gets or sets the bone used as pole
  120578. */
  120579. poleTargetBone: Nullable<Bone>;
  120580. /**
  120581. * Gets or sets the target position
  120582. */
  120583. targetPosition: Vector3;
  120584. /**
  120585. * Gets or sets the pole target position
  120586. */
  120587. poleTargetPosition: Vector3;
  120588. /**
  120589. * Gets or sets the pole target local offset
  120590. */
  120591. poleTargetLocalOffset: Vector3;
  120592. /**
  120593. * Gets or sets the pole angle
  120594. */
  120595. poleAngle: number;
  120596. /**
  120597. * Gets or sets the mesh associated with the controller
  120598. */
  120599. mesh: AbstractMesh;
  120600. /**
  120601. * 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)
  120602. */
  120603. slerpAmount: number;
  120604. private _bone1Quat;
  120605. private _bone1Mat;
  120606. private _bone2Ang;
  120607. private _bone1;
  120608. private _bone2;
  120609. private _bone1Length;
  120610. private _bone2Length;
  120611. private _maxAngle;
  120612. private _maxReach;
  120613. private _rightHandedSystem;
  120614. private _bendAxis;
  120615. private _slerping;
  120616. private _adjustRoll;
  120617. /**
  120618. * Gets or sets maximum allowed angle
  120619. */
  120620. get maxAngle(): number;
  120621. set maxAngle(value: number);
  120622. /**
  120623. * Creates a new BoneIKController
  120624. * @param mesh defines the mesh to control
  120625. * @param bone defines the bone to control
  120626. * @param options defines options to set up the controller
  120627. */
  120628. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120629. targetMesh?: AbstractMesh;
  120630. poleTargetMesh?: AbstractMesh;
  120631. poleTargetBone?: Bone;
  120632. poleTargetLocalOffset?: Vector3;
  120633. poleAngle?: number;
  120634. bendAxis?: Vector3;
  120635. maxAngle?: number;
  120636. slerpAmount?: number;
  120637. });
  120638. private _setMaxAngle;
  120639. /**
  120640. * Force the controller to update the bones
  120641. */
  120642. update(): void;
  120643. }
  120644. }
  120645. declare module BABYLON {
  120646. /**
  120647. * Class used to make a bone look toward a point in space
  120648. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120649. */
  120650. export class BoneLookController {
  120651. private static _tmpVecs;
  120652. private static _tmpQuat;
  120653. private static _tmpMats;
  120654. /**
  120655. * The target Vector3 that the bone will look at
  120656. */
  120657. target: Vector3;
  120658. /**
  120659. * The mesh that the bone is attached to
  120660. */
  120661. mesh: AbstractMesh;
  120662. /**
  120663. * The bone that will be looking to the target
  120664. */
  120665. bone: Bone;
  120666. /**
  120667. * The up axis of the coordinate system that is used when the bone is rotated
  120668. */
  120669. upAxis: Vector3;
  120670. /**
  120671. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120672. */
  120673. upAxisSpace: Space;
  120674. /**
  120675. * Used to make an adjustment to the yaw of the bone
  120676. */
  120677. adjustYaw: number;
  120678. /**
  120679. * Used to make an adjustment to the pitch of the bone
  120680. */
  120681. adjustPitch: number;
  120682. /**
  120683. * Used to make an adjustment to the roll of the bone
  120684. */
  120685. adjustRoll: number;
  120686. /**
  120687. * 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)
  120688. */
  120689. slerpAmount: number;
  120690. private _minYaw;
  120691. private _maxYaw;
  120692. private _minPitch;
  120693. private _maxPitch;
  120694. private _minYawSin;
  120695. private _minYawCos;
  120696. private _maxYawSin;
  120697. private _maxYawCos;
  120698. private _midYawConstraint;
  120699. private _minPitchTan;
  120700. private _maxPitchTan;
  120701. private _boneQuat;
  120702. private _slerping;
  120703. private _transformYawPitch;
  120704. private _transformYawPitchInv;
  120705. private _firstFrameSkipped;
  120706. private _yawRange;
  120707. private _fowardAxis;
  120708. /**
  120709. * Gets or sets the minimum yaw angle that the bone can look to
  120710. */
  120711. get minYaw(): number;
  120712. set minYaw(value: number);
  120713. /**
  120714. * Gets or sets the maximum yaw angle that the bone can look to
  120715. */
  120716. get maxYaw(): number;
  120717. set maxYaw(value: number);
  120718. /**
  120719. * Gets or sets the minimum pitch angle that the bone can look to
  120720. */
  120721. get minPitch(): number;
  120722. set minPitch(value: number);
  120723. /**
  120724. * Gets or sets the maximum pitch angle that the bone can look to
  120725. */
  120726. get maxPitch(): number;
  120727. set maxPitch(value: number);
  120728. /**
  120729. * Create a BoneLookController
  120730. * @param mesh the mesh that the bone belongs to
  120731. * @param bone the bone that will be looking to the target
  120732. * @param target the target Vector3 to look at
  120733. * @param options optional settings:
  120734. * * maxYaw: the maximum angle the bone will yaw to
  120735. * * minYaw: the minimum angle the bone will yaw to
  120736. * * maxPitch: the maximum angle the bone will pitch to
  120737. * * minPitch: the minimum angle the bone will yaw to
  120738. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120739. * * upAxis: the up axis of the coordinate system
  120740. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120741. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120742. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120743. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120744. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120745. * * adjustRoll: used to make an adjustment to the roll of the bone
  120746. **/
  120747. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120748. maxYaw?: number;
  120749. minYaw?: number;
  120750. maxPitch?: number;
  120751. minPitch?: number;
  120752. slerpAmount?: number;
  120753. upAxis?: Vector3;
  120754. upAxisSpace?: Space;
  120755. yawAxis?: Vector3;
  120756. pitchAxis?: Vector3;
  120757. adjustYaw?: number;
  120758. adjustPitch?: number;
  120759. adjustRoll?: number;
  120760. });
  120761. /**
  120762. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120763. */
  120764. update(): void;
  120765. private _getAngleDiff;
  120766. private _getAngleBetween;
  120767. private _isAngleBetween;
  120768. }
  120769. }
  120770. declare module BABYLON {
  120771. /**
  120772. * Manage the gamepad inputs to control an arc rotate camera.
  120773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120774. */
  120775. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120776. /**
  120777. * Defines the camera the input is attached to.
  120778. */
  120779. camera: ArcRotateCamera;
  120780. /**
  120781. * Defines the gamepad the input is gathering event from.
  120782. */
  120783. gamepad: Nullable<Gamepad>;
  120784. /**
  120785. * Defines the gamepad rotation sensiblity.
  120786. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120787. */
  120788. gamepadRotationSensibility: number;
  120789. /**
  120790. * Defines the gamepad move sensiblity.
  120791. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120792. */
  120793. gamepadMoveSensibility: number;
  120794. private _yAxisScale;
  120795. /**
  120796. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120797. */
  120798. get invertYAxis(): boolean;
  120799. set invertYAxis(value: boolean);
  120800. private _onGamepadConnectedObserver;
  120801. private _onGamepadDisconnectedObserver;
  120802. /**
  120803. * Attach the input controls to a specific dom element to get the input from.
  120804. * @param element Defines the element the controls should be listened from
  120805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120806. */
  120807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120808. /**
  120809. * Detach the current controls from the specified dom element.
  120810. * @param element Defines the element to stop listening the inputs from
  120811. */
  120812. detachControl(element: Nullable<HTMLElement>): void;
  120813. /**
  120814. * Update the current camera state depending on the inputs that have been used this frame.
  120815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120816. */
  120817. checkInputs(): void;
  120818. /**
  120819. * Gets the class name of the current intput.
  120820. * @returns the class name
  120821. */
  120822. getClassName(): string;
  120823. /**
  120824. * Get the friendly name associated with the input class.
  120825. * @returns the input friendly name
  120826. */
  120827. getSimpleName(): string;
  120828. }
  120829. }
  120830. declare module BABYLON {
  120831. interface ArcRotateCameraInputsManager {
  120832. /**
  120833. * Add orientation input support to the input manager.
  120834. * @returns the current input manager
  120835. */
  120836. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120837. }
  120838. /**
  120839. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120841. */
  120842. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120843. /**
  120844. * Defines the camera the input is attached to.
  120845. */
  120846. camera: ArcRotateCamera;
  120847. /**
  120848. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120849. */
  120850. alphaCorrection: number;
  120851. /**
  120852. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120853. */
  120854. gammaCorrection: number;
  120855. private _alpha;
  120856. private _gamma;
  120857. private _dirty;
  120858. private _deviceOrientationHandler;
  120859. /**
  120860. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120861. */
  120862. constructor();
  120863. /**
  120864. * Attach the input controls to a specific dom element to get the input from.
  120865. * @param element Defines the element the controls should be listened from
  120866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120867. */
  120868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120869. /** @hidden */
  120870. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120871. /**
  120872. * Update the current camera state depending on the inputs that have been used this frame.
  120873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120874. */
  120875. checkInputs(): void;
  120876. /**
  120877. * Detach the current controls from the specified dom element.
  120878. * @param element Defines the element to stop listening the inputs from
  120879. */
  120880. detachControl(element: Nullable<HTMLElement>): void;
  120881. /**
  120882. * Gets the class name of the current intput.
  120883. * @returns the class name
  120884. */
  120885. getClassName(): string;
  120886. /**
  120887. * Get the friendly name associated with the input class.
  120888. * @returns the input friendly name
  120889. */
  120890. getSimpleName(): string;
  120891. }
  120892. }
  120893. declare module BABYLON {
  120894. /**
  120895. * Listen to mouse events to control the camera.
  120896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120897. */
  120898. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120899. /**
  120900. * Defines the camera the input is attached to.
  120901. */
  120902. camera: FlyCamera;
  120903. /**
  120904. * Defines if touch is enabled. (Default is true.)
  120905. */
  120906. touchEnabled: boolean;
  120907. /**
  120908. * Defines the buttons associated with the input to handle camera rotation.
  120909. */
  120910. buttons: number[];
  120911. /**
  120912. * Assign buttons for Yaw control.
  120913. */
  120914. buttonsYaw: number[];
  120915. /**
  120916. * Assign buttons for Pitch control.
  120917. */
  120918. buttonsPitch: number[];
  120919. /**
  120920. * Assign buttons for Roll control.
  120921. */
  120922. buttonsRoll: number[];
  120923. /**
  120924. * Detect if any button is being pressed while mouse is moved.
  120925. * -1 = Mouse locked.
  120926. * 0 = Left button.
  120927. * 1 = Middle Button.
  120928. * 2 = Right Button.
  120929. */
  120930. activeButton: number;
  120931. /**
  120932. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120933. * Higher values reduce its sensitivity.
  120934. */
  120935. angularSensibility: number;
  120936. private _mousemoveCallback;
  120937. private _observer;
  120938. private _rollObserver;
  120939. private previousPosition;
  120940. private noPreventDefault;
  120941. private element;
  120942. /**
  120943. * Listen to mouse events to control the camera.
  120944. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120946. */
  120947. constructor(touchEnabled?: boolean);
  120948. /**
  120949. * Attach the mouse control to the HTML DOM element.
  120950. * @param element Defines the element that listens to the input events.
  120951. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120952. */
  120953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120954. /**
  120955. * Detach the current controls from the specified dom element.
  120956. * @param element Defines the element to stop listening the inputs from
  120957. */
  120958. detachControl(element: Nullable<HTMLElement>): void;
  120959. /**
  120960. * Gets the class name of the current input.
  120961. * @returns the class name.
  120962. */
  120963. getClassName(): string;
  120964. /**
  120965. * Get the friendly name associated with the input class.
  120966. * @returns the input's friendly name.
  120967. */
  120968. getSimpleName(): string;
  120969. private _pointerInput;
  120970. private _onMouseMove;
  120971. /**
  120972. * Rotate camera by mouse offset.
  120973. */
  120974. private rotateCamera;
  120975. }
  120976. }
  120977. declare module BABYLON {
  120978. /**
  120979. * Default Inputs manager for the FlyCamera.
  120980. * It groups all the default supported inputs for ease of use.
  120981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120982. */
  120983. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120984. /**
  120985. * Instantiates a new FlyCameraInputsManager.
  120986. * @param camera Defines the camera the inputs belong to.
  120987. */
  120988. constructor(camera: FlyCamera);
  120989. /**
  120990. * Add keyboard input support to the input manager.
  120991. * @returns the new FlyCameraKeyboardMoveInput().
  120992. */
  120993. addKeyboard(): FlyCameraInputsManager;
  120994. /**
  120995. * Add mouse input support to the input manager.
  120996. * @param touchEnabled Enable touch screen support.
  120997. * @returns the new FlyCameraMouseInput().
  120998. */
  120999. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121000. }
  121001. }
  121002. declare module BABYLON {
  121003. /**
  121004. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121005. * such as in a 3D Space Shooter or a Flight Simulator.
  121006. */
  121007. export class FlyCamera extends TargetCamera {
  121008. /**
  121009. * Define the collision ellipsoid of the camera.
  121010. * This is helpful for simulating a camera body, like a player's body.
  121011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121012. */
  121013. ellipsoid: Vector3;
  121014. /**
  121015. * Define an offset for the position of the ellipsoid around the camera.
  121016. * This can be helpful if the camera is attached away from the player's body center,
  121017. * such as at its head.
  121018. */
  121019. ellipsoidOffset: Vector3;
  121020. /**
  121021. * Enable or disable collisions of the camera with the rest of the scene objects.
  121022. */
  121023. checkCollisions: boolean;
  121024. /**
  121025. * Enable or disable gravity on the camera.
  121026. */
  121027. applyGravity: boolean;
  121028. /**
  121029. * Define the current direction the camera is moving to.
  121030. */
  121031. cameraDirection: Vector3;
  121032. /**
  121033. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121034. * This overrides and empties cameraRotation.
  121035. */
  121036. rotationQuaternion: Quaternion;
  121037. /**
  121038. * Track Roll to maintain the wanted Rolling when looking around.
  121039. */
  121040. _trackRoll: number;
  121041. /**
  121042. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121043. */
  121044. rollCorrect: number;
  121045. /**
  121046. * Mimic a banked turn, Rolling the camera when Yawing.
  121047. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121048. */
  121049. bankedTurn: boolean;
  121050. /**
  121051. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121052. */
  121053. bankedTurnLimit: number;
  121054. /**
  121055. * Value of 0 disables the banked Roll.
  121056. * Value of 1 is equal to the Yaw angle in radians.
  121057. */
  121058. bankedTurnMultiplier: number;
  121059. /**
  121060. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121061. */
  121062. inputs: FlyCameraInputsManager;
  121063. /**
  121064. * Gets the input sensibility for mouse input.
  121065. * Higher values reduce sensitivity.
  121066. */
  121067. get angularSensibility(): number;
  121068. /**
  121069. * Sets the input sensibility for a mouse input.
  121070. * Higher values reduce sensitivity.
  121071. */
  121072. set angularSensibility(value: number);
  121073. /**
  121074. * Get the keys for camera movement forward.
  121075. */
  121076. get keysForward(): number[];
  121077. /**
  121078. * Set the keys for camera movement forward.
  121079. */
  121080. set keysForward(value: number[]);
  121081. /**
  121082. * Get the keys for camera movement backward.
  121083. */
  121084. get keysBackward(): number[];
  121085. set keysBackward(value: number[]);
  121086. /**
  121087. * Get the keys for camera movement up.
  121088. */
  121089. get keysUp(): number[];
  121090. /**
  121091. * Set the keys for camera movement up.
  121092. */
  121093. set keysUp(value: number[]);
  121094. /**
  121095. * Get the keys for camera movement down.
  121096. */
  121097. get keysDown(): number[];
  121098. /**
  121099. * Set the keys for camera movement down.
  121100. */
  121101. set keysDown(value: number[]);
  121102. /**
  121103. * Get the keys for camera movement left.
  121104. */
  121105. get keysLeft(): number[];
  121106. /**
  121107. * Set the keys for camera movement left.
  121108. */
  121109. set keysLeft(value: number[]);
  121110. /**
  121111. * Set the keys for camera movement right.
  121112. */
  121113. get keysRight(): number[];
  121114. /**
  121115. * Set the keys for camera movement right.
  121116. */
  121117. set keysRight(value: number[]);
  121118. /**
  121119. * Event raised when the camera collides with a mesh in the scene.
  121120. */
  121121. onCollide: (collidedMesh: AbstractMesh) => void;
  121122. private _collider;
  121123. private _needMoveForGravity;
  121124. private _oldPosition;
  121125. private _diffPosition;
  121126. private _newPosition;
  121127. /** @hidden */
  121128. _localDirection: Vector3;
  121129. /** @hidden */
  121130. _transformedDirection: Vector3;
  121131. /**
  121132. * Instantiates a FlyCamera.
  121133. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121134. * such as in a 3D Space Shooter or a Flight Simulator.
  121135. * @param name Define the name of the camera in the scene.
  121136. * @param position Define the starting position of the camera in the scene.
  121137. * @param scene Define the scene the camera belongs to.
  121138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121139. */
  121140. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121141. /**
  121142. * Attach a control to the HTML DOM element.
  121143. * @param element Defines the element that listens to the input events.
  121144. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121145. */
  121146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121147. /**
  121148. * Detach a control from the HTML DOM element.
  121149. * The camera will stop reacting to that input.
  121150. * @param element Defines the element that listens to the input events.
  121151. */
  121152. detachControl(element: HTMLElement): void;
  121153. private _collisionMask;
  121154. /**
  121155. * Get the mask that the camera ignores in collision events.
  121156. */
  121157. get collisionMask(): number;
  121158. /**
  121159. * Set the mask that the camera ignores in collision events.
  121160. */
  121161. set collisionMask(mask: number);
  121162. /** @hidden */
  121163. _collideWithWorld(displacement: Vector3): void;
  121164. /** @hidden */
  121165. private _onCollisionPositionChange;
  121166. /** @hidden */
  121167. _checkInputs(): void;
  121168. /** @hidden */
  121169. _decideIfNeedsToMove(): boolean;
  121170. /** @hidden */
  121171. _updatePosition(): void;
  121172. /**
  121173. * Restore the Roll to its target value at the rate specified.
  121174. * @param rate - Higher means slower restoring.
  121175. * @hidden
  121176. */
  121177. restoreRoll(rate: number): void;
  121178. /**
  121179. * Destroy the camera and release the current resources held by it.
  121180. */
  121181. dispose(): void;
  121182. /**
  121183. * Get the current object class name.
  121184. * @returns the class name.
  121185. */
  121186. getClassName(): string;
  121187. }
  121188. }
  121189. declare module BABYLON {
  121190. /**
  121191. * Listen to keyboard events to control the camera.
  121192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121193. */
  121194. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121195. /**
  121196. * Defines the camera the input is attached to.
  121197. */
  121198. camera: FlyCamera;
  121199. /**
  121200. * The list of keyboard keys used to control the forward move of the camera.
  121201. */
  121202. keysForward: number[];
  121203. /**
  121204. * The list of keyboard keys used to control the backward move of the camera.
  121205. */
  121206. keysBackward: number[];
  121207. /**
  121208. * The list of keyboard keys used to control the forward move of the camera.
  121209. */
  121210. keysUp: number[];
  121211. /**
  121212. * The list of keyboard keys used to control the backward move of the camera.
  121213. */
  121214. keysDown: number[];
  121215. /**
  121216. * The list of keyboard keys used to control the right strafe move of the camera.
  121217. */
  121218. keysRight: number[];
  121219. /**
  121220. * The list of keyboard keys used to control the left strafe move of the camera.
  121221. */
  121222. keysLeft: number[];
  121223. private _keys;
  121224. private _onCanvasBlurObserver;
  121225. private _onKeyboardObserver;
  121226. private _engine;
  121227. private _scene;
  121228. /**
  121229. * Attach the input controls to a specific dom element to get the input from.
  121230. * @param element Defines the element the controls should be listened from
  121231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121232. */
  121233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121234. /**
  121235. * Detach the current controls from the specified dom element.
  121236. * @param element Defines the element to stop listening the inputs from
  121237. */
  121238. detachControl(element: Nullable<HTMLElement>): void;
  121239. /**
  121240. * Gets the class name of the current intput.
  121241. * @returns the class name
  121242. */
  121243. getClassName(): string;
  121244. /** @hidden */
  121245. _onLostFocus(e: FocusEvent): void;
  121246. /**
  121247. * Get the friendly name associated with the input class.
  121248. * @returns the input friendly name
  121249. */
  121250. getSimpleName(): string;
  121251. /**
  121252. * Update the current camera state depending on the inputs that have been used this frame.
  121253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121254. */
  121255. checkInputs(): void;
  121256. }
  121257. }
  121258. declare module BABYLON {
  121259. /**
  121260. * Manage the mouse wheel inputs to control a follow camera.
  121261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121262. */
  121263. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121264. /**
  121265. * Defines the camera the input is attached to.
  121266. */
  121267. camera: FollowCamera;
  121268. /**
  121269. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121270. */
  121271. axisControlRadius: boolean;
  121272. /**
  121273. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121274. */
  121275. axisControlHeight: boolean;
  121276. /**
  121277. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121278. */
  121279. axisControlRotation: boolean;
  121280. /**
  121281. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121282. * relation to mouseWheel events.
  121283. */
  121284. wheelPrecision: number;
  121285. /**
  121286. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121287. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121288. */
  121289. wheelDeltaPercentage: number;
  121290. private _wheel;
  121291. private _observer;
  121292. /**
  121293. * Attach the input controls to a specific dom element to get the input from.
  121294. * @param element Defines the element the controls should be listened from
  121295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121296. */
  121297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121298. /**
  121299. * Detach the current controls from the specified dom element.
  121300. * @param element Defines the element to stop listening the inputs from
  121301. */
  121302. detachControl(element: Nullable<HTMLElement>): void;
  121303. /**
  121304. * Gets the class name of the current intput.
  121305. * @returns the class name
  121306. */
  121307. getClassName(): string;
  121308. /**
  121309. * Get the friendly name associated with the input class.
  121310. * @returns the input friendly name
  121311. */
  121312. getSimpleName(): string;
  121313. }
  121314. }
  121315. declare module BABYLON {
  121316. /**
  121317. * Manage the pointers inputs to control an follow camera.
  121318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121319. */
  121320. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121321. /**
  121322. * Defines the camera the input is attached to.
  121323. */
  121324. camera: FollowCamera;
  121325. /**
  121326. * Gets the class name of the current input.
  121327. * @returns the class name
  121328. */
  121329. getClassName(): string;
  121330. /**
  121331. * Defines the pointer angular sensibility along the X axis or how fast is
  121332. * the camera rotating.
  121333. * A negative number will reverse the axis direction.
  121334. */
  121335. angularSensibilityX: number;
  121336. /**
  121337. * Defines the pointer angular sensibility along the Y axis or how fast is
  121338. * the camera rotating.
  121339. * A negative number will reverse the axis direction.
  121340. */
  121341. angularSensibilityY: number;
  121342. /**
  121343. * Defines the pointer pinch precision or how fast is the camera zooming.
  121344. * A negative number will reverse the axis direction.
  121345. */
  121346. pinchPrecision: number;
  121347. /**
  121348. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121349. * from 0.
  121350. * It defines the percentage of current camera.radius to use as delta when
  121351. * pinch zoom is used.
  121352. */
  121353. pinchDeltaPercentage: number;
  121354. /**
  121355. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121356. */
  121357. axisXControlRadius: boolean;
  121358. /**
  121359. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121360. */
  121361. axisXControlHeight: boolean;
  121362. /**
  121363. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121364. */
  121365. axisXControlRotation: boolean;
  121366. /**
  121367. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121368. */
  121369. axisYControlRadius: boolean;
  121370. /**
  121371. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121372. */
  121373. axisYControlHeight: boolean;
  121374. /**
  121375. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121376. */
  121377. axisYControlRotation: boolean;
  121378. /**
  121379. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121380. */
  121381. axisPinchControlRadius: boolean;
  121382. /**
  121383. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121384. */
  121385. axisPinchControlHeight: boolean;
  121386. /**
  121387. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121388. */
  121389. axisPinchControlRotation: boolean;
  121390. /**
  121391. * Log error messages if basic misconfiguration has occurred.
  121392. */
  121393. warningEnable: boolean;
  121394. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121396. private _warningCounter;
  121397. private _warning;
  121398. }
  121399. }
  121400. declare module BABYLON {
  121401. /**
  121402. * Default Inputs manager for the FollowCamera.
  121403. * It groups all the default supported inputs for ease of use.
  121404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121405. */
  121406. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121407. /**
  121408. * Instantiates a new FollowCameraInputsManager.
  121409. * @param camera Defines the camera the inputs belong to
  121410. */
  121411. constructor(camera: FollowCamera);
  121412. /**
  121413. * Add keyboard input support to the input manager.
  121414. * @returns the current input manager
  121415. */
  121416. addKeyboard(): FollowCameraInputsManager;
  121417. /**
  121418. * Add mouse wheel input support to the input manager.
  121419. * @returns the current input manager
  121420. */
  121421. addMouseWheel(): FollowCameraInputsManager;
  121422. /**
  121423. * Add pointers input support to the input manager.
  121424. * @returns the current input manager
  121425. */
  121426. addPointers(): FollowCameraInputsManager;
  121427. /**
  121428. * Add orientation input support to the input manager.
  121429. * @returns the current input manager
  121430. */
  121431. addVRDeviceOrientation(): FollowCameraInputsManager;
  121432. }
  121433. }
  121434. declare module BABYLON {
  121435. /**
  121436. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121437. * an arc rotate version arcFollowCamera are available.
  121438. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121439. */
  121440. export class FollowCamera extends TargetCamera {
  121441. /**
  121442. * Distance the follow camera should follow an object at
  121443. */
  121444. radius: number;
  121445. /**
  121446. * Minimum allowed distance of the camera to the axis of rotation
  121447. * (The camera can not get closer).
  121448. * This can help limiting how the Camera is able to move in the scene.
  121449. */
  121450. lowerRadiusLimit: Nullable<number>;
  121451. /**
  121452. * Maximum allowed distance of the camera to the axis of rotation
  121453. * (The camera can not get further).
  121454. * This can help limiting how the Camera is able to move in the scene.
  121455. */
  121456. upperRadiusLimit: Nullable<number>;
  121457. /**
  121458. * Define a rotation offset between the camera and the object it follows
  121459. */
  121460. rotationOffset: number;
  121461. /**
  121462. * Minimum allowed angle to camera position relative to target object.
  121463. * This can help limiting how the Camera is able to move in the scene.
  121464. */
  121465. lowerRotationOffsetLimit: Nullable<number>;
  121466. /**
  121467. * Maximum allowed angle to camera position relative to target object.
  121468. * This can help limiting how the Camera is able to move in the scene.
  121469. */
  121470. upperRotationOffsetLimit: Nullable<number>;
  121471. /**
  121472. * Define a height offset between the camera and the object it follows.
  121473. * It can help following an object from the top (like a car chaing a plane)
  121474. */
  121475. heightOffset: number;
  121476. /**
  121477. * Minimum allowed height of camera position relative to target object.
  121478. * This can help limiting how the Camera is able to move in the scene.
  121479. */
  121480. lowerHeightOffsetLimit: Nullable<number>;
  121481. /**
  121482. * Maximum allowed height of camera position relative to target object.
  121483. * This can help limiting how the Camera is able to move in the scene.
  121484. */
  121485. upperHeightOffsetLimit: Nullable<number>;
  121486. /**
  121487. * Define how fast the camera can accelerate to follow it s target.
  121488. */
  121489. cameraAcceleration: number;
  121490. /**
  121491. * Define the speed limit of the camera following an object.
  121492. */
  121493. maxCameraSpeed: number;
  121494. /**
  121495. * Define the target of the camera.
  121496. */
  121497. lockedTarget: Nullable<AbstractMesh>;
  121498. /**
  121499. * Defines the input associated with the camera.
  121500. */
  121501. inputs: FollowCameraInputsManager;
  121502. /**
  121503. * Instantiates the follow camera.
  121504. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121505. * @param name Define the name of the camera in the scene
  121506. * @param position Define the position of the camera
  121507. * @param scene Define the scene the camera belong to
  121508. * @param lockedTarget Define the target of the camera
  121509. */
  121510. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121511. private _follow;
  121512. /**
  121513. * Attached controls to the current camera.
  121514. * @param element Defines the element the controls should be listened from
  121515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121516. */
  121517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121518. /**
  121519. * Detach the current controls from the camera.
  121520. * The camera will stop reacting to inputs.
  121521. * @param element Defines the element to stop listening the inputs from
  121522. */
  121523. detachControl(element: HTMLElement): void;
  121524. /** @hidden */
  121525. _checkInputs(): void;
  121526. private _checkLimits;
  121527. /**
  121528. * Gets the camera class name.
  121529. * @returns the class name
  121530. */
  121531. getClassName(): string;
  121532. }
  121533. /**
  121534. * Arc Rotate version of the follow camera.
  121535. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121536. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121537. */
  121538. export class ArcFollowCamera extends TargetCamera {
  121539. /** The longitudinal angle of the camera */
  121540. alpha: number;
  121541. /** The latitudinal angle of the camera */
  121542. beta: number;
  121543. /** The radius of the camera from its target */
  121544. radius: number;
  121545. /** Define the camera target (the mesh it should follow) */
  121546. target: Nullable<AbstractMesh>;
  121547. private _cartesianCoordinates;
  121548. /**
  121549. * Instantiates a new ArcFollowCamera
  121550. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121551. * @param name Define the name of the camera
  121552. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121553. * @param beta Define the rotation angle of the camera around the elevation axis
  121554. * @param radius Define the radius of the camera from its target point
  121555. * @param target Define the target of the camera
  121556. * @param scene Define the scene the camera belongs to
  121557. */
  121558. constructor(name: string,
  121559. /** The longitudinal angle of the camera */
  121560. alpha: number,
  121561. /** The latitudinal angle of the camera */
  121562. beta: number,
  121563. /** The radius of the camera from its target */
  121564. radius: number,
  121565. /** Define the camera target (the mesh it should follow) */
  121566. target: Nullable<AbstractMesh>, scene: Scene);
  121567. private _follow;
  121568. /** @hidden */
  121569. _checkInputs(): void;
  121570. /**
  121571. * Returns the class name of the object.
  121572. * It is mostly used internally for serialization purposes.
  121573. */
  121574. getClassName(): string;
  121575. }
  121576. }
  121577. declare module BABYLON {
  121578. /**
  121579. * Manage the keyboard inputs to control the movement of a follow camera.
  121580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121581. */
  121582. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121583. /**
  121584. * Defines the camera the input is attached to.
  121585. */
  121586. camera: FollowCamera;
  121587. /**
  121588. * Defines the list of key codes associated with the up action (increase heightOffset)
  121589. */
  121590. keysHeightOffsetIncr: number[];
  121591. /**
  121592. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121593. */
  121594. keysHeightOffsetDecr: number[];
  121595. /**
  121596. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121597. */
  121598. keysHeightOffsetModifierAlt: boolean;
  121599. /**
  121600. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121601. */
  121602. keysHeightOffsetModifierCtrl: boolean;
  121603. /**
  121604. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121605. */
  121606. keysHeightOffsetModifierShift: boolean;
  121607. /**
  121608. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121609. */
  121610. keysRotationOffsetIncr: number[];
  121611. /**
  121612. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121613. */
  121614. keysRotationOffsetDecr: number[];
  121615. /**
  121616. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121617. */
  121618. keysRotationOffsetModifierAlt: boolean;
  121619. /**
  121620. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121621. */
  121622. keysRotationOffsetModifierCtrl: boolean;
  121623. /**
  121624. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121625. */
  121626. keysRotationOffsetModifierShift: boolean;
  121627. /**
  121628. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121629. */
  121630. keysRadiusIncr: number[];
  121631. /**
  121632. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121633. */
  121634. keysRadiusDecr: number[];
  121635. /**
  121636. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121637. */
  121638. keysRadiusModifierAlt: boolean;
  121639. /**
  121640. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121641. */
  121642. keysRadiusModifierCtrl: boolean;
  121643. /**
  121644. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121645. */
  121646. keysRadiusModifierShift: boolean;
  121647. /**
  121648. * Defines the rate of change of heightOffset.
  121649. */
  121650. heightSensibility: number;
  121651. /**
  121652. * Defines the rate of change of rotationOffset.
  121653. */
  121654. rotationSensibility: number;
  121655. /**
  121656. * Defines the rate of change of radius.
  121657. */
  121658. radiusSensibility: number;
  121659. private _keys;
  121660. private _ctrlPressed;
  121661. private _altPressed;
  121662. private _shiftPressed;
  121663. private _onCanvasBlurObserver;
  121664. private _onKeyboardObserver;
  121665. private _engine;
  121666. private _scene;
  121667. /**
  121668. * Attach the input controls to a specific dom element to get the input from.
  121669. * @param element Defines the element the controls should be listened from
  121670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121671. */
  121672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121673. /**
  121674. * Detach the current controls from the specified dom element.
  121675. * @param element Defines the element to stop listening the inputs from
  121676. */
  121677. detachControl(element: Nullable<HTMLElement>): void;
  121678. /**
  121679. * Update the current camera state depending on the inputs that have been used this frame.
  121680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121681. */
  121682. checkInputs(): void;
  121683. /**
  121684. * Gets the class name of the current input.
  121685. * @returns the class name
  121686. */
  121687. getClassName(): string;
  121688. /**
  121689. * Get the friendly name associated with the input class.
  121690. * @returns the input friendly name
  121691. */
  121692. getSimpleName(): string;
  121693. /**
  121694. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121695. * allow modification of the heightOffset value.
  121696. */
  121697. private _modifierHeightOffset;
  121698. /**
  121699. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121700. * allow modification of the rotationOffset value.
  121701. */
  121702. private _modifierRotationOffset;
  121703. /**
  121704. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121705. * allow modification of the radius value.
  121706. */
  121707. private _modifierRadius;
  121708. }
  121709. }
  121710. declare module BABYLON {
  121711. interface FreeCameraInputsManager {
  121712. /**
  121713. * @hidden
  121714. */
  121715. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121716. /**
  121717. * Add orientation input support to the input manager.
  121718. * @returns the current input manager
  121719. */
  121720. addDeviceOrientation(): FreeCameraInputsManager;
  121721. }
  121722. /**
  121723. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121724. * Screen rotation is taken into account.
  121725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121726. */
  121727. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121728. private _camera;
  121729. private _screenOrientationAngle;
  121730. private _constantTranform;
  121731. private _screenQuaternion;
  121732. private _alpha;
  121733. private _beta;
  121734. private _gamma;
  121735. /**
  121736. * Can be used to detect if a device orientation sensor is available on a device
  121737. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121738. * @returns a promise that will resolve on orientation change
  121739. */
  121740. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121741. /**
  121742. * @hidden
  121743. */
  121744. _onDeviceOrientationChangedObservable: Observable<void>;
  121745. /**
  121746. * Instantiates a new input
  121747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121748. */
  121749. constructor();
  121750. /**
  121751. * Define the camera controlled by the input.
  121752. */
  121753. get camera(): FreeCamera;
  121754. set camera(camera: FreeCamera);
  121755. /**
  121756. * Attach the input controls to a specific dom element to get the input from.
  121757. * @param element Defines the element the controls should be listened from
  121758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121759. */
  121760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121761. private _orientationChanged;
  121762. private _deviceOrientation;
  121763. /**
  121764. * Detach the current controls from the specified dom element.
  121765. * @param element Defines the element to stop listening the inputs from
  121766. */
  121767. detachControl(element: Nullable<HTMLElement>): void;
  121768. /**
  121769. * Update the current camera state depending on the inputs that have been used this frame.
  121770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121771. */
  121772. checkInputs(): void;
  121773. /**
  121774. * Gets the class name of the current intput.
  121775. * @returns the class name
  121776. */
  121777. getClassName(): string;
  121778. /**
  121779. * Get the friendly name associated with the input class.
  121780. * @returns the input friendly name
  121781. */
  121782. getSimpleName(): string;
  121783. }
  121784. }
  121785. declare module BABYLON {
  121786. /**
  121787. * Manage the gamepad inputs to control a free camera.
  121788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121789. */
  121790. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121791. /**
  121792. * Define the camera the input is attached to.
  121793. */
  121794. camera: FreeCamera;
  121795. /**
  121796. * Define the Gamepad controlling the input
  121797. */
  121798. gamepad: Nullable<Gamepad>;
  121799. /**
  121800. * Defines the gamepad rotation sensiblity.
  121801. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121802. */
  121803. gamepadAngularSensibility: number;
  121804. /**
  121805. * Defines the gamepad move sensiblity.
  121806. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121807. */
  121808. gamepadMoveSensibility: number;
  121809. private _yAxisScale;
  121810. /**
  121811. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121812. */
  121813. get invertYAxis(): boolean;
  121814. set invertYAxis(value: boolean);
  121815. private _onGamepadConnectedObserver;
  121816. private _onGamepadDisconnectedObserver;
  121817. private _cameraTransform;
  121818. private _deltaTransform;
  121819. private _vector3;
  121820. private _vector2;
  121821. /**
  121822. * Attach the input controls to a specific dom element to get the input from.
  121823. * @param element Defines the element the controls should be listened from
  121824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121825. */
  121826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121827. /**
  121828. * Detach the current controls from the specified dom element.
  121829. * @param element Defines the element to stop listening the inputs from
  121830. */
  121831. detachControl(element: Nullable<HTMLElement>): void;
  121832. /**
  121833. * Update the current camera state depending on the inputs that have been used this frame.
  121834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121835. */
  121836. checkInputs(): void;
  121837. /**
  121838. * Gets the class name of the current intput.
  121839. * @returns the class name
  121840. */
  121841. getClassName(): string;
  121842. /**
  121843. * Get the friendly name associated with the input class.
  121844. * @returns the input friendly name
  121845. */
  121846. getSimpleName(): string;
  121847. }
  121848. }
  121849. declare module BABYLON {
  121850. /**
  121851. * Defines the potential axis of a Joystick
  121852. */
  121853. export enum JoystickAxis {
  121854. /** X axis */
  121855. X = 0,
  121856. /** Y axis */
  121857. Y = 1,
  121858. /** Z axis */
  121859. Z = 2
  121860. }
  121861. /**
  121862. * Represents the different customization options available
  121863. * for VirtualJoystick
  121864. */
  121865. interface VirtualJoystickCustomizations {
  121866. /**
  121867. * Size of the joystick's puck
  121868. */
  121869. puckSize: number;
  121870. /**
  121871. * Size of the joystick's container
  121872. */
  121873. containerSize: number;
  121874. /**
  121875. * Color of the joystick && puck
  121876. */
  121877. color: string;
  121878. /**
  121879. * Image URL for the joystick's puck
  121880. */
  121881. puckImage?: string;
  121882. /**
  121883. * Image URL for the joystick's container
  121884. */
  121885. containerImage?: string;
  121886. /**
  121887. * Defines the unmoving position of the joystick container
  121888. */
  121889. position?: {
  121890. x: number;
  121891. y: number;
  121892. };
  121893. /**
  121894. * Defines whether or not the joystick container is always visible
  121895. */
  121896. alwaysVisible: boolean;
  121897. /**
  121898. * Defines whether or not to limit the movement of the puck to the joystick's container
  121899. */
  121900. limitToContainer: boolean;
  121901. }
  121902. /**
  121903. * Class used to define virtual joystick (used in touch mode)
  121904. */
  121905. export class VirtualJoystick {
  121906. /**
  121907. * Gets or sets a boolean indicating that left and right values must be inverted
  121908. */
  121909. reverseLeftRight: boolean;
  121910. /**
  121911. * Gets or sets a boolean indicating that up and down values must be inverted
  121912. */
  121913. reverseUpDown: boolean;
  121914. /**
  121915. * Gets the offset value for the position (ie. the change of the position value)
  121916. */
  121917. deltaPosition: Vector3;
  121918. /**
  121919. * Gets a boolean indicating if the virtual joystick was pressed
  121920. */
  121921. pressed: boolean;
  121922. /**
  121923. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121924. */
  121925. static Canvas: Nullable<HTMLCanvasElement>;
  121926. /**
  121927. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  121928. */
  121929. limitToContainer: boolean;
  121930. private static _globalJoystickIndex;
  121931. private static _alwaysVisibleSticks;
  121932. private static vjCanvasContext;
  121933. private static vjCanvasWidth;
  121934. private static vjCanvasHeight;
  121935. private static halfWidth;
  121936. private static _GetDefaultOptions;
  121937. private _action;
  121938. private _axisTargetedByLeftAndRight;
  121939. private _axisTargetedByUpAndDown;
  121940. private _joystickSensibility;
  121941. private _inversedSensibility;
  121942. private _joystickPointerID;
  121943. private _joystickColor;
  121944. private _joystickPointerPos;
  121945. private _joystickPreviousPointerPos;
  121946. private _joystickPointerStartPos;
  121947. private _deltaJoystickVector;
  121948. private _leftJoystick;
  121949. private _touches;
  121950. private _joystickPosition;
  121951. private _alwaysVisible;
  121952. private _puckImage;
  121953. private _containerImage;
  121954. private _joystickPuckSize;
  121955. private _joystickContainerSize;
  121956. private _clearPuckSize;
  121957. private _clearContainerSize;
  121958. private _clearPuckSizeOffset;
  121959. private _clearContainerSizeOffset;
  121960. private _onPointerDownHandlerRef;
  121961. private _onPointerMoveHandlerRef;
  121962. private _onPointerUpHandlerRef;
  121963. private _onResize;
  121964. /**
  121965. * Creates a new virtual joystick
  121966. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121967. * @param customizations Defines the options we want to customize the VirtualJoystick
  121968. */
  121969. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  121970. /**
  121971. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121972. * @param newJoystickSensibility defines the new sensibility
  121973. */
  121974. setJoystickSensibility(newJoystickSensibility: number): void;
  121975. private _onPointerDown;
  121976. private _onPointerMove;
  121977. private _onPointerUp;
  121978. /**
  121979. * Change the color of the virtual joystick
  121980. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121981. */
  121982. setJoystickColor(newColor: string): void;
  121983. /**
  121984. * Size of the joystick's container
  121985. */
  121986. set containerSize(newSize: number);
  121987. get containerSize(): number;
  121988. /**
  121989. * Size of the joystick's puck
  121990. */
  121991. set puckSize(newSize: number);
  121992. get puckSize(): number;
  121993. /**
  121994. * Clears the set position of the joystick
  121995. */
  121996. clearPosition(): void;
  121997. /**
  121998. * Defines whether or not the joystick container is always visible
  121999. */
  122000. set alwaysVisible(value: boolean);
  122001. get alwaysVisible(): boolean;
  122002. /**
  122003. * Sets the constant position of the Joystick container
  122004. * @param x X axis coordinate
  122005. * @param y Y axis coordinate
  122006. */
  122007. setPosition(x: number, y: number): void;
  122008. /**
  122009. * Defines a callback to call when the joystick is touched
  122010. * @param action defines the callback
  122011. */
  122012. setActionOnTouch(action: () => any): void;
  122013. /**
  122014. * Defines which axis you'd like to control for left & right
  122015. * @param axis defines the axis to use
  122016. */
  122017. setAxisForLeftRight(axis: JoystickAxis): void;
  122018. /**
  122019. * Defines which axis you'd like to control for up & down
  122020. * @param axis defines the axis to use
  122021. */
  122022. setAxisForUpDown(axis: JoystickAxis): void;
  122023. /**
  122024. * Clears the canvas from the previous puck / container draw
  122025. */
  122026. private _clearPreviousDraw;
  122027. /**
  122028. * Loads `urlPath` to be used for the container's image
  122029. * @param urlPath defines the urlPath of an image to use
  122030. */
  122031. setContainerImage(urlPath: string): void;
  122032. /**
  122033. * Loads `urlPath` to be used for the puck's image
  122034. * @param urlPath defines the urlPath of an image to use
  122035. */
  122036. setPuckImage(urlPath: string): void;
  122037. /**
  122038. * Draws the Virtual Joystick's container
  122039. */
  122040. private _drawContainer;
  122041. /**
  122042. * Draws the Virtual Joystick's puck
  122043. */
  122044. private _drawPuck;
  122045. private _drawVirtualJoystick;
  122046. /**
  122047. * Release internal HTML canvas
  122048. */
  122049. releaseCanvas(): void;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. interface FreeCameraInputsManager {
  122054. /**
  122055. * Add virtual joystick input support to the input manager.
  122056. * @returns the current input manager
  122057. */
  122058. addVirtualJoystick(): FreeCameraInputsManager;
  122059. }
  122060. /**
  122061. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  122063. */
  122064. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122065. /**
  122066. * Defines the camera the input is attached to.
  122067. */
  122068. camera: FreeCamera;
  122069. private _leftjoystick;
  122070. private _rightjoystick;
  122071. /**
  122072. * Gets the left stick of the virtual joystick.
  122073. * @returns The virtual Joystick
  122074. */
  122075. getLeftJoystick(): VirtualJoystick;
  122076. /**
  122077. * Gets the right stick of the virtual joystick.
  122078. * @returns The virtual Joystick
  122079. */
  122080. getRightJoystick(): VirtualJoystick;
  122081. /**
  122082. * Update the current camera state depending on the inputs that have been used this frame.
  122083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122084. */
  122085. checkInputs(): void;
  122086. /**
  122087. * Attach the input controls to a specific dom element to get the input from.
  122088. * @param element Defines the element the controls should be listened from
  122089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122090. */
  122091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122092. /**
  122093. * Detach the current controls from the specified dom element.
  122094. * @param element Defines the element to stop listening the inputs from
  122095. */
  122096. detachControl(element: Nullable<HTMLElement>): void;
  122097. /**
  122098. * Gets the class name of the current intput.
  122099. * @returns the class name
  122100. */
  122101. getClassName(): string;
  122102. /**
  122103. * Get the friendly name associated with the input class.
  122104. * @returns the input friendly name
  122105. */
  122106. getSimpleName(): string;
  122107. }
  122108. }
  122109. declare module BABYLON {
  122110. /**
  122111. * This represents a FPS type of camera controlled by touch.
  122112. * This is like a universal camera minus the Gamepad controls.
  122113. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122114. */
  122115. export class TouchCamera extends FreeCamera {
  122116. /**
  122117. * Defines the touch sensibility for rotation.
  122118. * The higher the faster.
  122119. */
  122120. get touchAngularSensibility(): number;
  122121. set touchAngularSensibility(value: number);
  122122. /**
  122123. * Defines the touch sensibility for move.
  122124. * The higher the faster.
  122125. */
  122126. get touchMoveSensibility(): number;
  122127. set touchMoveSensibility(value: number);
  122128. /**
  122129. * Instantiates a new touch camera.
  122130. * This represents a FPS type of camera controlled by touch.
  122131. * This is like a universal camera minus the Gamepad controls.
  122132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122133. * @param name Define the name of the camera in the scene
  122134. * @param position Define the start position of the camera in the scene
  122135. * @param scene Define the scene the camera belongs to
  122136. */
  122137. constructor(name: string, position: Vector3, scene: Scene);
  122138. /**
  122139. * Gets the current object class name.
  122140. * @return the class name
  122141. */
  122142. getClassName(): string;
  122143. /** @hidden */
  122144. _setupInputs(): void;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122150. * being tilted forward or back and left or right.
  122151. */
  122152. export class DeviceOrientationCamera extends FreeCamera {
  122153. private _initialQuaternion;
  122154. private _quaternionCache;
  122155. private _tmpDragQuaternion;
  122156. private _disablePointerInputWhenUsingDeviceOrientation;
  122157. /**
  122158. * Creates a new device orientation camera
  122159. * @param name The name of the camera
  122160. * @param position The start position camera
  122161. * @param scene The scene the camera belongs to
  122162. */
  122163. constructor(name: string, position: Vector3, scene: Scene);
  122164. /**
  122165. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122166. */
  122167. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122168. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122169. private _dragFactor;
  122170. /**
  122171. * Enabled turning on the y axis when the orientation sensor is active
  122172. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122173. */
  122174. enableHorizontalDragging(dragFactor?: number): void;
  122175. /**
  122176. * Gets the current instance class name ("DeviceOrientationCamera").
  122177. * This helps avoiding instanceof at run time.
  122178. * @returns the class name
  122179. */
  122180. getClassName(): string;
  122181. /**
  122182. * @hidden
  122183. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122184. */
  122185. _checkInputs(): void;
  122186. /**
  122187. * Reset the camera to its default orientation on the specified axis only.
  122188. * @param axis The axis to reset
  122189. */
  122190. resetToCurrentRotation(axis?: Axis): void;
  122191. }
  122192. }
  122193. declare module BABYLON {
  122194. /**
  122195. * Defines supported buttons for XBox360 compatible gamepads
  122196. */
  122197. export enum Xbox360Button {
  122198. /** A */
  122199. A = 0,
  122200. /** B */
  122201. B = 1,
  122202. /** X */
  122203. X = 2,
  122204. /** Y */
  122205. Y = 3,
  122206. /** Left button */
  122207. LB = 4,
  122208. /** Right button */
  122209. RB = 5,
  122210. /** Back */
  122211. Back = 8,
  122212. /** Start */
  122213. Start = 9,
  122214. /** Left stick */
  122215. LeftStick = 10,
  122216. /** Right stick */
  122217. RightStick = 11
  122218. }
  122219. /** Defines values for XBox360 DPad */
  122220. export enum Xbox360Dpad {
  122221. /** Up */
  122222. Up = 12,
  122223. /** Down */
  122224. Down = 13,
  122225. /** Left */
  122226. Left = 14,
  122227. /** Right */
  122228. Right = 15
  122229. }
  122230. /**
  122231. * Defines a XBox360 gamepad
  122232. */
  122233. export class Xbox360Pad extends Gamepad {
  122234. private _leftTrigger;
  122235. private _rightTrigger;
  122236. private _onlefttriggerchanged;
  122237. private _onrighttriggerchanged;
  122238. private _onbuttondown;
  122239. private _onbuttonup;
  122240. private _ondpaddown;
  122241. private _ondpadup;
  122242. /** Observable raised when a button is pressed */
  122243. onButtonDownObservable: Observable<Xbox360Button>;
  122244. /** Observable raised when a button is released */
  122245. onButtonUpObservable: Observable<Xbox360Button>;
  122246. /** Observable raised when a pad is pressed */
  122247. onPadDownObservable: Observable<Xbox360Dpad>;
  122248. /** Observable raised when a pad is released */
  122249. onPadUpObservable: Observable<Xbox360Dpad>;
  122250. private _buttonA;
  122251. private _buttonB;
  122252. private _buttonX;
  122253. private _buttonY;
  122254. private _buttonBack;
  122255. private _buttonStart;
  122256. private _buttonLB;
  122257. private _buttonRB;
  122258. private _buttonLeftStick;
  122259. private _buttonRightStick;
  122260. private _dPadUp;
  122261. private _dPadDown;
  122262. private _dPadLeft;
  122263. private _dPadRight;
  122264. private _isXboxOnePad;
  122265. /**
  122266. * Creates a new XBox360 gamepad object
  122267. * @param id defines the id of this gamepad
  122268. * @param index defines its index
  122269. * @param gamepad defines the internal HTML gamepad object
  122270. * @param xboxOne defines if it is a XBox One gamepad
  122271. */
  122272. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122273. /**
  122274. * Defines the callback to call when left trigger is pressed
  122275. * @param callback defines the callback to use
  122276. */
  122277. onlefttriggerchanged(callback: (value: number) => void): void;
  122278. /**
  122279. * Defines the callback to call when right trigger is pressed
  122280. * @param callback defines the callback to use
  122281. */
  122282. onrighttriggerchanged(callback: (value: number) => void): void;
  122283. /**
  122284. * Gets the left trigger value
  122285. */
  122286. get leftTrigger(): number;
  122287. /**
  122288. * Sets the left trigger value
  122289. */
  122290. set leftTrigger(newValue: number);
  122291. /**
  122292. * Gets the right trigger value
  122293. */
  122294. get rightTrigger(): number;
  122295. /**
  122296. * Sets the right trigger value
  122297. */
  122298. set rightTrigger(newValue: number);
  122299. /**
  122300. * Defines the callback to call when a button is pressed
  122301. * @param callback defines the callback to use
  122302. */
  122303. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122304. /**
  122305. * Defines the callback to call when a button is released
  122306. * @param callback defines the callback to use
  122307. */
  122308. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122309. /**
  122310. * Defines the callback to call when a pad is pressed
  122311. * @param callback defines the callback to use
  122312. */
  122313. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122314. /**
  122315. * Defines the callback to call when a pad is released
  122316. * @param callback defines the callback to use
  122317. */
  122318. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122319. private _setButtonValue;
  122320. private _setDPadValue;
  122321. /**
  122322. * Gets the value of the `A` button
  122323. */
  122324. get buttonA(): number;
  122325. /**
  122326. * Sets the value of the `A` button
  122327. */
  122328. set buttonA(value: number);
  122329. /**
  122330. * Gets the value of the `B` button
  122331. */
  122332. get buttonB(): number;
  122333. /**
  122334. * Sets the value of the `B` button
  122335. */
  122336. set buttonB(value: number);
  122337. /**
  122338. * Gets the value of the `X` button
  122339. */
  122340. get buttonX(): number;
  122341. /**
  122342. * Sets the value of the `X` button
  122343. */
  122344. set buttonX(value: number);
  122345. /**
  122346. * Gets the value of the `Y` button
  122347. */
  122348. get buttonY(): number;
  122349. /**
  122350. * Sets the value of the `Y` button
  122351. */
  122352. set buttonY(value: number);
  122353. /**
  122354. * Gets the value of the `Start` button
  122355. */
  122356. get buttonStart(): number;
  122357. /**
  122358. * Sets the value of the `Start` button
  122359. */
  122360. set buttonStart(value: number);
  122361. /**
  122362. * Gets the value of the `Back` button
  122363. */
  122364. get buttonBack(): number;
  122365. /**
  122366. * Sets the value of the `Back` button
  122367. */
  122368. set buttonBack(value: number);
  122369. /**
  122370. * Gets the value of the `Left` button
  122371. */
  122372. get buttonLB(): number;
  122373. /**
  122374. * Sets the value of the `Left` button
  122375. */
  122376. set buttonLB(value: number);
  122377. /**
  122378. * Gets the value of the `Right` button
  122379. */
  122380. get buttonRB(): number;
  122381. /**
  122382. * Sets the value of the `Right` button
  122383. */
  122384. set buttonRB(value: number);
  122385. /**
  122386. * Gets the value of the Left joystick
  122387. */
  122388. get buttonLeftStick(): number;
  122389. /**
  122390. * Sets the value of the Left joystick
  122391. */
  122392. set buttonLeftStick(value: number);
  122393. /**
  122394. * Gets the value of the Right joystick
  122395. */
  122396. get buttonRightStick(): number;
  122397. /**
  122398. * Sets the value of the Right joystick
  122399. */
  122400. set buttonRightStick(value: number);
  122401. /**
  122402. * Gets the value of D-pad up
  122403. */
  122404. get dPadUp(): number;
  122405. /**
  122406. * Sets the value of D-pad up
  122407. */
  122408. set dPadUp(value: number);
  122409. /**
  122410. * Gets the value of D-pad down
  122411. */
  122412. get dPadDown(): number;
  122413. /**
  122414. * Sets the value of D-pad down
  122415. */
  122416. set dPadDown(value: number);
  122417. /**
  122418. * Gets the value of D-pad left
  122419. */
  122420. get dPadLeft(): number;
  122421. /**
  122422. * Sets the value of D-pad left
  122423. */
  122424. set dPadLeft(value: number);
  122425. /**
  122426. * Gets the value of D-pad right
  122427. */
  122428. get dPadRight(): number;
  122429. /**
  122430. * Sets the value of D-pad right
  122431. */
  122432. set dPadRight(value: number);
  122433. /**
  122434. * Force the gamepad to synchronize with device values
  122435. */
  122436. update(): void;
  122437. /**
  122438. * Disposes the gamepad
  122439. */
  122440. dispose(): void;
  122441. }
  122442. }
  122443. declare module BABYLON {
  122444. /**
  122445. * Defines supported buttons for DualShock compatible gamepads
  122446. */
  122447. export enum DualShockButton {
  122448. /** Cross */
  122449. Cross = 0,
  122450. /** Circle */
  122451. Circle = 1,
  122452. /** Square */
  122453. Square = 2,
  122454. /** Triangle */
  122455. Triangle = 3,
  122456. /** L1 */
  122457. L1 = 4,
  122458. /** R1 */
  122459. R1 = 5,
  122460. /** Share */
  122461. Share = 8,
  122462. /** Options */
  122463. Options = 9,
  122464. /** Left stick */
  122465. LeftStick = 10,
  122466. /** Right stick */
  122467. RightStick = 11
  122468. }
  122469. /** Defines values for DualShock DPad */
  122470. export enum DualShockDpad {
  122471. /** Up */
  122472. Up = 12,
  122473. /** Down */
  122474. Down = 13,
  122475. /** Left */
  122476. Left = 14,
  122477. /** Right */
  122478. Right = 15
  122479. }
  122480. /**
  122481. * Defines a DualShock gamepad
  122482. */
  122483. export class DualShockPad extends Gamepad {
  122484. private _leftTrigger;
  122485. private _rightTrigger;
  122486. private _onlefttriggerchanged;
  122487. private _onrighttriggerchanged;
  122488. private _onbuttondown;
  122489. private _onbuttonup;
  122490. private _ondpaddown;
  122491. private _ondpadup;
  122492. /** Observable raised when a button is pressed */
  122493. onButtonDownObservable: Observable<DualShockButton>;
  122494. /** Observable raised when a button is released */
  122495. onButtonUpObservable: Observable<DualShockButton>;
  122496. /** Observable raised when a pad is pressed */
  122497. onPadDownObservable: Observable<DualShockDpad>;
  122498. /** Observable raised when a pad is released */
  122499. onPadUpObservable: Observable<DualShockDpad>;
  122500. private _buttonCross;
  122501. private _buttonCircle;
  122502. private _buttonSquare;
  122503. private _buttonTriangle;
  122504. private _buttonShare;
  122505. private _buttonOptions;
  122506. private _buttonL1;
  122507. private _buttonR1;
  122508. private _buttonLeftStick;
  122509. private _buttonRightStick;
  122510. private _dPadUp;
  122511. private _dPadDown;
  122512. private _dPadLeft;
  122513. private _dPadRight;
  122514. /**
  122515. * Creates a new DualShock gamepad object
  122516. * @param id defines the id of this gamepad
  122517. * @param index defines its index
  122518. * @param gamepad defines the internal HTML gamepad object
  122519. */
  122520. constructor(id: string, index: number, gamepad: any);
  122521. /**
  122522. * Defines the callback to call when left trigger is pressed
  122523. * @param callback defines the callback to use
  122524. */
  122525. onlefttriggerchanged(callback: (value: number) => void): void;
  122526. /**
  122527. * Defines the callback to call when right trigger is pressed
  122528. * @param callback defines the callback to use
  122529. */
  122530. onrighttriggerchanged(callback: (value: number) => void): void;
  122531. /**
  122532. * Gets the left trigger value
  122533. */
  122534. get leftTrigger(): number;
  122535. /**
  122536. * Sets the left trigger value
  122537. */
  122538. set leftTrigger(newValue: number);
  122539. /**
  122540. * Gets the right trigger value
  122541. */
  122542. get rightTrigger(): number;
  122543. /**
  122544. * Sets the right trigger value
  122545. */
  122546. set rightTrigger(newValue: number);
  122547. /**
  122548. * Defines the callback to call when a button is pressed
  122549. * @param callback defines the callback to use
  122550. */
  122551. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122552. /**
  122553. * Defines the callback to call when a button is released
  122554. * @param callback defines the callback to use
  122555. */
  122556. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122557. /**
  122558. * Defines the callback to call when a pad is pressed
  122559. * @param callback defines the callback to use
  122560. */
  122561. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122562. /**
  122563. * Defines the callback to call when a pad is released
  122564. * @param callback defines the callback to use
  122565. */
  122566. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122567. private _setButtonValue;
  122568. private _setDPadValue;
  122569. /**
  122570. * Gets the value of the `Cross` button
  122571. */
  122572. get buttonCross(): number;
  122573. /**
  122574. * Sets the value of the `Cross` button
  122575. */
  122576. set buttonCross(value: number);
  122577. /**
  122578. * Gets the value of the `Circle` button
  122579. */
  122580. get buttonCircle(): number;
  122581. /**
  122582. * Sets the value of the `Circle` button
  122583. */
  122584. set buttonCircle(value: number);
  122585. /**
  122586. * Gets the value of the `Square` button
  122587. */
  122588. get buttonSquare(): number;
  122589. /**
  122590. * Sets the value of the `Square` button
  122591. */
  122592. set buttonSquare(value: number);
  122593. /**
  122594. * Gets the value of the `Triangle` button
  122595. */
  122596. get buttonTriangle(): number;
  122597. /**
  122598. * Sets the value of the `Triangle` button
  122599. */
  122600. set buttonTriangle(value: number);
  122601. /**
  122602. * Gets the value of the `Options` button
  122603. */
  122604. get buttonOptions(): number;
  122605. /**
  122606. * Sets the value of the `Options` button
  122607. */
  122608. set buttonOptions(value: number);
  122609. /**
  122610. * Gets the value of the `Share` button
  122611. */
  122612. get buttonShare(): number;
  122613. /**
  122614. * Sets the value of the `Share` button
  122615. */
  122616. set buttonShare(value: number);
  122617. /**
  122618. * Gets the value of the `L1` button
  122619. */
  122620. get buttonL1(): number;
  122621. /**
  122622. * Sets the value of the `L1` button
  122623. */
  122624. set buttonL1(value: number);
  122625. /**
  122626. * Gets the value of the `R1` button
  122627. */
  122628. get buttonR1(): number;
  122629. /**
  122630. * Sets the value of the `R1` button
  122631. */
  122632. set buttonR1(value: number);
  122633. /**
  122634. * Gets the value of the Left joystick
  122635. */
  122636. get buttonLeftStick(): number;
  122637. /**
  122638. * Sets the value of the Left joystick
  122639. */
  122640. set buttonLeftStick(value: number);
  122641. /**
  122642. * Gets the value of the Right joystick
  122643. */
  122644. get buttonRightStick(): number;
  122645. /**
  122646. * Sets the value of the Right joystick
  122647. */
  122648. set buttonRightStick(value: number);
  122649. /**
  122650. * Gets the value of D-pad up
  122651. */
  122652. get dPadUp(): number;
  122653. /**
  122654. * Sets the value of D-pad up
  122655. */
  122656. set dPadUp(value: number);
  122657. /**
  122658. * Gets the value of D-pad down
  122659. */
  122660. get dPadDown(): number;
  122661. /**
  122662. * Sets the value of D-pad down
  122663. */
  122664. set dPadDown(value: number);
  122665. /**
  122666. * Gets the value of D-pad left
  122667. */
  122668. get dPadLeft(): number;
  122669. /**
  122670. * Sets the value of D-pad left
  122671. */
  122672. set dPadLeft(value: number);
  122673. /**
  122674. * Gets the value of D-pad right
  122675. */
  122676. get dPadRight(): number;
  122677. /**
  122678. * Sets the value of D-pad right
  122679. */
  122680. set dPadRight(value: number);
  122681. /**
  122682. * Force the gamepad to synchronize with device values
  122683. */
  122684. update(): void;
  122685. /**
  122686. * Disposes the gamepad
  122687. */
  122688. dispose(): void;
  122689. }
  122690. }
  122691. declare module BABYLON {
  122692. /**
  122693. * Manager for handling gamepads
  122694. */
  122695. export class GamepadManager {
  122696. private _scene?;
  122697. private _babylonGamepads;
  122698. private _oneGamepadConnected;
  122699. /** @hidden */
  122700. _isMonitoring: boolean;
  122701. private _gamepadEventSupported;
  122702. private _gamepadSupport?;
  122703. /**
  122704. * observable to be triggered when the gamepad controller has been connected
  122705. */
  122706. onGamepadConnectedObservable: Observable<Gamepad>;
  122707. /**
  122708. * observable to be triggered when the gamepad controller has been disconnected
  122709. */
  122710. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122711. private _onGamepadConnectedEvent;
  122712. private _onGamepadDisconnectedEvent;
  122713. /**
  122714. * Initializes the gamepad manager
  122715. * @param _scene BabylonJS scene
  122716. */
  122717. constructor(_scene?: Scene | undefined);
  122718. /**
  122719. * The gamepads in the game pad manager
  122720. */
  122721. get gamepads(): Gamepad[];
  122722. /**
  122723. * Get the gamepad controllers based on type
  122724. * @param type The type of gamepad controller
  122725. * @returns Nullable gamepad
  122726. */
  122727. getGamepadByType(type?: number): Nullable<Gamepad>;
  122728. /**
  122729. * Disposes the gamepad manager
  122730. */
  122731. dispose(): void;
  122732. private _addNewGamepad;
  122733. private _startMonitoringGamepads;
  122734. private _stopMonitoringGamepads;
  122735. /** @hidden */
  122736. _checkGamepadsStatus(): void;
  122737. private _updateGamepadObjects;
  122738. }
  122739. }
  122740. declare module BABYLON {
  122741. interface Scene {
  122742. /** @hidden */
  122743. _gamepadManager: Nullable<GamepadManager>;
  122744. /**
  122745. * Gets the gamepad manager associated with the scene
  122746. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122747. */
  122748. gamepadManager: GamepadManager;
  122749. }
  122750. /**
  122751. * Interface representing a free camera inputs manager
  122752. */
  122753. interface FreeCameraInputsManager {
  122754. /**
  122755. * Adds gamepad input support to the FreeCameraInputsManager.
  122756. * @returns the FreeCameraInputsManager
  122757. */
  122758. addGamepad(): FreeCameraInputsManager;
  122759. }
  122760. /**
  122761. * Interface representing an arc rotate camera inputs manager
  122762. */
  122763. interface ArcRotateCameraInputsManager {
  122764. /**
  122765. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122766. * @returns the camera inputs manager
  122767. */
  122768. addGamepad(): ArcRotateCameraInputsManager;
  122769. }
  122770. /**
  122771. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122772. */
  122773. export class GamepadSystemSceneComponent implements ISceneComponent {
  122774. /**
  122775. * The component name helpfull to identify the component in the list of scene components.
  122776. */
  122777. readonly name: string;
  122778. /**
  122779. * The scene the component belongs to.
  122780. */
  122781. scene: Scene;
  122782. /**
  122783. * Creates a new instance of the component for the given scene
  122784. * @param scene Defines the scene to register the component in
  122785. */
  122786. constructor(scene: Scene);
  122787. /**
  122788. * Registers the component in a given scene
  122789. */
  122790. register(): void;
  122791. /**
  122792. * Rebuilds the elements related to this component in case of
  122793. * context lost for instance.
  122794. */
  122795. rebuild(): void;
  122796. /**
  122797. * Disposes the component and the associated ressources
  122798. */
  122799. dispose(): void;
  122800. private _beforeCameraUpdate;
  122801. }
  122802. }
  122803. declare module BABYLON {
  122804. /**
  122805. * 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,
  122806. * which still works and will still be found in many Playgrounds.
  122807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122808. */
  122809. export class UniversalCamera extends TouchCamera {
  122810. /**
  122811. * Defines the gamepad rotation sensiblity.
  122812. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122813. */
  122814. get gamepadAngularSensibility(): number;
  122815. set gamepadAngularSensibility(value: number);
  122816. /**
  122817. * Defines the gamepad move sensiblity.
  122818. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122819. */
  122820. get gamepadMoveSensibility(): number;
  122821. set gamepadMoveSensibility(value: number);
  122822. /**
  122823. * 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,
  122824. * which still works and will still be found in many Playgrounds.
  122825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122826. * @param name Define the name of the camera in the scene
  122827. * @param position Define the start position of the camera in the scene
  122828. * @param scene Define the scene the camera belongs to
  122829. */
  122830. constructor(name: string, position: Vector3, scene: Scene);
  122831. /**
  122832. * Gets the current object class name.
  122833. * @return the class name
  122834. */
  122835. getClassName(): string;
  122836. }
  122837. }
  122838. declare module BABYLON {
  122839. /**
  122840. * This represents a FPS type of camera. This is only here for back compat purpose.
  122841. * Please use the UniversalCamera instead as both are identical.
  122842. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122843. */
  122844. export class GamepadCamera extends UniversalCamera {
  122845. /**
  122846. * Instantiates a new Gamepad Camera
  122847. * This represents a FPS type of camera. This is only here for back compat purpose.
  122848. * Please use the UniversalCamera instead as both are identical.
  122849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122850. * @param name Define the name of the camera in the scene
  122851. * @param position Define the start position of the camera in the scene
  122852. * @param scene Define the scene the camera belongs to
  122853. */
  122854. constructor(name: string, position: Vector3, scene: Scene);
  122855. /**
  122856. * Gets the current object class name.
  122857. * @return the class name
  122858. */
  122859. getClassName(): string;
  122860. }
  122861. }
  122862. declare module BABYLON {
  122863. /** @hidden */
  122864. export var passPixelShader: {
  122865. name: string;
  122866. shader: string;
  122867. };
  122868. }
  122869. declare module BABYLON {
  122870. /** @hidden */
  122871. export var passCubePixelShader: {
  122872. name: string;
  122873. shader: string;
  122874. };
  122875. }
  122876. declare module BABYLON {
  122877. /**
  122878. * PassPostProcess which produces an output the same as it's input
  122879. */
  122880. export class PassPostProcess extends PostProcess {
  122881. /**
  122882. * Creates the PassPostProcess
  122883. * @param name The name of the effect.
  122884. * @param options The required width/height ratio to downsize to before computing the render pass.
  122885. * @param camera The camera to apply the render pass to.
  122886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122887. * @param engine The engine which the post process will be applied. (default: current engine)
  122888. * @param reusable If the post process can be reused on the same frame. (default: false)
  122889. * @param textureType The type of texture to be used when performing the post processing.
  122890. * @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)
  122891. */
  122892. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122893. }
  122894. /**
  122895. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122896. */
  122897. export class PassCubePostProcess extends PostProcess {
  122898. private _face;
  122899. /**
  122900. * Gets or sets the cube face to display.
  122901. * * 0 is +X
  122902. * * 1 is -X
  122903. * * 2 is +Y
  122904. * * 3 is -Y
  122905. * * 4 is +Z
  122906. * * 5 is -Z
  122907. */
  122908. get face(): number;
  122909. set face(value: number);
  122910. /**
  122911. * Creates the PassCubePostProcess
  122912. * @param name The name of the effect.
  122913. * @param options The required width/height ratio to downsize to before computing the render pass.
  122914. * @param camera The camera to apply the render pass to.
  122915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122916. * @param engine The engine which the post process will be applied. (default: current engine)
  122917. * @param reusable If the post process can be reused on the same frame. (default: false)
  122918. * @param textureType The type of texture to be used when performing the post processing.
  122919. * @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)
  122920. */
  122921. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122922. }
  122923. }
  122924. declare module BABYLON {
  122925. /** @hidden */
  122926. export var anaglyphPixelShader: {
  122927. name: string;
  122928. shader: string;
  122929. };
  122930. }
  122931. declare module BABYLON {
  122932. /**
  122933. * Postprocess used to generate anaglyphic rendering
  122934. */
  122935. export class AnaglyphPostProcess extends PostProcess {
  122936. private _passedProcess;
  122937. /**
  122938. * Creates a new AnaglyphPostProcess
  122939. * @param name defines postprocess name
  122940. * @param options defines creation options or target ratio scale
  122941. * @param rigCameras defines cameras using this postprocess
  122942. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122943. * @param engine defines hosting engine
  122944. * @param reusable defines if the postprocess will be reused multiple times per frame
  122945. */
  122946. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122947. }
  122948. }
  122949. declare module BABYLON {
  122950. /**
  122951. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122952. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122953. */
  122954. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122955. /**
  122956. * Creates a new AnaglyphArcRotateCamera
  122957. * @param name defines camera name
  122958. * @param alpha defines alpha angle (in radians)
  122959. * @param beta defines beta angle (in radians)
  122960. * @param radius defines radius
  122961. * @param target defines camera target
  122962. * @param interaxialDistance defines distance between each color axis
  122963. * @param scene defines the hosting scene
  122964. */
  122965. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122966. /**
  122967. * Gets camera class name
  122968. * @returns AnaglyphArcRotateCamera
  122969. */
  122970. getClassName(): string;
  122971. }
  122972. }
  122973. declare module BABYLON {
  122974. /**
  122975. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122976. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122977. */
  122978. export class AnaglyphFreeCamera extends FreeCamera {
  122979. /**
  122980. * Creates a new AnaglyphFreeCamera
  122981. * @param name defines camera name
  122982. * @param position defines initial position
  122983. * @param interaxialDistance defines distance between each color axis
  122984. * @param scene defines the hosting scene
  122985. */
  122986. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122987. /**
  122988. * Gets camera class name
  122989. * @returns AnaglyphFreeCamera
  122990. */
  122991. getClassName(): string;
  122992. }
  122993. }
  122994. declare module BABYLON {
  122995. /**
  122996. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122997. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122998. */
  122999. export class AnaglyphGamepadCamera extends GamepadCamera {
  123000. /**
  123001. * Creates a new AnaglyphGamepadCamera
  123002. * @param name defines camera name
  123003. * @param position defines initial position
  123004. * @param interaxialDistance defines distance between each color axis
  123005. * @param scene defines the hosting scene
  123006. */
  123007. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123008. /**
  123009. * Gets camera class name
  123010. * @returns AnaglyphGamepadCamera
  123011. */
  123012. getClassName(): string;
  123013. }
  123014. }
  123015. declare module BABYLON {
  123016. /**
  123017. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123018. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123019. */
  123020. export class AnaglyphUniversalCamera extends UniversalCamera {
  123021. /**
  123022. * Creates a new AnaglyphUniversalCamera
  123023. * @param name defines camera name
  123024. * @param position defines initial position
  123025. * @param interaxialDistance defines distance between each color axis
  123026. * @param scene defines the hosting scene
  123027. */
  123028. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123029. /**
  123030. * Gets camera class name
  123031. * @returns AnaglyphUniversalCamera
  123032. */
  123033. getClassName(): string;
  123034. }
  123035. }
  123036. declare module BABYLON {
  123037. /**
  123038. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123039. * @see http://doc.babylonjs.com/features/cameras
  123040. */
  123041. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123042. /**
  123043. * Creates a new StereoscopicArcRotateCamera
  123044. * @param name defines camera name
  123045. * @param alpha defines alpha angle (in radians)
  123046. * @param beta defines beta angle (in radians)
  123047. * @param radius defines radius
  123048. * @param target defines camera target
  123049. * @param interaxialDistance defines distance between each color axis
  123050. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123051. * @param scene defines the hosting scene
  123052. */
  123053. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123054. /**
  123055. * Gets camera class name
  123056. * @returns StereoscopicArcRotateCamera
  123057. */
  123058. getClassName(): string;
  123059. }
  123060. }
  123061. declare module BABYLON {
  123062. /**
  123063. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123064. * @see http://doc.babylonjs.com/features/cameras
  123065. */
  123066. export class StereoscopicFreeCamera extends FreeCamera {
  123067. /**
  123068. * Creates a new StereoscopicFreeCamera
  123069. * @param name defines camera name
  123070. * @param position defines initial position
  123071. * @param interaxialDistance defines distance between each color axis
  123072. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123073. * @param scene defines the hosting scene
  123074. */
  123075. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123076. /**
  123077. * Gets camera class name
  123078. * @returns StereoscopicFreeCamera
  123079. */
  123080. getClassName(): string;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123086. * @see http://doc.babylonjs.com/features/cameras
  123087. */
  123088. export class StereoscopicGamepadCamera extends GamepadCamera {
  123089. /**
  123090. * Creates a new StereoscopicGamepadCamera
  123091. * @param name defines camera name
  123092. * @param position defines initial position
  123093. * @param interaxialDistance defines distance between each color axis
  123094. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123095. * @param scene defines the hosting scene
  123096. */
  123097. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123098. /**
  123099. * Gets camera class name
  123100. * @returns StereoscopicGamepadCamera
  123101. */
  123102. getClassName(): string;
  123103. }
  123104. }
  123105. declare module BABYLON {
  123106. /**
  123107. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123108. * @see http://doc.babylonjs.com/features/cameras
  123109. */
  123110. export class StereoscopicUniversalCamera extends UniversalCamera {
  123111. /**
  123112. * Creates a new StereoscopicUniversalCamera
  123113. * @param name defines camera name
  123114. * @param position defines initial position
  123115. * @param interaxialDistance defines distance between each color axis
  123116. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123117. * @param scene defines the hosting scene
  123118. */
  123119. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123120. /**
  123121. * Gets camera class name
  123122. * @returns StereoscopicUniversalCamera
  123123. */
  123124. getClassName(): string;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. /**
  123129. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123130. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123131. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123132. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123133. */
  123134. export class VirtualJoysticksCamera extends FreeCamera {
  123135. /**
  123136. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123137. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123138. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123139. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123140. * @param name Define the name of the camera in the scene
  123141. * @param position Define the start position of the camera in the scene
  123142. * @param scene Define the scene the camera belongs to
  123143. */
  123144. constructor(name: string, position: Vector3, scene: Scene);
  123145. /**
  123146. * Gets the current object class name.
  123147. * @return the class name
  123148. */
  123149. getClassName(): string;
  123150. }
  123151. }
  123152. declare module BABYLON {
  123153. /**
  123154. * This represents all the required metrics to create a VR camera.
  123155. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123156. */
  123157. export class VRCameraMetrics {
  123158. /**
  123159. * Define the horizontal resolution off the screen.
  123160. */
  123161. hResolution: number;
  123162. /**
  123163. * Define the vertical resolution off the screen.
  123164. */
  123165. vResolution: number;
  123166. /**
  123167. * Define the horizontal screen size.
  123168. */
  123169. hScreenSize: number;
  123170. /**
  123171. * Define the vertical screen size.
  123172. */
  123173. vScreenSize: number;
  123174. /**
  123175. * Define the vertical screen center position.
  123176. */
  123177. vScreenCenter: number;
  123178. /**
  123179. * Define the distance of the eyes to the screen.
  123180. */
  123181. eyeToScreenDistance: number;
  123182. /**
  123183. * Define the distance between both lenses
  123184. */
  123185. lensSeparationDistance: number;
  123186. /**
  123187. * Define the distance between both viewer's eyes.
  123188. */
  123189. interpupillaryDistance: number;
  123190. /**
  123191. * Define the distortion factor of the VR postprocess.
  123192. * Please, touch with care.
  123193. */
  123194. distortionK: number[];
  123195. /**
  123196. * Define the chromatic aberration correction factors for the VR post process.
  123197. */
  123198. chromaAbCorrection: number[];
  123199. /**
  123200. * Define the scale factor of the post process.
  123201. * The smaller the better but the slower.
  123202. */
  123203. postProcessScaleFactor: number;
  123204. /**
  123205. * Define an offset for the lens center.
  123206. */
  123207. lensCenterOffset: number;
  123208. /**
  123209. * Define if the current vr camera should compensate the distortion of the lense or not.
  123210. */
  123211. compensateDistortion: boolean;
  123212. /**
  123213. * Defines if multiview should be enabled when rendering (Default: false)
  123214. */
  123215. multiviewEnabled: boolean;
  123216. /**
  123217. * Gets the rendering aspect ratio based on the provided resolutions.
  123218. */
  123219. get aspectRatio(): number;
  123220. /**
  123221. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123222. */
  123223. get aspectRatioFov(): number;
  123224. /**
  123225. * @hidden
  123226. */
  123227. get leftHMatrix(): Matrix;
  123228. /**
  123229. * @hidden
  123230. */
  123231. get rightHMatrix(): Matrix;
  123232. /**
  123233. * @hidden
  123234. */
  123235. get leftPreViewMatrix(): Matrix;
  123236. /**
  123237. * @hidden
  123238. */
  123239. get rightPreViewMatrix(): Matrix;
  123240. /**
  123241. * Get the default VRMetrics based on the most generic setup.
  123242. * @returns the default vr metrics
  123243. */
  123244. static GetDefault(): VRCameraMetrics;
  123245. }
  123246. }
  123247. declare module BABYLON {
  123248. /** @hidden */
  123249. export var vrDistortionCorrectionPixelShader: {
  123250. name: string;
  123251. shader: string;
  123252. };
  123253. }
  123254. declare module BABYLON {
  123255. /**
  123256. * VRDistortionCorrectionPostProcess used for mobile VR
  123257. */
  123258. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123259. private _isRightEye;
  123260. private _distortionFactors;
  123261. private _postProcessScaleFactor;
  123262. private _lensCenterOffset;
  123263. private _scaleIn;
  123264. private _scaleFactor;
  123265. private _lensCenter;
  123266. /**
  123267. * Initializes the VRDistortionCorrectionPostProcess
  123268. * @param name The name of the effect.
  123269. * @param camera The camera to apply the render pass to.
  123270. * @param isRightEye If this is for the right eye distortion
  123271. * @param vrMetrics All the required metrics for the VR camera
  123272. */
  123273. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123274. }
  123275. }
  123276. declare module BABYLON {
  123277. /**
  123278. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123279. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123280. */
  123281. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123282. /**
  123283. * Creates a new VRDeviceOrientationArcRotateCamera
  123284. * @param name defines camera name
  123285. * @param alpha defines the camera rotation along the logitudinal axis
  123286. * @param beta defines the camera rotation along the latitudinal axis
  123287. * @param radius defines the camera distance from its target
  123288. * @param target defines the camera target
  123289. * @param scene defines the scene the camera belongs to
  123290. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123291. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123292. */
  123293. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123294. /**
  123295. * Gets camera class name
  123296. * @returns VRDeviceOrientationArcRotateCamera
  123297. */
  123298. getClassName(): string;
  123299. }
  123300. }
  123301. declare module BABYLON {
  123302. /**
  123303. * Camera used to simulate VR rendering (based on FreeCamera)
  123304. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123305. */
  123306. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123307. /**
  123308. * Creates a new VRDeviceOrientationFreeCamera
  123309. * @param name defines camera name
  123310. * @param position defines the start position of the camera
  123311. * @param scene defines the scene the camera belongs to
  123312. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123313. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123314. */
  123315. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123316. /**
  123317. * Gets camera class name
  123318. * @returns VRDeviceOrientationFreeCamera
  123319. */
  123320. getClassName(): string;
  123321. }
  123322. }
  123323. declare module BABYLON {
  123324. /**
  123325. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123326. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123327. */
  123328. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123329. /**
  123330. * Creates a new VRDeviceOrientationGamepadCamera
  123331. * @param name defines camera name
  123332. * @param position defines the start position of the camera
  123333. * @param scene defines the scene the camera belongs to
  123334. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123335. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123336. */
  123337. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123338. /**
  123339. * Gets camera class name
  123340. * @returns VRDeviceOrientationGamepadCamera
  123341. */
  123342. getClassName(): string;
  123343. }
  123344. }
  123345. declare module BABYLON {
  123346. /**
  123347. * A class extending Texture allowing drawing on a texture
  123348. * @see http://doc.babylonjs.com/how_to/dynamictexture
  123349. */
  123350. export class DynamicTexture extends Texture {
  123351. private _generateMipMaps;
  123352. private _canvas;
  123353. private _context;
  123354. /**
  123355. * Creates a DynamicTexture
  123356. * @param name defines the name of the texture
  123357. * @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
  123358. * @param scene defines the scene where you want the texture
  123359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123362. */
  123363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123364. /**
  123365. * Get the current class name of the texture useful for serialization or dynamic coding.
  123366. * @returns "DynamicTexture"
  123367. */
  123368. getClassName(): string;
  123369. /**
  123370. * Gets the current state of canRescale
  123371. */
  123372. get canRescale(): boolean;
  123373. private _recreate;
  123374. /**
  123375. * Scales the texture
  123376. * @param ratio the scale factor to apply to both width and height
  123377. */
  123378. scale(ratio: number): void;
  123379. /**
  123380. * Resizes the texture
  123381. * @param width the new width
  123382. * @param height the new height
  123383. */
  123384. scaleTo(width: number, height: number): void;
  123385. /**
  123386. * Gets the context of the canvas used by the texture
  123387. * @returns the canvas context of the dynamic texture
  123388. */
  123389. getContext(): CanvasRenderingContext2D;
  123390. /**
  123391. * Clears the texture
  123392. */
  123393. clear(): void;
  123394. /**
  123395. * Updates the texture
  123396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123398. */
  123399. update(invertY?: boolean, premulAlpha?: boolean): void;
  123400. /**
  123401. * Draws text onto the texture
  123402. * @param text defines the text to be drawn
  123403. * @param x defines the placement of the text from the left
  123404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123405. * @param font defines the font to be used with font-style, font-size, font-name
  123406. * @param color defines the color used for the text
  123407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123409. * @param update defines whether texture is immediately update (default is true)
  123410. */
  123411. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123412. /**
  123413. * Clones the texture
  123414. * @returns the clone of the texture.
  123415. */
  123416. clone(): DynamicTexture;
  123417. /**
  123418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123419. * @returns a serialized dynamic texture object
  123420. */
  123421. serialize(): any;
  123422. private _IsCanvasElement;
  123423. /** @hidden */
  123424. _rebuild(): void;
  123425. }
  123426. }
  123427. declare module BABYLON {
  123428. /** @hidden */
  123429. export var imageProcessingPixelShader: {
  123430. name: string;
  123431. shader: string;
  123432. };
  123433. }
  123434. declare module BABYLON {
  123435. /**
  123436. * ImageProcessingPostProcess
  123437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123438. */
  123439. export class ImageProcessingPostProcess extends PostProcess {
  123440. /**
  123441. * Default configuration related to image processing available in the PBR Material.
  123442. */
  123443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123444. /**
  123445. * Gets the image processing configuration used either in this material.
  123446. */
  123447. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123448. /**
  123449. * Sets the Default image processing configuration used either in the this material.
  123450. *
  123451. * If sets to null, the scene one is in use.
  123452. */
  123453. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123454. /**
  123455. * Keep track of the image processing observer to allow dispose and replace.
  123456. */
  123457. private _imageProcessingObserver;
  123458. /**
  123459. * Attaches a new image processing configuration to the PBR Material.
  123460. * @param configuration
  123461. */
  123462. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123463. /**
  123464. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123465. */
  123466. get colorCurves(): Nullable<ColorCurves>;
  123467. /**
  123468. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123469. */
  123470. set colorCurves(value: Nullable<ColorCurves>);
  123471. /**
  123472. * Gets wether the color curves effect is enabled.
  123473. */
  123474. get colorCurvesEnabled(): boolean;
  123475. /**
  123476. * Sets wether the color curves effect is enabled.
  123477. */
  123478. set colorCurvesEnabled(value: boolean);
  123479. /**
  123480. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123481. */
  123482. get colorGradingTexture(): Nullable<BaseTexture>;
  123483. /**
  123484. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123485. */
  123486. set colorGradingTexture(value: Nullable<BaseTexture>);
  123487. /**
  123488. * Gets wether the color grading effect is enabled.
  123489. */
  123490. get colorGradingEnabled(): boolean;
  123491. /**
  123492. * Gets wether the color grading effect is enabled.
  123493. */
  123494. set colorGradingEnabled(value: boolean);
  123495. /**
  123496. * Gets exposure used in the effect.
  123497. */
  123498. get exposure(): number;
  123499. /**
  123500. * Sets exposure used in the effect.
  123501. */
  123502. set exposure(value: number);
  123503. /**
  123504. * Gets wether tonemapping is enabled or not.
  123505. */
  123506. get toneMappingEnabled(): boolean;
  123507. /**
  123508. * Sets wether tonemapping is enabled or not
  123509. */
  123510. set toneMappingEnabled(value: boolean);
  123511. /**
  123512. * Gets the type of tone mapping effect.
  123513. */
  123514. get toneMappingType(): number;
  123515. /**
  123516. * Sets the type of tone mapping effect.
  123517. */
  123518. set toneMappingType(value: number);
  123519. /**
  123520. * Gets contrast used in the effect.
  123521. */
  123522. get contrast(): number;
  123523. /**
  123524. * Sets contrast used in the effect.
  123525. */
  123526. set contrast(value: number);
  123527. /**
  123528. * Gets Vignette stretch size.
  123529. */
  123530. get vignetteStretch(): number;
  123531. /**
  123532. * Sets Vignette stretch size.
  123533. */
  123534. set vignetteStretch(value: number);
  123535. /**
  123536. * Gets Vignette centre X Offset.
  123537. */
  123538. get vignetteCentreX(): number;
  123539. /**
  123540. * Sets Vignette centre X Offset.
  123541. */
  123542. set vignetteCentreX(value: number);
  123543. /**
  123544. * Gets Vignette centre Y Offset.
  123545. */
  123546. get vignetteCentreY(): number;
  123547. /**
  123548. * Sets Vignette centre Y Offset.
  123549. */
  123550. set vignetteCentreY(value: number);
  123551. /**
  123552. * Gets Vignette weight or intensity of the vignette effect.
  123553. */
  123554. get vignetteWeight(): number;
  123555. /**
  123556. * Sets Vignette weight or intensity of the vignette effect.
  123557. */
  123558. set vignetteWeight(value: number);
  123559. /**
  123560. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123561. * if vignetteEnabled is set to true.
  123562. */
  123563. get vignetteColor(): Color4;
  123564. /**
  123565. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123566. * if vignetteEnabled is set to true.
  123567. */
  123568. set vignetteColor(value: Color4);
  123569. /**
  123570. * Gets Camera field of view used by the Vignette effect.
  123571. */
  123572. get vignetteCameraFov(): number;
  123573. /**
  123574. * Sets Camera field of view used by the Vignette effect.
  123575. */
  123576. set vignetteCameraFov(value: number);
  123577. /**
  123578. * Gets the vignette blend mode allowing different kind of effect.
  123579. */
  123580. get vignetteBlendMode(): number;
  123581. /**
  123582. * Sets the vignette blend mode allowing different kind of effect.
  123583. */
  123584. set vignetteBlendMode(value: number);
  123585. /**
  123586. * Gets wether the vignette effect is enabled.
  123587. */
  123588. get vignetteEnabled(): boolean;
  123589. /**
  123590. * Sets wether the vignette effect is enabled.
  123591. */
  123592. set vignetteEnabled(value: boolean);
  123593. private _fromLinearSpace;
  123594. /**
  123595. * Gets wether the input of the processing is in Gamma or Linear Space.
  123596. */
  123597. get fromLinearSpace(): boolean;
  123598. /**
  123599. * Sets wether the input of the processing is in Gamma or Linear Space.
  123600. */
  123601. set fromLinearSpace(value: boolean);
  123602. /**
  123603. * Defines cache preventing GC.
  123604. */
  123605. private _defines;
  123606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  123607. /**
  123608. * "ImageProcessingPostProcess"
  123609. * @returns "ImageProcessingPostProcess"
  123610. */
  123611. getClassName(): string;
  123612. protected _updateParameters(): void;
  123613. dispose(camera?: Camera): void;
  123614. }
  123615. }
  123616. declare module BABYLON {
  123617. /**
  123618. * Class containing static functions to help procedurally build meshes
  123619. */
  123620. export class GroundBuilder {
  123621. /**
  123622. * Creates a ground mesh
  123623. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123624. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123626. * @param name defines the name of the mesh
  123627. * @param options defines the options used to create the mesh
  123628. * @param scene defines the hosting scene
  123629. * @returns the ground mesh
  123630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123631. */
  123632. static CreateGround(name: string, options: {
  123633. width?: number;
  123634. height?: number;
  123635. subdivisions?: number;
  123636. subdivisionsX?: number;
  123637. subdivisionsY?: number;
  123638. updatable?: boolean;
  123639. }, scene: any): Mesh;
  123640. /**
  123641. * Creates a tiled ground mesh
  123642. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123643. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123644. * * 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
  123645. * * 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
  123646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123647. * @param name defines the name of the mesh
  123648. * @param options defines the options used to create the mesh
  123649. * @param scene defines the hosting scene
  123650. * @returns the tiled ground mesh
  123651. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123652. */
  123653. static CreateTiledGround(name: string, options: {
  123654. xmin: number;
  123655. zmin: number;
  123656. xmax: number;
  123657. zmax: number;
  123658. subdivisions?: {
  123659. w: number;
  123660. h: number;
  123661. };
  123662. precision?: {
  123663. w: number;
  123664. h: number;
  123665. };
  123666. updatable?: boolean;
  123667. }, scene?: Nullable<Scene>): Mesh;
  123668. /**
  123669. * Creates a ground mesh from a height map
  123670. * * The parameter `url` sets the URL of the height map image resource.
  123671. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123672. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123673. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123674. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123675. * * 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.
  123676. * * 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).
  123677. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123679. * @param name defines the name of the mesh
  123680. * @param url defines the url to the height map
  123681. * @param options defines the options used to create the mesh
  123682. * @param scene defines the hosting scene
  123683. * @returns the ground mesh
  123684. * @see https://doc.babylonjs.com/babylon101/height_map
  123685. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123686. */
  123687. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123688. width?: number;
  123689. height?: number;
  123690. subdivisions?: number;
  123691. minHeight?: number;
  123692. maxHeight?: number;
  123693. colorFilter?: Color3;
  123694. alphaFilter?: number;
  123695. updatable?: boolean;
  123696. onReady?: (mesh: GroundMesh) => void;
  123697. }, scene?: Nullable<Scene>): GroundMesh;
  123698. }
  123699. }
  123700. declare module BABYLON {
  123701. /**
  123702. * Class containing static functions to help procedurally build meshes
  123703. */
  123704. export class TorusBuilder {
  123705. /**
  123706. * Creates a torus mesh
  123707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123713. * @param name defines the name of the mesh
  123714. * @param options defines the options used to create the mesh
  123715. * @param scene defines the hosting scene
  123716. * @returns the torus mesh
  123717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123718. */
  123719. static CreateTorus(name: string, options: {
  123720. diameter?: number;
  123721. thickness?: number;
  123722. tessellation?: number;
  123723. updatable?: boolean;
  123724. sideOrientation?: number;
  123725. frontUVs?: Vector4;
  123726. backUVs?: Vector4;
  123727. }, scene: any): Mesh;
  123728. }
  123729. }
  123730. declare module BABYLON {
  123731. /**
  123732. * Class containing static functions to help procedurally build meshes
  123733. */
  123734. export class CylinderBuilder {
  123735. /**
  123736. * Creates a cylinder or a cone mesh
  123737. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123738. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123739. * * 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.
  123740. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123741. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123742. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123743. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123744. * * 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).
  123745. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123746. * * 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).
  123747. * * 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
  123748. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123749. * * 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
  123750. * * 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.
  123751. * * If `enclose` is false, a ring surface is one element.
  123752. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123753. * * 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
  123754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123757. * @param name defines the name of the mesh
  123758. * @param options defines the options used to create the mesh
  123759. * @param scene defines the hosting scene
  123760. * @returns the cylinder mesh
  123761. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123762. */
  123763. static CreateCylinder(name: string, options: {
  123764. height?: number;
  123765. diameterTop?: number;
  123766. diameterBottom?: number;
  123767. diameter?: number;
  123768. tessellation?: number;
  123769. subdivisions?: number;
  123770. arc?: number;
  123771. faceColors?: Color4[];
  123772. faceUV?: Vector4[];
  123773. updatable?: boolean;
  123774. hasRings?: boolean;
  123775. enclose?: boolean;
  123776. cap?: number;
  123777. sideOrientation?: number;
  123778. frontUVs?: Vector4;
  123779. backUVs?: Vector4;
  123780. }, scene: any): Mesh;
  123781. }
  123782. }
  123783. declare module BABYLON {
  123784. /**
  123785. * States of the webXR experience
  123786. */
  123787. export enum WebXRState {
  123788. /**
  123789. * Transitioning to being in XR mode
  123790. */
  123791. ENTERING_XR = 0,
  123792. /**
  123793. * Transitioning to non XR mode
  123794. */
  123795. EXITING_XR = 1,
  123796. /**
  123797. * In XR mode and presenting
  123798. */
  123799. IN_XR = 2,
  123800. /**
  123801. * Not entered XR mode
  123802. */
  123803. NOT_IN_XR = 3
  123804. }
  123805. /**
  123806. * Abstraction of the XR render target
  123807. */
  123808. export interface WebXRRenderTarget extends IDisposable {
  123809. /**
  123810. * xrpresent context of the canvas which can be used to display/mirror xr content
  123811. */
  123812. canvasContext: WebGLRenderingContext;
  123813. /**
  123814. * xr layer for the canvas
  123815. */
  123816. xrLayer: Nullable<XRWebGLLayer>;
  123817. /**
  123818. * Initializes the xr layer for the session
  123819. * @param xrSession xr session
  123820. * @returns a promise that will resolve once the XR Layer has been created
  123821. */
  123822. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123823. }
  123824. }
  123825. declare module BABYLON {
  123826. /**
  123827. * COnfiguration object for WebXR output canvas
  123828. */
  123829. export class WebXRManagedOutputCanvasOptions {
  123830. /**
  123831. * An optional canvas in case you wish to create it yourself and provide it here.
  123832. * If not provided, a new canvas will be created
  123833. */
  123834. canvasElement?: HTMLCanvasElement;
  123835. /**
  123836. * Options for this XR Layer output
  123837. */
  123838. canvasOptions?: XRWebGLLayerOptions;
  123839. /**
  123840. * CSS styling for a newly created canvas (if not provided)
  123841. */
  123842. newCanvasCssStyle?: string;
  123843. /**
  123844. * Get the default values of the configuration object
  123845. * @returns default values of this configuration object
  123846. */
  123847. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123848. }
  123849. /**
  123850. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123851. */
  123852. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123853. private _options;
  123854. private _canvas;
  123855. private _engine;
  123856. /**
  123857. * Rendering context of the canvas which can be used to display/mirror xr content
  123858. */
  123859. canvasContext: WebGLRenderingContext;
  123860. /**
  123861. * xr layer for the canvas
  123862. */
  123863. xrLayer: Nullable<XRWebGLLayer>;
  123864. /**
  123865. * Initializes the canvas to be added/removed upon entering/exiting xr
  123866. * @param _xrSessionManager The XR Session manager
  123867. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123868. */
  123869. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123870. /**
  123871. * Disposes of the object
  123872. */
  123873. dispose(): void;
  123874. /**
  123875. * Initializes the xr layer for the session
  123876. * @param xrSession xr session
  123877. * @returns a promise that will resolve once the XR Layer has been created
  123878. */
  123879. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123880. private _addCanvas;
  123881. private _removeCanvas;
  123882. private _setManagedOutputCanvas;
  123883. }
  123884. }
  123885. declare module BABYLON {
  123886. /**
  123887. * Manages an XRSession to work with Babylon's engine
  123888. * @see https://doc.babylonjs.com/how_to/webxr
  123889. */
  123890. export class WebXRSessionManager implements IDisposable {
  123891. /** The scene which the session should be created for */
  123892. scene: Scene;
  123893. private _referenceSpace;
  123894. private _rttProvider;
  123895. private _sessionEnded;
  123896. private _xrNavigator;
  123897. private baseLayer;
  123898. /**
  123899. * The base reference space from which the session started. good if you want to reset your
  123900. * reference space
  123901. */
  123902. baseReferenceSpace: XRReferenceSpace;
  123903. /**
  123904. * Current XR frame
  123905. */
  123906. currentFrame: Nullable<XRFrame>;
  123907. /** WebXR timestamp updated every frame */
  123908. currentTimestamp: number;
  123909. /**
  123910. * Used just in case of a failure to initialize an immersive session.
  123911. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123912. */
  123913. defaultHeightCompensation: number;
  123914. /**
  123915. * Fires every time a new xrFrame arrives which can be used to update the camera
  123916. */
  123917. onXRFrameObservable: Observable<XRFrame>;
  123918. /**
  123919. * Fires when the reference space changed
  123920. */
  123921. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123922. /**
  123923. * Fires when the xr session is ended either by the device or manually done
  123924. */
  123925. onXRSessionEnded: Observable<any>;
  123926. /**
  123927. * Fires when the xr session is ended either by the device or manually done
  123928. */
  123929. onXRSessionInit: Observable<XRSession>;
  123930. /**
  123931. * Underlying xr session
  123932. */
  123933. session: XRSession;
  123934. /**
  123935. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123936. * or get the offset the player is currently at.
  123937. */
  123938. viewerReferenceSpace: XRReferenceSpace;
  123939. /**
  123940. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123941. * @param scene The scene which the session should be created for
  123942. */
  123943. constructor(
  123944. /** The scene which the session should be created for */
  123945. scene: Scene);
  123946. /**
  123947. * The current reference space used in this session. This reference space can constantly change!
  123948. * It is mainly used to offset the camera's position.
  123949. */
  123950. get referenceSpace(): XRReferenceSpace;
  123951. /**
  123952. * Set a new reference space and triggers the observable
  123953. */
  123954. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123955. /**
  123956. * Disposes of the session manager
  123957. */
  123958. dispose(): void;
  123959. /**
  123960. * Stops the xrSession and restores the render loop
  123961. * @returns Promise which resolves after it exits XR
  123962. */
  123963. exitXRAsync(): Promise<void>;
  123964. /**
  123965. * Gets the correct render target texture to be rendered this frame for this eye
  123966. * @param eye the eye for which to get the render target
  123967. * @returns the render target for the specified eye
  123968. */
  123969. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123970. /**
  123971. * Creates a WebXRRenderTarget object for the XR session
  123972. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123973. * @param options optional options to provide when creating a new render target
  123974. * @returns a WebXR render target to which the session can render
  123975. */
  123976. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123977. /**
  123978. * Initializes the manager
  123979. * After initialization enterXR can be called to start an XR session
  123980. * @returns Promise which resolves after it is initialized
  123981. */
  123982. initializeAsync(): Promise<void>;
  123983. /**
  123984. * Initializes an xr session
  123985. * @param xrSessionMode mode to initialize
  123986. * @param xrSessionInit defines optional and required values to pass to the session builder
  123987. * @returns a promise which will resolve once the session has been initialized
  123988. */
  123989. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123990. /**
  123991. * Checks if a session would be supported for the creation options specified
  123992. * @param sessionMode session mode to check if supported eg. immersive-vr
  123993. * @returns A Promise that resolves to true if supported and false if not
  123994. */
  123995. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123996. /**
  123997. * Resets the reference space to the one started the session
  123998. */
  123999. resetReferenceSpace(): void;
  124000. /**
  124001. * Starts rendering to the xr layer
  124002. */
  124003. runXRRenderLoop(): void;
  124004. /**
  124005. * Sets the reference space on the xr session
  124006. * @param referenceSpaceType space to set
  124007. * @returns a promise that will resolve once the reference space has been set
  124008. */
  124009. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124010. /**
  124011. * Updates the render state of the session
  124012. * @param state state to set
  124013. * @returns a promise that resolves once the render state has been updated
  124014. */
  124015. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124016. /**
  124017. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124018. * @param sessionMode defines the session to test
  124019. * @returns a promise with boolean as final value
  124020. */
  124021. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124022. private _createRenderTargetTexture;
  124023. }
  124024. }
  124025. declare module BABYLON {
  124026. /**
  124027. * WebXR Camera which holds the views for the xrSession
  124028. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124029. */
  124030. export class WebXRCamera extends FreeCamera {
  124031. private _xrSessionManager;
  124032. private _firstFrame;
  124033. private _referenceQuaternion;
  124034. private _referencedPosition;
  124035. private _xrInvPositionCache;
  124036. private _xrInvQuaternionCache;
  124037. /**
  124038. * Should position compensation execute on first frame.
  124039. * This is used when copying the position from a native (non XR) camera
  124040. */
  124041. compensateOnFirstFrame: boolean;
  124042. /**
  124043. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124044. * @param name the name of the camera
  124045. * @param scene the scene to add the camera to
  124046. * @param _xrSessionManager a constructed xr session manager
  124047. */
  124048. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124049. /**
  124050. * Return the user's height, unrelated to the current ground.
  124051. * This will be the y position of this camera, when ground level is 0.
  124052. */
  124053. get realWorldHeight(): number;
  124054. /** @hidden */
  124055. _updateForDualEyeDebugging(): void;
  124056. /**
  124057. * Sets this camera's transformation based on a non-vr camera
  124058. * @param otherCamera the non-vr camera to copy the transformation from
  124059. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124060. */
  124061. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124062. /**
  124063. * Gets the current instance class name ("WebXRCamera").
  124064. * @returns the class name
  124065. */
  124066. getClassName(): string;
  124067. /**
  124068. * Overriding the _getViewMatrix function, as it is computed by WebXR
  124069. */
  124070. _getViewMatrix(): Matrix;
  124071. private _updateFromXRSession;
  124072. private _updateNumberOfRigCameras;
  124073. private _updateReferenceSpace;
  124074. private _updateReferenceSpaceOffset;
  124075. }
  124076. }
  124077. declare module BABYLON {
  124078. /**
  124079. * Defining the interface required for a (webxr) feature
  124080. */
  124081. export interface IWebXRFeature extends IDisposable {
  124082. /**
  124083. * Is this feature attached
  124084. */
  124085. attached: boolean;
  124086. /**
  124087. * Should auto-attach be disabled?
  124088. */
  124089. disableAutoAttach: boolean;
  124090. /**
  124091. * Attach the feature to the session
  124092. * Will usually be called by the features manager
  124093. *
  124094. * @param force should attachment be forced (even when already attached)
  124095. * @returns true if successful.
  124096. */
  124097. attach(force?: boolean): boolean;
  124098. /**
  124099. * Detach the feature from the session
  124100. * Will usually be called by the features manager
  124101. *
  124102. * @returns true if successful.
  124103. */
  124104. detach(): boolean;
  124105. }
  124106. /**
  124107. * A list of the currently available features without referencing them
  124108. */
  124109. export class WebXRFeatureName {
  124110. /**
  124111. * The name of the anchor system feature
  124112. */
  124113. static ANCHOR_SYSTEM: string;
  124114. /**
  124115. * The name of the background remover feature
  124116. */
  124117. static BACKGROUND_REMOVER: string;
  124118. /**
  124119. * The name of the hit test feature
  124120. */
  124121. static HIT_TEST: string;
  124122. /**
  124123. * physics impostors for xr controllers feature
  124124. */
  124125. static PHYSICS_CONTROLLERS: string;
  124126. /**
  124127. * The name of the plane detection feature
  124128. */
  124129. static PLANE_DETECTION: string;
  124130. /**
  124131. * The name of the pointer selection feature
  124132. */
  124133. static POINTER_SELECTION: string;
  124134. /**
  124135. * The name of the teleportation feature
  124136. */
  124137. static TELEPORTATION: string;
  124138. }
  124139. /**
  124140. * Defining the constructor of a feature. Used to register the modules.
  124141. */
  124142. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124143. /**
  124144. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124145. * It is mainly used in AR sessions.
  124146. *
  124147. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124148. */
  124149. export class WebXRFeaturesManager implements IDisposable {
  124150. private _xrSessionManager;
  124151. private static readonly _AvailableFeatures;
  124152. private _features;
  124153. /**
  124154. * constructs a new features manages.
  124155. *
  124156. * @param _xrSessionManager an instance of WebXRSessionManager
  124157. */
  124158. constructor(_xrSessionManager: WebXRSessionManager);
  124159. /**
  124160. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124161. * Mainly used internally.
  124162. *
  124163. * @param featureName the name of the feature to register
  124164. * @param constructorFunction the function used to construct the module
  124165. * @param version the (babylon) version of the module
  124166. * @param stable is that a stable version of this module
  124167. */
  124168. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124169. /**
  124170. * Returns a constructor of a specific feature.
  124171. *
  124172. * @param featureName the name of the feature to construct
  124173. * @param version the version of the feature to load
  124174. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124175. * @param options optional options provided to the module.
  124176. * @returns a function that, when called, will return a new instance of this feature
  124177. */
  124178. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124179. /**
  124180. * Can be used to return the list of features currently registered
  124181. *
  124182. * @returns an Array of available features
  124183. */
  124184. static GetAvailableFeatures(): string[];
  124185. /**
  124186. * Gets the versions available for a specific feature
  124187. * @param featureName the name of the feature
  124188. * @returns an array with the available versions
  124189. */
  124190. static GetAvailableVersions(featureName: string): string[];
  124191. /**
  124192. * Return the latest unstable version of this feature
  124193. * @param featureName the name of the feature to search
  124194. * @returns the version number. if not found will return -1
  124195. */
  124196. static GetLatestVersionOfFeature(featureName: string): number;
  124197. /**
  124198. * Return the latest stable version of this feature
  124199. * @param featureName the name of the feature to search
  124200. * @returns the version number. if not found will return -1
  124201. */
  124202. static GetStableVersionOfFeature(featureName: string): number;
  124203. /**
  124204. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124205. * Can be used during a session to start a feature
  124206. * @param featureName the name of feature to attach
  124207. */
  124208. attachFeature(featureName: string): void;
  124209. /**
  124210. * Can be used inside a session or when the session ends to detach a specific feature
  124211. * @param featureName the name of the feature to detach
  124212. */
  124213. detachFeature(featureName: string): void;
  124214. /**
  124215. * Used to disable an already-enabled feature
  124216. * The feature will be disposed and will be recreated once enabled.
  124217. * @param featureName the feature to disable
  124218. * @returns true if disable was successful
  124219. */
  124220. disableFeature(featureName: string | {
  124221. Name: string;
  124222. }): boolean;
  124223. /**
  124224. * dispose this features manager
  124225. */
  124226. dispose(): void;
  124227. /**
  124228. * 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.
  124229. * 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.
  124230. *
  124231. * @param featureName the name of the feature to load or the class of the feature
  124232. * @param version optional version to load. if not provided the latest version will be enabled
  124233. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124234. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124235. * @returns a new constructed feature or throws an error if feature not found.
  124236. */
  124237. enableFeature(featureName: string | {
  124238. Name: string;
  124239. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124240. /**
  124241. * get the implementation of an enabled feature.
  124242. * @param featureName the name of the feature to load
  124243. * @returns the feature class, if found
  124244. */
  124245. getEnabledFeature(featureName: string): IWebXRFeature;
  124246. /**
  124247. * Get the list of enabled features
  124248. * @returns an array of enabled features
  124249. */
  124250. getEnabledFeatures(): string[];
  124251. }
  124252. }
  124253. declare module BABYLON {
  124254. /**
  124255. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124256. * @see https://doc.babylonjs.com/how_to/webxr
  124257. */
  124258. export class WebXRExperienceHelper implements IDisposable {
  124259. private scene;
  124260. private _nonVRCamera;
  124261. private _originalSceneAutoClear;
  124262. private _supported;
  124263. /**
  124264. * Camera used to render xr content
  124265. */
  124266. camera: WebXRCamera;
  124267. /** A features manager for this xr session */
  124268. featuresManager: WebXRFeaturesManager;
  124269. /**
  124270. * Observers registered here will be triggered after the camera's initial transformation is set
  124271. * This can be used to set a different ground level or an extra rotation.
  124272. *
  124273. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124274. * to the position set after this observable is done executing.
  124275. */
  124276. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124277. /**
  124278. * Fires when the state of the experience helper has changed
  124279. */
  124280. onStateChangedObservable: Observable<WebXRState>;
  124281. /** Session manager used to keep track of xr session */
  124282. sessionManager: WebXRSessionManager;
  124283. /**
  124284. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124285. */
  124286. state: WebXRState;
  124287. /**
  124288. * Creates a WebXRExperienceHelper
  124289. * @param scene The scene the helper should be created in
  124290. */
  124291. private constructor();
  124292. /**
  124293. * Creates the experience helper
  124294. * @param scene the scene to attach the experience helper to
  124295. * @returns a promise for the experience helper
  124296. */
  124297. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124298. /**
  124299. * Disposes of the experience helper
  124300. */
  124301. dispose(): void;
  124302. /**
  124303. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124304. * @param sessionMode options for the XR session
  124305. * @param referenceSpaceType frame of reference of the XR session
  124306. * @param renderTarget the output canvas that will be used to enter XR mode
  124307. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124308. * @returns promise that resolves after xr mode has entered
  124309. */
  124310. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124311. /**
  124312. * Exits XR mode and returns the scene to its original state
  124313. * @returns promise that resolves after xr mode has exited
  124314. */
  124315. exitXRAsync(): Promise<void>;
  124316. private _nonXRToXRCamera;
  124317. private _setState;
  124318. }
  124319. }
  124320. declare module BABYLON {
  124321. /**
  124322. * X-Y values for axes in WebXR
  124323. */
  124324. export interface IWebXRMotionControllerAxesValue {
  124325. /**
  124326. * The value of the x axis
  124327. */
  124328. x: number;
  124329. /**
  124330. * The value of the y-axis
  124331. */
  124332. y: number;
  124333. }
  124334. /**
  124335. * changed / previous values for the values of this component
  124336. */
  124337. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124338. /**
  124339. * current (this frame) value
  124340. */
  124341. current: T;
  124342. /**
  124343. * previous (last change) value
  124344. */
  124345. previous: T;
  124346. }
  124347. /**
  124348. * Represents changes in the component between current frame and last values recorded
  124349. */
  124350. export interface IWebXRMotionControllerComponentChanges {
  124351. /**
  124352. * will be populated with previous and current values if axes changed
  124353. */
  124354. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124355. /**
  124356. * will be populated with previous and current values if pressed changed
  124357. */
  124358. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124359. /**
  124360. * will be populated with previous and current values if touched changed
  124361. */
  124362. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124363. /**
  124364. * will be populated with previous and current values if value changed
  124365. */
  124366. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124367. }
  124368. /**
  124369. * This class represents a single component (for example button or thumbstick) of a motion controller
  124370. */
  124371. export class WebXRControllerComponent implements IDisposable {
  124372. /**
  124373. * the id of this component
  124374. */
  124375. id: string;
  124376. /**
  124377. * the type of the component
  124378. */
  124379. type: MotionControllerComponentType;
  124380. private _buttonIndex;
  124381. private _axesIndices;
  124382. private _axes;
  124383. private _changes;
  124384. private _currentValue;
  124385. private _hasChanges;
  124386. private _pressed;
  124387. private _touched;
  124388. /**
  124389. * button component type
  124390. */
  124391. static BUTTON_TYPE: MotionControllerComponentType;
  124392. /**
  124393. * squeeze component type
  124394. */
  124395. static SQUEEZE_TYPE: MotionControllerComponentType;
  124396. /**
  124397. * Thumbstick component type
  124398. */
  124399. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124400. /**
  124401. * Touchpad component type
  124402. */
  124403. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124404. /**
  124405. * trigger component type
  124406. */
  124407. static TRIGGER_TYPE: MotionControllerComponentType;
  124408. /**
  124409. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124410. * the axes data changes
  124411. */
  124412. onAxisValueChangedObservable: Observable<{
  124413. x: number;
  124414. y: number;
  124415. }>;
  124416. /**
  124417. * Observers registered here will be triggered when the state of a button changes
  124418. * State change is either pressed / touched / value
  124419. */
  124420. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124421. /**
  124422. * Creates a new component for a motion controller.
  124423. * It is created by the motion controller itself
  124424. *
  124425. * @param id the id of this component
  124426. * @param type the type of the component
  124427. * @param _buttonIndex index in the buttons array of the gamepad
  124428. * @param _axesIndices indices of the values in the axes array of the gamepad
  124429. */
  124430. constructor(
  124431. /**
  124432. * the id of this component
  124433. */
  124434. id: string,
  124435. /**
  124436. * the type of the component
  124437. */
  124438. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124439. /**
  124440. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124441. */
  124442. get axes(): IWebXRMotionControllerAxesValue;
  124443. /**
  124444. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124445. */
  124446. get changes(): IWebXRMotionControllerComponentChanges;
  124447. /**
  124448. * Return whether or not the component changed the last frame
  124449. */
  124450. get hasChanges(): boolean;
  124451. /**
  124452. * is the button currently pressed
  124453. */
  124454. get pressed(): boolean;
  124455. /**
  124456. * is the button currently touched
  124457. */
  124458. get touched(): boolean;
  124459. /**
  124460. * Get the current value of this component
  124461. */
  124462. get value(): number;
  124463. /**
  124464. * Dispose this component
  124465. */
  124466. dispose(): void;
  124467. /**
  124468. * Are there axes correlating to this component
  124469. * @return true is axes data is available
  124470. */
  124471. isAxes(): boolean;
  124472. /**
  124473. * Is this component a button (hence - pressable)
  124474. * @returns true if can be pressed
  124475. */
  124476. isButton(): boolean;
  124477. /**
  124478. * update this component using the gamepad object it is in. Called on every frame
  124479. * @param nativeController the native gamepad controller object
  124480. */
  124481. update(nativeController: IMinimalMotionControllerObject): void;
  124482. }
  124483. }
  124484. declare module BABYLON {
  124485. /**
  124486. * Interface used to represent data loading progression
  124487. */
  124488. export interface ISceneLoaderProgressEvent {
  124489. /**
  124490. * Defines if data length to load can be evaluated
  124491. */
  124492. readonly lengthComputable: boolean;
  124493. /**
  124494. * Defines the loaded data length
  124495. */
  124496. readonly loaded: number;
  124497. /**
  124498. * Defines the data length to load
  124499. */
  124500. readonly total: number;
  124501. }
  124502. /**
  124503. * Interface used by SceneLoader plugins to define supported file extensions
  124504. */
  124505. export interface ISceneLoaderPluginExtensions {
  124506. /**
  124507. * Defines the list of supported extensions
  124508. */
  124509. [extension: string]: {
  124510. isBinary: boolean;
  124511. };
  124512. }
  124513. /**
  124514. * Interface used by SceneLoader plugin factory
  124515. */
  124516. export interface ISceneLoaderPluginFactory {
  124517. /**
  124518. * Defines the name of the factory
  124519. */
  124520. name: string;
  124521. /**
  124522. * Function called to create a new plugin
  124523. * @return the new plugin
  124524. */
  124525. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124526. /**
  124527. * The callback that returns true if the data can be directly loaded.
  124528. * @param data string containing the file data
  124529. * @returns if the data can be loaded directly
  124530. */
  124531. canDirectLoad?(data: string): boolean;
  124532. }
  124533. /**
  124534. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124535. */
  124536. export interface ISceneLoaderPluginBase {
  124537. /**
  124538. * The friendly name of this plugin.
  124539. */
  124540. name: string;
  124541. /**
  124542. * The file extensions supported by this plugin.
  124543. */
  124544. extensions: string | ISceneLoaderPluginExtensions;
  124545. /**
  124546. * The callback called when loading from a url.
  124547. * @param scene scene loading this url
  124548. * @param url url to load
  124549. * @param onSuccess callback called when the file successfully loads
  124550. * @param onProgress callback called while file is loading (if the server supports this mode)
  124551. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124552. * @param onError callback called when the file fails to load
  124553. * @returns a file request object
  124554. */
  124555. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124556. /**
  124557. * The callback called when loading from a file object.
  124558. * @param scene scene loading this file
  124559. * @param file defines the file to load
  124560. * @param onSuccess defines the callback to call when data is loaded
  124561. * @param onProgress defines the callback to call during loading process
  124562. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124563. * @param onError defines the callback to call when an error occurs
  124564. * @returns a file request object
  124565. */
  124566. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124567. /**
  124568. * The callback that returns true if the data can be directly loaded.
  124569. * @param data string containing the file data
  124570. * @returns if the data can be loaded directly
  124571. */
  124572. canDirectLoad?(data: string): boolean;
  124573. /**
  124574. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124575. * @param scene scene loading this data
  124576. * @param data string containing the data
  124577. * @returns data to pass to the plugin
  124578. */
  124579. directLoad?(scene: Scene, data: string): any;
  124580. /**
  124581. * The callback that allows custom handling of the root url based on the response url.
  124582. * @param rootUrl the original root url
  124583. * @param responseURL the response url if available
  124584. * @returns the new root url
  124585. */
  124586. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124587. }
  124588. /**
  124589. * Interface used to define a SceneLoader plugin
  124590. */
  124591. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  124592. /**
  124593. * Import meshes into a scene.
  124594. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124595. * @param scene The scene to import into
  124596. * @param data The data to import
  124597. * @param rootUrl The root url for scene and resources
  124598. * @param meshes The meshes array to import into
  124599. * @param particleSystems The particle systems array to import into
  124600. * @param skeletons The skeletons array to import into
  124601. * @param onError The callback when import fails
  124602. * @returns True if successful or false otherwise
  124603. */
  124604. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124605. /**
  124606. * Load into a scene.
  124607. * @param scene The scene to load into
  124608. * @param data The data to import
  124609. * @param rootUrl The root url for scene and resources
  124610. * @param onError The callback when import fails
  124611. * @returns True if successful or false otherwise
  124612. */
  124613. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124614. /**
  124615. * Load into an asset container.
  124616. * @param scene The scene to load into
  124617. * @param data The data to import
  124618. * @param rootUrl The root url for scene and resources
  124619. * @param onError The callback when import fails
  124620. * @returns The loaded asset container
  124621. */
  124622. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124623. }
  124624. /**
  124625. * Interface used to define an async SceneLoader plugin
  124626. */
  124627. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124628. /**
  124629. * Import meshes into a scene.
  124630. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124631. * @param scene The scene to import into
  124632. * @param data The data to import
  124633. * @param rootUrl The root url for scene and resources
  124634. * @param onProgress The callback when the load progresses
  124635. * @param fileName Defines the name of the file to load
  124636. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124637. */
  124638. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124639. meshes: AbstractMesh[];
  124640. particleSystems: IParticleSystem[];
  124641. skeletons: Skeleton[];
  124642. animationGroups: AnimationGroup[];
  124643. }>;
  124644. /**
  124645. * Load into a scene.
  124646. * @param scene The scene to load into
  124647. * @param data The data to import
  124648. * @param rootUrl The root url for scene and resources
  124649. * @param onProgress The callback when the load progresses
  124650. * @param fileName Defines the name of the file to load
  124651. * @returns Nothing
  124652. */
  124653. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124654. /**
  124655. * Load into an asset container.
  124656. * @param scene The scene to load into
  124657. * @param data The data to import
  124658. * @param rootUrl The root url for scene and resources
  124659. * @param onProgress The callback when the load progresses
  124660. * @param fileName Defines the name of the file to load
  124661. * @returns The loaded asset container
  124662. */
  124663. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124664. }
  124665. /**
  124666. * Mode that determines how to handle old animation groups before loading new ones.
  124667. */
  124668. export enum SceneLoaderAnimationGroupLoadingMode {
  124669. /**
  124670. * Reset all old animations to initial state then dispose them.
  124671. */
  124672. Clean = 0,
  124673. /**
  124674. * Stop all old animations.
  124675. */
  124676. Stop = 1,
  124677. /**
  124678. * Restart old animations from first frame.
  124679. */
  124680. Sync = 2,
  124681. /**
  124682. * Old animations remains untouched.
  124683. */
  124684. NoSync = 3
  124685. }
  124686. /**
  124687. * Class used to load scene from various file formats using registered plugins
  124688. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124689. */
  124690. export class SceneLoader {
  124691. /**
  124692. * No logging while loading
  124693. */
  124694. static readonly NO_LOGGING: number;
  124695. /**
  124696. * Minimal logging while loading
  124697. */
  124698. static readonly MINIMAL_LOGGING: number;
  124699. /**
  124700. * Summary logging while loading
  124701. */
  124702. static readonly SUMMARY_LOGGING: number;
  124703. /**
  124704. * Detailled logging while loading
  124705. */
  124706. static readonly DETAILED_LOGGING: number;
  124707. /**
  124708. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124709. */
  124710. static get ForceFullSceneLoadingForIncremental(): boolean;
  124711. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124712. /**
  124713. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124714. */
  124715. static get ShowLoadingScreen(): boolean;
  124716. static set ShowLoadingScreen(value: boolean);
  124717. /**
  124718. * Defines the current logging level (while loading the scene)
  124719. * @ignorenaming
  124720. */
  124721. static get loggingLevel(): number;
  124722. static set loggingLevel(value: number);
  124723. /**
  124724. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124725. */
  124726. static get CleanBoneMatrixWeights(): boolean;
  124727. static set CleanBoneMatrixWeights(value: boolean);
  124728. /**
  124729. * Event raised when a plugin is used to load a scene
  124730. */
  124731. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124732. private static _registeredPlugins;
  124733. private static _getDefaultPlugin;
  124734. private static _getPluginForExtension;
  124735. private static _getPluginForDirectLoad;
  124736. private static _getPluginForFilename;
  124737. private static _getDirectLoad;
  124738. private static _loadData;
  124739. private static _getFileInfo;
  124740. /**
  124741. * Gets a plugin that can load the given extension
  124742. * @param extension defines the extension to load
  124743. * @returns a plugin or null if none works
  124744. */
  124745. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124746. /**
  124747. * Gets a boolean indicating that the given extension can be loaded
  124748. * @param extension defines the extension to load
  124749. * @returns true if the extension is supported
  124750. */
  124751. static IsPluginForExtensionAvailable(extension: string): boolean;
  124752. /**
  124753. * Adds a new plugin to the list of registered plugins
  124754. * @param plugin defines the plugin to add
  124755. */
  124756. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124757. /**
  124758. * Import meshes into a scene
  124759. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124760. * @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)
  124761. * @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)
  124762. * @param scene the instance of BABYLON.Scene to append to
  124763. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124764. * @param onProgress a callback with a progress event for each file being loaded
  124765. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124766. * @param pluginExtension the extension used to determine the plugin
  124767. * @returns The loaded plugin
  124768. */
  124769. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124770. /**
  124771. * Import meshes into a scene
  124772. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124773. * @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)
  124774. * @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)
  124775. * @param scene the instance of BABYLON.Scene to append to
  124776. * @param onProgress a callback with a progress event for each file being loaded
  124777. * @param pluginExtension the extension used to determine the plugin
  124778. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124779. */
  124780. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124781. meshes: AbstractMesh[];
  124782. particleSystems: IParticleSystem[];
  124783. skeletons: Skeleton[];
  124784. animationGroups: AnimationGroup[];
  124785. }>;
  124786. /**
  124787. * Load a scene
  124788. * @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)
  124789. * @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)
  124790. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124791. * @param onSuccess a callback with the scene when import succeeds
  124792. * @param onProgress a callback with a progress event for each file being loaded
  124793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124794. * @param pluginExtension the extension used to determine the plugin
  124795. * @returns The loaded plugin
  124796. */
  124797. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124798. /**
  124799. * Load a scene
  124800. * @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)
  124801. * @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)
  124802. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124803. * @param onProgress a callback with a progress event for each file being loaded
  124804. * @param pluginExtension the extension used to determine the plugin
  124805. * @returns The loaded scene
  124806. */
  124807. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124808. /**
  124809. * Append a scene
  124810. * @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)
  124811. * @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)
  124812. * @param scene is the instance of BABYLON.Scene to append to
  124813. * @param onSuccess a callback with the scene when import succeeds
  124814. * @param onProgress a callback with a progress event for each file being loaded
  124815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124816. * @param pluginExtension the extension used to determine the plugin
  124817. * @returns The loaded plugin
  124818. */
  124819. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124820. /**
  124821. * Append a scene
  124822. * @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)
  124823. * @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)
  124824. * @param scene is the instance of BABYLON.Scene to append to
  124825. * @param onProgress a callback with a progress event for each file being loaded
  124826. * @param pluginExtension the extension used to determine the plugin
  124827. * @returns The given scene
  124828. */
  124829. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124830. /**
  124831. * Load a scene into an asset container
  124832. * @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)
  124833. * @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)
  124834. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124835. * @param onSuccess a callback with the scene when import succeeds
  124836. * @param onProgress a callback with a progress event for each file being loaded
  124837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124838. * @param pluginExtension the extension used to determine the plugin
  124839. * @returns The loaded plugin
  124840. */
  124841. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124842. /**
  124843. * Load a scene into an asset container
  124844. * @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)
  124845. * @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)
  124846. * @param scene is the instance of Scene to append to
  124847. * @param onProgress a callback with a progress event for each file being loaded
  124848. * @param pluginExtension the extension used to determine the plugin
  124849. * @returns The loaded asset container
  124850. */
  124851. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124852. /**
  124853. * Import animations from a file into a scene
  124854. * @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)
  124855. * @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)
  124856. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124857. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124858. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124859. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124860. * @param onSuccess a callback with the scene when import succeeds
  124861. * @param onProgress a callback with a progress event for each file being loaded
  124862. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124863. */
  124864. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  124865. /**
  124866. * Import animations from a file into a scene
  124867. * @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)
  124868. * @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)
  124869. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124870. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124871. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124872. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124873. * @param onSuccess a callback with the scene when import succeeds
  124874. * @param onProgress a callback with a progress event for each file being loaded
  124875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124876. * @returns the updated scene with imported animations
  124877. */
  124878. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  124879. }
  124880. }
  124881. declare module BABYLON {
  124882. /**
  124883. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124884. */
  124885. export type MotionControllerHandedness = "none" | "left" | "right";
  124886. /**
  124887. * The type of components available in motion controllers.
  124888. * This is not the name of the component.
  124889. */
  124890. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124891. /**
  124892. * The state of a controller component
  124893. */
  124894. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124895. /**
  124896. * The schema of motion controller layout.
  124897. * No object will be initialized using this interface
  124898. * This is used just to define the profile.
  124899. */
  124900. export interface IMotionControllerLayout {
  124901. /**
  124902. * Path to load the assets. Usually relative to the base path
  124903. */
  124904. assetPath: string;
  124905. /**
  124906. * Available components (unsorted)
  124907. */
  124908. components: {
  124909. /**
  124910. * A map of component Ids
  124911. */
  124912. [componentId: string]: {
  124913. /**
  124914. * The type of input the component outputs
  124915. */
  124916. type: MotionControllerComponentType;
  124917. /**
  124918. * The indices of this component in the gamepad object
  124919. */
  124920. gamepadIndices: {
  124921. /**
  124922. * Index of button
  124923. */
  124924. button?: number;
  124925. /**
  124926. * If available, index of x-axis
  124927. */
  124928. xAxis?: number;
  124929. /**
  124930. * If available, index of y-axis
  124931. */
  124932. yAxis?: number;
  124933. };
  124934. /**
  124935. * The mesh's root node name
  124936. */
  124937. rootNodeName: string;
  124938. /**
  124939. * Animation definitions for this model
  124940. */
  124941. visualResponses: {
  124942. [stateKey: string]: {
  124943. /**
  124944. * What property will be animated
  124945. */
  124946. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124947. /**
  124948. * What states influence this visual response
  124949. */
  124950. states: MotionControllerComponentStateType[];
  124951. /**
  124952. * Type of animation - movement or visibility
  124953. */
  124954. valueNodeProperty: "transform" | "visibility";
  124955. /**
  124956. * Base node name to move. Its position will be calculated according to the min and max nodes
  124957. */
  124958. valueNodeName?: string;
  124959. /**
  124960. * Minimum movement node
  124961. */
  124962. minNodeName?: string;
  124963. /**
  124964. * Max movement node
  124965. */
  124966. maxNodeName?: string;
  124967. };
  124968. };
  124969. /**
  124970. * If touch enabled, what is the name of node to display user feedback
  124971. */
  124972. touchPointNodeName?: string;
  124973. };
  124974. };
  124975. /**
  124976. * Is it xr standard mapping or not
  124977. */
  124978. gamepadMapping: "" | "xr-standard";
  124979. /**
  124980. * Base root node of this entire model
  124981. */
  124982. rootNodeName: string;
  124983. /**
  124984. * Defines the main button component id
  124985. */
  124986. selectComponentId: string;
  124987. }
  124988. /**
  124989. * A definition for the layout map in the input profile
  124990. */
  124991. export interface IMotionControllerLayoutMap {
  124992. /**
  124993. * Layouts with handedness type as a key
  124994. */
  124995. [handedness: string]: IMotionControllerLayout;
  124996. }
  124997. /**
  124998. * The XR Input profile schema
  124999. * Profiles can be found here:
  125000. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125001. */
  125002. export interface IMotionControllerProfile {
  125003. /**
  125004. * fallback profiles for this profileId
  125005. */
  125006. fallbackProfileIds: string[];
  125007. /**
  125008. * The layout map, with handedness as key
  125009. */
  125010. layouts: IMotionControllerLayoutMap;
  125011. /**
  125012. * The id of this profile
  125013. * correlates to the profile(s) in the xrInput.profiles array
  125014. */
  125015. profileId: string;
  125016. }
  125017. /**
  125018. * A helper-interface for the 3 meshes needed for controller button animation
  125019. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125020. */
  125021. export interface IMotionControllerButtonMeshMap {
  125022. /**
  125023. * the mesh that defines the pressed value mesh position.
  125024. * This is used to find the max-position of this button
  125025. */
  125026. pressedMesh: AbstractMesh;
  125027. /**
  125028. * the mesh that defines the unpressed value mesh position.
  125029. * This is used to find the min (or initial) position of this button
  125030. */
  125031. unpressedMesh: AbstractMesh;
  125032. /**
  125033. * The mesh that will be changed when value changes
  125034. */
  125035. valueMesh: AbstractMesh;
  125036. }
  125037. /**
  125038. * A helper-interface for the 3 meshes needed for controller axis animation.
  125039. * This will be expanded when touchpad animations are fully supported
  125040. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125041. */
  125042. export interface IMotionControllerMeshMap {
  125043. /**
  125044. * the mesh that defines the maximum value mesh position.
  125045. */
  125046. maxMesh?: AbstractMesh;
  125047. /**
  125048. * the mesh that defines the minimum value mesh position.
  125049. */
  125050. minMesh?: AbstractMesh;
  125051. /**
  125052. * The mesh that will be changed when axis value changes
  125053. */
  125054. valueMesh: AbstractMesh;
  125055. }
  125056. /**
  125057. * The elements needed for change-detection of the gamepad objects in motion controllers
  125058. */
  125059. export interface IMinimalMotionControllerObject {
  125060. /**
  125061. * Available axes of this controller
  125062. */
  125063. axes: number[];
  125064. /**
  125065. * An array of available buttons
  125066. */
  125067. buttons: Array<{
  125068. /**
  125069. * Value of the button/trigger
  125070. */
  125071. value: number;
  125072. /**
  125073. * If the button/trigger is currently touched
  125074. */
  125075. touched: boolean;
  125076. /**
  125077. * If the button/trigger is currently pressed
  125078. */
  125079. pressed: boolean;
  125080. }>;
  125081. /**
  125082. * EXPERIMENTAL haptic support.
  125083. */
  125084. hapticActuators?: Array<{
  125085. pulse: (value: number, duration: number) => Promise<boolean>;
  125086. }>;
  125087. }
  125088. /**
  125089. * An Abstract Motion controller
  125090. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125091. * Each component has an observable to check for changes in value and state
  125092. */
  125093. export abstract class WebXRAbstractMotionController implements IDisposable {
  125094. protected scene: Scene;
  125095. protected layout: IMotionControllerLayout;
  125096. /**
  125097. * The gamepad object correlating to this controller
  125098. */
  125099. gamepadObject: IMinimalMotionControllerObject;
  125100. /**
  125101. * handedness (left/right/none) of this controller
  125102. */
  125103. handedness: MotionControllerHandedness;
  125104. private _initComponent;
  125105. private _modelReady;
  125106. /**
  125107. * A map of components (WebXRControllerComponent) in this motion controller
  125108. * Components have a ComponentType and can also have both button and axis definitions
  125109. */
  125110. readonly components: {
  125111. [id: string]: WebXRControllerComponent;
  125112. };
  125113. /**
  125114. * Disable the model's animation. Can be set at any time.
  125115. */
  125116. disableAnimation: boolean;
  125117. /**
  125118. * Observers registered here will be triggered when the model of this controller is done loading
  125119. */
  125120. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125121. /**
  125122. * The profile id of this motion controller
  125123. */
  125124. abstract profileId: string;
  125125. /**
  125126. * The root mesh of the model. It is null if the model was not yet initialized
  125127. */
  125128. rootMesh: Nullable<AbstractMesh>;
  125129. /**
  125130. * constructs a new abstract motion controller
  125131. * @param scene the scene to which the model of the controller will be added
  125132. * @param layout The profile layout to load
  125133. * @param gamepadObject The gamepad object correlating to this controller
  125134. * @param handedness handedness (left/right/none) of this controller
  125135. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125136. */
  125137. constructor(scene: Scene, layout: IMotionControllerLayout,
  125138. /**
  125139. * The gamepad object correlating to this controller
  125140. */
  125141. gamepadObject: IMinimalMotionControllerObject,
  125142. /**
  125143. * handedness (left/right/none) of this controller
  125144. */
  125145. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125146. /**
  125147. * Dispose this controller, the model mesh and all its components
  125148. */
  125149. dispose(): void;
  125150. /**
  125151. * Returns all components of specific type
  125152. * @param type the type to search for
  125153. * @return an array of components with this type
  125154. */
  125155. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125156. /**
  125157. * get a component based an its component id as defined in layout.components
  125158. * @param id the id of the component
  125159. * @returns the component correlates to the id or undefined if not found
  125160. */
  125161. getComponent(id: string): WebXRControllerComponent;
  125162. /**
  125163. * Get the list of components available in this motion controller
  125164. * @returns an array of strings correlating to available components
  125165. */
  125166. getComponentIds(): string[];
  125167. /**
  125168. * Get the first component of specific type
  125169. * @param type type of component to find
  125170. * @return a controller component or null if not found
  125171. */
  125172. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125173. /**
  125174. * Get the main (Select) component of this controller as defined in the layout
  125175. * @returns the main component of this controller
  125176. */
  125177. getMainComponent(): WebXRControllerComponent;
  125178. /**
  125179. * Loads the model correlating to this controller
  125180. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125181. * @returns A promise fulfilled with the result of the model loading
  125182. */
  125183. loadModel(): Promise<boolean>;
  125184. /**
  125185. * Update this model using the current XRFrame
  125186. * @param xrFrame the current xr frame to use and update the model
  125187. */
  125188. updateFromXRFrame(xrFrame: XRFrame): void;
  125189. /**
  125190. * Backwards compatibility due to a deeply-integrated typo
  125191. */
  125192. get handness(): XREye;
  125193. /**
  125194. * Pulse (vibrate) this controller
  125195. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125196. * Consecutive calls to this function will cancel the last pulse call
  125197. *
  125198. * @param value the strength of the pulse in 0.0...1.0 range
  125199. * @param duration Duration of the pulse in milliseconds
  125200. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125201. * @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
  125202. */
  125203. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125204. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125205. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125206. /**
  125207. * Moves the axis on the controller mesh based on its current state
  125208. * @param axis the index of the axis
  125209. * @param axisValue the value of the axis which determines the meshes new position
  125210. * @hidden
  125211. */
  125212. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125213. /**
  125214. * Update the model itself with the current frame data
  125215. * @param xrFrame the frame to use for updating the model mesh
  125216. */
  125217. protected updateModel(xrFrame: XRFrame): void;
  125218. /**
  125219. * Get the filename and path for this controller's model
  125220. * @returns a map of filename and path
  125221. */
  125222. protected abstract _getFilenameAndPath(): {
  125223. filename: string;
  125224. path: string;
  125225. };
  125226. /**
  125227. * This function is called before the mesh is loaded. It checks for loading constraints.
  125228. * For example, this function can check if the GLB loader is available
  125229. * If this function returns false, the generic controller will be loaded instead
  125230. * @returns Is the client ready to load the mesh
  125231. */
  125232. protected abstract _getModelLoadingConstraints(): boolean;
  125233. /**
  125234. * This function will be called after the model was successfully loaded and can be used
  125235. * for mesh transformations before it is available for the user
  125236. * @param meshes the loaded meshes
  125237. */
  125238. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125239. /**
  125240. * Set the root mesh for this controller. Important for the WebXR controller class
  125241. * @param meshes the loaded meshes
  125242. */
  125243. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125244. /**
  125245. * A function executed each frame that updates the mesh (if needed)
  125246. * @param xrFrame the current xrFrame
  125247. */
  125248. protected abstract _updateModel(xrFrame: XRFrame): void;
  125249. private _getGenericFilenameAndPath;
  125250. private _getGenericParentMesh;
  125251. }
  125252. }
  125253. declare module BABYLON {
  125254. /**
  125255. * A generic trigger-only motion controller for WebXR
  125256. */
  125257. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125258. /**
  125259. * Static version of the profile id of this controller
  125260. */
  125261. static ProfileId: string;
  125262. profileId: string;
  125263. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125264. protected _getFilenameAndPath(): {
  125265. filename: string;
  125266. path: string;
  125267. };
  125268. protected _getModelLoadingConstraints(): boolean;
  125269. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125270. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125271. protected _updateModel(): void;
  125272. }
  125273. }
  125274. declare module BABYLON {
  125275. /**
  125276. * Class containing static functions to help procedurally build meshes
  125277. */
  125278. export class SphereBuilder {
  125279. /**
  125280. * Creates a sphere mesh
  125281. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125282. * * 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`)
  125283. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125284. * * 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
  125285. * * 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)
  125286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125289. * @param name defines the name of the mesh
  125290. * @param options defines the options used to create the mesh
  125291. * @param scene defines the hosting scene
  125292. * @returns the sphere mesh
  125293. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125294. */
  125295. static CreateSphere(name: string, options: {
  125296. segments?: number;
  125297. diameter?: number;
  125298. diameterX?: number;
  125299. diameterY?: number;
  125300. diameterZ?: number;
  125301. arc?: number;
  125302. slice?: number;
  125303. sideOrientation?: number;
  125304. frontUVs?: Vector4;
  125305. backUVs?: Vector4;
  125306. updatable?: boolean;
  125307. }, scene?: Nullable<Scene>): Mesh;
  125308. }
  125309. }
  125310. declare module BABYLON {
  125311. /**
  125312. * A profiled motion controller has its profile loaded from an online repository.
  125313. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125314. */
  125315. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125316. private _repositoryUrl;
  125317. private _buttonMeshMapping;
  125318. private _touchDots;
  125319. /**
  125320. * The profile ID of this controller. Will be populated when the controller initializes.
  125321. */
  125322. profileId: string;
  125323. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125324. dispose(): void;
  125325. protected _getFilenameAndPath(): {
  125326. filename: string;
  125327. path: string;
  125328. };
  125329. protected _getModelLoadingConstraints(): boolean;
  125330. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125331. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125332. protected _updateModel(_xrFrame: XRFrame): void;
  125333. }
  125334. }
  125335. declare module BABYLON {
  125336. /**
  125337. * A construction function type to create a new controller based on an xrInput object
  125338. */
  125339. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125340. /**
  125341. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125342. *
  125343. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125344. * it should be replaced with auto-loaded controllers.
  125345. *
  125346. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125347. */
  125348. export class WebXRMotionControllerManager {
  125349. private static _AvailableControllers;
  125350. private static _Fallbacks;
  125351. private static _ProfileLoadingPromises;
  125352. private static _ProfilesList;
  125353. /**
  125354. * The base URL of the online controller repository. Can be changed at any time.
  125355. */
  125356. static BaseRepositoryUrl: string;
  125357. /**
  125358. * Which repository gets priority - local or online
  125359. */
  125360. static PrioritizeOnlineRepository: boolean;
  125361. /**
  125362. * Use the online repository, or use only locally-defined controllers
  125363. */
  125364. static UseOnlineRepository: boolean;
  125365. /**
  125366. * Clear the cache used for profile loading and reload when requested again
  125367. */
  125368. static ClearProfilesCache(): void;
  125369. /**
  125370. * Register the default fallbacks.
  125371. * This function is called automatically when this file is imported.
  125372. */
  125373. static DefaultFallbacks(): void;
  125374. /**
  125375. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125376. * @param profileId the profile to which a fallback needs to be found
  125377. * @return an array with corresponding fallback profiles
  125378. */
  125379. static FindFallbackWithProfileId(profileId: string): string[];
  125380. /**
  125381. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125382. * The order of search:
  125383. *
  125384. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125385. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125386. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125387. * 4) return the generic trigger controller if none were found
  125388. *
  125389. * @param xrInput the xrInput to which a new controller is initialized
  125390. * @param scene the scene to which the model will be added
  125391. * @param forceProfile force a certain profile for this controller
  125392. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125393. */
  125394. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125395. /**
  125396. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125397. *
  125398. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125399. *
  125400. * @param type the profile type to register
  125401. * @param constructFunction the function to be called when loading this profile
  125402. */
  125403. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125404. /**
  125405. * Register a fallback to a specific profile.
  125406. * @param profileId the profileId that will receive the fallbacks
  125407. * @param fallbacks A list of fallback profiles
  125408. */
  125409. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125410. /**
  125411. * Will update the list of profiles available in the repository
  125412. * @return a promise that resolves to a map of profiles available online
  125413. */
  125414. static UpdateProfilesList(): Promise<{
  125415. [profile: string]: string;
  125416. }>;
  125417. private static _LoadProfileFromRepository;
  125418. private static _LoadProfilesFromAvailableControllers;
  125419. }
  125420. }
  125421. declare module BABYLON {
  125422. /**
  125423. * Configuration options for the WebXR controller creation
  125424. */
  125425. export interface IWebXRControllerOptions {
  125426. /**
  125427. * Should the controller mesh be animated when a user interacts with it
  125428. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125429. */
  125430. disableMotionControllerAnimation?: boolean;
  125431. /**
  125432. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125433. */
  125434. doNotLoadControllerMesh?: boolean;
  125435. /**
  125436. * Force a specific controller type for this controller.
  125437. * This can be used when creating your own profile or when testing different controllers
  125438. */
  125439. forceControllerProfile?: string;
  125440. /**
  125441. * Defines a rendering group ID for meshes that will be loaded.
  125442. * This is for the default controllers only.
  125443. */
  125444. renderingGroupId?: number;
  125445. }
  125446. /**
  125447. * Represents an XR controller
  125448. */
  125449. export class WebXRInputSource {
  125450. private _scene;
  125451. /** The underlying input source for the controller */
  125452. inputSource: XRInputSource;
  125453. private _options;
  125454. private _tmpVector;
  125455. private _uniqueId;
  125456. /**
  125457. * 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
  125458. */
  125459. grip?: AbstractMesh;
  125460. /**
  125461. * If available, this is the gamepad object related to this controller.
  125462. * Using this object it is possible to get click events and trackpad changes of the
  125463. * webxr controller that is currently being used.
  125464. */
  125465. motionController?: WebXRAbstractMotionController;
  125466. /**
  125467. * Event that fires when the controller is removed/disposed.
  125468. * The object provided as event data is this controller, after associated assets were disposed.
  125469. * uniqueId is still available.
  125470. */
  125471. onDisposeObservable: Observable<WebXRInputSource>;
  125472. /**
  125473. * Will be triggered when the mesh associated with the motion controller is done loading.
  125474. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125475. * A shortened version of controller -> motion controller -> on mesh loaded.
  125476. */
  125477. onMeshLoadedObservable: Observable<AbstractMesh>;
  125478. /**
  125479. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125480. */
  125481. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125482. /**
  125483. * Pointer which can be used to select objects or attach a visible laser to
  125484. */
  125485. pointer: AbstractMesh;
  125486. /**
  125487. * Creates the controller
  125488. * @see https://doc.babylonjs.com/how_to/webxr
  125489. * @param _scene the scene which the controller should be associated to
  125490. * @param inputSource the underlying input source for the controller
  125491. * @param _options options for this controller creation
  125492. */
  125493. constructor(_scene: Scene,
  125494. /** The underlying input source for the controller */
  125495. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125496. /**
  125497. * Get this controllers unique id
  125498. */
  125499. get uniqueId(): string;
  125500. /**
  125501. * Disposes of the object
  125502. */
  125503. dispose(): void;
  125504. /**
  125505. * Gets a world space ray coming from the pointer or grip
  125506. * @param result the resulting ray
  125507. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125508. */
  125509. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125510. /**
  125511. * Updates the controller pose based on the given XRFrame
  125512. * @param xrFrame xr frame to update the pose with
  125513. * @param referenceSpace reference space to use
  125514. */
  125515. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125516. }
  125517. }
  125518. declare module BABYLON {
  125519. /**
  125520. * The schema for initialization options of the XR Input class
  125521. */
  125522. export interface IWebXRInputOptions {
  125523. /**
  125524. * If set to true no model will be automatically loaded
  125525. */
  125526. doNotLoadControllerMeshes?: boolean;
  125527. /**
  125528. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125529. * If not found, the xr input profile data will be used.
  125530. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125531. */
  125532. forceInputProfile?: string;
  125533. /**
  125534. * Do not send a request to the controller repository to load the profile.
  125535. *
  125536. * Instead, use the controllers available in babylon itself.
  125537. */
  125538. disableOnlineControllerRepository?: boolean;
  125539. /**
  125540. * A custom URL for the controllers repository
  125541. */
  125542. customControllersRepositoryURL?: string;
  125543. /**
  125544. * Should the controller model's components not move according to the user input
  125545. */
  125546. disableControllerAnimation?: boolean;
  125547. /**
  125548. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125549. */
  125550. controllerOptions?: IWebXRControllerOptions;
  125551. }
  125552. /**
  125553. * XR input used to track XR inputs such as controllers/rays
  125554. */
  125555. export class WebXRInput implements IDisposable {
  125556. /**
  125557. * the xr session manager for this session
  125558. */
  125559. xrSessionManager: WebXRSessionManager;
  125560. /**
  125561. * the WebXR camera for this session. Mainly used for teleportation
  125562. */
  125563. xrCamera: WebXRCamera;
  125564. private readonly options;
  125565. /**
  125566. * XR controllers being tracked
  125567. */
  125568. controllers: Array<WebXRInputSource>;
  125569. private _frameObserver;
  125570. private _sessionEndedObserver;
  125571. private _sessionInitObserver;
  125572. /**
  125573. * Event when a controller has been connected/added
  125574. */
  125575. onControllerAddedObservable: Observable<WebXRInputSource>;
  125576. /**
  125577. * Event when a controller has been removed/disconnected
  125578. */
  125579. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125580. /**
  125581. * Initializes the WebXRInput
  125582. * @param xrSessionManager the xr session manager for this session
  125583. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125584. * @param options = initialization options for this xr input
  125585. */
  125586. constructor(
  125587. /**
  125588. * the xr session manager for this session
  125589. */
  125590. xrSessionManager: WebXRSessionManager,
  125591. /**
  125592. * the WebXR camera for this session. Mainly used for teleportation
  125593. */
  125594. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125595. private _onInputSourcesChange;
  125596. private _addAndRemoveControllers;
  125597. /**
  125598. * Disposes of the object
  125599. */
  125600. dispose(): void;
  125601. }
  125602. }
  125603. declare module BABYLON {
  125604. /**
  125605. * This is the base class for all WebXR features.
  125606. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125607. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125608. */
  125609. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125610. protected _xrSessionManager: WebXRSessionManager;
  125611. private _attached;
  125612. private _removeOnDetach;
  125613. /**
  125614. * Should auto-attach be disabled?
  125615. */
  125616. disableAutoAttach: boolean;
  125617. /**
  125618. * Construct a new (abstract) WebXR feature
  125619. * @param _xrSessionManager the xr session manager for this feature
  125620. */
  125621. constructor(_xrSessionManager: WebXRSessionManager);
  125622. /**
  125623. * Is this feature attached
  125624. */
  125625. get attached(): boolean;
  125626. /**
  125627. * attach this feature
  125628. *
  125629. * @param force should attachment be forced (even when already attached)
  125630. * @returns true if successful, false is failed or already attached
  125631. */
  125632. attach(force?: boolean): boolean;
  125633. /**
  125634. * detach this feature.
  125635. *
  125636. * @returns true if successful, false if failed or already detached
  125637. */
  125638. detach(): boolean;
  125639. /**
  125640. * Dispose this feature and all of the resources attached
  125641. */
  125642. dispose(): void;
  125643. /**
  125644. * This is used to register callbacks that will automatically be removed when detach is called.
  125645. * @param observable the observable to which the observer will be attached
  125646. * @param callback the callback to register
  125647. */
  125648. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125649. /**
  125650. * Code in this function will be executed on each xrFrame received from the browser.
  125651. * This function will not execute after the feature is detached.
  125652. * @param _xrFrame the current frame
  125653. */
  125654. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125655. }
  125656. }
  125657. declare module BABYLON {
  125658. /**
  125659. * Renders a layer on top of an existing scene
  125660. */
  125661. export class UtilityLayerRenderer implements IDisposable {
  125662. /** the original scene that will be rendered on top of */
  125663. originalScene: Scene;
  125664. private _pointerCaptures;
  125665. private _lastPointerEvents;
  125666. private static _DefaultUtilityLayer;
  125667. private static _DefaultKeepDepthUtilityLayer;
  125668. private _sharedGizmoLight;
  125669. private _renderCamera;
  125670. /**
  125671. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125672. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125673. * @returns the camera that is used when rendering the utility layer
  125674. */
  125675. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125676. /**
  125677. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125678. * @param cam the camera that should be used when rendering the utility layer
  125679. */
  125680. setRenderCamera(cam: Nullable<Camera>): void;
  125681. /**
  125682. * @hidden
  125683. * Light which used by gizmos to get light shading
  125684. */
  125685. _getSharedGizmoLight(): HemisphericLight;
  125686. /**
  125687. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125688. */
  125689. pickUtilitySceneFirst: boolean;
  125690. /**
  125691. * 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)
  125692. */
  125693. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125694. /**
  125695. * 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)
  125696. */
  125697. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125698. /**
  125699. * The scene that is rendered on top of the original scene
  125700. */
  125701. utilityLayerScene: Scene;
  125702. /**
  125703. * If the utility layer should automatically be rendered on top of existing scene
  125704. */
  125705. shouldRender: boolean;
  125706. /**
  125707. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125708. */
  125709. onlyCheckPointerDownEvents: boolean;
  125710. /**
  125711. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125712. */
  125713. processAllEvents: boolean;
  125714. /**
  125715. * Observable raised when the pointer move from the utility layer scene to the main scene
  125716. */
  125717. onPointerOutObservable: Observable<number>;
  125718. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125719. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125720. private _afterRenderObserver;
  125721. private _sceneDisposeObserver;
  125722. private _originalPointerObserver;
  125723. /**
  125724. * Instantiates a UtilityLayerRenderer
  125725. * @param originalScene the original scene that will be rendered on top of
  125726. * @param handleEvents boolean indicating if the utility layer should handle events
  125727. */
  125728. constructor(
  125729. /** the original scene that will be rendered on top of */
  125730. originalScene: Scene, handleEvents?: boolean);
  125731. private _notifyObservers;
  125732. /**
  125733. * Renders the utility layers scene on top of the original scene
  125734. */
  125735. render(): void;
  125736. /**
  125737. * Disposes of the renderer
  125738. */
  125739. dispose(): void;
  125740. private _updateCamera;
  125741. }
  125742. }
  125743. declare module BABYLON {
  125744. /**
  125745. * Options interface for the pointer selection module
  125746. */
  125747. export interface IWebXRControllerPointerSelectionOptions {
  125748. /**
  125749. * if provided, this scene will be used to render meshes.
  125750. */
  125751. customUtilityLayerScene?: Scene;
  125752. /**
  125753. * 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)
  125754. * If not disabled, the last picked point will be used to execute a pointer up event
  125755. * If disabled, pointer up event will be triggered right after the pointer down event.
  125756. * Used in screen and gaze target ray mode only
  125757. */
  125758. disablePointerUpOnTouchOut: boolean;
  125759. /**
  125760. * For gaze mode (time to select instead of press)
  125761. */
  125762. forceGazeMode: boolean;
  125763. /**
  125764. * 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
  125765. * to start a new countdown to the pointer down event.
  125766. * Defaults to 1.
  125767. */
  125768. gazeModePointerMovedFactor?: number;
  125769. /**
  125770. * Different button type to use instead of the main component
  125771. */
  125772. overrideButtonId?: string;
  125773. /**
  125774. * use this rendering group id for the meshes (optional)
  125775. */
  125776. renderingGroupId?: number;
  125777. /**
  125778. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125779. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125780. * 3000 means 3 seconds between pointing at something and selecting it
  125781. */
  125782. timeToSelect?: number;
  125783. /**
  125784. * Should meshes created here be added to a utility layer or the main scene
  125785. */
  125786. useUtilityLayer?: boolean;
  125787. /**
  125788. * the xr input to use with this pointer selection
  125789. */
  125790. xrInput: WebXRInput;
  125791. }
  125792. /**
  125793. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125794. */
  125795. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125796. private readonly _options;
  125797. private static _idCounter;
  125798. private _attachController;
  125799. private _controllers;
  125800. private _scene;
  125801. private _tmpVectorForPickCompare;
  125802. /**
  125803. * The module's name
  125804. */
  125805. static readonly Name: string;
  125806. /**
  125807. * The (Babylon) version of this module.
  125808. * This is an integer representing the implementation version.
  125809. * This number does not correspond to the WebXR specs version
  125810. */
  125811. static readonly Version: number;
  125812. /**
  125813. * Disable lighting on the laser pointer (so it will always be visible)
  125814. */
  125815. disablePointerLighting: boolean;
  125816. /**
  125817. * Disable lighting on the selection mesh (so it will always be visible)
  125818. */
  125819. disableSelectionMeshLighting: boolean;
  125820. /**
  125821. * Should the laser pointer be displayed
  125822. */
  125823. displayLaserPointer: boolean;
  125824. /**
  125825. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125826. */
  125827. displaySelectionMesh: boolean;
  125828. /**
  125829. * This color will be set to the laser pointer when selection is triggered
  125830. */
  125831. laserPointerPickedColor: Color3;
  125832. /**
  125833. * Default color of the laser pointer
  125834. */
  125835. laserPointerDefaultColor: Color3;
  125836. /**
  125837. * default color of the selection ring
  125838. */
  125839. selectionMeshDefaultColor: Color3;
  125840. /**
  125841. * This color will be applied to the selection ring when selection is triggered
  125842. */
  125843. selectionMeshPickedColor: Color3;
  125844. /**
  125845. * Optional filter to be used for ray selection. This predicate shares behavior with
  125846. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125847. */
  125848. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125849. /**
  125850. * constructs a new background remover module
  125851. * @param _xrSessionManager the session manager for this module
  125852. * @param _options read-only options to be used in this module
  125853. */
  125854. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125855. /**
  125856. * attach this feature
  125857. * Will usually be called by the features manager
  125858. *
  125859. * @returns true if successful.
  125860. */
  125861. attach(): boolean;
  125862. /**
  125863. * detach this feature.
  125864. * Will usually be called by the features manager
  125865. *
  125866. * @returns true if successful.
  125867. */
  125868. detach(): boolean;
  125869. /**
  125870. * Will get the mesh under a specific pointer.
  125871. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125872. * @param controllerId the controllerId to check
  125873. * @returns The mesh under pointer or null if no mesh is under the pointer
  125874. */
  125875. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125876. /**
  125877. * Get the xr controller that correlates to the pointer id in the pointer event
  125878. *
  125879. * @param id the pointer id to search for
  125880. * @returns the controller that correlates to this id or null if not found
  125881. */
  125882. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125883. protected _onXRFrame(_xrFrame: XRFrame): void;
  125884. private _attachGazeMode;
  125885. private _attachScreenRayMode;
  125886. private _attachTrackedPointerRayMode;
  125887. private _convertNormalToDirectionOfRay;
  125888. private _detachController;
  125889. private _generateNewMeshPair;
  125890. private _pickingMoved;
  125891. private _updatePointerDistance;
  125892. /** @hidden */
  125893. get lasterPointerDefaultColor(): Color3;
  125894. }
  125895. }
  125896. declare module BABYLON {
  125897. /**
  125898. * Button which can be used to enter a different mode of XR
  125899. */
  125900. export class WebXREnterExitUIButton {
  125901. /** button element */
  125902. element: HTMLElement;
  125903. /** XR initialization options for the button */
  125904. sessionMode: XRSessionMode;
  125905. /** Reference space type */
  125906. referenceSpaceType: XRReferenceSpaceType;
  125907. /**
  125908. * Creates a WebXREnterExitUIButton
  125909. * @param element button element
  125910. * @param sessionMode XR initialization session mode
  125911. * @param referenceSpaceType the type of reference space to be used
  125912. */
  125913. constructor(
  125914. /** button element */
  125915. element: HTMLElement,
  125916. /** XR initialization options for the button */
  125917. sessionMode: XRSessionMode,
  125918. /** Reference space type */
  125919. referenceSpaceType: XRReferenceSpaceType);
  125920. /**
  125921. * Extendable function which can be used to update the button's visuals when the state changes
  125922. * @param activeButton the current active button in the UI
  125923. */
  125924. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125925. }
  125926. /**
  125927. * Options to create the webXR UI
  125928. */
  125929. export class WebXREnterExitUIOptions {
  125930. /**
  125931. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125932. */
  125933. customButtons?: Array<WebXREnterExitUIButton>;
  125934. /**
  125935. * A reference space type to use when creating the default button.
  125936. * Default is local-floor
  125937. */
  125938. referenceSpaceType?: XRReferenceSpaceType;
  125939. /**
  125940. * Context to enter xr with
  125941. */
  125942. renderTarget?: Nullable<WebXRRenderTarget>;
  125943. /**
  125944. * A session mode to use when creating the default button.
  125945. * Default is immersive-vr
  125946. */
  125947. sessionMode?: XRSessionMode;
  125948. /**
  125949. * A list of optional features to init the session with
  125950. */
  125951. optionalFeatures?: string[];
  125952. }
  125953. /**
  125954. * UI to allow the user to enter/exit XR mode
  125955. */
  125956. export class WebXREnterExitUI implements IDisposable {
  125957. private scene;
  125958. /** version of the options passed to this UI */
  125959. options: WebXREnterExitUIOptions;
  125960. private _activeButton;
  125961. private _buttons;
  125962. private _overlay;
  125963. /**
  125964. * Fired every time the active button is changed.
  125965. *
  125966. * When xr is entered via a button that launches xr that button will be the callback parameter
  125967. *
  125968. * When exiting xr the callback parameter will be null)
  125969. */
  125970. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125971. /**
  125972. *
  125973. * @param scene babylon scene object to use
  125974. * @param options (read-only) version of the options passed to this UI
  125975. */
  125976. private constructor();
  125977. /**
  125978. * Creates UI to allow the user to enter/exit XR mode
  125979. * @param scene the scene to add the ui to
  125980. * @param helper the xr experience helper to enter/exit xr with
  125981. * @param options options to configure the UI
  125982. * @returns the created ui
  125983. */
  125984. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125985. /**
  125986. * Disposes of the XR UI component
  125987. */
  125988. dispose(): void;
  125989. private _updateButtons;
  125990. }
  125991. }
  125992. declare module BABYLON {
  125993. /**
  125994. * Class containing static functions to help procedurally build meshes
  125995. */
  125996. export class LinesBuilder {
  125997. /**
  125998. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125999. * * 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
  126000. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126001. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126002. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126003. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126004. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126005. * * 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
  126006. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126009. * @param name defines the name of the new line system
  126010. * @param options defines the options used to create the line system
  126011. * @param scene defines the hosting scene
  126012. * @returns a new line system mesh
  126013. */
  126014. static CreateLineSystem(name: string, options: {
  126015. lines: Vector3[][];
  126016. updatable?: boolean;
  126017. instance?: Nullable<LinesMesh>;
  126018. colors?: Nullable<Color4[][]>;
  126019. useVertexAlpha?: boolean;
  126020. }, scene: Nullable<Scene>): LinesMesh;
  126021. /**
  126022. * Creates a line mesh
  126023. * 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
  126024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126025. * * The parameter `points` is an array successive Vector3
  126026. * * 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
  126027. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126029. * * When updating an instance, remember that only point positions can change, not the number of points
  126030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126032. * @param name defines the name of the new line system
  126033. * @param options defines the options used to create the line system
  126034. * @param scene defines the hosting scene
  126035. * @returns a new line mesh
  126036. */
  126037. static CreateLines(name: string, options: {
  126038. points: Vector3[];
  126039. updatable?: boolean;
  126040. instance?: Nullable<LinesMesh>;
  126041. colors?: Color4[];
  126042. useVertexAlpha?: boolean;
  126043. }, scene?: Nullable<Scene>): LinesMesh;
  126044. /**
  126045. * Creates a dashed line mesh
  126046. * * 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
  126047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126048. * * The parameter `points` is an array successive Vector3
  126049. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126050. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126051. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126052. * * 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
  126053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126054. * * When updating an instance, remember that only point positions can change, not the number of points
  126055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126056. * @param name defines the name of the mesh
  126057. * @param options defines the options used to create the mesh
  126058. * @param scene defines the hosting scene
  126059. * @returns the dashed line mesh
  126060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126061. */
  126062. static CreateDashedLines(name: string, options: {
  126063. points: Vector3[];
  126064. dashSize?: number;
  126065. gapSize?: number;
  126066. dashNb?: number;
  126067. updatable?: boolean;
  126068. instance?: LinesMesh;
  126069. useVertexAlpha?: boolean;
  126070. }, scene?: Nullable<Scene>): LinesMesh;
  126071. }
  126072. }
  126073. declare module BABYLON {
  126074. /**
  126075. * Construction options for a timer
  126076. */
  126077. export interface ITimerOptions<T> {
  126078. /**
  126079. * Time-to-end
  126080. */
  126081. timeout: number;
  126082. /**
  126083. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126084. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126085. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126086. */
  126087. contextObservable: Observable<T>;
  126088. /**
  126089. * Optional parameters when adding an observer to the observable
  126090. */
  126091. observableParameters?: {
  126092. mask?: number;
  126093. insertFirst?: boolean;
  126094. scope?: any;
  126095. };
  126096. /**
  126097. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126098. */
  126099. breakCondition?: (data?: ITimerData<T>) => boolean;
  126100. /**
  126101. * Will be triggered when the time condition has met
  126102. */
  126103. onEnded?: (data: ITimerData<any>) => void;
  126104. /**
  126105. * Will be triggered when the break condition has met (prematurely ended)
  126106. */
  126107. onAborted?: (data: ITimerData<any>) => void;
  126108. /**
  126109. * Optional function to execute on each tick (or count)
  126110. */
  126111. onTick?: (data: ITimerData<any>) => void;
  126112. }
  126113. /**
  126114. * An interface defining the data sent by the timer
  126115. */
  126116. export interface ITimerData<T> {
  126117. /**
  126118. * When did it start
  126119. */
  126120. startTime: number;
  126121. /**
  126122. * Time now
  126123. */
  126124. currentTime: number;
  126125. /**
  126126. * Time passed since started
  126127. */
  126128. deltaTime: number;
  126129. /**
  126130. * How much is completed, in [0.0...1.0].
  126131. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126132. */
  126133. completeRate: number;
  126134. /**
  126135. * What the registered observable sent in the last count
  126136. */
  126137. payload: T;
  126138. }
  126139. /**
  126140. * The current state of the timer
  126141. */
  126142. export enum TimerState {
  126143. /**
  126144. * Timer initialized, not yet started
  126145. */
  126146. INIT = 0,
  126147. /**
  126148. * Timer started and counting
  126149. */
  126150. STARTED = 1,
  126151. /**
  126152. * Timer ended (whether aborted or time reached)
  126153. */
  126154. ENDED = 2
  126155. }
  126156. /**
  126157. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126158. *
  126159. * @param options options with which to initialize this timer
  126160. */
  126161. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126162. /**
  126163. * An advanced implementation of a timer class
  126164. */
  126165. export class AdvancedTimer<T = any> implements IDisposable {
  126166. /**
  126167. * Will notify each time the timer calculates the remaining time
  126168. */
  126169. onEachCountObservable: Observable<ITimerData<T>>;
  126170. /**
  126171. * Will trigger when the timer was aborted due to the break condition
  126172. */
  126173. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126174. /**
  126175. * Will trigger when the timer ended successfully
  126176. */
  126177. onTimerEndedObservable: Observable<ITimerData<T>>;
  126178. /**
  126179. * Will trigger when the timer state has changed
  126180. */
  126181. onStateChangedObservable: Observable<TimerState>;
  126182. private _observer;
  126183. private _contextObservable;
  126184. private _observableParameters;
  126185. private _startTime;
  126186. private _timer;
  126187. private _state;
  126188. private _breakCondition;
  126189. private _timeToEnd;
  126190. private _breakOnNextTick;
  126191. /**
  126192. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126193. * @param options construction options for this advanced timer
  126194. */
  126195. constructor(options: ITimerOptions<T>);
  126196. /**
  126197. * set a breaking condition for this timer. Default is to never break during count
  126198. * @param predicate the new break condition. Returns true to break, false otherwise
  126199. */
  126200. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126201. /**
  126202. * Reset ALL associated observables in this advanced timer
  126203. */
  126204. clearObservables(): void;
  126205. /**
  126206. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126207. *
  126208. * @param timeToEnd how much time to measure until timer ended
  126209. */
  126210. start(timeToEnd?: number): void;
  126211. /**
  126212. * Will force a stop on the next tick.
  126213. */
  126214. stop(): void;
  126215. /**
  126216. * Dispose this timer, clearing all resources
  126217. */
  126218. dispose(): void;
  126219. private _setState;
  126220. private _tick;
  126221. private _stop;
  126222. }
  126223. }
  126224. declare module BABYLON {
  126225. /**
  126226. * The options container for the teleportation module
  126227. */
  126228. export interface IWebXRTeleportationOptions {
  126229. /**
  126230. * if provided, this scene will be used to render meshes.
  126231. */
  126232. customUtilityLayerScene?: Scene;
  126233. /**
  126234. * Values to configure the default target mesh
  126235. */
  126236. defaultTargetMeshOptions?: {
  126237. /**
  126238. * Fill color of the teleportation area
  126239. */
  126240. teleportationFillColor?: string;
  126241. /**
  126242. * Border color for the teleportation area
  126243. */
  126244. teleportationBorderColor?: string;
  126245. /**
  126246. * Disable the mesh's animation sequence
  126247. */
  126248. disableAnimation?: boolean;
  126249. /**
  126250. * Disable lighting on the material or the ring and arrow
  126251. */
  126252. disableLighting?: boolean;
  126253. /**
  126254. * Override the default material of the torus and arrow
  126255. */
  126256. torusArrowMaterial?: Material;
  126257. };
  126258. /**
  126259. * A list of meshes to use as floor meshes.
  126260. * Meshes can be added and removed after initializing the feature using the
  126261. * addFloorMesh and removeFloorMesh functions
  126262. * If empty, rotation will still work
  126263. */
  126264. floorMeshes?: AbstractMesh[];
  126265. /**
  126266. * use this rendering group id for the meshes (optional)
  126267. */
  126268. renderingGroupId?: number;
  126269. /**
  126270. * Should teleportation move only to snap points
  126271. */
  126272. snapPointsOnly?: boolean;
  126273. /**
  126274. * An array of points to which the teleportation will snap to.
  126275. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126276. */
  126277. snapPositions?: Vector3[];
  126278. /**
  126279. * How close should the teleportation ray be in order to snap to position.
  126280. * Default to 0.8 units (meters)
  126281. */
  126282. snapToPositionRadius?: number;
  126283. /**
  126284. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126285. * If you want to support rotation, make sure your mesh has a direction indicator.
  126286. *
  126287. * When left untouched, the default mesh will be initialized.
  126288. */
  126289. teleportationTargetMesh?: AbstractMesh;
  126290. /**
  126291. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126292. */
  126293. timeToTeleport?: number;
  126294. /**
  126295. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126296. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126297. */
  126298. useMainComponentOnly?: boolean;
  126299. /**
  126300. * Should meshes created here be added to a utility layer or the main scene
  126301. */
  126302. useUtilityLayer?: boolean;
  126303. /**
  126304. * Babylon XR Input class for controller
  126305. */
  126306. xrInput: WebXRInput;
  126307. }
  126308. /**
  126309. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126310. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126311. * the input of the attached controllers.
  126312. */
  126313. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126314. private _options;
  126315. private _controllers;
  126316. private _currentTeleportationControllerId;
  126317. private _floorMeshes;
  126318. private _quadraticBezierCurve;
  126319. private _selectionFeature;
  126320. private _snapToPositions;
  126321. private _snappedToPoint;
  126322. private _teleportationRingMaterial?;
  126323. private _tmpRay;
  126324. private _tmpVector;
  126325. /**
  126326. * The module's name
  126327. */
  126328. static readonly Name: string;
  126329. /**
  126330. * The (Babylon) version of this module.
  126331. * This is an integer representing the implementation version.
  126332. * This number does not correspond to the webxr specs version
  126333. */
  126334. static readonly Version: number;
  126335. /**
  126336. * Is movement backwards enabled
  126337. */
  126338. backwardsMovementEnabled: boolean;
  126339. /**
  126340. * Distance to travel when moving backwards
  126341. */
  126342. backwardsTeleportationDistance: number;
  126343. /**
  126344. * The distance from the user to the inspection point in the direction of the controller
  126345. * A higher number will allow the user to move further
  126346. * defaults to 5 (meters, in xr units)
  126347. */
  126348. parabolicCheckRadius: number;
  126349. /**
  126350. * Should the module support parabolic ray on top of direct ray
  126351. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126352. * Very helpful when moving between floors / different heights
  126353. */
  126354. parabolicRayEnabled: boolean;
  126355. /**
  126356. * How much rotation should be applied when rotating right and left
  126357. */
  126358. rotationAngle: number;
  126359. /**
  126360. * Is rotation enabled when moving forward?
  126361. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126362. */
  126363. rotationEnabled: boolean;
  126364. /**
  126365. * constructs a new anchor system
  126366. * @param _xrSessionManager an instance of WebXRSessionManager
  126367. * @param _options configuration object for this feature
  126368. */
  126369. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126370. /**
  126371. * Get the snapPointsOnly flag
  126372. */
  126373. get snapPointsOnly(): boolean;
  126374. /**
  126375. * Sets the snapPointsOnly flag
  126376. * @param snapToPoints should teleportation be exclusively to snap points
  126377. */
  126378. set snapPointsOnly(snapToPoints: boolean);
  126379. /**
  126380. * Add a new mesh to the floor meshes array
  126381. * @param mesh the mesh to use as floor mesh
  126382. */
  126383. addFloorMesh(mesh: AbstractMesh): void;
  126384. /**
  126385. * Add a new snap-to point to fix teleportation to this position
  126386. * @param newSnapPoint The new Snap-To point
  126387. */
  126388. addSnapPoint(newSnapPoint: Vector3): void;
  126389. attach(): boolean;
  126390. detach(): boolean;
  126391. dispose(): void;
  126392. /**
  126393. * Remove a mesh from the floor meshes array
  126394. * @param mesh the mesh to remove
  126395. */
  126396. removeFloorMesh(mesh: AbstractMesh): void;
  126397. /**
  126398. * Remove a mesh from the floor meshes array using its name
  126399. * @param name the mesh name to remove
  126400. */
  126401. removeFloorMeshByName(name: string): void;
  126402. /**
  126403. * 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
  126404. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126405. * @returns was the point found and removed or not
  126406. */
  126407. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126408. /**
  126409. * This function sets a selection feature that will be disabled when
  126410. * the forward ray is shown and will be reattached when hidden.
  126411. * This is used to remove the selection rays when moving.
  126412. * @param selectionFeature the feature to disable when forward movement is enabled
  126413. */
  126414. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126415. protected _onXRFrame(_xrFrame: XRFrame): void;
  126416. private _attachController;
  126417. private _createDefaultTargetMesh;
  126418. private _detachController;
  126419. private _findClosestSnapPointWithRadius;
  126420. private _setTargetMeshPosition;
  126421. private _setTargetMeshVisibility;
  126422. private _showParabolicPath;
  126423. private _teleportForward;
  126424. }
  126425. }
  126426. declare module BABYLON {
  126427. /**
  126428. * Options for the default xr helper
  126429. */
  126430. export class WebXRDefaultExperienceOptions {
  126431. /**
  126432. * Enable or disable default UI to enter XR
  126433. */
  126434. disableDefaultUI?: boolean;
  126435. /**
  126436. * Should teleportation not initialize. defaults to false.
  126437. */
  126438. disableTeleportation?: boolean;
  126439. /**
  126440. * Floor meshes that will be used for teleport
  126441. */
  126442. floorMeshes?: Array<AbstractMesh>;
  126443. /**
  126444. * If set to true, the first frame will not be used to reset position
  126445. * The first frame is mainly used when copying transformation from the old camera
  126446. * Mainly used in AR
  126447. */
  126448. ignoreNativeCameraTransformation?: boolean;
  126449. /**
  126450. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126451. */
  126452. inputOptions?: IWebXRInputOptions;
  126453. /**
  126454. * optional configuration for the output canvas
  126455. */
  126456. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126457. /**
  126458. * optional UI options. This can be used among other to change session mode and reference space type
  126459. */
  126460. uiOptions?: WebXREnterExitUIOptions;
  126461. /**
  126462. * When loading teleportation and pointer select, use stable versions instead of latest.
  126463. */
  126464. useStablePlugins?: boolean;
  126465. /**
  126466. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126467. */
  126468. renderingGroupId?: number;
  126469. /**
  126470. * A list of optional features to init the session with
  126471. * If set to true, all features we support will be added
  126472. */
  126473. optionalFeatures?: boolean | string[];
  126474. }
  126475. /**
  126476. * Default experience which provides a similar setup to the previous webVRExperience
  126477. */
  126478. export class WebXRDefaultExperience {
  126479. /**
  126480. * Base experience
  126481. */
  126482. baseExperience: WebXRExperienceHelper;
  126483. /**
  126484. * Enables ui for entering/exiting xr
  126485. */
  126486. enterExitUI: WebXREnterExitUI;
  126487. /**
  126488. * Input experience extension
  126489. */
  126490. input: WebXRInput;
  126491. /**
  126492. * Enables laser pointer and selection
  126493. */
  126494. pointerSelection: WebXRControllerPointerSelection;
  126495. /**
  126496. * Default target xr should render to
  126497. */
  126498. renderTarget: WebXRRenderTarget;
  126499. /**
  126500. * Enables teleportation
  126501. */
  126502. teleportation: WebXRMotionControllerTeleportation;
  126503. private constructor();
  126504. /**
  126505. * Creates the default xr experience
  126506. * @param scene scene
  126507. * @param options options for basic configuration
  126508. * @returns resulting WebXRDefaultExperience
  126509. */
  126510. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126511. /**
  126512. * DIsposes of the experience helper
  126513. */
  126514. dispose(): void;
  126515. }
  126516. }
  126517. declare module BABYLON {
  126518. /**
  126519. * Options to modify the vr teleportation behavior.
  126520. */
  126521. export interface VRTeleportationOptions {
  126522. /**
  126523. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126524. */
  126525. floorMeshName?: string;
  126526. /**
  126527. * A list of meshes to be used as the teleportation floor. (default: empty)
  126528. */
  126529. floorMeshes?: Mesh[];
  126530. /**
  126531. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126532. */
  126533. teleportationMode?: number;
  126534. /**
  126535. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126536. */
  126537. teleportationTime?: number;
  126538. /**
  126539. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126540. */
  126541. teleportationSpeed?: number;
  126542. /**
  126543. * The easing function used in the animation or null for Linear. (default CircleEase)
  126544. */
  126545. easingFunction?: EasingFunction;
  126546. }
  126547. /**
  126548. * Options to modify the vr experience helper's behavior.
  126549. */
  126550. export interface VRExperienceHelperOptions extends WebVROptions {
  126551. /**
  126552. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126553. */
  126554. createDeviceOrientationCamera?: boolean;
  126555. /**
  126556. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126557. */
  126558. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126559. /**
  126560. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126561. */
  126562. laserToggle?: boolean;
  126563. /**
  126564. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126565. */
  126566. floorMeshes?: Mesh[];
  126567. /**
  126568. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126569. */
  126570. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126571. /**
  126572. * Defines if WebXR should be used instead of WebVR (if available)
  126573. */
  126574. useXR?: boolean;
  126575. }
  126576. /**
  126577. * Event containing information after VR has been entered
  126578. */
  126579. export class OnAfterEnteringVRObservableEvent {
  126580. /**
  126581. * If entering vr was successful
  126582. */
  126583. success: boolean;
  126584. }
  126585. /**
  126586. * Helps to quickly add VR support to an existing scene.
  126587. * See http://doc.babylonjs.com/how_to/webvr_helper
  126588. */
  126589. export class VRExperienceHelper {
  126590. /** Options to modify the vr experience helper's behavior. */
  126591. webVROptions: VRExperienceHelperOptions;
  126592. private _scene;
  126593. private _position;
  126594. private _btnVR;
  126595. private _btnVRDisplayed;
  126596. private _webVRsupported;
  126597. private _webVRready;
  126598. private _webVRrequesting;
  126599. private _webVRpresenting;
  126600. private _hasEnteredVR;
  126601. private _fullscreenVRpresenting;
  126602. private _inputElement;
  126603. private _webVRCamera;
  126604. private _vrDeviceOrientationCamera;
  126605. private _deviceOrientationCamera;
  126606. private _existingCamera;
  126607. private _onKeyDown;
  126608. private _onVrDisplayPresentChange;
  126609. private _onVRDisplayChanged;
  126610. private _onVRRequestPresentStart;
  126611. private _onVRRequestPresentComplete;
  126612. /**
  126613. * 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)
  126614. */
  126615. enableGazeEvenWhenNoPointerLock: boolean;
  126616. /**
  126617. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126618. */
  126619. exitVROnDoubleTap: boolean;
  126620. /**
  126621. * Observable raised right before entering VR.
  126622. */
  126623. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126624. /**
  126625. * Observable raised when entering VR has completed.
  126626. */
  126627. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126628. /**
  126629. * Observable raised when exiting VR.
  126630. */
  126631. onExitingVRObservable: Observable<VRExperienceHelper>;
  126632. /**
  126633. * Observable raised when controller mesh is loaded.
  126634. */
  126635. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126636. /** Return this.onEnteringVRObservable
  126637. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126638. */
  126639. get onEnteringVR(): Observable<VRExperienceHelper>;
  126640. /** Return this.onExitingVRObservable
  126641. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126642. */
  126643. get onExitingVR(): Observable<VRExperienceHelper>;
  126644. /** Return this.onControllerMeshLoadedObservable
  126645. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126646. */
  126647. get onControllerMeshLoaded(): Observable<WebVRController>;
  126648. private _rayLength;
  126649. private _useCustomVRButton;
  126650. private _teleportationRequested;
  126651. private _teleportActive;
  126652. private _floorMeshName;
  126653. private _floorMeshesCollection;
  126654. private _teleportationMode;
  126655. private _teleportationTime;
  126656. private _teleportationSpeed;
  126657. private _teleportationEasing;
  126658. private _rotationAllowed;
  126659. private _teleportBackwardsVector;
  126660. private _teleportationTarget;
  126661. private _isDefaultTeleportationTarget;
  126662. private _postProcessMove;
  126663. private _teleportationFillColor;
  126664. private _teleportationBorderColor;
  126665. private _rotationAngle;
  126666. private _haloCenter;
  126667. private _cameraGazer;
  126668. private _padSensibilityUp;
  126669. private _padSensibilityDown;
  126670. private _leftController;
  126671. private _rightController;
  126672. private _gazeColor;
  126673. private _laserColor;
  126674. private _pickedLaserColor;
  126675. private _pickedGazeColor;
  126676. /**
  126677. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126678. */
  126679. onNewMeshSelected: Observable<AbstractMesh>;
  126680. /**
  126681. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126682. * This observable will provide the mesh and the controller used to select the mesh
  126683. */
  126684. onMeshSelectedWithController: Observable<{
  126685. mesh: AbstractMesh;
  126686. controller: WebVRController;
  126687. }>;
  126688. /**
  126689. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126690. */
  126691. onNewMeshPicked: Observable<PickingInfo>;
  126692. private _circleEase;
  126693. /**
  126694. * Observable raised before camera teleportation
  126695. */
  126696. onBeforeCameraTeleport: Observable<Vector3>;
  126697. /**
  126698. * Observable raised after camera teleportation
  126699. */
  126700. onAfterCameraTeleport: Observable<Vector3>;
  126701. /**
  126702. * Observable raised when current selected mesh gets unselected
  126703. */
  126704. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126705. private _raySelectionPredicate;
  126706. /**
  126707. * To be optionaly changed by user to define custom ray selection
  126708. */
  126709. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126710. /**
  126711. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126712. */
  126713. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126714. /**
  126715. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126716. */
  126717. teleportationEnabled: boolean;
  126718. private _defaultHeight;
  126719. private _teleportationInitialized;
  126720. private _interactionsEnabled;
  126721. private _interactionsRequested;
  126722. private _displayGaze;
  126723. private _displayLaserPointer;
  126724. /**
  126725. * The mesh used to display where the user is going to teleport.
  126726. */
  126727. get teleportationTarget(): Mesh;
  126728. /**
  126729. * Sets the mesh to be used to display where the user is going to teleport.
  126730. */
  126731. set teleportationTarget(value: Mesh);
  126732. /**
  126733. * 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
  126734. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126735. * See http://doc.babylonjs.com/resources/baking_transformations
  126736. */
  126737. get gazeTrackerMesh(): Mesh;
  126738. set gazeTrackerMesh(value: Mesh);
  126739. /**
  126740. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126741. */
  126742. updateGazeTrackerScale: boolean;
  126743. /**
  126744. * If the gaze trackers color should be updated when selecting meshes
  126745. */
  126746. updateGazeTrackerColor: boolean;
  126747. /**
  126748. * If the controller laser color should be updated when selecting meshes
  126749. */
  126750. updateControllerLaserColor: boolean;
  126751. /**
  126752. * The gaze tracking mesh corresponding to the left controller
  126753. */
  126754. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126755. /**
  126756. * The gaze tracking mesh corresponding to the right controller
  126757. */
  126758. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126759. /**
  126760. * If the ray of the gaze should be displayed.
  126761. */
  126762. get displayGaze(): boolean;
  126763. /**
  126764. * Sets if the ray of the gaze should be displayed.
  126765. */
  126766. set displayGaze(value: boolean);
  126767. /**
  126768. * If the ray of the LaserPointer should be displayed.
  126769. */
  126770. get displayLaserPointer(): boolean;
  126771. /**
  126772. * Sets if the ray of the LaserPointer should be displayed.
  126773. */
  126774. set displayLaserPointer(value: boolean);
  126775. /**
  126776. * The deviceOrientationCamera used as the camera when not in VR.
  126777. */
  126778. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126779. /**
  126780. * Based on the current WebVR support, returns the current VR camera used.
  126781. */
  126782. get currentVRCamera(): Nullable<Camera>;
  126783. /**
  126784. * The webVRCamera which is used when in VR.
  126785. */
  126786. get webVRCamera(): WebVRFreeCamera;
  126787. /**
  126788. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126789. */
  126790. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126791. /**
  126792. * The html button that is used to trigger entering into VR.
  126793. */
  126794. get vrButton(): Nullable<HTMLButtonElement>;
  126795. private get _teleportationRequestInitiated();
  126796. /**
  126797. * Defines whether or not Pointer lock should be requested when switching to
  126798. * full screen.
  126799. */
  126800. requestPointerLockOnFullScreen: boolean;
  126801. /**
  126802. * If asking to force XR, this will be populated with the default xr experience
  126803. */
  126804. xr: WebXRDefaultExperience;
  126805. /**
  126806. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126807. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126808. */
  126809. xrTestDone: boolean;
  126810. /**
  126811. * Instantiates a VRExperienceHelper.
  126812. * Helps to quickly add VR support to an existing scene.
  126813. * @param scene The scene the VRExperienceHelper belongs to.
  126814. * @param webVROptions Options to modify the vr experience helper's behavior.
  126815. */
  126816. constructor(scene: Scene,
  126817. /** Options to modify the vr experience helper's behavior. */
  126818. webVROptions?: VRExperienceHelperOptions);
  126819. private completeVRInit;
  126820. private _onDefaultMeshLoaded;
  126821. private _onResize;
  126822. private _onFullscreenChange;
  126823. /**
  126824. * Gets a value indicating if we are currently in VR mode.
  126825. */
  126826. get isInVRMode(): boolean;
  126827. private onVrDisplayPresentChange;
  126828. private onVRDisplayChanged;
  126829. private moveButtonToBottomRight;
  126830. private displayVRButton;
  126831. private updateButtonVisibility;
  126832. private _cachedAngularSensibility;
  126833. /**
  126834. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126835. * Otherwise, will use the fullscreen API.
  126836. */
  126837. enterVR(): void;
  126838. /**
  126839. * Attempt to exit VR, or fullscreen.
  126840. */
  126841. exitVR(): void;
  126842. /**
  126843. * The position of the vr experience helper.
  126844. */
  126845. get position(): Vector3;
  126846. /**
  126847. * Sets the position of the vr experience helper.
  126848. */
  126849. set position(value: Vector3);
  126850. /**
  126851. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126852. */
  126853. enableInteractions(): void;
  126854. private get _noControllerIsActive();
  126855. private beforeRender;
  126856. private _isTeleportationFloor;
  126857. /**
  126858. * Adds a floor mesh to be used for teleportation.
  126859. * @param floorMesh the mesh to be used for teleportation.
  126860. */
  126861. addFloorMesh(floorMesh: Mesh): void;
  126862. /**
  126863. * Removes a floor mesh from being used for teleportation.
  126864. * @param floorMesh the mesh to be removed.
  126865. */
  126866. removeFloorMesh(floorMesh: Mesh): void;
  126867. /**
  126868. * Enables interactions and teleportation using the VR controllers and gaze.
  126869. * @param vrTeleportationOptions options to modify teleportation behavior.
  126870. */
  126871. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126872. private _onNewGamepadConnected;
  126873. private _tryEnableInteractionOnController;
  126874. private _onNewGamepadDisconnected;
  126875. private _enableInteractionOnController;
  126876. private _checkTeleportWithRay;
  126877. private _checkRotate;
  126878. private _checkTeleportBackwards;
  126879. private _enableTeleportationOnController;
  126880. private _createTeleportationCircles;
  126881. private _displayTeleportationTarget;
  126882. private _hideTeleportationTarget;
  126883. private _rotateCamera;
  126884. private _moveTeleportationSelectorTo;
  126885. private _workingVector;
  126886. private _workingQuaternion;
  126887. private _workingMatrix;
  126888. /**
  126889. * Time Constant Teleportation Mode
  126890. */
  126891. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126892. /**
  126893. * Speed Constant Teleportation Mode
  126894. */
  126895. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126896. /**
  126897. * Teleports the users feet to the desired location
  126898. * @param location The location where the user's feet should be placed
  126899. */
  126900. teleportCamera(location: Vector3): void;
  126901. private _convertNormalToDirectionOfRay;
  126902. private _castRayAndSelectObject;
  126903. private _notifySelectedMeshUnselected;
  126904. /**
  126905. * Permanently set new colors for the laser pointer
  126906. * @param color the new laser color
  126907. * @param pickedColor the new laser color when picked mesh detected
  126908. */
  126909. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126910. /**
  126911. * Set lighting enabled / disabled on the laser pointer of both controllers
  126912. * @param enabled should the lighting be enabled on the laser pointer
  126913. */
  126914. setLaserLightingState(enabled?: boolean): void;
  126915. /**
  126916. * Permanently set new colors for the gaze pointer
  126917. * @param color the new gaze color
  126918. * @param pickedColor the new gaze color when picked mesh detected
  126919. */
  126920. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126921. /**
  126922. * Sets the color of the laser ray from the vr controllers.
  126923. * @param color new color for the ray.
  126924. */
  126925. changeLaserColor(color: Color3): void;
  126926. /**
  126927. * Sets the color of the ray from the vr headsets gaze.
  126928. * @param color new color for the ray.
  126929. */
  126930. changeGazeColor(color: Color3): void;
  126931. /**
  126932. * Exits VR and disposes of the vr experience helper
  126933. */
  126934. dispose(): void;
  126935. /**
  126936. * Gets the name of the VRExperienceHelper class
  126937. * @returns "VRExperienceHelper"
  126938. */
  126939. getClassName(): string;
  126940. }
  126941. }
  126942. declare module BABYLON {
  126943. /**
  126944. * Contains an array of blocks representing the octree
  126945. */
  126946. export interface IOctreeContainer<T> {
  126947. /**
  126948. * Blocks within the octree
  126949. */
  126950. blocks: Array<OctreeBlock<T>>;
  126951. }
  126952. /**
  126953. * Class used to store a cell in an octree
  126954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126955. */
  126956. export class OctreeBlock<T> {
  126957. /**
  126958. * Gets the content of the current block
  126959. */
  126960. entries: T[];
  126961. /**
  126962. * Gets the list of block children
  126963. */
  126964. blocks: Array<OctreeBlock<T>>;
  126965. private _depth;
  126966. private _maxDepth;
  126967. private _capacity;
  126968. private _minPoint;
  126969. private _maxPoint;
  126970. private _boundingVectors;
  126971. private _creationFunc;
  126972. /**
  126973. * Creates a new block
  126974. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126975. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126976. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126977. * @param depth defines the current depth of this block in the octree
  126978. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126979. * @param creationFunc defines a callback to call when an element is added to the block
  126980. */
  126981. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126982. /**
  126983. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126984. */
  126985. get capacity(): number;
  126986. /**
  126987. * Gets the minimum vector (in world space) of the block's bounding box
  126988. */
  126989. get minPoint(): Vector3;
  126990. /**
  126991. * Gets the maximum vector (in world space) of the block's bounding box
  126992. */
  126993. get maxPoint(): Vector3;
  126994. /**
  126995. * Add a new element to this block
  126996. * @param entry defines the element to add
  126997. */
  126998. addEntry(entry: T): void;
  126999. /**
  127000. * Remove an element from this block
  127001. * @param entry defines the element to remove
  127002. */
  127003. removeEntry(entry: T): void;
  127004. /**
  127005. * Add an array of elements to this block
  127006. * @param entries defines the array of elements to add
  127007. */
  127008. addEntries(entries: T[]): void;
  127009. /**
  127010. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127011. * @param frustumPlanes defines the frustum planes to test
  127012. * @param selection defines the array to store current content if selection is positive
  127013. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127014. */
  127015. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127016. /**
  127017. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127018. * @param sphereCenter defines the bounding sphere center
  127019. * @param sphereRadius defines the bounding sphere radius
  127020. * @param selection defines the array to store current content if selection is positive
  127021. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127022. */
  127023. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127024. /**
  127025. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127026. * @param ray defines the ray to test with
  127027. * @param selection defines the array to store current content if selection is positive
  127028. */
  127029. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127030. /**
  127031. * Subdivide the content into child blocks (this block will then be empty)
  127032. */
  127033. createInnerBlocks(): void;
  127034. /**
  127035. * @hidden
  127036. */
  127037. 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;
  127038. }
  127039. }
  127040. declare module BABYLON {
  127041. /**
  127042. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127044. */
  127045. export class Octree<T> {
  127046. /** 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.) */
  127047. maxDepth: number;
  127048. /**
  127049. * Blocks within the octree containing objects
  127050. */
  127051. blocks: Array<OctreeBlock<T>>;
  127052. /**
  127053. * Content stored in the octree
  127054. */
  127055. dynamicContent: T[];
  127056. private _maxBlockCapacity;
  127057. private _selectionContent;
  127058. private _creationFunc;
  127059. /**
  127060. * Creates a octree
  127061. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127062. * @param creationFunc function to be used to instatiate the octree
  127063. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127064. * @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.)
  127065. */
  127066. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127067. /** 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.) */
  127068. maxDepth?: number);
  127069. /**
  127070. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127071. * @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);
  127072. * @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);
  127073. * @param entries meshes to be added to the octree blocks
  127074. */
  127075. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127076. /**
  127077. * Adds a mesh to the octree
  127078. * @param entry Mesh to add to the octree
  127079. */
  127080. addMesh(entry: T): void;
  127081. /**
  127082. * Remove an element from the octree
  127083. * @param entry defines the element to remove
  127084. */
  127085. removeMesh(entry: T): void;
  127086. /**
  127087. * Selects an array of meshes within the frustum
  127088. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127089. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127090. * @returns array of meshes within the frustum
  127091. */
  127092. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127093. /**
  127094. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127095. * @param sphereCenter defines the bounding sphere center
  127096. * @param sphereRadius defines the bounding sphere radius
  127097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127098. * @returns an array of objects that intersect the sphere
  127099. */
  127100. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127101. /**
  127102. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127103. * @param ray defines the ray to test with
  127104. * @returns array of intersected objects
  127105. */
  127106. intersectsRay(ray: Ray): SmartArray<T>;
  127107. /**
  127108. * Adds a mesh into the octree block if it intersects the block
  127109. */
  127110. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127111. /**
  127112. * Adds a submesh into the octree block if it intersects the block
  127113. */
  127114. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127115. }
  127116. }
  127117. declare module BABYLON {
  127118. interface Scene {
  127119. /**
  127120. * @hidden
  127121. * Backing Filed
  127122. */
  127123. _selectionOctree: Octree<AbstractMesh>;
  127124. /**
  127125. * Gets the octree used to boost mesh selection (picking)
  127126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127127. */
  127128. selectionOctree: Octree<AbstractMesh>;
  127129. /**
  127130. * Creates or updates the octree used to boost selection (picking)
  127131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127132. * @param maxCapacity defines the maximum capacity per leaf
  127133. * @param maxDepth defines the maximum depth of the octree
  127134. * @returns an octree of AbstractMesh
  127135. */
  127136. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127137. }
  127138. interface AbstractMesh {
  127139. /**
  127140. * @hidden
  127141. * Backing Field
  127142. */
  127143. _submeshesOctree: Octree<SubMesh>;
  127144. /**
  127145. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127146. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127147. * @param maxCapacity defines the maximum size of each block (64 by default)
  127148. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127149. * @returns the new octree
  127150. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127152. */
  127153. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127154. }
  127155. /**
  127156. * Defines the octree scene component responsible to manage any octrees
  127157. * in a given scene.
  127158. */
  127159. export class OctreeSceneComponent {
  127160. /**
  127161. * The component name help to identify the component in the list of scene components.
  127162. */
  127163. readonly name: string;
  127164. /**
  127165. * The scene the component belongs to.
  127166. */
  127167. scene: Scene;
  127168. /**
  127169. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127170. */
  127171. readonly checksIsEnabled: boolean;
  127172. /**
  127173. * Creates a new instance of the component for the given scene
  127174. * @param scene Defines the scene to register the component in
  127175. */
  127176. constructor(scene: Scene);
  127177. /**
  127178. * Registers the component in a given scene
  127179. */
  127180. register(): void;
  127181. /**
  127182. * Return the list of active meshes
  127183. * @returns the list of active meshes
  127184. */
  127185. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127186. /**
  127187. * Return the list of active sub meshes
  127188. * @param mesh The mesh to get the candidates sub meshes from
  127189. * @returns the list of active sub meshes
  127190. */
  127191. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127192. private _tempRay;
  127193. /**
  127194. * Return the list of sub meshes intersecting with a given local ray
  127195. * @param mesh defines the mesh to find the submesh for
  127196. * @param localRay defines the ray in local space
  127197. * @returns the list of intersecting sub meshes
  127198. */
  127199. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127200. /**
  127201. * Return the list of sub meshes colliding with a collider
  127202. * @param mesh defines the mesh to find the submesh for
  127203. * @param collider defines the collider to evaluate the collision against
  127204. * @returns the list of colliding sub meshes
  127205. */
  127206. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127207. /**
  127208. * Rebuilds the elements related to this component in case of
  127209. * context lost for instance.
  127210. */
  127211. rebuild(): void;
  127212. /**
  127213. * Disposes the component and the associated ressources.
  127214. */
  127215. dispose(): void;
  127216. }
  127217. }
  127218. declare module BABYLON {
  127219. /**
  127220. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127221. */
  127222. export class Gizmo implements IDisposable {
  127223. /** The utility layer the gizmo will be added to */
  127224. gizmoLayer: UtilityLayerRenderer;
  127225. /**
  127226. * The root mesh of the gizmo
  127227. */
  127228. _rootMesh: Mesh;
  127229. private _attachedMesh;
  127230. /**
  127231. * Ratio for the scale of the gizmo (Default: 1)
  127232. */
  127233. scaleRatio: number;
  127234. /**
  127235. * If a custom mesh has been set (Default: false)
  127236. */
  127237. protected _customMeshSet: boolean;
  127238. /**
  127239. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127240. * * When set, interactions will be enabled
  127241. */
  127242. get attachedMesh(): Nullable<AbstractMesh>;
  127243. set attachedMesh(value: Nullable<AbstractMesh>);
  127244. /**
  127245. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127246. * @param mesh The mesh to replace the default mesh of the gizmo
  127247. */
  127248. setCustomMesh(mesh: Mesh): void;
  127249. /**
  127250. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127251. */
  127252. updateGizmoRotationToMatchAttachedMesh: boolean;
  127253. /**
  127254. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127255. */
  127256. updateGizmoPositionToMatchAttachedMesh: boolean;
  127257. /**
  127258. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127259. */
  127260. updateScale: boolean;
  127261. protected _interactionsEnabled: boolean;
  127262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127263. private _beforeRenderObserver;
  127264. private _tempVector;
  127265. /**
  127266. * Creates a gizmo
  127267. * @param gizmoLayer The utility layer the gizmo will be added to
  127268. */
  127269. constructor(
  127270. /** The utility layer the gizmo will be added to */
  127271. gizmoLayer?: UtilityLayerRenderer);
  127272. /**
  127273. * Updates the gizmo to match the attached mesh's position/rotation
  127274. */
  127275. protected _update(): void;
  127276. /**
  127277. * Disposes of the gizmo
  127278. */
  127279. dispose(): void;
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /**
  127284. * Single plane drag gizmo
  127285. */
  127286. export class PlaneDragGizmo extends Gizmo {
  127287. /**
  127288. * Drag behavior responsible for the gizmos dragging interactions
  127289. */
  127290. dragBehavior: PointerDragBehavior;
  127291. private _pointerObserver;
  127292. /**
  127293. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127294. */
  127295. snapDistance: number;
  127296. /**
  127297. * Event that fires each time the gizmo snaps to a new location.
  127298. * * snapDistance is the the change in distance
  127299. */
  127300. onSnapObservable: Observable<{
  127301. snapDistance: number;
  127302. }>;
  127303. private _plane;
  127304. private _coloredMaterial;
  127305. private _hoverMaterial;
  127306. private _isEnabled;
  127307. private _parent;
  127308. /** @hidden */
  127309. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127310. /** @hidden */
  127311. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127312. /**
  127313. * Creates a PlaneDragGizmo
  127314. * @param gizmoLayer The utility layer the gizmo will be added to
  127315. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127316. * @param color The color of the gizmo
  127317. */
  127318. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127319. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127320. /**
  127321. * If the gizmo is enabled
  127322. */
  127323. set isEnabled(value: boolean);
  127324. get isEnabled(): boolean;
  127325. /**
  127326. * Disposes of the gizmo
  127327. */
  127328. dispose(): void;
  127329. }
  127330. }
  127331. declare module BABYLON {
  127332. /**
  127333. * Gizmo that enables dragging a mesh along 3 axis
  127334. */
  127335. export class PositionGizmo extends Gizmo {
  127336. /**
  127337. * Internal gizmo used for interactions on the x axis
  127338. */
  127339. xGizmo: AxisDragGizmo;
  127340. /**
  127341. * Internal gizmo used for interactions on the y axis
  127342. */
  127343. yGizmo: AxisDragGizmo;
  127344. /**
  127345. * Internal gizmo used for interactions on the z axis
  127346. */
  127347. zGizmo: AxisDragGizmo;
  127348. /**
  127349. * Internal gizmo used for interactions on the yz plane
  127350. */
  127351. xPlaneGizmo: PlaneDragGizmo;
  127352. /**
  127353. * Internal gizmo used for interactions on the xz plane
  127354. */
  127355. yPlaneGizmo: PlaneDragGizmo;
  127356. /**
  127357. * Internal gizmo used for interactions on the xy plane
  127358. */
  127359. zPlaneGizmo: PlaneDragGizmo;
  127360. /**
  127361. * private variables
  127362. */
  127363. private _meshAttached;
  127364. private _updateGizmoRotationToMatchAttachedMesh;
  127365. private _snapDistance;
  127366. private _scaleRatio;
  127367. /** Fires an event when any of it's sub gizmos are dragged */
  127368. onDragStartObservable: Observable<unknown>;
  127369. /** Fires an event when any of it's sub gizmos are released from dragging */
  127370. onDragEndObservable: Observable<unknown>;
  127371. /**
  127372. * If set to true, planar drag is enabled
  127373. */
  127374. private _planarGizmoEnabled;
  127375. get attachedMesh(): Nullable<AbstractMesh>;
  127376. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127377. /**
  127378. * Creates a PositionGizmo
  127379. * @param gizmoLayer The utility layer the gizmo will be added to
  127380. */
  127381. constructor(gizmoLayer?: UtilityLayerRenderer);
  127382. /**
  127383. * If the planar drag gizmo is enabled
  127384. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127385. */
  127386. set planarGizmoEnabled(value: boolean);
  127387. get planarGizmoEnabled(): boolean;
  127388. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127389. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127390. /**
  127391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127392. */
  127393. set snapDistance(value: number);
  127394. get snapDistance(): number;
  127395. /**
  127396. * Ratio for the scale of the gizmo (Default: 1)
  127397. */
  127398. set scaleRatio(value: number);
  127399. get scaleRatio(): number;
  127400. /**
  127401. * Disposes of the gizmo
  127402. */
  127403. dispose(): void;
  127404. /**
  127405. * CustomMeshes are not supported by this gizmo
  127406. * @param mesh The mesh to replace the default mesh of the gizmo
  127407. */
  127408. setCustomMesh(mesh: Mesh): void;
  127409. }
  127410. }
  127411. declare module BABYLON {
  127412. /**
  127413. * Single axis drag gizmo
  127414. */
  127415. export class AxisDragGizmo extends Gizmo {
  127416. /**
  127417. * Drag behavior responsible for the gizmos dragging interactions
  127418. */
  127419. dragBehavior: PointerDragBehavior;
  127420. private _pointerObserver;
  127421. /**
  127422. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127423. */
  127424. snapDistance: number;
  127425. /**
  127426. * Event that fires each time the gizmo snaps to a new location.
  127427. * * snapDistance is the the change in distance
  127428. */
  127429. onSnapObservable: Observable<{
  127430. snapDistance: number;
  127431. }>;
  127432. private _isEnabled;
  127433. private _parent;
  127434. private _arrow;
  127435. private _coloredMaterial;
  127436. private _hoverMaterial;
  127437. /** @hidden */
  127438. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127439. /** @hidden */
  127440. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127441. /**
  127442. * Creates an AxisDragGizmo
  127443. * @param gizmoLayer The utility layer the gizmo will be added to
  127444. * @param dragAxis The axis which the gizmo will be able to drag on
  127445. * @param color The color of the gizmo
  127446. */
  127447. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127449. /**
  127450. * If the gizmo is enabled
  127451. */
  127452. set isEnabled(value: boolean);
  127453. get isEnabled(): boolean;
  127454. /**
  127455. * Disposes of the gizmo
  127456. */
  127457. dispose(): void;
  127458. }
  127459. }
  127460. declare module BABYLON.Debug {
  127461. /**
  127462. * The Axes viewer will show 3 axes in a specific point in space
  127463. */
  127464. export class AxesViewer {
  127465. private _xAxis;
  127466. private _yAxis;
  127467. private _zAxis;
  127468. private _scaleLinesFactor;
  127469. private _instanced;
  127470. /**
  127471. * Gets the hosting scene
  127472. */
  127473. scene: Scene;
  127474. /**
  127475. * Gets or sets a number used to scale line length
  127476. */
  127477. scaleLines: number;
  127478. /** Gets the node hierarchy used to render x-axis */
  127479. get xAxis(): TransformNode;
  127480. /** Gets the node hierarchy used to render y-axis */
  127481. get yAxis(): TransformNode;
  127482. /** Gets the node hierarchy used to render z-axis */
  127483. get zAxis(): TransformNode;
  127484. /**
  127485. * Creates a new AxesViewer
  127486. * @param scene defines the hosting scene
  127487. * @param scaleLines defines a number used to scale line length (1 by default)
  127488. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127489. * @param xAxis defines the node hierarchy used to render the x-axis
  127490. * @param yAxis defines the node hierarchy used to render the y-axis
  127491. * @param zAxis defines the node hierarchy used to render the z-axis
  127492. */
  127493. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127494. /**
  127495. * Force the viewer to update
  127496. * @param position defines the position of the viewer
  127497. * @param xaxis defines the x axis of the viewer
  127498. * @param yaxis defines the y axis of the viewer
  127499. * @param zaxis defines the z axis of the viewer
  127500. */
  127501. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127502. /**
  127503. * Creates an instance of this axes viewer.
  127504. * @returns a new axes viewer with instanced meshes
  127505. */
  127506. createInstance(): AxesViewer;
  127507. /** Releases resources */
  127508. dispose(): void;
  127509. private static _SetRenderingGroupId;
  127510. }
  127511. }
  127512. declare module BABYLON.Debug {
  127513. /**
  127514. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127515. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127516. */
  127517. export class BoneAxesViewer extends AxesViewer {
  127518. /**
  127519. * Gets or sets the target mesh where to display the axes viewer
  127520. */
  127521. mesh: Nullable<Mesh>;
  127522. /**
  127523. * Gets or sets the target bone where to display the axes viewer
  127524. */
  127525. bone: Nullable<Bone>;
  127526. /** Gets current position */
  127527. pos: Vector3;
  127528. /** Gets direction of X axis */
  127529. xaxis: Vector3;
  127530. /** Gets direction of Y axis */
  127531. yaxis: Vector3;
  127532. /** Gets direction of Z axis */
  127533. zaxis: Vector3;
  127534. /**
  127535. * Creates a new BoneAxesViewer
  127536. * @param scene defines the hosting scene
  127537. * @param bone defines the target bone
  127538. * @param mesh defines the target mesh
  127539. * @param scaleLines defines a scaling factor for line length (1 by default)
  127540. */
  127541. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127542. /**
  127543. * Force the viewer to update
  127544. */
  127545. update(): void;
  127546. /** Releases resources */
  127547. dispose(): void;
  127548. }
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * Interface used to define scene explorer extensibility option
  127553. */
  127554. export interface IExplorerExtensibilityOption {
  127555. /**
  127556. * Define the option label
  127557. */
  127558. label: string;
  127559. /**
  127560. * Defines the action to execute on click
  127561. */
  127562. action: (entity: any) => void;
  127563. }
  127564. /**
  127565. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127566. */
  127567. export interface IExplorerExtensibilityGroup {
  127568. /**
  127569. * Defines a predicate to test if a given type mut be extended
  127570. */
  127571. predicate: (entity: any) => boolean;
  127572. /**
  127573. * Gets the list of options added to a type
  127574. */
  127575. entries: IExplorerExtensibilityOption[];
  127576. }
  127577. /**
  127578. * Interface used to define the options to use to create the Inspector
  127579. */
  127580. export interface IInspectorOptions {
  127581. /**
  127582. * Display in overlay mode (default: false)
  127583. */
  127584. overlay?: boolean;
  127585. /**
  127586. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127587. */
  127588. globalRoot?: HTMLElement;
  127589. /**
  127590. * Display the Scene explorer
  127591. */
  127592. showExplorer?: boolean;
  127593. /**
  127594. * Display the property inspector
  127595. */
  127596. showInspector?: boolean;
  127597. /**
  127598. * Display in embed mode (both panes on the right)
  127599. */
  127600. embedMode?: boolean;
  127601. /**
  127602. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127603. */
  127604. handleResize?: boolean;
  127605. /**
  127606. * Allow the panes to popup (default: true)
  127607. */
  127608. enablePopup?: boolean;
  127609. /**
  127610. * Allow the panes to be closed by users (default: true)
  127611. */
  127612. enableClose?: boolean;
  127613. /**
  127614. * Optional list of extensibility entries
  127615. */
  127616. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127617. /**
  127618. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127619. */
  127620. inspectorURL?: string;
  127621. /**
  127622. * Optional initial tab (default to DebugLayerTab.Properties)
  127623. */
  127624. initialTab?: DebugLayerTab;
  127625. }
  127626. interface Scene {
  127627. /**
  127628. * @hidden
  127629. * Backing field
  127630. */
  127631. _debugLayer: DebugLayer;
  127632. /**
  127633. * Gets the debug layer (aka Inspector) associated with the scene
  127634. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127635. */
  127636. debugLayer: DebugLayer;
  127637. }
  127638. /**
  127639. * Enum of inspector action tab
  127640. */
  127641. export enum DebugLayerTab {
  127642. /**
  127643. * Properties tag (default)
  127644. */
  127645. Properties = 0,
  127646. /**
  127647. * Debug tab
  127648. */
  127649. Debug = 1,
  127650. /**
  127651. * Statistics tab
  127652. */
  127653. Statistics = 2,
  127654. /**
  127655. * Tools tab
  127656. */
  127657. Tools = 3,
  127658. /**
  127659. * Settings tab
  127660. */
  127661. Settings = 4
  127662. }
  127663. /**
  127664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127665. * what is happening in your scene
  127666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127667. */
  127668. export class DebugLayer {
  127669. /**
  127670. * Define the url to get the inspector script from.
  127671. * By default it uses the babylonjs CDN.
  127672. * @ignoreNaming
  127673. */
  127674. static InspectorURL: string;
  127675. private _scene;
  127676. private BJSINSPECTOR;
  127677. private _onPropertyChangedObservable?;
  127678. /**
  127679. * Observable triggered when a property is changed through the inspector.
  127680. */
  127681. get onPropertyChangedObservable(): any;
  127682. /**
  127683. * Instantiates a new debug layer.
  127684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127685. * what is happening in your scene
  127686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127687. * @param scene Defines the scene to inspect
  127688. */
  127689. constructor(scene: Scene);
  127690. /** Creates the inspector window. */
  127691. private _createInspector;
  127692. /**
  127693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127694. * @param entity defines the entity to select
  127695. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127696. */
  127697. select(entity: any, lineContainerTitles?: string | string[]): void;
  127698. /** Get the inspector from bundle or global */
  127699. private _getGlobalInspector;
  127700. /**
  127701. * Get if the inspector is visible or not.
  127702. * @returns true if visible otherwise, false
  127703. */
  127704. isVisible(): boolean;
  127705. /**
  127706. * Hide the inspector and close its window.
  127707. */
  127708. hide(): void;
  127709. /**
  127710. * Update the scene in the inspector
  127711. */
  127712. setAsActiveScene(): void;
  127713. /**
  127714. * Launch the debugLayer.
  127715. * @param config Define the configuration of the inspector
  127716. * @return a promise fulfilled when the debug layer is visible
  127717. */
  127718. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127719. }
  127720. }
  127721. declare module BABYLON {
  127722. /**
  127723. * Class containing static functions to help procedurally build meshes
  127724. */
  127725. export class BoxBuilder {
  127726. /**
  127727. * Creates a box mesh
  127728. * * The parameter `size` sets the size (float) of each box side (default 1)
  127729. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127730. * * 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)
  127731. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127735. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127736. * @param name defines the name of the mesh
  127737. * @param options defines the options used to create the mesh
  127738. * @param scene defines the hosting scene
  127739. * @returns the box mesh
  127740. */
  127741. static CreateBox(name: string, options: {
  127742. size?: number;
  127743. width?: number;
  127744. height?: number;
  127745. depth?: number;
  127746. faceUV?: Vector4[];
  127747. faceColors?: Color4[];
  127748. sideOrientation?: number;
  127749. frontUVs?: Vector4;
  127750. backUVs?: Vector4;
  127751. wrap?: boolean;
  127752. topBaseAt?: number;
  127753. bottomBaseAt?: number;
  127754. updatable?: boolean;
  127755. }, scene?: Nullable<Scene>): Mesh;
  127756. }
  127757. }
  127758. declare module BABYLON.Debug {
  127759. /**
  127760. * Used to show the physics impostor around the specific mesh
  127761. */
  127762. export class PhysicsViewer {
  127763. /** @hidden */
  127764. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127765. /** @hidden */
  127766. protected _meshes: Array<Nullable<AbstractMesh>>;
  127767. /** @hidden */
  127768. protected _scene: Nullable<Scene>;
  127769. /** @hidden */
  127770. protected _numMeshes: number;
  127771. /** @hidden */
  127772. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127773. private _renderFunction;
  127774. private _utilityLayer;
  127775. private _debugBoxMesh;
  127776. private _debugSphereMesh;
  127777. private _debugCylinderMesh;
  127778. private _debugMaterial;
  127779. private _debugMeshMeshes;
  127780. /**
  127781. * Creates a new PhysicsViewer
  127782. * @param scene defines the hosting scene
  127783. */
  127784. constructor(scene: Scene);
  127785. /** @hidden */
  127786. protected _updateDebugMeshes(): void;
  127787. /**
  127788. * Renders a specified physic impostor
  127789. * @param impostor defines the impostor to render
  127790. * @param targetMesh defines the mesh represented by the impostor
  127791. * @returns the new debug mesh used to render the impostor
  127792. */
  127793. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127794. /**
  127795. * Hides a specified physic impostor
  127796. * @param impostor defines the impostor to hide
  127797. */
  127798. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127799. private _getDebugMaterial;
  127800. private _getDebugBoxMesh;
  127801. private _getDebugSphereMesh;
  127802. private _getDebugCylinderMesh;
  127803. private _getDebugMeshMesh;
  127804. private _getDebugMesh;
  127805. /** Releases all resources */
  127806. dispose(): void;
  127807. }
  127808. }
  127809. declare module BABYLON {
  127810. /**
  127811. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127812. * in order to better appreciate the issue one might have.
  127813. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127814. */
  127815. export class RayHelper {
  127816. /**
  127817. * Defines the ray we are currently tryin to visualize.
  127818. */
  127819. ray: Nullable<Ray>;
  127820. private _renderPoints;
  127821. private _renderLine;
  127822. private _renderFunction;
  127823. private _scene;
  127824. private _updateToMeshFunction;
  127825. private _attachedToMesh;
  127826. private _meshSpaceDirection;
  127827. private _meshSpaceOrigin;
  127828. /**
  127829. * Helper function to create a colored helper in a scene in one line.
  127830. * @param ray Defines the ray we are currently tryin to visualize
  127831. * @param scene Defines the scene the ray is used in
  127832. * @param color Defines the color we want to see the ray in
  127833. * @returns The newly created ray helper.
  127834. */
  127835. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127836. /**
  127837. * Instantiate a new ray helper.
  127838. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127839. * in order to better appreciate the issue one might have.
  127840. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127841. * @param ray Defines the ray we are currently tryin to visualize
  127842. */
  127843. constructor(ray: Ray);
  127844. /**
  127845. * Shows the ray we are willing to debug.
  127846. * @param scene Defines the scene the ray needs to be rendered in
  127847. * @param color Defines the color the ray needs to be rendered in
  127848. */
  127849. show(scene: Scene, color?: Color3): void;
  127850. /**
  127851. * Hides the ray we are debugging.
  127852. */
  127853. hide(): void;
  127854. private _render;
  127855. /**
  127856. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127857. * @param mesh Defines the mesh we want the helper attached to
  127858. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127859. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127860. * @param length Defines the length of the ray
  127861. */
  127862. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127863. /**
  127864. * Detach the ray helper from the mesh it has previously been attached to.
  127865. */
  127866. detachFromMesh(): void;
  127867. private _updateToMesh;
  127868. /**
  127869. * Dispose the helper and release its associated resources.
  127870. */
  127871. dispose(): void;
  127872. }
  127873. }
  127874. declare module BABYLON.Debug {
  127875. /**
  127876. * Class used to render a debug view of a given skeleton
  127877. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127878. */
  127879. export class SkeletonViewer {
  127880. /** defines the skeleton to render */
  127881. skeleton: Skeleton;
  127882. /** defines the mesh attached to the skeleton */
  127883. mesh: AbstractMesh;
  127884. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127885. autoUpdateBonesMatrices: boolean;
  127886. /** defines the rendering group id to use with the viewer */
  127887. renderingGroupId: number;
  127888. /** Gets or sets the color used to render the skeleton */
  127889. color: Color3;
  127890. private _scene;
  127891. private _debugLines;
  127892. private _debugMesh;
  127893. private _isEnabled;
  127894. private _renderFunction;
  127895. private _utilityLayer;
  127896. /**
  127897. * Returns the mesh used to render the bones
  127898. */
  127899. get debugMesh(): Nullable<LinesMesh>;
  127900. /**
  127901. * Creates a new SkeletonViewer
  127902. * @param skeleton defines the skeleton to render
  127903. * @param mesh defines the mesh attached to the skeleton
  127904. * @param scene defines the hosting scene
  127905. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127906. * @param renderingGroupId defines the rendering group id to use with the viewer
  127907. */
  127908. constructor(
  127909. /** defines the skeleton to render */
  127910. skeleton: Skeleton,
  127911. /** defines the mesh attached to the skeleton */
  127912. mesh: AbstractMesh, scene: Scene,
  127913. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127914. autoUpdateBonesMatrices?: boolean,
  127915. /** defines the rendering group id to use with the viewer */
  127916. renderingGroupId?: number);
  127917. /** Gets or sets a boolean indicating if the viewer is enabled */
  127918. set isEnabled(value: boolean);
  127919. get isEnabled(): boolean;
  127920. private _getBonePosition;
  127921. private _getLinesForBonesWithLength;
  127922. private _getLinesForBonesNoLength;
  127923. /** Update the viewer to sync with current skeleton state */
  127924. update(): void;
  127925. /** Release associated resources */
  127926. dispose(): void;
  127927. }
  127928. }
  127929. declare module BABYLON {
  127930. /**
  127931. * Enum for Device Types
  127932. */
  127933. export enum DeviceType {
  127934. /** Generic */
  127935. Generic = 0,
  127936. /** Keyboard */
  127937. Keyboard = 1,
  127938. /** Mouse */
  127939. Mouse = 2,
  127940. /** Touch Pointers */
  127941. Touch = 3,
  127942. /** PS4 Dual Shock */
  127943. DualShock = 4,
  127944. /** Xbox */
  127945. Xbox = 5,
  127946. /** Switch Controller */
  127947. Switch = 6
  127948. }
  127949. /**
  127950. * Enum for All Pointers (Touch/Mouse)
  127951. */
  127952. export enum PointerInput {
  127953. /** Horizontal Axis */
  127954. Horizontal = 0,
  127955. /** Vertical Axis */
  127956. Vertical = 1,
  127957. /** Left Click or Touch */
  127958. LeftClick = 2,
  127959. /** Middle Click */
  127960. MiddleClick = 3,
  127961. /** Right Click */
  127962. RightClick = 4,
  127963. /** Browser Back */
  127964. BrowserBack = 5,
  127965. /** Browser Forward */
  127966. BrowserForward = 6
  127967. }
  127968. /**
  127969. * Enum for Dual Shock Gamepad
  127970. */
  127971. export enum DualShockInput {
  127972. /** Cross */
  127973. Cross = 0,
  127974. /** Circle */
  127975. Circle = 1,
  127976. /** Square */
  127977. Square = 2,
  127978. /** Triangle */
  127979. Triangle = 3,
  127980. /** L1 */
  127981. L1 = 4,
  127982. /** R1 */
  127983. R1 = 5,
  127984. /** L2 */
  127985. L2 = 6,
  127986. /** R2 */
  127987. R2 = 7,
  127988. /** Share */
  127989. Share = 8,
  127990. /** Options */
  127991. Options = 9,
  127992. /** L3 */
  127993. L3 = 10,
  127994. /** R3 */
  127995. R3 = 11,
  127996. /** DPadUp */
  127997. DPadUp = 12,
  127998. /** DPadDown */
  127999. DPadDown = 13,
  128000. /** DPadLeft */
  128001. DPadLeft = 14,
  128002. /** DRight */
  128003. DPadRight = 15,
  128004. /** Home */
  128005. Home = 16,
  128006. /** TouchPad */
  128007. TouchPad = 17,
  128008. /** LStickXAxis */
  128009. LStickXAxis = 18,
  128010. /** LStickYAxis */
  128011. LStickYAxis = 19,
  128012. /** RStickXAxis */
  128013. RStickXAxis = 20,
  128014. /** RStickYAxis */
  128015. RStickYAxis = 21
  128016. }
  128017. /**
  128018. * Enum for Xbox Gamepad
  128019. */
  128020. export enum XboxInput {
  128021. /** A */
  128022. A = 0,
  128023. /** B */
  128024. B = 1,
  128025. /** X */
  128026. X = 2,
  128027. /** Y */
  128028. Y = 3,
  128029. /** LB */
  128030. LB = 4,
  128031. /** RB */
  128032. RB = 5,
  128033. /** LT */
  128034. LT = 6,
  128035. /** RT */
  128036. RT = 7,
  128037. /** Back */
  128038. Back = 8,
  128039. /** Start */
  128040. Start = 9,
  128041. /** LS */
  128042. LS = 10,
  128043. /** RS */
  128044. RS = 11,
  128045. /** DPadUp */
  128046. DPadUp = 12,
  128047. /** DPadDown */
  128048. DPadDown = 13,
  128049. /** DPadLeft */
  128050. DPadLeft = 14,
  128051. /** DRight */
  128052. DPadRight = 15,
  128053. /** Home */
  128054. Home = 16,
  128055. /** LStickXAxis */
  128056. LStickXAxis = 17,
  128057. /** LStickYAxis */
  128058. LStickYAxis = 18,
  128059. /** RStickXAxis */
  128060. RStickXAxis = 19,
  128061. /** RStickYAxis */
  128062. RStickYAxis = 20
  128063. }
  128064. /**
  128065. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128066. */
  128067. export enum SwitchInput {
  128068. /** B */
  128069. B = 0,
  128070. /** A */
  128071. A = 1,
  128072. /** Y */
  128073. Y = 2,
  128074. /** X */
  128075. X = 3,
  128076. /** L */
  128077. L = 4,
  128078. /** R */
  128079. R = 5,
  128080. /** ZL */
  128081. ZL = 6,
  128082. /** ZR */
  128083. ZR = 7,
  128084. /** Minus */
  128085. Minus = 8,
  128086. /** Plus */
  128087. Plus = 9,
  128088. /** LS */
  128089. LS = 10,
  128090. /** RS */
  128091. RS = 11,
  128092. /** DPadUp */
  128093. DPadUp = 12,
  128094. /** DPadDown */
  128095. DPadDown = 13,
  128096. /** DPadLeft */
  128097. DPadLeft = 14,
  128098. /** DRight */
  128099. DPadRight = 15,
  128100. /** Home */
  128101. Home = 16,
  128102. /** Capture */
  128103. Capture = 17,
  128104. /** LStickXAxis */
  128105. LStickXAxis = 18,
  128106. /** LStickYAxis */
  128107. LStickYAxis = 19,
  128108. /** RStickXAxis */
  128109. RStickXAxis = 20,
  128110. /** RStickYAxis */
  128111. RStickYAxis = 21
  128112. }
  128113. }
  128114. declare module BABYLON {
  128115. /**
  128116. * This class will take all inputs from Keyboard, Pointer, and
  128117. * any Gamepads and provide a polling system that all devices
  128118. * will use. This class assumes that there will only be one
  128119. * pointer device and one keyboard.
  128120. */
  128121. export class DeviceInputSystem implements IDisposable {
  128122. /**
  128123. * Callback to be triggered when a device is connected
  128124. */
  128125. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128126. /**
  128127. * Callback to be triggered when a device is disconnected
  128128. */
  128129. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128130. /**
  128131. * Callback to be triggered when event driven input is updated
  128132. */
  128133. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128134. private _inputs;
  128135. private _gamepads;
  128136. private _keyboardActive;
  128137. private _pointerActive;
  128138. private _elementToAttachTo;
  128139. private _keyboardDownEvent;
  128140. private _keyboardUpEvent;
  128141. private _pointerMoveEvent;
  128142. private _pointerDownEvent;
  128143. private _pointerUpEvent;
  128144. private _gamepadConnectedEvent;
  128145. private _gamepadDisconnectedEvent;
  128146. private static _MAX_KEYCODES;
  128147. private static _MAX_POINTER_INPUTS;
  128148. private constructor();
  128149. /**
  128150. * Creates a new DeviceInputSystem instance
  128151. * @param engine Engine to pull input element from
  128152. * @returns The new instance
  128153. */
  128154. static Create(engine: Engine): DeviceInputSystem;
  128155. /**
  128156. * Checks for current device input value, given an id and input index
  128157. * @param deviceName Id of connected device
  128158. * @param inputIndex Index of device input
  128159. * @returns Current value of input
  128160. */
  128161. /**
  128162. * Checks for current device input value, given an id and input index
  128163. * @param deviceType Enum specifiying device type
  128164. * @param deviceSlot "Slot" or index that device is referenced in
  128165. * @param inputIndex Id of input to be checked
  128166. * @returns Current value of input
  128167. */
  128168. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128169. /**
  128170. * Dispose of all the eventlisteners
  128171. */
  128172. dispose(): void;
  128173. /**
  128174. * Add device and inputs to device array
  128175. * @param deviceType Enum specifiying device type
  128176. * @param deviceSlot "Slot" or index that device is referenced in
  128177. * @param numberOfInputs Number of input entries to create for given device
  128178. */
  128179. private _registerDevice;
  128180. /**
  128181. * Given a specific device name, remove that device from the device map
  128182. * @param deviceType Enum specifiying device type
  128183. * @param deviceSlot "Slot" or index that device is referenced in
  128184. */
  128185. private _unregisterDevice;
  128186. /**
  128187. * Handle all actions that come from keyboard interaction
  128188. */
  128189. private _handleKeyActions;
  128190. /**
  128191. * Handle all actions that come from pointer interaction
  128192. */
  128193. private _handlePointerActions;
  128194. /**
  128195. * Handle all actions that come from gamepad interaction
  128196. */
  128197. private _handleGamepadActions;
  128198. /**
  128199. * Update all non-event based devices with each frame
  128200. * @param deviceType Enum specifiying device type
  128201. * @param deviceSlot "Slot" or index that device is referenced in
  128202. * @param inputIndex Id of input to be checked
  128203. */
  128204. private _updateDevice;
  128205. /**
  128206. * Gets DeviceType from the device name
  128207. * @param deviceName Name of Device from DeviceInputSystem
  128208. * @returns DeviceType enum value
  128209. */
  128210. private _getGamepadDeviceType;
  128211. }
  128212. }
  128213. declare module BABYLON {
  128214. /**
  128215. * Type to handle enforcement of inputs
  128216. */
  128217. 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;
  128218. }
  128219. declare module BABYLON {
  128220. /**
  128221. * Class that handles all input for a specific device
  128222. */
  128223. export class DeviceSource<T extends DeviceType> {
  128224. /** Type of device */
  128225. readonly deviceType: DeviceType;
  128226. /** "Slot" or index that device is referenced in */
  128227. readonly deviceSlot: number;
  128228. /**
  128229. * Observable to handle device input changes per device
  128230. */
  128231. readonly onInputChangedObservable: Observable<{
  128232. inputIndex: DeviceInput<T>;
  128233. previousState: Nullable<number>;
  128234. currentState: Nullable<number>;
  128235. }>;
  128236. private readonly _deviceInputSystem;
  128237. /**
  128238. * Default Constructor
  128239. * @param deviceInputSystem Reference to DeviceInputSystem
  128240. * @param deviceType Type of device
  128241. * @param deviceSlot "Slot" or index that device is referenced in
  128242. */
  128243. constructor(deviceInputSystem: DeviceInputSystem,
  128244. /** Type of device */
  128245. deviceType: DeviceType,
  128246. /** "Slot" or index that device is referenced in */
  128247. deviceSlot?: number);
  128248. /**
  128249. * Get input for specific input
  128250. * @param inputIndex index of specific input on device
  128251. * @returns Input value from DeviceInputSystem
  128252. */
  128253. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128254. }
  128255. /**
  128256. * Class to keep track of devices
  128257. */
  128258. export class DeviceSourceManager implements IDisposable {
  128259. /**
  128260. * Observable to be triggered when before a device is connected
  128261. */
  128262. readonly onBeforeDeviceConnectedObservable: Observable<{
  128263. deviceType: DeviceType;
  128264. deviceSlot: number;
  128265. }>;
  128266. /**
  128267. * Observable to be triggered when before a device is disconnected
  128268. */
  128269. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128270. deviceType: DeviceType;
  128271. deviceSlot: number;
  128272. }>;
  128273. /**
  128274. * Observable to be triggered when after a device is connected
  128275. */
  128276. readonly onAfterDeviceConnectedObservable: Observable<{
  128277. deviceType: DeviceType;
  128278. deviceSlot: number;
  128279. }>;
  128280. /**
  128281. * Observable to be triggered when after a device is disconnected
  128282. */
  128283. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128284. deviceType: DeviceType;
  128285. deviceSlot: number;
  128286. }>;
  128287. private readonly _devices;
  128288. private readonly _firstDevice;
  128289. private readonly _deviceInputSystem;
  128290. /**
  128291. * Default Constructor
  128292. * @param engine engine to pull input element from
  128293. */
  128294. constructor(engine: Engine);
  128295. /**
  128296. * Gets a DeviceSource, given a type and slot
  128297. * @param deviceType Enum specifying device type
  128298. * @param deviceSlot "Slot" or index that device is referenced in
  128299. * @returns DeviceSource object
  128300. */
  128301. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128302. /**
  128303. * Gets an array of DeviceSource objects for a given device type
  128304. * @param deviceType Enum specifying device type
  128305. * @returns Array of DeviceSource objects
  128306. */
  128307. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128308. /**
  128309. * Dispose of DeviceInputSystem and other parts
  128310. */
  128311. dispose(): void;
  128312. /**
  128313. * Function to add device name to device list
  128314. * @param deviceType Enum specifying device type
  128315. * @param deviceSlot "Slot" or index that device is referenced in
  128316. */
  128317. private _addDevice;
  128318. /**
  128319. * Function to remove device name to device list
  128320. * @param deviceType Enum specifying device type
  128321. * @param deviceSlot "Slot" or index that device is referenced in
  128322. */
  128323. private _removeDevice;
  128324. /**
  128325. * Updates array storing first connected device of each type
  128326. * @param type Type of Device
  128327. */
  128328. private _updateFirstDevices;
  128329. }
  128330. }
  128331. declare module BABYLON {
  128332. /**
  128333. * Options to create the null engine
  128334. */
  128335. export class NullEngineOptions {
  128336. /**
  128337. * Render width (Default: 512)
  128338. */
  128339. renderWidth: number;
  128340. /**
  128341. * Render height (Default: 256)
  128342. */
  128343. renderHeight: number;
  128344. /**
  128345. * Texture size (Default: 512)
  128346. */
  128347. textureSize: number;
  128348. /**
  128349. * If delta time between frames should be constant
  128350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128351. */
  128352. deterministicLockstep: boolean;
  128353. /**
  128354. * Maximum about of steps between frames (Default: 4)
  128355. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128356. */
  128357. lockstepMaxSteps: number;
  128358. }
  128359. /**
  128360. * The null engine class provides support for headless version of babylon.js.
  128361. * This can be used in server side scenario or for testing purposes
  128362. */
  128363. export class NullEngine extends Engine {
  128364. private _options;
  128365. /**
  128366. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128367. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128368. * @returns true if engine is in deterministic lock step mode
  128369. */
  128370. isDeterministicLockStep(): boolean;
  128371. /**
  128372. * Gets the max steps when engine is running in deterministic lock step
  128373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128374. * @returns the max steps
  128375. */
  128376. getLockstepMaxSteps(): number;
  128377. /**
  128378. * Gets the current hardware scaling level.
  128379. * By default the hardware scaling level is computed from the window device ratio.
  128380. * 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.
  128381. * @returns a number indicating the current hardware scaling level
  128382. */
  128383. getHardwareScalingLevel(): number;
  128384. constructor(options?: NullEngineOptions);
  128385. /**
  128386. * Creates a vertex buffer
  128387. * @param vertices the data for the vertex buffer
  128388. * @returns the new WebGL static buffer
  128389. */
  128390. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128391. /**
  128392. * Creates a new index buffer
  128393. * @param indices defines the content of the index buffer
  128394. * @param updatable defines if the index buffer must be updatable
  128395. * @returns a new webGL buffer
  128396. */
  128397. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128398. /**
  128399. * Clear the current render buffer or the current render target (if any is set up)
  128400. * @param color defines the color to use
  128401. * @param backBuffer defines if the back buffer must be cleared
  128402. * @param depth defines if the depth buffer must be cleared
  128403. * @param stencil defines if the stencil buffer must be cleared
  128404. */
  128405. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128406. /**
  128407. * Gets the current render width
  128408. * @param useScreen defines if screen size must be used (or the current render target if any)
  128409. * @returns a number defining the current render width
  128410. */
  128411. getRenderWidth(useScreen?: boolean): number;
  128412. /**
  128413. * Gets the current render height
  128414. * @param useScreen defines if screen size must be used (or the current render target if any)
  128415. * @returns a number defining the current render height
  128416. */
  128417. getRenderHeight(useScreen?: boolean): number;
  128418. /**
  128419. * Set the WebGL's viewport
  128420. * @param viewport defines the viewport element to be used
  128421. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128422. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128423. */
  128424. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128425. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128426. /**
  128427. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128428. * @param pipelineContext defines the pipeline context to use
  128429. * @param uniformsNames defines the list of uniform names
  128430. * @returns an array of webGL uniform locations
  128431. */
  128432. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128433. /**
  128434. * Gets the lsit of active attributes for a given webGL program
  128435. * @param pipelineContext defines the pipeline context to use
  128436. * @param attributesNames defines the list of attribute names to get
  128437. * @returns an array of indices indicating the offset of each attribute
  128438. */
  128439. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128440. /**
  128441. * Binds an effect to the webGL context
  128442. * @param effect defines the effect to bind
  128443. */
  128444. bindSamplers(effect: Effect): void;
  128445. /**
  128446. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128447. * @param effect defines the effect to activate
  128448. */
  128449. enableEffect(effect: Effect): void;
  128450. /**
  128451. * Set various states to the webGL context
  128452. * @param culling defines backface culling state
  128453. * @param zOffset defines the value to apply to zOffset (0 by default)
  128454. * @param force defines if states must be applied even if cache is up to date
  128455. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128456. */
  128457. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128458. /**
  128459. * Set the value of an uniform to an array of int32
  128460. * @param uniform defines the webGL uniform location where to store the value
  128461. * @param array defines the array of int32 to store
  128462. */
  128463. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128464. /**
  128465. * Set the value of an uniform to an array of int32 (stored as vec2)
  128466. * @param uniform defines the webGL uniform location where to store the value
  128467. * @param array defines the array of int32 to store
  128468. */
  128469. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128470. /**
  128471. * Set the value of an uniform to an array of int32 (stored as vec3)
  128472. * @param uniform defines the webGL uniform location where to store the value
  128473. * @param array defines the array of int32 to store
  128474. */
  128475. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128476. /**
  128477. * Set the value of an uniform to an array of int32 (stored as vec4)
  128478. * @param uniform defines the webGL uniform location where to store the value
  128479. * @param array defines the array of int32 to store
  128480. */
  128481. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128482. /**
  128483. * Set the value of an uniform to an array of float32
  128484. * @param uniform defines the webGL uniform location where to store the value
  128485. * @param array defines the array of float32 to store
  128486. */
  128487. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128488. /**
  128489. * Set the value of an uniform to an array of float32 (stored as vec2)
  128490. * @param uniform defines the webGL uniform location where to store the value
  128491. * @param array defines the array of float32 to store
  128492. */
  128493. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128494. /**
  128495. * Set the value of an uniform to an array of float32 (stored as vec3)
  128496. * @param uniform defines the webGL uniform location where to store the value
  128497. * @param array defines the array of float32 to store
  128498. */
  128499. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128500. /**
  128501. * Set the value of an uniform to an array of float32 (stored as vec4)
  128502. * @param uniform defines the webGL uniform location where to store the value
  128503. * @param array defines the array of float32 to store
  128504. */
  128505. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128506. /**
  128507. * Set the value of an uniform to an array of number
  128508. * @param uniform defines the webGL uniform location where to store the value
  128509. * @param array defines the array of number to store
  128510. */
  128511. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128512. /**
  128513. * Set the value of an uniform to an array of number (stored as vec2)
  128514. * @param uniform defines the webGL uniform location where to store the value
  128515. * @param array defines the array of number to store
  128516. */
  128517. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128518. /**
  128519. * Set the value of an uniform to an array of number (stored as vec3)
  128520. * @param uniform defines the webGL uniform location where to store the value
  128521. * @param array defines the array of number to store
  128522. */
  128523. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128524. /**
  128525. * Set the value of an uniform to an array of number (stored as vec4)
  128526. * @param uniform defines the webGL uniform location where to store the value
  128527. * @param array defines the array of number to store
  128528. */
  128529. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128530. /**
  128531. * Set the value of an uniform to an array of float32 (stored as matrices)
  128532. * @param uniform defines the webGL uniform location where to store the value
  128533. * @param matrices defines the array of float32 to store
  128534. */
  128535. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128536. /**
  128537. * Set the value of an uniform to a matrix (3x3)
  128538. * @param uniform defines the webGL uniform location where to store the value
  128539. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128540. */
  128541. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128542. /**
  128543. * Set the value of an uniform to a matrix (2x2)
  128544. * @param uniform defines the webGL uniform location where to store the value
  128545. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128546. */
  128547. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128548. /**
  128549. * Set the value of an uniform to a number (float)
  128550. * @param uniform defines the webGL uniform location where to store the value
  128551. * @param value defines the float number to store
  128552. */
  128553. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128554. /**
  128555. * Set the value of an uniform to a vec2
  128556. * @param uniform defines the webGL uniform location where to store the value
  128557. * @param x defines the 1st component of the value
  128558. * @param y defines the 2nd component of the value
  128559. */
  128560. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128561. /**
  128562. * Set the value of an uniform to a vec3
  128563. * @param uniform defines the webGL uniform location where to store the value
  128564. * @param x defines the 1st component of the value
  128565. * @param y defines the 2nd component of the value
  128566. * @param z defines the 3rd component of the value
  128567. */
  128568. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128569. /**
  128570. * Set the value of an uniform to a boolean
  128571. * @param uniform defines the webGL uniform location where to store the value
  128572. * @param bool defines the boolean to store
  128573. */
  128574. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128575. /**
  128576. * Set the value of an uniform to a vec4
  128577. * @param uniform defines the webGL uniform location where to store the value
  128578. * @param x defines the 1st component of the value
  128579. * @param y defines the 2nd component of the value
  128580. * @param z defines the 3rd component of the value
  128581. * @param w defines the 4th component of the value
  128582. */
  128583. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128584. /**
  128585. * Sets the current alpha mode
  128586. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128587. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128589. */
  128590. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128591. /**
  128592. * Bind webGl buffers directly to the webGL context
  128593. * @param vertexBuffers defines the vertex buffer to bind
  128594. * @param indexBuffer defines the index buffer to bind
  128595. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128596. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128597. * @param effect defines the effect associated with the vertex buffer
  128598. */
  128599. bindBuffers(vertexBuffers: {
  128600. [key: string]: VertexBuffer;
  128601. }, indexBuffer: DataBuffer, effect: Effect): void;
  128602. /**
  128603. * Force the entire cache to be cleared
  128604. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128605. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128606. */
  128607. wipeCaches(bruteForce?: boolean): void;
  128608. /**
  128609. * Send a draw order
  128610. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128611. * @param indexStart defines the starting index
  128612. * @param indexCount defines the number of index to draw
  128613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128614. */
  128615. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128616. /**
  128617. * Draw a list of indexed primitives
  128618. * @param fillMode defines the primitive to use
  128619. * @param indexStart defines the starting index
  128620. * @param indexCount defines the number of index to draw
  128621. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128622. */
  128623. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128624. /**
  128625. * Draw a list of unindexed primitives
  128626. * @param fillMode defines the primitive to use
  128627. * @param verticesStart defines the index of first vertex to draw
  128628. * @param verticesCount defines the count of vertices to draw
  128629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128630. */
  128631. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128632. /** @hidden */
  128633. _createTexture(): WebGLTexture;
  128634. /** @hidden */
  128635. _releaseTexture(texture: InternalTexture): void;
  128636. /**
  128637. * Usually called from Texture.ts.
  128638. * Passed information to create a WebGLTexture
  128639. * @param urlArg defines a value which contains one of the following:
  128640. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128641. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128642. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128644. * @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)
  128645. * @param scene needed for loading to the correct scene
  128646. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128647. * @param onLoad optional callback to be called upon successful completion
  128648. * @param onError optional callback to be called upon failure
  128649. * @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
  128650. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128651. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128652. * @param forcedExtension defines the extension to use to pick the right loader
  128653. * @param mimeType defines an optional mime type
  128654. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128655. */
  128656. 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;
  128657. /**
  128658. * Creates a new render target texture
  128659. * @param size defines the size of the texture
  128660. * @param options defines the options used to create the texture
  128661. * @returns a new render target texture stored in an InternalTexture
  128662. */
  128663. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128664. /**
  128665. * Update the sampling mode of a given texture
  128666. * @param samplingMode defines the required sampling mode
  128667. * @param texture defines the texture to update
  128668. */
  128669. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128670. /**
  128671. * Binds the frame buffer to the specified texture.
  128672. * @param texture The texture to render to or null for the default canvas
  128673. * @param faceIndex The face of the texture to render to in case of cube texture
  128674. * @param requiredWidth The width of the target to render to
  128675. * @param requiredHeight The height of the target to render to
  128676. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128677. * @param lodLevel defines le lod level to bind to the frame buffer
  128678. */
  128679. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128680. /**
  128681. * Unbind the current render target texture from the webGL context
  128682. * @param texture defines the render target texture to unbind
  128683. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128684. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128685. */
  128686. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128687. /**
  128688. * Creates a dynamic vertex buffer
  128689. * @param vertices the data for the dynamic vertex buffer
  128690. * @returns the new WebGL dynamic buffer
  128691. */
  128692. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128693. /**
  128694. * Update the content of a dynamic texture
  128695. * @param texture defines the texture to update
  128696. * @param canvas defines the canvas containing the source
  128697. * @param invertY defines if data must be stored with Y axis inverted
  128698. * @param premulAlpha defines if alpha is stored as premultiplied
  128699. * @param format defines the format of the data
  128700. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128701. */
  128702. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128703. /**
  128704. * Gets a boolean indicating if all created effects are ready
  128705. * @returns true if all effects are ready
  128706. */
  128707. areAllEffectsReady(): boolean;
  128708. /**
  128709. * @hidden
  128710. * Get the current error code of the webGL context
  128711. * @returns the error code
  128712. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128713. */
  128714. getError(): number;
  128715. /** @hidden */
  128716. _getUnpackAlignement(): number;
  128717. /** @hidden */
  128718. _unpackFlipY(value: boolean): void;
  128719. /**
  128720. * Update a dynamic index buffer
  128721. * @param indexBuffer defines the target index buffer
  128722. * @param indices defines the data to update
  128723. * @param offset defines the offset in the target index buffer where update should start
  128724. */
  128725. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128726. /**
  128727. * Updates a dynamic vertex buffer.
  128728. * @param vertexBuffer the vertex buffer to update
  128729. * @param vertices the data used to update the vertex buffer
  128730. * @param byteOffset the byte offset of the data (optional)
  128731. * @param byteLength the byte length of the data (optional)
  128732. */
  128733. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128734. /** @hidden */
  128735. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128736. /** @hidden */
  128737. _bindTexture(channel: number, texture: InternalTexture): void;
  128738. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128739. /**
  128740. * 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
  128741. */
  128742. releaseEffects(): void;
  128743. displayLoadingUI(): void;
  128744. hideLoadingUI(): void;
  128745. /** @hidden */
  128746. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128747. /** @hidden */
  128748. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128749. /** @hidden */
  128750. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128751. /** @hidden */
  128752. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128753. }
  128754. }
  128755. declare module BABYLON {
  128756. /**
  128757. * @hidden
  128758. **/
  128759. export class _TimeToken {
  128760. _startTimeQuery: Nullable<WebGLQuery>;
  128761. _endTimeQuery: Nullable<WebGLQuery>;
  128762. _timeElapsedQuery: Nullable<WebGLQuery>;
  128763. _timeElapsedQueryEnded: boolean;
  128764. }
  128765. }
  128766. declare module BABYLON {
  128767. /** @hidden */
  128768. export class _OcclusionDataStorage {
  128769. /** @hidden */
  128770. occlusionInternalRetryCounter: number;
  128771. /** @hidden */
  128772. isOcclusionQueryInProgress: boolean;
  128773. /** @hidden */
  128774. isOccluded: boolean;
  128775. /** @hidden */
  128776. occlusionRetryCount: number;
  128777. /** @hidden */
  128778. occlusionType: number;
  128779. /** @hidden */
  128780. occlusionQueryAlgorithmType: number;
  128781. }
  128782. interface Engine {
  128783. /**
  128784. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128785. * @return the new query
  128786. */
  128787. createQuery(): WebGLQuery;
  128788. /**
  128789. * Delete and release a webGL query
  128790. * @param query defines the query to delete
  128791. * @return the current engine
  128792. */
  128793. deleteQuery(query: WebGLQuery): Engine;
  128794. /**
  128795. * Check if a given query has resolved and got its value
  128796. * @param query defines the query to check
  128797. * @returns true if the query got its value
  128798. */
  128799. isQueryResultAvailable(query: WebGLQuery): boolean;
  128800. /**
  128801. * Gets the value of a given query
  128802. * @param query defines the query to check
  128803. * @returns the value of the query
  128804. */
  128805. getQueryResult(query: WebGLQuery): number;
  128806. /**
  128807. * Initiates an occlusion query
  128808. * @param algorithmType defines the algorithm to use
  128809. * @param query defines the query to use
  128810. * @returns the current engine
  128811. * @see http://doc.babylonjs.com/features/occlusionquery
  128812. */
  128813. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128814. /**
  128815. * Ends an occlusion query
  128816. * @see http://doc.babylonjs.com/features/occlusionquery
  128817. * @param algorithmType defines the algorithm to use
  128818. * @returns the current engine
  128819. */
  128820. endOcclusionQuery(algorithmType: number): Engine;
  128821. /**
  128822. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128823. * Please note that only one query can be issued at a time
  128824. * @returns a time token used to track the time span
  128825. */
  128826. startTimeQuery(): Nullable<_TimeToken>;
  128827. /**
  128828. * Ends a time query
  128829. * @param token defines the token used to measure the time span
  128830. * @returns the time spent (in ns)
  128831. */
  128832. endTimeQuery(token: _TimeToken): int;
  128833. /** @hidden */
  128834. _currentNonTimestampToken: Nullable<_TimeToken>;
  128835. /** @hidden */
  128836. _createTimeQuery(): WebGLQuery;
  128837. /** @hidden */
  128838. _deleteTimeQuery(query: WebGLQuery): void;
  128839. /** @hidden */
  128840. _getGlAlgorithmType(algorithmType: number): number;
  128841. /** @hidden */
  128842. _getTimeQueryResult(query: WebGLQuery): any;
  128843. /** @hidden */
  128844. _getTimeQueryAvailability(query: WebGLQuery): any;
  128845. }
  128846. interface AbstractMesh {
  128847. /**
  128848. * Backing filed
  128849. * @hidden
  128850. */
  128851. __occlusionDataStorage: _OcclusionDataStorage;
  128852. /**
  128853. * Access property
  128854. * @hidden
  128855. */
  128856. _occlusionDataStorage: _OcclusionDataStorage;
  128857. /**
  128858. * 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.
  128859. * The default value is -1 which means don't break the query and wait till the result
  128860. * @see http://doc.babylonjs.com/features/occlusionquery
  128861. */
  128862. occlusionRetryCount: number;
  128863. /**
  128864. * 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:
  128865. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128866. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128867. * * 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.
  128868. * @see http://doc.babylonjs.com/features/occlusionquery
  128869. */
  128870. occlusionType: number;
  128871. /**
  128872. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128873. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128874. * * 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.
  128875. * @see http://doc.babylonjs.com/features/occlusionquery
  128876. */
  128877. occlusionQueryAlgorithmType: number;
  128878. /**
  128879. * 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
  128880. * @see http://doc.babylonjs.com/features/occlusionquery
  128881. */
  128882. isOccluded: boolean;
  128883. /**
  128884. * Flag to check the progress status of the query
  128885. * @see http://doc.babylonjs.com/features/occlusionquery
  128886. */
  128887. isOcclusionQueryInProgress: boolean;
  128888. }
  128889. }
  128890. declare module BABYLON {
  128891. /** @hidden */
  128892. export var _forceTransformFeedbackToBundle: boolean;
  128893. interface Engine {
  128894. /**
  128895. * Creates a webGL transform feedback object
  128896. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128897. * @returns the webGL transform feedback object
  128898. */
  128899. createTransformFeedback(): WebGLTransformFeedback;
  128900. /**
  128901. * Delete a webGL transform feedback object
  128902. * @param value defines the webGL transform feedback object to delete
  128903. */
  128904. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128905. /**
  128906. * Bind a webGL transform feedback object to the webgl context
  128907. * @param value defines the webGL transform feedback object to bind
  128908. */
  128909. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128910. /**
  128911. * Begins a transform feedback operation
  128912. * @param usePoints defines if points or triangles must be used
  128913. */
  128914. beginTransformFeedback(usePoints: boolean): void;
  128915. /**
  128916. * Ends a transform feedback operation
  128917. */
  128918. endTransformFeedback(): void;
  128919. /**
  128920. * Specify the varyings to use with transform feedback
  128921. * @param program defines the associated webGL program
  128922. * @param value defines the list of strings representing the varying names
  128923. */
  128924. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128925. /**
  128926. * Bind a webGL buffer for a transform feedback operation
  128927. * @param value defines the webGL buffer to bind
  128928. */
  128929. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128930. }
  128931. }
  128932. declare module BABYLON {
  128933. /**
  128934. * Creation options of the multi render target texture.
  128935. */
  128936. export interface IMultiRenderTargetOptions {
  128937. /**
  128938. * Define if the texture needs to create mip maps after render.
  128939. */
  128940. generateMipMaps?: boolean;
  128941. /**
  128942. * Define the types of all the draw buffers we want to create
  128943. */
  128944. types?: number[];
  128945. /**
  128946. * Define the sampling modes of all the draw buffers we want to create
  128947. */
  128948. samplingModes?: number[];
  128949. /**
  128950. * Define if a depth buffer is required
  128951. */
  128952. generateDepthBuffer?: boolean;
  128953. /**
  128954. * Define if a stencil buffer is required
  128955. */
  128956. generateStencilBuffer?: boolean;
  128957. /**
  128958. * Define if a depth texture is required instead of a depth buffer
  128959. */
  128960. generateDepthTexture?: boolean;
  128961. /**
  128962. * Define the number of desired draw buffers
  128963. */
  128964. textureCount?: number;
  128965. /**
  128966. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128967. */
  128968. doNotChangeAspectRatio?: boolean;
  128969. /**
  128970. * Define the default type of the buffers we are creating
  128971. */
  128972. defaultType?: number;
  128973. }
  128974. /**
  128975. * A multi render target, like a render target provides the ability to render to a texture.
  128976. * Unlike the render target, it can render to several draw buffers in one draw.
  128977. * This is specially interesting in deferred rendering or for any effects requiring more than
  128978. * just one color from a single pass.
  128979. */
  128980. export class MultiRenderTarget extends RenderTargetTexture {
  128981. private _internalTextures;
  128982. private _textures;
  128983. private _multiRenderTargetOptions;
  128984. /**
  128985. * Get if draw buffers are currently supported by the used hardware and browser.
  128986. */
  128987. get isSupported(): boolean;
  128988. /**
  128989. * Get the list of textures generated by the multi render target.
  128990. */
  128991. get textures(): Texture[];
  128992. /**
  128993. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128994. */
  128995. get depthTexture(): Texture;
  128996. /**
  128997. * Set the wrapping mode on U of all the textures we are rendering to.
  128998. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128999. */
  129000. set wrapU(wrap: number);
  129001. /**
  129002. * Set the wrapping mode on V of all the textures we are rendering to.
  129003. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129004. */
  129005. set wrapV(wrap: number);
  129006. /**
  129007. * Instantiate a new multi render target texture.
  129008. * A multi render target, like a render target provides the ability to render to a texture.
  129009. * Unlike the render target, it can render to several draw buffers in one draw.
  129010. * This is specially interesting in deferred rendering or for any effects requiring more than
  129011. * just one color from a single pass.
  129012. * @param name Define the name of the texture
  129013. * @param size Define the size of the buffers to render to
  129014. * @param count Define the number of target we are rendering into
  129015. * @param scene Define the scene the texture belongs to
  129016. * @param options Define the options used to create the multi render target
  129017. */
  129018. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129019. /** @hidden */
  129020. _rebuild(): void;
  129021. private _createInternalTextures;
  129022. private _createTextures;
  129023. /**
  129024. * Define the number of samples used if MSAA is enabled.
  129025. */
  129026. get samples(): number;
  129027. set samples(value: number);
  129028. /**
  129029. * Resize all the textures in the multi render target.
  129030. * Be carrefull as it will recreate all the data in the new texture.
  129031. * @param size Define the new size
  129032. */
  129033. resize(size: any): void;
  129034. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129035. /**
  129036. * Dispose the render targets and their associated resources
  129037. */
  129038. dispose(): void;
  129039. /**
  129040. * Release all the underlying texture used as draw buffers.
  129041. */
  129042. releaseInternalTextures(): void;
  129043. }
  129044. }
  129045. declare module BABYLON {
  129046. interface ThinEngine {
  129047. /**
  129048. * Unbind a list of render target textures from the webGL context
  129049. * This is used only when drawBuffer extension or webGL2 are active
  129050. * @param textures defines the render target textures to unbind
  129051. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129052. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129053. */
  129054. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129055. /**
  129056. * Create a multi render target texture
  129057. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  129058. * @param size defines the size of the texture
  129059. * @param options defines the creation options
  129060. * @returns the cube texture as an InternalTexture
  129061. */
  129062. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129063. /**
  129064. * Update the sample count for a given multiple render target texture
  129065. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129066. * @param textures defines the textures to update
  129067. * @param samples defines the sample count to set
  129068. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129069. */
  129070. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129071. }
  129072. }
  129073. declare module BABYLON {
  129074. /**
  129075. * Class used to define an additional view for the engine
  129076. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129077. */
  129078. export class EngineView {
  129079. /** Defines the canvas where to render the view */
  129080. target: HTMLCanvasElement;
  129081. /** Defines an optional camera used to render the view (will use active camera else) */
  129082. camera?: Camera;
  129083. }
  129084. interface Engine {
  129085. /**
  129086. * Gets or sets the HTML element to use for attaching events
  129087. */
  129088. inputElement: Nullable<HTMLElement>;
  129089. /**
  129090. * Gets the current engine view
  129091. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129092. */
  129093. activeView: Nullable<EngineView>;
  129094. /** Gets or sets the list of views */
  129095. views: EngineView[];
  129096. /**
  129097. * Register a new child canvas
  129098. * @param canvas defines the canvas to register
  129099. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129100. * @returns the associated view
  129101. */
  129102. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129103. /**
  129104. * Remove a registered child canvas
  129105. * @param canvas defines the canvas to remove
  129106. * @returns the current engine
  129107. */
  129108. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129109. }
  129110. }
  129111. declare module BABYLON {
  129112. interface Engine {
  129113. /** @hidden */
  129114. _excludedCompressedTextures: string[];
  129115. /** @hidden */
  129116. _textureFormatInUse: string;
  129117. /**
  129118. * Gets the list of texture formats supported
  129119. */
  129120. readonly texturesSupported: Array<string>;
  129121. /**
  129122. * Gets the texture format in use
  129123. */
  129124. readonly textureFormatInUse: Nullable<string>;
  129125. /**
  129126. * Set the compressed texture extensions or file names to skip.
  129127. *
  129128. * @param skippedFiles defines the list of those texture files you want to skip
  129129. * Example: [".dds", ".env", "myfile.png"]
  129130. */
  129131. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129132. /**
  129133. * Set the compressed texture format to use, based on the formats you have, and the formats
  129134. * supported by the hardware / browser.
  129135. *
  129136. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129137. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129138. * to API arguments needed to compressed textures. This puts the burden on the container
  129139. * generator to house the arcane code for determining these for current & future formats.
  129140. *
  129141. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129142. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129143. *
  129144. * Note: The result of this call is not taken into account when a texture is base64.
  129145. *
  129146. * @param formatsAvailable defines the list of those format families you have created
  129147. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129148. *
  129149. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129150. * @returns The extension selected.
  129151. */
  129152. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129153. }
  129154. }
  129155. declare module BABYLON {
  129156. /**
  129157. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129158. */
  129159. export interface CubeMapInfo {
  129160. /**
  129161. * The pixel array for the front face.
  129162. * This is stored in format, left to right, up to down format.
  129163. */
  129164. front: Nullable<ArrayBufferView>;
  129165. /**
  129166. * The pixel array for the back face.
  129167. * This is stored in format, left to right, up to down format.
  129168. */
  129169. back: Nullable<ArrayBufferView>;
  129170. /**
  129171. * The pixel array for the left face.
  129172. * This is stored in format, left to right, up to down format.
  129173. */
  129174. left: Nullable<ArrayBufferView>;
  129175. /**
  129176. * The pixel array for the right face.
  129177. * This is stored in format, left to right, up to down format.
  129178. */
  129179. right: Nullable<ArrayBufferView>;
  129180. /**
  129181. * The pixel array for the up face.
  129182. * This is stored in format, left to right, up to down format.
  129183. */
  129184. up: Nullable<ArrayBufferView>;
  129185. /**
  129186. * The pixel array for the down face.
  129187. * This is stored in format, left to right, up to down format.
  129188. */
  129189. down: Nullable<ArrayBufferView>;
  129190. /**
  129191. * The size of the cubemap stored.
  129192. *
  129193. * Each faces will be size * size pixels.
  129194. */
  129195. size: number;
  129196. /**
  129197. * The format of the texture.
  129198. *
  129199. * RGBA, RGB.
  129200. */
  129201. format: number;
  129202. /**
  129203. * The type of the texture data.
  129204. *
  129205. * UNSIGNED_INT, FLOAT.
  129206. */
  129207. type: number;
  129208. /**
  129209. * Specifies whether the texture is in gamma space.
  129210. */
  129211. gammaSpace: boolean;
  129212. }
  129213. /**
  129214. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129215. */
  129216. export class PanoramaToCubeMapTools {
  129217. private static FACE_LEFT;
  129218. private static FACE_RIGHT;
  129219. private static FACE_FRONT;
  129220. private static FACE_BACK;
  129221. private static FACE_DOWN;
  129222. private static FACE_UP;
  129223. /**
  129224. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129225. *
  129226. * @param float32Array The source data.
  129227. * @param inputWidth The width of the input panorama.
  129228. * @param inputHeight The height of the input panorama.
  129229. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129230. * @return The cubemap data
  129231. */
  129232. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129233. private static CreateCubemapTexture;
  129234. private static CalcProjectionSpherical;
  129235. }
  129236. }
  129237. declare module BABYLON {
  129238. /**
  129239. * Helper class dealing with the extraction of spherical polynomial dataArray
  129240. * from a cube map.
  129241. */
  129242. export class CubeMapToSphericalPolynomialTools {
  129243. private static FileFaces;
  129244. /**
  129245. * Converts a texture to the according Spherical Polynomial data.
  129246. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129247. *
  129248. * @param texture The texture to extract the information from.
  129249. * @return The Spherical Polynomial data.
  129250. */
  129251. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129252. /**
  129253. * Converts a cubemap to the according Spherical Polynomial data.
  129254. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129255. *
  129256. * @param cubeInfo The Cube map to extract the information from.
  129257. * @return The Spherical Polynomial data.
  129258. */
  129259. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129260. }
  129261. }
  129262. declare module BABYLON {
  129263. interface BaseTexture {
  129264. /**
  129265. * Get the polynomial representation of the texture data.
  129266. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129267. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129268. */
  129269. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129270. }
  129271. }
  129272. declare module BABYLON {
  129273. /** @hidden */
  129274. export var rgbdEncodePixelShader: {
  129275. name: string;
  129276. shader: string;
  129277. };
  129278. }
  129279. declare module BABYLON {
  129280. /** @hidden */
  129281. export var rgbdDecodePixelShader: {
  129282. name: string;
  129283. shader: string;
  129284. };
  129285. }
  129286. declare module BABYLON {
  129287. /**
  129288. * Raw texture data and descriptor sufficient for WebGL texture upload
  129289. */
  129290. export interface EnvironmentTextureInfo {
  129291. /**
  129292. * Version of the environment map
  129293. */
  129294. version: number;
  129295. /**
  129296. * Width of image
  129297. */
  129298. width: number;
  129299. /**
  129300. * Irradiance information stored in the file.
  129301. */
  129302. irradiance: any;
  129303. /**
  129304. * Specular information stored in the file.
  129305. */
  129306. specular: any;
  129307. }
  129308. /**
  129309. * Defines One Image in the file. It requires only the position in the file
  129310. * as well as the length.
  129311. */
  129312. interface BufferImageData {
  129313. /**
  129314. * Length of the image data.
  129315. */
  129316. length: number;
  129317. /**
  129318. * Position of the data from the null terminator delimiting the end of the JSON.
  129319. */
  129320. position: number;
  129321. }
  129322. /**
  129323. * Defines the specular data enclosed in the file.
  129324. * This corresponds to the version 1 of the data.
  129325. */
  129326. export interface EnvironmentTextureSpecularInfoV1 {
  129327. /**
  129328. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129329. */
  129330. specularDataPosition?: number;
  129331. /**
  129332. * This contains all the images data needed to reconstruct the cubemap.
  129333. */
  129334. mipmaps: Array<BufferImageData>;
  129335. /**
  129336. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129337. */
  129338. lodGenerationScale: number;
  129339. }
  129340. /**
  129341. * Sets of helpers addressing the serialization and deserialization of environment texture
  129342. * stored in a BabylonJS env file.
  129343. * Those files are usually stored as .env files.
  129344. */
  129345. export class EnvironmentTextureTools {
  129346. /**
  129347. * Magic number identifying the env file.
  129348. */
  129349. private static _MagicBytes;
  129350. /**
  129351. * Gets the environment info from an env file.
  129352. * @param data The array buffer containing the .env bytes.
  129353. * @returns the environment file info (the json header) if successfully parsed.
  129354. */
  129355. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129356. /**
  129357. * Creates an environment texture from a loaded cube texture.
  129358. * @param texture defines the cube texture to convert in env file
  129359. * @return a promise containing the environment data if succesfull.
  129360. */
  129361. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129362. /**
  129363. * Creates a JSON representation of the spherical data.
  129364. * @param texture defines the texture containing the polynomials
  129365. * @return the JSON representation of the spherical info
  129366. */
  129367. private static _CreateEnvTextureIrradiance;
  129368. /**
  129369. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129370. * @param data the image data
  129371. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129372. * @return the views described by info providing access to the underlying buffer
  129373. */
  129374. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129375. /**
  129376. * Uploads the texture info contained in the env file to the GPU.
  129377. * @param texture defines the internal texture to upload to
  129378. * @param data defines the data to load
  129379. * @param info defines the texture info retrieved through the GetEnvInfo method
  129380. * @returns a promise
  129381. */
  129382. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129383. private static _OnImageReadyAsync;
  129384. /**
  129385. * Uploads the levels of image data to the GPU.
  129386. * @param texture defines the internal texture to upload to
  129387. * @param imageData defines the array buffer views of image data [mipmap][face]
  129388. * @returns a promise
  129389. */
  129390. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129391. /**
  129392. * Uploads spherical polynomials information to the texture.
  129393. * @param texture defines the texture we are trying to upload the information to
  129394. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129395. */
  129396. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129397. /** @hidden */
  129398. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129399. }
  129400. }
  129401. declare module BABYLON {
  129402. /** @hidden */
  129403. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  129404. private _genericAttributeLocation;
  129405. private _varyingLocationCount;
  129406. private _varyingLocationMap;
  129407. private _replacements;
  129408. private _textureCount;
  129409. private _uniforms;
  129410. lineProcessor(line: string): string;
  129411. attributeProcessor(attribute: string): string;
  129412. varyingProcessor(varying: string, isFragment: boolean): string;
  129413. uniformProcessor(uniform: string): string;
  129414. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  129415. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  129416. }
  129417. }
  129418. declare module BABYLON {
  129419. /**
  129420. * Class used to inline functions in shader code
  129421. */
  129422. export class ShaderCodeInliner {
  129423. private static readonly _RegexpFindFunctionNameAndType;
  129424. private _sourceCode;
  129425. private _functionDescr;
  129426. private _numMaxIterations;
  129427. /** Gets or sets the token used to mark the functions to inline */
  129428. inlineToken: string;
  129429. /** Gets or sets the debug mode */
  129430. debug: boolean;
  129431. /** Gets the code after the inlining process */
  129432. get code(): string;
  129433. /**
  129434. * Initializes the inliner
  129435. * @param sourceCode shader code source to inline
  129436. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129437. */
  129438. constructor(sourceCode: string, numMaxIterations?: number);
  129439. /**
  129440. * Start the processing of the shader code
  129441. */
  129442. processCode(): void;
  129443. private _collectFunctions;
  129444. private _processInlining;
  129445. private _extractBetweenMarkers;
  129446. private _skipWhitespaces;
  129447. private _removeComments;
  129448. private _replaceFunctionCallsByCode;
  129449. private _findBackward;
  129450. private _escapeRegExp;
  129451. private _replaceNames;
  129452. }
  129453. }
  129454. declare module BABYLON {
  129455. /**
  129456. * Container for accessors for natively-stored mesh data buffers.
  129457. */
  129458. class NativeDataBuffer extends DataBuffer {
  129459. /**
  129460. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129461. */
  129462. nativeIndexBuffer?: any;
  129463. /**
  129464. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129465. */
  129466. nativeVertexBuffer?: any;
  129467. }
  129468. /** @hidden */
  129469. class NativeTexture extends InternalTexture {
  129470. getInternalTexture(): InternalTexture;
  129471. getViewCount(): number;
  129472. }
  129473. /** @hidden */
  129474. export class NativeEngine extends Engine {
  129475. private readonly _native;
  129476. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129477. private readonly INVALID_HANDLE;
  129478. getHardwareScalingLevel(): number;
  129479. constructor();
  129480. dispose(): void;
  129481. /**
  129482. * Can be used to override the current requestAnimationFrame requester.
  129483. * @hidden
  129484. */
  129485. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129486. /**
  129487. * Override default engine behavior.
  129488. * @param color
  129489. * @param backBuffer
  129490. * @param depth
  129491. * @param stencil
  129492. */
  129493. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129494. /**
  129495. * Gets host document
  129496. * @returns the host document object
  129497. */
  129498. getHostDocument(): Nullable<Document>;
  129499. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129500. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129501. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129502. recordVertexArrayObject(vertexBuffers: {
  129503. [key: string]: VertexBuffer;
  129504. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129505. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129506. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129507. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129508. /**
  129509. * Draw a list of indexed primitives
  129510. * @param fillMode defines the primitive to use
  129511. * @param indexStart defines the starting index
  129512. * @param indexCount defines the number of index to draw
  129513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129514. */
  129515. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129516. /**
  129517. * Draw a list of unindexed primitives
  129518. * @param fillMode defines the primitive to use
  129519. * @param verticesStart defines the index of first vertex to draw
  129520. * @param verticesCount defines the count of vertices to draw
  129521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129522. */
  129523. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129524. createPipelineContext(): IPipelineContext;
  129525. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129526. /** @hidden */
  129527. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129528. /** @hidden */
  129529. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129530. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129531. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129532. protected _setProgram(program: WebGLProgram): void;
  129533. _releaseEffect(effect: Effect): void;
  129534. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129535. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129536. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129537. bindSamplers(effect: Effect): void;
  129538. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129539. getRenderWidth(useScreen?: boolean): number;
  129540. getRenderHeight(useScreen?: boolean): number;
  129541. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129542. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129543. /**
  129544. * Set the z offset to apply to current rendering
  129545. * @param value defines the offset to apply
  129546. */
  129547. setZOffset(value: number): void;
  129548. /**
  129549. * Gets the current value of the zOffset
  129550. * @returns the current zOffset state
  129551. */
  129552. getZOffset(): number;
  129553. /**
  129554. * Enable or disable depth buffering
  129555. * @param enable defines the state to set
  129556. */
  129557. setDepthBuffer(enable: boolean): void;
  129558. /**
  129559. * Gets a boolean indicating if depth writing is enabled
  129560. * @returns the current depth writing state
  129561. */
  129562. getDepthWrite(): boolean;
  129563. /**
  129564. * Enable or disable depth writing
  129565. * @param enable defines the state to set
  129566. */
  129567. setDepthWrite(enable: boolean): void;
  129568. /**
  129569. * Enable or disable color writing
  129570. * @param enable defines the state to set
  129571. */
  129572. setColorWrite(enable: boolean): void;
  129573. /**
  129574. * Gets a boolean indicating if color writing is enabled
  129575. * @returns the current color writing state
  129576. */
  129577. getColorWrite(): boolean;
  129578. /**
  129579. * Sets alpha constants used by some alpha blending modes
  129580. * @param r defines the red component
  129581. * @param g defines the green component
  129582. * @param b defines the blue component
  129583. * @param a defines the alpha component
  129584. */
  129585. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129586. /**
  129587. * Sets the current alpha mode
  129588. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129589. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129591. */
  129592. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129593. /**
  129594. * Gets the current alpha mode
  129595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129596. * @returns the current alpha mode
  129597. */
  129598. getAlphaMode(): number;
  129599. setInt(uniform: WebGLUniformLocation, int: number): void;
  129600. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129601. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129602. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129603. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129604. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129605. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129606. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129607. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129608. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129609. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129610. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129611. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129612. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129613. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129614. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129615. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129616. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129617. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129618. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129619. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129620. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129621. wipeCaches(bruteForce?: boolean): void;
  129622. _createTexture(): WebGLTexture;
  129623. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129624. /**
  129625. * Usually called from Texture.ts.
  129626. * Passed information to create a WebGLTexture
  129627. * @param url defines a value which contains one of the following:
  129628. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129629. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129630. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129632. * @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)
  129633. * @param scene needed for loading to the correct scene
  129634. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129635. * @param onLoad optional callback to be called upon successful completion
  129636. * @param onError optional callback to be called upon failure
  129637. * @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
  129638. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129639. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129640. * @param forcedExtension defines the extension to use to pick the right loader
  129641. * @param mimeType defines an optional mime type
  129642. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129643. */
  129644. 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;
  129645. /**
  129646. * Creates a cube texture
  129647. * @param rootUrl defines the url where the files to load is located
  129648. * @param scene defines the current scene
  129649. * @param files defines the list of files to load (1 per face)
  129650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129651. * @param onLoad defines an optional callback raised when the texture is loaded
  129652. * @param onError defines an optional callback raised if there is an issue to load the texture
  129653. * @param format defines the format of the data
  129654. * @param forcedExtension defines the extension to use to pick the right loader
  129655. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129656. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129657. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129658. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129659. * @returns the cube texture as an InternalTexture
  129660. */
  129661. 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;
  129662. private _getSamplingFilter;
  129663. private static _GetNativeTextureFormat;
  129664. createRenderTargetTexture(size: number | {
  129665. width: number;
  129666. height: number;
  129667. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129668. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129669. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129670. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129671. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129672. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129673. /**
  129674. * Updates a dynamic vertex buffer.
  129675. * @param vertexBuffer the vertex buffer to update
  129676. * @param data the data used to update the vertex buffer
  129677. * @param byteOffset the byte offset of the data (optional)
  129678. * @param byteLength the byte length of the data (optional)
  129679. */
  129680. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129681. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129682. private _updateAnisotropicLevel;
  129683. private _getAddressMode;
  129684. /** @hidden */
  129685. _bindTexture(channel: number, texture: InternalTexture): void;
  129686. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129687. releaseEffects(): void;
  129688. /** @hidden */
  129689. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129690. /** @hidden */
  129691. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129692. /** @hidden */
  129693. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129694. /** @hidden */
  129695. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129696. }
  129697. }
  129698. declare module BABYLON {
  129699. /**
  129700. * Gather the list of clipboard event types as constants.
  129701. */
  129702. export class ClipboardEventTypes {
  129703. /**
  129704. * The clipboard event is fired when a copy command is active (pressed).
  129705. */
  129706. static readonly COPY: number;
  129707. /**
  129708. * The clipboard event is fired when a cut command is active (pressed).
  129709. */
  129710. static readonly CUT: number;
  129711. /**
  129712. * The clipboard event is fired when a paste command is active (pressed).
  129713. */
  129714. static readonly PASTE: number;
  129715. }
  129716. /**
  129717. * This class is used to store clipboard related info for the onClipboardObservable event.
  129718. */
  129719. export class ClipboardInfo {
  129720. /**
  129721. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129722. */
  129723. type: number;
  129724. /**
  129725. * Defines the related dom event
  129726. */
  129727. event: ClipboardEvent;
  129728. /**
  129729. *Creates an instance of ClipboardInfo.
  129730. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129731. * @param event Defines the related dom event
  129732. */
  129733. constructor(
  129734. /**
  129735. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129736. */
  129737. type: number,
  129738. /**
  129739. * Defines the related dom event
  129740. */
  129741. event: ClipboardEvent);
  129742. /**
  129743. * Get the clipboard event's type from the keycode.
  129744. * @param keyCode Defines the keyCode for the current keyboard event.
  129745. * @return {number}
  129746. */
  129747. static GetTypeFromCharacter(keyCode: number): number;
  129748. }
  129749. }
  129750. declare module BABYLON {
  129751. /**
  129752. * Google Daydream controller
  129753. */
  129754. export class DaydreamController extends WebVRController {
  129755. /**
  129756. * Base Url for the controller model.
  129757. */
  129758. static MODEL_BASE_URL: string;
  129759. /**
  129760. * File name for the controller model.
  129761. */
  129762. static MODEL_FILENAME: string;
  129763. /**
  129764. * Gamepad Id prefix used to identify Daydream Controller.
  129765. */
  129766. static readonly GAMEPAD_ID_PREFIX: string;
  129767. /**
  129768. * Creates a new DaydreamController from a gamepad
  129769. * @param vrGamepad the gamepad that the controller should be created from
  129770. */
  129771. constructor(vrGamepad: any);
  129772. /**
  129773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129774. * @param scene scene in which to add meshes
  129775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129776. */
  129777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129778. /**
  129779. * Called once for each button that changed state since the last frame
  129780. * @param buttonIdx Which button index changed
  129781. * @param state New state of the button
  129782. * @param changes Which properties on the state changed since last frame
  129783. */
  129784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129785. }
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * Gear VR Controller
  129790. */
  129791. export class GearVRController extends WebVRController {
  129792. /**
  129793. * Base Url for the controller model.
  129794. */
  129795. static MODEL_BASE_URL: string;
  129796. /**
  129797. * File name for the controller model.
  129798. */
  129799. static MODEL_FILENAME: string;
  129800. /**
  129801. * Gamepad Id prefix used to identify this controller.
  129802. */
  129803. static readonly GAMEPAD_ID_PREFIX: string;
  129804. private readonly _buttonIndexToObservableNameMap;
  129805. /**
  129806. * Creates a new GearVRController from a gamepad
  129807. * @param vrGamepad the gamepad that the controller should be created from
  129808. */
  129809. constructor(vrGamepad: any);
  129810. /**
  129811. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129812. * @param scene scene in which to add meshes
  129813. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129814. */
  129815. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129816. /**
  129817. * Called once for each button that changed state since the last frame
  129818. * @param buttonIdx Which button index changed
  129819. * @param state New state of the button
  129820. * @param changes Which properties on the state changed since last frame
  129821. */
  129822. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129823. }
  129824. }
  129825. declare module BABYLON {
  129826. /**
  129827. * Generic Controller
  129828. */
  129829. export class GenericController extends WebVRController {
  129830. /**
  129831. * Base Url for the controller model.
  129832. */
  129833. static readonly MODEL_BASE_URL: string;
  129834. /**
  129835. * File name for the controller model.
  129836. */
  129837. static readonly MODEL_FILENAME: string;
  129838. /**
  129839. * Creates a new GenericController from a gamepad
  129840. * @param vrGamepad the gamepad that the controller should be created from
  129841. */
  129842. constructor(vrGamepad: any);
  129843. /**
  129844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129845. * @param scene scene in which to add meshes
  129846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129847. */
  129848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129849. /**
  129850. * Called once for each button that changed state since the last frame
  129851. * @param buttonIdx Which button index changed
  129852. * @param state New state of the button
  129853. * @param changes Which properties on the state changed since last frame
  129854. */
  129855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129856. }
  129857. }
  129858. declare module BABYLON {
  129859. /**
  129860. * Oculus Touch Controller
  129861. */
  129862. export class OculusTouchController extends WebVRController {
  129863. /**
  129864. * Base Url for the controller model.
  129865. */
  129866. static MODEL_BASE_URL: string;
  129867. /**
  129868. * File name for the left controller model.
  129869. */
  129870. static MODEL_LEFT_FILENAME: string;
  129871. /**
  129872. * File name for the right controller model.
  129873. */
  129874. static MODEL_RIGHT_FILENAME: string;
  129875. /**
  129876. * Base Url for the Quest controller model.
  129877. */
  129878. static QUEST_MODEL_BASE_URL: string;
  129879. /**
  129880. * @hidden
  129881. * If the controllers are running on a device that needs the updated Quest controller models
  129882. */
  129883. static _IsQuest: boolean;
  129884. /**
  129885. * Fired when the secondary trigger on this controller is modified
  129886. */
  129887. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129888. /**
  129889. * Fired when the thumb rest on this controller is modified
  129890. */
  129891. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129892. /**
  129893. * Creates a new OculusTouchController from a gamepad
  129894. * @param vrGamepad the gamepad that the controller should be created from
  129895. */
  129896. constructor(vrGamepad: any);
  129897. /**
  129898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129899. * @param scene scene in which to add meshes
  129900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129901. */
  129902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129903. /**
  129904. * Fired when the A button on this controller is modified
  129905. */
  129906. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129907. /**
  129908. * Fired when the B button on this controller is modified
  129909. */
  129910. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129911. /**
  129912. * Fired when the X button on this controller is modified
  129913. */
  129914. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129915. /**
  129916. * Fired when the Y button on this controller is modified
  129917. */
  129918. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129919. /**
  129920. * Called once for each button that changed state since the last frame
  129921. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129922. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129923. * 2) secondary trigger (same)
  129924. * 3) A (right) X (left), touch, pressed = value
  129925. * 4) B / Y
  129926. * 5) thumb rest
  129927. * @param buttonIdx Which button index changed
  129928. * @param state New state of the button
  129929. * @param changes Which properties on the state changed since last frame
  129930. */
  129931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129932. }
  129933. }
  129934. declare module BABYLON {
  129935. /**
  129936. * Vive Controller
  129937. */
  129938. export class ViveController extends WebVRController {
  129939. /**
  129940. * Base Url for the controller model.
  129941. */
  129942. static MODEL_BASE_URL: string;
  129943. /**
  129944. * File name for the controller model.
  129945. */
  129946. static MODEL_FILENAME: string;
  129947. /**
  129948. * Creates a new ViveController from a gamepad
  129949. * @param vrGamepad the gamepad that the controller should be created from
  129950. */
  129951. constructor(vrGamepad: any);
  129952. /**
  129953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129954. * @param scene scene in which to add meshes
  129955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129956. */
  129957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129958. /**
  129959. * Fired when the left button on this controller is modified
  129960. */
  129961. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129962. /**
  129963. * Fired when the right button on this controller is modified
  129964. */
  129965. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129966. /**
  129967. * Fired when the menu button on this controller is modified
  129968. */
  129969. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129970. /**
  129971. * Called once for each button that changed state since the last frame
  129972. * Vive mapping:
  129973. * 0: touchpad
  129974. * 1: trigger
  129975. * 2: left AND right buttons
  129976. * 3: menu button
  129977. * @param buttonIdx Which button index changed
  129978. * @param state New state of the button
  129979. * @param changes Which properties on the state changed since last frame
  129980. */
  129981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129982. }
  129983. }
  129984. declare module BABYLON {
  129985. /**
  129986. * Defines the WindowsMotionController object that the state of the windows motion controller
  129987. */
  129988. export class WindowsMotionController extends WebVRController {
  129989. /**
  129990. * The base url used to load the left and right controller models
  129991. */
  129992. static MODEL_BASE_URL: string;
  129993. /**
  129994. * The name of the left controller model file
  129995. */
  129996. static MODEL_LEFT_FILENAME: string;
  129997. /**
  129998. * The name of the right controller model file
  129999. */
  130000. static MODEL_RIGHT_FILENAME: string;
  130001. /**
  130002. * The controller name prefix for this controller type
  130003. */
  130004. static readonly GAMEPAD_ID_PREFIX: string;
  130005. /**
  130006. * The controller id pattern for this controller type
  130007. */
  130008. private static readonly GAMEPAD_ID_PATTERN;
  130009. private _loadedMeshInfo;
  130010. protected readonly _mapping: {
  130011. buttons: string[];
  130012. buttonMeshNames: {
  130013. trigger: string;
  130014. menu: string;
  130015. grip: string;
  130016. thumbstick: string;
  130017. trackpad: string;
  130018. };
  130019. buttonObservableNames: {
  130020. trigger: string;
  130021. menu: string;
  130022. grip: string;
  130023. thumbstick: string;
  130024. trackpad: string;
  130025. };
  130026. axisMeshNames: string[];
  130027. pointingPoseMeshName: string;
  130028. };
  130029. /**
  130030. * Fired when the trackpad on this controller is clicked
  130031. */
  130032. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130033. /**
  130034. * Fired when the trackpad on this controller is modified
  130035. */
  130036. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130037. /**
  130038. * The current x and y values of this controller's trackpad
  130039. */
  130040. trackpad: StickValues;
  130041. /**
  130042. * Creates a new WindowsMotionController from a gamepad
  130043. * @param vrGamepad the gamepad that the controller should be created from
  130044. */
  130045. constructor(vrGamepad: any);
  130046. /**
  130047. * Fired when the trigger on this controller is modified
  130048. */
  130049. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130050. /**
  130051. * Fired when the menu button on this controller is modified
  130052. */
  130053. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130054. /**
  130055. * Fired when the grip button on this controller is modified
  130056. */
  130057. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130058. /**
  130059. * Fired when the thumbstick button on this controller is modified
  130060. */
  130061. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130062. /**
  130063. * Fired when the touchpad button on this controller is modified
  130064. */
  130065. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130066. /**
  130067. * Fired when the touchpad values on this controller are modified
  130068. */
  130069. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130070. protected _updateTrackpad(): void;
  130071. /**
  130072. * Called once per frame by the engine.
  130073. */
  130074. update(): void;
  130075. /**
  130076. * Called once for each button that changed state since the last frame
  130077. * @param buttonIdx Which button index changed
  130078. * @param state New state of the button
  130079. * @param changes Which properties on the state changed since last frame
  130080. */
  130081. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130082. /**
  130083. * Moves the buttons on the controller mesh based on their current state
  130084. * @param buttonName the name of the button to move
  130085. * @param buttonValue the value of the button which determines the buttons new position
  130086. */
  130087. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130088. /**
  130089. * Moves the axis on the controller mesh based on its current state
  130090. * @param axis the index of the axis
  130091. * @param axisValue the value of the axis which determines the meshes new position
  130092. * @hidden
  130093. */
  130094. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130095. /**
  130096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130097. * @param scene scene in which to add meshes
  130098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130099. */
  130100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130101. /**
  130102. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130103. * can be transformed by button presses and axes values, based on this._mapping.
  130104. *
  130105. * @param scene scene in which the meshes exist
  130106. * @param meshes list of meshes that make up the controller model to process
  130107. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130108. */
  130109. private processModel;
  130110. private createMeshInfo;
  130111. /**
  130112. * Gets the ray of the controller in the direction the controller is pointing
  130113. * @param length the length the resulting ray should be
  130114. * @returns a ray in the direction the controller is pointing
  130115. */
  130116. getForwardRay(length?: number): Ray;
  130117. /**
  130118. * Disposes of the controller
  130119. */
  130120. dispose(): void;
  130121. }
  130122. /**
  130123. * This class represents a new windows motion controller in XR.
  130124. */
  130125. export class XRWindowsMotionController extends WindowsMotionController {
  130126. /**
  130127. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130128. */
  130129. protected readonly _mapping: {
  130130. buttons: string[];
  130131. buttonMeshNames: {
  130132. trigger: string;
  130133. menu: string;
  130134. grip: string;
  130135. thumbstick: string;
  130136. trackpad: string;
  130137. };
  130138. buttonObservableNames: {
  130139. trigger: string;
  130140. menu: string;
  130141. grip: string;
  130142. thumbstick: string;
  130143. trackpad: string;
  130144. };
  130145. axisMeshNames: string[];
  130146. pointingPoseMeshName: string;
  130147. };
  130148. /**
  130149. * Construct a new XR-Based windows motion controller
  130150. *
  130151. * @param gamepadInfo the gamepad object from the browser
  130152. */
  130153. constructor(gamepadInfo: any);
  130154. /**
  130155. * holds the thumbstick values (X,Y)
  130156. */
  130157. thumbstickValues: StickValues;
  130158. /**
  130159. * Fired when the thumbstick on this controller is clicked
  130160. */
  130161. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130162. /**
  130163. * Fired when the thumbstick on this controller is modified
  130164. */
  130165. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130166. /**
  130167. * Fired when the touchpad button on this controller is modified
  130168. */
  130169. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130170. /**
  130171. * Fired when the touchpad values on this controller are modified
  130172. */
  130173. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130174. /**
  130175. * Fired when the thumbstick button on this controller is modified
  130176. * here to prevent breaking changes
  130177. */
  130178. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130179. /**
  130180. * updating the thumbstick(!) and not the trackpad.
  130181. * This is named this way due to the difference between WebVR and XR and to avoid
  130182. * changing the parent class.
  130183. */
  130184. protected _updateTrackpad(): void;
  130185. /**
  130186. * Disposes the class with joy
  130187. */
  130188. dispose(): void;
  130189. }
  130190. }
  130191. declare module BABYLON {
  130192. /**
  130193. * Class containing static functions to help procedurally build meshes
  130194. */
  130195. export class PolyhedronBuilder {
  130196. /**
  130197. * Creates a polyhedron mesh
  130198. * * 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
  130199. * * The parameter `size` (positive float, default 1) sets the polygon size
  130200. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130201. * * 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`
  130202. * * 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
  130203. * * 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)`)
  130204. * * 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
  130205. * * 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
  130206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130209. * @param name defines the name of the mesh
  130210. * @param options defines the options used to create the mesh
  130211. * @param scene defines the hosting scene
  130212. * @returns the polyhedron mesh
  130213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130214. */
  130215. static CreatePolyhedron(name: string, options: {
  130216. type?: number;
  130217. size?: number;
  130218. sizeX?: number;
  130219. sizeY?: number;
  130220. sizeZ?: number;
  130221. custom?: any;
  130222. faceUV?: Vector4[];
  130223. faceColors?: Color4[];
  130224. flat?: boolean;
  130225. updatable?: boolean;
  130226. sideOrientation?: number;
  130227. frontUVs?: Vector4;
  130228. backUVs?: Vector4;
  130229. }, scene?: Nullable<Scene>): Mesh;
  130230. }
  130231. }
  130232. declare module BABYLON {
  130233. /**
  130234. * Gizmo that enables scaling a mesh along 3 axis
  130235. */
  130236. export class ScaleGizmo extends Gizmo {
  130237. /**
  130238. * Internal gizmo used for interactions on the x axis
  130239. */
  130240. xGizmo: AxisScaleGizmo;
  130241. /**
  130242. * Internal gizmo used for interactions on the y axis
  130243. */
  130244. yGizmo: AxisScaleGizmo;
  130245. /**
  130246. * Internal gizmo used for interactions on the z axis
  130247. */
  130248. zGizmo: AxisScaleGizmo;
  130249. /**
  130250. * Internal gizmo used to scale all axis equally
  130251. */
  130252. uniformScaleGizmo: AxisScaleGizmo;
  130253. private _meshAttached;
  130254. private _updateGizmoRotationToMatchAttachedMesh;
  130255. private _snapDistance;
  130256. private _scaleRatio;
  130257. private _uniformScalingMesh;
  130258. private _octahedron;
  130259. private _sensitivity;
  130260. /** Fires an event when any of it's sub gizmos are dragged */
  130261. onDragStartObservable: Observable<unknown>;
  130262. /** Fires an event when any of it's sub gizmos are released from dragging */
  130263. onDragEndObservable: Observable<unknown>;
  130264. get attachedMesh(): Nullable<AbstractMesh>;
  130265. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130266. /**
  130267. * Creates a ScaleGizmo
  130268. * @param gizmoLayer The utility layer the gizmo will be added to
  130269. */
  130270. constructor(gizmoLayer?: UtilityLayerRenderer);
  130271. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130272. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130273. /**
  130274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130275. */
  130276. set snapDistance(value: number);
  130277. get snapDistance(): number;
  130278. /**
  130279. * Ratio for the scale of the gizmo (Default: 1)
  130280. */
  130281. set scaleRatio(value: number);
  130282. get scaleRatio(): number;
  130283. /**
  130284. * Sensitivity factor for dragging (Default: 1)
  130285. */
  130286. set sensitivity(value: number);
  130287. get sensitivity(): number;
  130288. /**
  130289. * Disposes of the gizmo
  130290. */
  130291. dispose(): void;
  130292. }
  130293. }
  130294. declare module BABYLON {
  130295. /**
  130296. * Single axis scale gizmo
  130297. */
  130298. export class AxisScaleGizmo extends Gizmo {
  130299. /**
  130300. * Drag behavior responsible for the gizmos dragging interactions
  130301. */
  130302. dragBehavior: PointerDragBehavior;
  130303. private _pointerObserver;
  130304. /**
  130305. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130306. */
  130307. snapDistance: number;
  130308. /**
  130309. * Event that fires each time the gizmo snaps to a new location.
  130310. * * snapDistance is the the change in distance
  130311. */
  130312. onSnapObservable: Observable<{
  130313. snapDistance: number;
  130314. }>;
  130315. /**
  130316. * If the scaling operation should be done on all axis (default: false)
  130317. */
  130318. uniformScaling: boolean;
  130319. /**
  130320. * Custom sensitivity value for the drag strength
  130321. */
  130322. sensitivity: number;
  130323. private _isEnabled;
  130324. private _parent;
  130325. private _arrow;
  130326. private _coloredMaterial;
  130327. private _hoverMaterial;
  130328. /**
  130329. * Creates an AxisScaleGizmo
  130330. * @param gizmoLayer The utility layer the gizmo will be added to
  130331. * @param dragAxis The axis which the gizmo will be able to scale on
  130332. * @param color The color of the gizmo
  130333. */
  130334. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130335. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130336. /**
  130337. * If the gizmo is enabled
  130338. */
  130339. set isEnabled(value: boolean);
  130340. get isEnabled(): boolean;
  130341. /**
  130342. * Disposes of the gizmo
  130343. */
  130344. dispose(): void;
  130345. /**
  130346. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130347. * @param mesh The mesh to replace the default mesh of the gizmo
  130348. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130349. */
  130350. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130351. }
  130352. }
  130353. declare module BABYLON {
  130354. /**
  130355. * Bounding box gizmo
  130356. */
  130357. export class BoundingBoxGizmo extends Gizmo {
  130358. private _lineBoundingBox;
  130359. private _rotateSpheresParent;
  130360. private _scaleBoxesParent;
  130361. private _boundingDimensions;
  130362. private _renderObserver;
  130363. private _pointerObserver;
  130364. private _scaleDragSpeed;
  130365. private _tmpQuaternion;
  130366. private _tmpVector;
  130367. private _tmpRotationMatrix;
  130368. /**
  130369. * 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)
  130370. */
  130371. ignoreChildren: boolean;
  130372. /**
  130373. * 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)
  130374. */
  130375. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130376. /**
  130377. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130378. */
  130379. rotationSphereSize: number;
  130380. /**
  130381. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130382. */
  130383. scaleBoxSize: number;
  130384. /**
  130385. * 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)
  130386. */
  130387. fixedDragMeshScreenSize: boolean;
  130388. /**
  130389. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130390. */
  130391. fixedDragMeshScreenSizeDistanceFactor: number;
  130392. /**
  130393. * Fired when a rotation sphere or scale box is dragged
  130394. */
  130395. onDragStartObservable: Observable<{}>;
  130396. /**
  130397. * Fired when a scale box is dragged
  130398. */
  130399. onScaleBoxDragObservable: Observable<{}>;
  130400. /**
  130401. * Fired when a scale box drag is ended
  130402. */
  130403. onScaleBoxDragEndObservable: Observable<{}>;
  130404. /**
  130405. * Fired when a rotation sphere is dragged
  130406. */
  130407. onRotationSphereDragObservable: Observable<{}>;
  130408. /**
  130409. * Fired when a rotation sphere drag is ended
  130410. */
  130411. onRotationSphereDragEndObservable: Observable<{}>;
  130412. /**
  130413. * 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)
  130414. */
  130415. scalePivot: Nullable<Vector3>;
  130416. /**
  130417. * Mesh used as a pivot to rotate the attached mesh
  130418. */
  130419. private _anchorMesh;
  130420. private _existingMeshScale;
  130421. private _dragMesh;
  130422. private pointerDragBehavior;
  130423. private coloredMaterial;
  130424. private hoverColoredMaterial;
  130425. /**
  130426. * Sets the color of the bounding box gizmo
  130427. * @param color the color to set
  130428. */
  130429. setColor(color: Color3): void;
  130430. /**
  130431. * Creates an BoundingBoxGizmo
  130432. * @param gizmoLayer The utility layer the gizmo will be added to
  130433. * @param color The color of the gizmo
  130434. */
  130435. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130436. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130437. private _selectNode;
  130438. /**
  130439. * Updates the bounding box information for the Gizmo
  130440. */
  130441. updateBoundingBox(): void;
  130442. private _updateRotationSpheres;
  130443. private _updateScaleBoxes;
  130444. /**
  130445. * Enables rotation on the specified axis and disables rotation on the others
  130446. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130447. */
  130448. setEnabledRotationAxis(axis: string): void;
  130449. /**
  130450. * Enables/disables scaling
  130451. * @param enable if scaling should be enabled
  130452. * @param homogeneousScaling defines if scaling should only be homogeneous
  130453. */
  130454. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130455. private _updateDummy;
  130456. /**
  130457. * Enables a pointer drag behavior on the bounding box of the gizmo
  130458. */
  130459. enableDragBehavior(): void;
  130460. /**
  130461. * Disposes of the gizmo
  130462. */
  130463. dispose(): void;
  130464. /**
  130465. * 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)
  130466. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130467. * @returns the bounding box mesh with the passed in mesh as a child
  130468. */
  130469. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130470. /**
  130471. * CustomMeshes are not supported by this gizmo
  130472. * @param mesh The mesh to replace the default mesh of the gizmo
  130473. */
  130474. setCustomMesh(mesh: Mesh): void;
  130475. }
  130476. }
  130477. declare module BABYLON {
  130478. /**
  130479. * Single plane rotation gizmo
  130480. */
  130481. export class PlaneRotationGizmo extends Gizmo {
  130482. /**
  130483. * Drag behavior responsible for the gizmos dragging interactions
  130484. */
  130485. dragBehavior: PointerDragBehavior;
  130486. private _pointerObserver;
  130487. /**
  130488. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130489. */
  130490. snapDistance: number;
  130491. /**
  130492. * Event that fires each time the gizmo snaps to a new location.
  130493. * * snapDistance is the the change in distance
  130494. */
  130495. onSnapObservable: Observable<{
  130496. snapDistance: number;
  130497. }>;
  130498. private _isEnabled;
  130499. private _parent;
  130500. /**
  130501. * Creates a PlaneRotationGizmo
  130502. * @param gizmoLayer The utility layer the gizmo will be added to
  130503. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130504. * @param color The color of the gizmo
  130505. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130506. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130507. */
  130508. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130509. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130510. /**
  130511. * If the gizmo is enabled
  130512. */
  130513. set isEnabled(value: boolean);
  130514. get isEnabled(): boolean;
  130515. /**
  130516. * Disposes of the gizmo
  130517. */
  130518. dispose(): void;
  130519. }
  130520. }
  130521. declare module BABYLON {
  130522. /**
  130523. * Gizmo that enables rotating a mesh along 3 axis
  130524. */
  130525. export class RotationGizmo extends Gizmo {
  130526. /**
  130527. * Internal gizmo used for interactions on the x axis
  130528. */
  130529. xGizmo: PlaneRotationGizmo;
  130530. /**
  130531. * Internal gizmo used for interactions on the y axis
  130532. */
  130533. yGizmo: PlaneRotationGizmo;
  130534. /**
  130535. * Internal gizmo used for interactions on the z axis
  130536. */
  130537. zGizmo: PlaneRotationGizmo;
  130538. /** Fires an event when any of it's sub gizmos are dragged */
  130539. onDragStartObservable: Observable<unknown>;
  130540. /** Fires an event when any of it's sub gizmos are released from dragging */
  130541. onDragEndObservable: Observable<unknown>;
  130542. private _meshAttached;
  130543. get attachedMesh(): Nullable<AbstractMesh>;
  130544. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130545. /**
  130546. * Creates a RotationGizmo
  130547. * @param gizmoLayer The utility layer the gizmo will be added to
  130548. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130549. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130550. */
  130551. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130552. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130553. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130554. /**
  130555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130556. */
  130557. set snapDistance(value: number);
  130558. get snapDistance(): number;
  130559. /**
  130560. * Ratio for the scale of the gizmo (Default: 1)
  130561. */
  130562. set scaleRatio(value: number);
  130563. get scaleRatio(): number;
  130564. /**
  130565. * Disposes of the gizmo
  130566. */
  130567. dispose(): void;
  130568. /**
  130569. * CustomMeshes are not supported by this gizmo
  130570. * @param mesh The mesh to replace the default mesh of the gizmo
  130571. */
  130572. setCustomMesh(mesh: Mesh): void;
  130573. }
  130574. }
  130575. declare module BABYLON {
  130576. /**
  130577. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130578. */
  130579. export class GizmoManager implements IDisposable {
  130580. private scene;
  130581. /**
  130582. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130583. */
  130584. gizmos: {
  130585. positionGizmo: Nullable<PositionGizmo>;
  130586. rotationGizmo: Nullable<RotationGizmo>;
  130587. scaleGizmo: Nullable<ScaleGizmo>;
  130588. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130589. };
  130590. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130591. clearGizmoOnEmptyPointerEvent: boolean;
  130592. /** Fires an event when the manager is attached to a mesh */
  130593. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130594. private _gizmosEnabled;
  130595. private _pointerObserver;
  130596. private _attachedMesh;
  130597. private _boundingBoxColor;
  130598. private _defaultUtilityLayer;
  130599. private _defaultKeepDepthUtilityLayer;
  130600. /**
  130601. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130602. */
  130603. boundingBoxDragBehavior: SixDofDragBehavior;
  130604. /**
  130605. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130606. */
  130607. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130608. /**
  130609. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130610. */
  130611. usePointerToAttachGizmos: boolean;
  130612. /**
  130613. * Utility layer that the bounding box gizmo belongs to
  130614. */
  130615. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130616. /**
  130617. * Utility layer that all gizmos besides bounding box belong to
  130618. */
  130619. get utilityLayer(): UtilityLayerRenderer;
  130620. /**
  130621. * Instatiates a gizmo manager
  130622. * @param scene the scene to overlay the gizmos on top of
  130623. */
  130624. constructor(scene: Scene);
  130625. /**
  130626. * Attaches a set of gizmos to the specified mesh
  130627. * @param mesh The mesh the gizmo's should be attached to
  130628. */
  130629. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130630. /**
  130631. * If the position gizmo is enabled
  130632. */
  130633. set positionGizmoEnabled(value: boolean);
  130634. get positionGizmoEnabled(): boolean;
  130635. /**
  130636. * If the rotation gizmo is enabled
  130637. */
  130638. set rotationGizmoEnabled(value: boolean);
  130639. get rotationGizmoEnabled(): boolean;
  130640. /**
  130641. * If the scale gizmo is enabled
  130642. */
  130643. set scaleGizmoEnabled(value: boolean);
  130644. get scaleGizmoEnabled(): boolean;
  130645. /**
  130646. * If the boundingBox gizmo is enabled
  130647. */
  130648. set boundingBoxGizmoEnabled(value: boolean);
  130649. get boundingBoxGizmoEnabled(): boolean;
  130650. /**
  130651. * Disposes of the gizmo manager
  130652. */
  130653. dispose(): void;
  130654. }
  130655. }
  130656. declare module BABYLON {
  130657. /**
  130658. * A directional light is defined by a direction (what a surprise!).
  130659. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130660. * 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.
  130661. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130662. */
  130663. export class DirectionalLight extends ShadowLight {
  130664. private _shadowFrustumSize;
  130665. /**
  130666. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130667. */
  130668. get shadowFrustumSize(): number;
  130669. /**
  130670. * Specifies a fix frustum size for the shadow generation.
  130671. */
  130672. set shadowFrustumSize(value: number);
  130673. private _shadowOrthoScale;
  130674. /**
  130675. * Gets the shadow projection scale against the optimal computed one.
  130676. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130677. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130678. */
  130679. get shadowOrthoScale(): number;
  130680. /**
  130681. * Sets the shadow projection scale against the optimal computed one.
  130682. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130683. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130684. */
  130685. set shadowOrthoScale(value: number);
  130686. /**
  130687. * Automatically compute the projection matrix to best fit (including all the casters)
  130688. * on each frame.
  130689. */
  130690. autoUpdateExtends: boolean;
  130691. /**
  130692. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130693. * on each frame. autoUpdateExtends must be set to true for this to work
  130694. */
  130695. autoCalcShadowZBounds: boolean;
  130696. private _orthoLeft;
  130697. private _orthoRight;
  130698. private _orthoTop;
  130699. private _orthoBottom;
  130700. /**
  130701. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130702. * The directional light is emitted from everywhere in the given direction.
  130703. * It can cast shadows.
  130704. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130705. * @param name The friendly name of the light
  130706. * @param direction The direction of the light
  130707. * @param scene The scene the light belongs to
  130708. */
  130709. constructor(name: string, direction: Vector3, scene: Scene);
  130710. /**
  130711. * Returns the string "DirectionalLight".
  130712. * @return The class name
  130713. */
  130714. getClassName(): string;
  130715. /**
  130716. * Returns the integer 1.
  130717. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130718. */
  130719. getTypeID(): number;
  130720. /**
  130721. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130722. * Returns the DirectionalLight Shadow projection matrix.
  130723. */
  130724. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130725. /**
  130726. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130727. * Returns the DirectionalLight Shadow projection matrix.
  130728. */
  130729. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130730. /**
  130731. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130732. * Returns the DirectionalLight Shadow projection matrix.
  130733. */
  130734. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130735. protected _buildUniformLayout(): void;
  130736. /**
  130737. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130738. * @param effect The effect to update
  130739. * @param lightIndex The index of the light in the effect to update
  130740. * @returns The directional light
  130741. */
  130742. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130743. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130744. /**
  130745. * Gets the minZ used for shadow according to both the scene and the light.
  130746. *
  130747. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130748. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130749. * @param activeCamera The camera we are returning the min for
  130750. * @returns the depth min z
  130751. */
  130752. getDepthMinZ(activeCamera: Camera): number;
  130753. /**
  130754. * Gets the maxZ used for shadow according to both the scene and the light.
  130755. *
  130756. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130757. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130758. * @param activeCamera The camera we are returning the max for
  130759. * @returns the depth max z
  130760. */
  130761. getDepthMaxZ(activeCamera: Camera): number;
  130762. /**
  130763. * Prepares the list of defines specific to the light type.
  130764. * @param defines the list of defines
  130765. * @param lightIndex defines the index of the light for the effect
  130766. */
  130767. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130768. }
  130769. }
  130770. declare module BABYLON {
  130771. /**
  130772. * Class containing static functions to help procedurally build meshes
  130773. */
  130774. export class HemisphereBuilder {
  130775. /**
  130776. * Creates a hemisphere mesh
  130777. * @param name defines the name of the mesh
  130778. * @param options defines the options used to create the mesh
  130779. * @param scene defines the hosting scene
  130780. * @returns the hemisphere mesh
  130781. */
  130782. static CreateHemisphere(name: string, options: {
  130783. segments?: number;
  130784. diameter?: number;
  130785. sideOrientation?: number;
  130786. }, scene: any): Mesh;
  130787. }
  130788. }
  130789. declare module BABYLON {
  130790. /**
  130791. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130792. * These values define a cone of light starting from the position, emitting toward the direction.
  130793. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130794. * and the exponent defines the speed of the decay of the light with distance (reach).
  130795. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130796. */
  130797. export class SpotLight extends ShadowLight {
  130798. private _angle;
  130799. private _innerAngle;
  130800. private _cosHalfAngle;
  130801. private _lightAngleScale;
  130802. private _lightAngleOffset;
  130803. /**
  130804. * Gets the cone angle of the spot light in Radians.
  130805. */
  130806. get angle(): number;
  130807. /**
  130808. * Sets the cone angle of the spot light in Radians.
  130809. */
  130810. set angle(value: number);
  130811. /**
  130812. * Only used in gltf falloff mode, this defines the angle where
  130813. * the directional falloff will start before cutting at angle which could be seen
  130814. * as outer angle.
  130815. */
  130816. get innerAngle(): number;
  130817. /**
  130818. * Only used in gltf falloff mode, this defines the angle where
  130819. * the directional falloff will start before cutting at angle which could be seen
  130820. * as outer angle.
  130821. */
  130822. set innerAngle(value: number);
  130823. private _shadowAngleScale;
  130824. /**
  130825. * Allows scaling the angle of the light for shadow generation only.
  130826. */
  130827. get shadowAngleScale(): number;
  130828. /**
  130829. * Allows scaling the angle of the light for shadow generation only.
  130830. */
  130831. set shadowAngleScale(value: number);
  130832. /**
  130833. * The light decay speed with the distance from the emission spot.
  130834. */
  130835. exponent: number;
  130836. private _projectionTextureMatrix;
  130837. /**
  130838. * Allows reading the projecton texture
  130839. */
  130840. get projectionTextureMatrix(): Matrix;
  130841. protected _projectionTextureLightNear: number;
  130842. /**
  130843. * Gets the near clip of the Spotlight for texture projection.
  130844. */
  130845. get projectionTextureLightNear(): number;
  130846. /**
  130847. * Sets the near clip of the Spotlight for texture projection.
  130848. */
  130849. set projectionTextureLightNear(value: number);
  130850. protected _projectionTextureLightFar: number;
  130851. /**
  130852. * Gets the far clip of the Spotlight for texture projection.
  130853. */
  130854. get projectionTextureLightFar(): number;
  130855. /**
  130856. * Sets the far clip of the Spotlight for texture projection.
  130857. */
  130858. set projectionTextureLightFar(value: number);
  130859. protected _projectionTextureUpDirection: Vector3;
  130860. /**
  130861. * Gets the Up vector of the Spotlight for texture projection.
  130862. */
  130863. get projectionTextureUpDirection(): Vector3;
  130864. /**
  130865. * Sets the Up vector of the Spotlight for texture projection.
  130866. */
  130867. set projectionTextureUpDirection(value: Vector3);
  130868. private _projectionTexture;
  130869. /**
  130870. * Gets the projection texture of the light.
  130871. */
  130872. get projectionTexture(): Nullable<BaseTexture>;
  130873. /**
  130874. * Sets the projection texture of the light.
  130875. */
  130876. set projectionTexture(value: Nullable<BaseTexture>);
  130877. private _projectionTextureViewLightDirty;
  130878. private _projectionTextureProjectionLightDirty;
  130879. private _projectionTextureDirty;
  130880. private _projectionTextureViewTargetVector;
  130881. private _projectionTextureViewLightMatrix;
  130882. private _projectionTextureProjectionLightMatrix;
  130883. private _projectionTextureScalingMatrix;
  130884. /**
  130885. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130886. * It can cast shadows.
  130887. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130888. * @param name The light friendly name
  130889. * @param position The position of the spot light in the scene
  130890. * @param direction The direction of the light in the scene
  130891. * @param angle The cone angle of the light in Radians
  130892. * @param exponent The light decay speed with the distance from the emission spot
  130893. * @param scene The scene the lights belongs to
  130894. */
  130895. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130896. /**
  130897. * Returns the string "SpotLight".
  130898. * @returns the class name
  130899. */
  130900. getClassName(): string;
  130901. /**
  130902. * Returns the integer 2.
  130903. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130904. */
  130905. getTypeID(): number;
  130906. /**
  130907. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130908. */
  130909. protected _setDirection(value: Vector3): void;
  130910. /**
  130911. * Overrides the position setter to recompute the projection texture view light Matrix.
  130912. */
  130913. protected _setPosition(value: Vector3): void;
  130914. /**
  130915. * 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.
  130916. * Returns the SpotLight.
  130917. */
  130918. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130919. protected _computeProjectionTextureViewLightMatrix(): void;
  130920. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130921. /**
  130922. * Main function for light texture projection matrix computing.
  130923. */
  130924. protected _computeProjectionTextureMatrix(): void;
  130925. protected _buildUniformLayout(): void;
  130926. private _computeAngleValues;
  130927. /**
  130928. * Sets the passed Effect "effect" with the Light textures.
  130929. * @param effect The effect to update
  130930. * @param lightIndex The index of the light in the effect to update
  130931. * @returns The light
  130932. */
  130933. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130934. /**
  130935. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130936. * @param effect The effect to update
  130937. * @param lightIndex The index of the light in the effect to update
  130938. * @returns The spot light
  130939. */
  130940. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130941. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130942. /**
  130943. * Disposes the light and the associated resources.
  130944. */
  130945. dispose(): void;
  130946. /**
  130947. * Prepares the list of defines specific to the light type.
  130948. * @param defines the list of defines
  130949. * @param lightIndex defines the index of the light for the effect
  130950. */
  130951. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130952. }
  130953. }
  130954. declare module BABYLON {
  130955. /**
  130956. * Gizmo that enables viewing a light
  130957. */
  130958. export class LightGizmo extends Gizmo {
  130959. private _lightMesh;
  130960. private _material;
  130961. private _cachedPosition;
  130962. private _cachedForward;
  130963. private _attachedMeshParent;
  130964. /**
  130965. * Creates a LightGizmo
  130966. * @param gizmoLayer The utility layer the gizmo will be added to
  130967. */
  130968. constructor(gizmoLayer?: UtilityLayerRenderer);
  130969. private _light;
  130970. /**
  130971. * The light that the gizmo is attached to
  130972. */
  130973. set light(light: Nullable<Light>);
  130974. get light(): Nullable<Light>;
  130975. /**
  130976. * Gets the material used to render the light gizmo
  130977. */
  130978. get material(): StandardMaterial;
  130979. /**
  130980. * @hidden
  130981. * Updates the gizmo to match the attached mesh's position/rotation
  130982. */
  130983. protected _update(): void;
  130984. private static _Scale;
  130985. /**
  130986. * Creates the lines for a light mesh
  130987. */
  130988. private static _CreateLightLines;
  130989. /**
  130990. * Disposes of the light gizmo
  130991. */
  130992. dispose(): void;
  130993. private static _CreateHemisphericLightMesh;
  130994. private static _CreatePointLightMesh;
  130995. private static _CreateSpotLightMesh;
  130996. private static _CreateDirectionalLightMesh;
  130997. }
  130998. }
  130999. declare module BABYLON {
  131000. /** @hidden */
  131001. export var backgroundFragmentDeclaration: {
  131002. name: string;
  131003. shader: string;
  131004. };
  131005. }
  131006. declare module BABYLON {
  131007. /** @hidden */
  131008. export var backgroundUboDeclaration: {
  131009. name: string;
  131010. shader: string;
  131011. };
  131012. }
  131013. declare module BABYLON {
  131014. /** @hidden */
  131015. export var backgroundPixelShader: {
  131016. name: string;
  131017. shader: string;
  131018. };
  131019. }
  131020. declare module BABYLON {
  131021. /** @hidden */
  131022. export var backgroundVertexDeclaration: {
  131023. name: string;
  131024. shader: string;
  131025. };
  131026. }
  131027. declare module BABYLON {
  131028. /** @hidden */
  131029. export var backgroundVertexShader: {
  131030. name: string;
  131031. shader: string;
  131032. };
  131033. }
  131034. declare module BABYLON {
  131035. /**
  131036. * Background material used to create an efficient environement around your scene.
  131037. */
  131038. export class BackgroundMaterial extends PushMaterial {
  131039. /**
  131040. * Standard reflectance value at parallel view angle.
  131041. */
  131042. static StandardReflectance0: number;
  131043. /**
  131044. * Standard reflectance value at grazing angle.
  131045. */
  131046. static StandardReflectance90: number;
  131047. protected _primaryColor: Color3;
  131048. /**
  131049. * Key light Color (multiply against the environement texture)
  131050. */
  131051. primaryColor: Color3;
  131052. protected __perceptualColor: Nullable<Color3>;
  131053. /**
  131054. * Experimental Internal Use Only.
  131055. *
  131056. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131057. * This acts as a helper to set the primary color to a more "human friendly" value.
  131058. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131059. * output color as close as possible from the chosen value.
  131060. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131061. * part of lighting setup.)
  131062. */
  131063. get _perceptualColor(): Nullable<Color3>;
  131064. set _perceptualColor(value: Nullable<Color3>);
  131065. protected _primaryColorShadowLevel: float;
  131066. /**
  131067. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131068. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131069. */
  131070. get primaryColorShadowLevel(): float;
  131071. set primaryColorShadowLevel(value: float);
  131072. protected _primaryColorHighlightLevel: float;
  131073. /**
  131074. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131075. * The primary color is used at the level chosen to define what the white area would look.
  131076. */
  131077. get primaryColorHighlightLevel(): float;
  131078. set primaryColorHighlightLevel(value: float);
  131079. protected _reflectionTexture: Nullable<BaseTexture>;
  131080. /**
  131081. * Reflection Texture used in the material.
  131082. * Should be author in a specific way for the best result (refer to the documentation).
  131083. */
  131084. reflectionTexture: Nullable<BaseTexture>;
  131085. protected _reflectionBlur: float;
  131086. /**
  131087. * Reflection Texture level of blur.
  131088. *
  131089. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131090. * texture twice.
  131091. */
  131092. reflectionBlur: float;
  131093. protected _diffuseTexture: Nullable<BaseTexture>;
  131094. /**
  131095. * Diffuse Texture used in the material.
  131096. * Should be author in a specific way for the best result (refer to the documentation).
  131097. */
  131098. diffuseTexture: Nullable<BaseTexture>;
  131099. protected _shadowLights: Nullable<IShadowLight[]>;
  131100. /**
  131101. * Specify the list of lights casting shadow on the material.
  131102. * All scene shadow lights will be included if null.
  131103. */
  131104. shadowLights: Nullable<IShadowLight[]>;
  131105. protected _shadowLevel: float;
  131106. /**
  131107. * Helps adjusting the shadow to a softer level if required.
  131108. * 0 means black shadows and 1 means no shadows.
  131109. */
  131110. shadowLevel: float;
  131111. protected _sceneCenter: Vector3;
  131112. /**
  131113. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131114. * It is usually zero but might be interesting to modify according to your setup.
  131115. */
  131116. sceneCenter: Vector3;
  131117. protected _opacityFresnel: boolean;
  131118. /**
  131119. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131120. * This helps ensuring a nice transition when the camera goes under the ground.
  131121. */
  131122. opacityFresnel: boolean;
  131123. protected _reflectionFresnel: boolean;
  131124. /**
  131125. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131126. * This helps adding a mirror texture on the ground.
  131127. */
  131128. reflectionFresnel: boolean;
  131129. protected _reflectionFalloffDistance: number;
  131130. /**
  131131. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131132. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131133. */
  131134. reflectionFalloffDistance: number;
  131135. protected _reflectionAmount: number;
  131136. /**
  131137. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131138. */
  131139. reflectionAmount: number;
  131140. protected _reflectionReflectance0: number;
  131141. /**
  131142. * This specifies the weight of the reflection at grazing angle.
  131143. */
  131144. reflectionReflectance0: number;
  131145. protected _reflectionReflectance90: number;
  131146. /**
  131147. * This specifies the weight of the reflection at a perpendicular point of view.
  131148. */
  131149. reflectionReflectance90: number;
  131150. /**
  131151. * Sets the reflection reflectance fresnel values according to the default standard
  131152. * empirically know to work well :-)
  131153. */
  131154. set reflectionStandardFresnelWeight(value: number);
  131155. protected _useRGBColor: boolean;
  131156. /**
  131157. * Helps to directly use the maps channels instead of their level.
  131158. */
  131159. useRGBColor: boolean;
  131160. protected _enableNoise: boolean;
  131161. /**
  131162. * This helps reducing the banding effect that could occur on the background.
  131163. */
  131164. enableNoise: boolean;
  131165. /**
  131166. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131167. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131168. * Recommended to be keep at 1.0 except for special cases.
  131169. */
  131170. get fovMultiplier(): number;
  131171. set fovMultiplier(value: number);
  131172. private _fovMultiplier;
  131173. /**
  131174. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131175. */
  131176. useEquirectangularFOV: boolean;
  131177. private _maxSimultaneousLights;
  131178. /**
  131179. * Number of Simultaneous lights allowed on the material.
  131180. */
  131181. maxSimultaneousLights: int;
  131182. private _shadowOnly;
  131183. /**
  131184. * Make the material only render shadows
  131185. */
  131186. shadowOnly: boolean;
  131187. /**
  131188. * Default configuration related to image processing available in the Background Material.
  131189. */
  131190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131191. /**
  131192. * Keep track of the image processing observer to allow dispose and replace.
  131193. */
  131194. private _imageProcessingObserver;
  131195. /**
  131196. * Attaches a new image processing configuration to the PBR Material.
  131197. * @param configuration (if null the scene configuration will be use)
  131198. */
  131199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131200. /**
  131201. * Gets the image processing configuration used either in this material.
  131202. */
  131203. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131204. /**
  131205. * Sets the Default image processing configuration used either in the this material.
  131206. *
  131207. * If sets to null, the scene one is in use.
  131208. */
  131209. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131210. /**
  131211. * Gets wether the color curves effect is enabled.
  131212. */
  131213. get cameraColorCurvesEnabled(): boolean;
  131214. /**
  131215. * Sets wether the color curves effect is enabled.
  131216. */
  131217. set cameraColorCurvesEnabled(value: boolean);
  131218. /**
  131219. * Gets wether the color grading effect is enabled.
  131220. */
  131221. get cameraColorGradingEnabled(): boolean;
  131222. /**
  131223. * Gets wether the color grading effect is enabled.
  131224. */
  131225. set cameraColorGradingEnabled(value: boolean);
  131226. /**
  131227. * Gets wether tonemapping is enabled or not.
  131228. */
  131229. get cameraToneMappingEnabled(): boolean;
  131230. /**
  131231. * Sets wether tonemapping is enabled or not
  131232. */
  131233. set cameraToneMappingEnabled(value: boolean);
  131234. /**
  131235. * The camera exposure used on this material.
  131236. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131237. * This corresponds to a photographic exposure.
  131238. */
  131239. get cameraExposure(): float;
  131240. /**
  131241. * The camera exposure used on this material.
  131242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131243. * This corresponds to a photographic exposure.
  131244. */
  131245. set cameraExposure(value: float);
  131246. /**
  131247. * Gets The camera contrast used on this material.
  131248. */
  131249. get cameraContrast(): float;
  131250. /**
  131251. * Sets The camera contrast used on this material.
  131252. */
  131253. set cameraContrast(value: float);
  131254. /**
  131255. * Gets the Color Grading 2D Lookup Texture.
  131256. */
  131257. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131258. /**
  131259. * Sets the Color Grading 2D Lookup Texture.
  131260. */
  131261. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131262. /**
  131263. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131264. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131265. * 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;
  131266. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131267. */
  131268. get cameraColorCurves(): Nullable<ColorCurves>;
  131269. /**
  131270. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131271. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131272. * 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;
  131273. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131274. */
  131275. set cameraColorCurves(value: Nullable<ColorCurves>);
  131276. /**
  131277. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131278. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131279. */
  131280. switchToBGR: boolean;
  131281. private _renderTargets;
  131282. private _reflectionControls;
  131283. private _white;
  131284. private _primaryShadowColor;
  131285. private _primaryHighlightColor;
  131286. /**
  131287. * Instantiates a Background Material in the given scene
  131288. * @param name The friendly name of the material
  131289. * @param scene The scene to add the material to
  131290. */
  131291. constructor(name: string, scene: Scene);
  131292. /**
  131293. * Gets a boolean indicating that current material needs to register RTT
  131294. */
  131295. get hasRenderTargetTextures(): boolean;
  131296. /**
  131297. * The entire material has been created in order to prevent overdraw.
  131298. * @returns false
  131299. */
  131300. needAlphaTesting(): boolean;
  131301. /**
  131302. * The entire material has been created in order to prevent overdraw.
  131303. * @returns true if blending is enable
  131304. */
  131305. needAlphaBlending(): boolean;
  131306. /**
  131307. * Checks wether the material is ready to be rendered for a given mesh.
  131308. * @param mesh The mesh to render
  131309. * @param subMesh The submesh to check against
  131310. * @param useInstances Specify wether or not the material is used with instances
  131311. * @returns true if all the dependencies are ready (Textures, Effects...)
  131312. */
  131313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131314. /**
  131315. * Compute the primary color according to the chosen perceptual color.
  131316. */
  131317. private _computePrimaryColorFromPerceptualColor;
  131318. /**
  131319. * Compute the highlights and shadow colors according to their chosen levels.
  131320. */
  131321. private _computePrimaryColors;
  131322. /**
  131323. * Build the uniform buffer used in the material.
  131324. */
  131325. buildUniformLayout(): void;
  131326. /**
  131327. * Unbind the material.
  131328. */
  131329. unbind(): void;
  131330. /**
  131331. * Bind only the world matrix to the material.
  131332. * @param world The world matrix to bind.
  131333. */
  131334. bindOnlyWorldMatrix(world: Matrix): void;
  131335. /**
  131336. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131337. * @param world The world matrix to bind.
  131338. * @param subMesh The submesh to bind for.
  131339. */
  131340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131341. /**
  131342. * Checks to see if a texture is used in the material.
  131343. * @param texture - Base texture to use.
  131344. * @returns - Boolean specifying if a texture is used in the material.
  131345. */
  131346. hasTexture(texture: BaseTexture): boolean;
  131347. /**
  131348. * Dispose the material.
  131349. * @param forceDisposeEffect Force disposal of the associated effect.
  131350. * @param forceDisposeTextures Force disposal of the associated textures.
  131351. */
  131352. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131353. /**
  131354. * Clones the material.
  131355. * @param name The cloned name.
  131356. * @returns The cloned material.
  131357. */
  131358. clone(name: string): BackgroundMaterial;
  131359. /**
  131360. * Serializes the current material to its JSON representation.
  131361. * @returns The JSON representation.
  131362. */
  131363. serialize(): any;
  131364. /**
  131365. * Gets the class name of the material
  131366. * @returns "BackgroundMaterial"
  131367. */
  131368. getClassName(): string;
  131369. /**
  131370. * Parse a JSON input to create back a background material.
  131371. * @param source The JSON data to parse
  131372. * @param scene The scene to create the parsed material in
  131373. * @param rootUrl The root url of the assets the material depends upon
  131374. * @returns the instantiated BackgroundMaterial.
  131375. */
  131376. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131377. }
  131378. }
  131379. declare module BABYLON {
  131380. /**
  131381. * Represents the different options available during the creation of
  131382. * a Environment helper.
  131383. *
  131384. * This can control the default ground, skybox and image processing setup of your scene.
  131385. */
  131386. export interface IEnvironmentHelperOptions {
  131387. /**
  131388. * Specifies whether or not to create a ground.
  131389. * True by default.
  131390. */
  131391. createGround: boolean;
  131392. /**
  131393. * Specifies the ground size.
  131394. * 15 by default.
  131395. */
  131396. groundSize: number;
  131397. /**
  131398. * The texture used on the ground for the main color.
  131399. * Comes from the BabylonJS CDN by default.
  131400. *
  131401. * Remarks: Can be either a texture or a url.
  131402. */
  131403. groundTexture: string | BaseTexture;
  131404. /**
  131405. * The color mixed in the ground texture by default.
  131406. * BabylonJS clearColor by default.
  131407. */
  131408. groundColor: Color3;
  131409. /**
  131410. * Specifies the ground opacity.
  131411. * 1 by default.
  131412. */
  131413. groundOpacity: number;
  131414. /**
  131415. * Enables the ground to receive shadows.
  131416. * True by default.
  131417. */
  131418. enableGroundShadow: boolean;
  131419. /**
  131420. * Helps preventing the shadow to be fully black on the ground.
  131421. * 0.5 by default.
  131422. */
  131423. groundShadowLevel: number;
  131424. /**
  131425. * Creates a mirror texture attach to the ground.
  131426. * false by default.
  131427. */
  131428. enableGroundMirror: boolean;
  131429. /**
  131430. * Specifies the ground mirror size ratio.
  131431. * 0.3 by default as the default kernel is 64.
  131432. */
  131433. groundMirrorSizeRatio: number;
  131434. /**
  131435. * Specifies the ground mirror blur kernel size.
  131436. * 64 by default.
  131437. */
  131438. groundMirrorBlurKernel: number;
  131439. /**
  131440. * Specifies the ground mirror visibility amount.
  131441. * 1 by default
  131442. */
  131443. groundMirrorAmount: number;
  131444. /**
  131445. * Specifies the ground mirror reflectance weight.
  131446. * This uses the standard weight of the background material to setup the fresnel effect
  131447. * of the mirror.
  131448. * 1 by default.
  131449. */
  131450. groundMirrorFresnelWeight: number;
  131451. /**
  131452. * Specifies the ground mirror Falloff distance.
  131453. * This can helps reducing the size of the reflection.
  131454. * 0 by Default.
  131455. */
  131456. groundMirrorFallOffDistance: number;
  131457. /**
  131458. * Specifies the ground mirror texture type.
  131459. * Unsigned Int by Default.
  131460. */
  131461. groundMirrorTextureType: number;
  131462. /**
  131463. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131464. * the shown objects.
  131465. */
  131466. groundYBias: number;
  131467. /**
  131468. * Specifies whether or not to create a skybox.
  131469. * True by default.
  131470. */
  131471. createSkybox: boolean;
  131472. /**
  131473. * Specifies the skybox size.
  131474. * 20 by default.
  131475. */
  131476. skyboxSize: number;
  131477. /**
  131478. * The texture used on the skybox for the main color.
  131479. * Comes from the BabylonJS CDN by default.
  131480. *
  131481. * Remarks: Can be either a texture or a url.
  131482. */
  131483. skyboxTexture: string | BaseTexture;
  131484. /**
  131485. * The color mixed in the skybox texture by default.
  131486. * BabylonJS clearColor by default.
  131487. */
  131488. skyboxColor: Color3;
  131489. /**
  131490. * The background rotation around the Y axis of the scene.
  131491. * This helps aligning the key lights of your scene with the background.
  131492. * 0 by default.
  131493. */
  131494. backgroundYRotation: number;
  131495. /**
  131496. * Compute automatically the size of the elements to best fit with the scene.
  131497. */
  131498. sizeAuto: boolean;
  131499. /**
  131500. * Default position of the rootMesh if autoSize is not true.
  131501. */
  131502. rootPosition: Vector3;
  131503. /**
  131504. * Sets up the image processing in the scene.
  131505. * true by default.
  131506. */
  131507. setupImageProcessing: boolean;
  131508. /**
  131509. * The texture used as your environment texture in the scene.
  131510. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131511. *
  131512. * Remarks: Can be either a texture or a url.
  131513. */
  131514. environmentTexture: string | BaseTexture;
  131515. /**
  131516. * The value of the exposure to apply to the scene.
  131517. * 0.6 by default if setupImageProcessing is true.
  131518. */
  131519. cameraExposure: number;
  131520. /**
  131521. * The value of the contrast to apply to the scene.
  131522. * 1.6 by default if setupImageProcessing is true.
  131523. */
  131524. cameraContrast: number;
  131525. /**
  131526. * Specifies whether or not tonemapping should be enabled in the scene.
  131527. * true by default if setupImageProcessing is true.
  131528. */
  131529. toneMappingEnabled: boolean;
  131530. }
  131531. /**
  131532. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131533. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131534. * It also helps with the default setup of your imageProcessing configuration.
  131535. */
  131536. export class EnvironmentHelper {
  131537. /**
  131538. * Default ground texture URL.
  131539. */
  131540. private static _groundTextureCDNUrl;
  131541. /**
  131542. * Default skybox texture URL.
  131543. */
  131544. private static _skyboxTextureCDNUrl;
  131545. /**
  131546. * Default environment texture URL.
  131547. */
  131548. private static _environmentTextureCDNUrl;
  131549. /**
  131550. * Creates the default options for the helper.
  131551. */
  131552. private static _getDefaultOptions;
  131553. private _rootMesh;
  131554. /**
  131555. * Gets the root mesh created by the helper.
  131556. */
  131557. get rootMesh(): Mesh;
  131558. private _skybox;
  131559. /**
  131560. * Gets the skybox created by the helper.
  131561. */
  131562. get skybox(): Nullable<Mesh>;
  131563. private _skyboxTexture;
  131564. /**
  131565. * Gets the skybox texture created by the helper.
  131566. */
  131567. get skyboxTexture(): Nullable<BaseTexture>;
  131568. private _skyboxMaterial;
  131569. /**
  131570. * Gets the skybox material created by the helper.
  131571. */
  131572. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131573. private _ground;
  131574. /**
  131575. * Gets the ground mesh created by the helper.
  131576. */
  131577. get ground(): Nullable<Mesh>;
  131578. private _groundTexture;
  131579. /**
  131580. * Gets the ground texture created by the helper.
  131581. */
  131582. get groundTexture(): Nullable<BaseTexture>;
  131583. private _groundMirror;
  131584. /**
  131585. * Gets the ground mirror created by the helper.
  131586. */
  131587. get groundMirror(): Nullable<MirrorTexture>;
  131588. /**
  131589. * Gets the ground mirror render list to helps pushing the meshes
  131590. * you wish in the ground reflection.
  131591. */
  131592. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131593. private _groundMaterial;
  131594. /**
  131595. * Gets the ground material created by the helper.
  131596. */
  131597. get groundMaterial(): Nullable<BackgroundMaterial>;
  131598. /**
  131599. * Stores the creation options.
  131600. */
  131601. private readonly _scene;
  131602. private _options;
  131603. /**
  131604. * This observable will be notified with any error during the creation of the environment,
  131605. * mainly texture creation errors.
  131606. */
  131607. onErrorObservable: Observable<{
  131608. message?: string;
  131609. exception?: any;
  131610. }>;
  131611. /**
  131612. * constructor
  131613. * @param options Defines the options we want to customize the helper
  131614. * @param scene The scene to add the material to
  131615. */
  131616. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131617. /**
  131618. * Updates the background according to the new options
  131619. * @param options
  131620. */
  131621. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131622. /**
  131623. * Sets the primary color of all the available elements.
  131624. * @param color the main color to affect to the ground and the background
  131625. */
  131626. setMainColor(color: Color3): void;
  131627. /**
  131628. * Setup the image processing according to the specified options.
  131629. */
  131630. private _setupImageProcessing;
  131631. /**
  131632. * Setup the environment texture according to the specified options.
  131633. */
  131634. private _setupEnvironmentTexture;
  131635. /**
  131636. * Setup the background according to the specified options.
  131637. */
  131638. private _setupBackground;
  131639. /**
  131640. * Get the scene sizes according to the setup.
  131641. */
  131642. private _getSceneSize;
  131643. /**
  131644. * Setup the ground according to the specified options.
  131645. */
  131646. private _setupGround;
  131647. /**
  131648. * Setup the ground material according to the specified options.
  131649. */
  131650. private _setupGroundMaterial;
  131651. /**
  131652. * Setup the ground diffuse texture according to the specified options.
  131653. */
  131654. private _setupGroundDiffuseTexture;
  131655. /**
  131656. * Setup the ground mirror texture according to the specified options.
  131657. */
  131658. private _setupGroundMirrorTexture;
  131659. /**
  131660. * Setup the ground to receive the mirror texture.
  131661. */
  131662. private _setupMirrorInGroundMaterial;
  131663. /**
  131664. * Setup the skybox according to the specified options.
  131665. */
  131666. private _setupSkybox;
  131667. /**
  131668. * Setup the skybox material according to the specified options.
  131669. */
  131670. private _setupSkyboxMaterial;
  131671. /**
  131672. * Setup the skybox reflection texture according to the specified options.
  131673. */
  131674. private _setupSkyboxReflectionTexture;
  131675. private _errorHandler;
  131676. /**
  131677. * Dispose all the elements created by the Helper.
  131678. */
  131679. dispose(): void;
  131680. }
  131681. }
  131682. declare module BABYLON {
  131683. /**
  131684. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131685. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131686. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131687. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131688. */
  131689. export class PhotoDome extends TransformNode {
  131690. /**
  131691. * Define the image as a Monoscopic panoramic 360 image.
  131692. */
  131693. static readonly MODE_MONOSCOPIC: number;
  131694. /**
  131695. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131696. */
  131697. static readonly MODE_TOPBOTTOM: number;
  131698. /**
  131699. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131700. */
  131701. static readonly MODE_SIDEBYSIDE: number;
  131702. private _useDirectMapping;
  131703. /**
  131704. * The texture being displayed on the sphere
  131705. */
  131706. protected _photoTexture: Texture;
  131707. /**
  131708. * Gets or sets the texture being displayed on the sphere
  131709. */
  131710. get photoTexture(): Texture;
  131711. set photoTexture(value: Texture);
  131712. /**
  131713. * Observable raised when an error occured while loading the 360 image
  131714. */
  131715. onLoadErrorObservable: Observable<string>;
  131716. /**
  131717. * The skybox material
  131718. */
  131719. protected _material: BackgroundMaterial;
  131720. /**
  131721. * The surface used for the skybox
  131722. */
  131723. protected _mesh: Mesh;
  131724. /**
  131725. * Gets the mesh used for the skybox.
  131726. */
  131727. get mesh(): Mesh;
  131728. /**
  131729. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131730. * Also see the options.resolution property.
  131731. */
  131732. get fovMultiplier(): number;
  131733. set fovMultiplier(value: number);
  131734. private _imageMode;
  131735. /**
  131736. * Gets or set the current video mode for the video. It can be:
  131737. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131738. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131739. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131740. */
  131741. get imageMode(): number;
  131742. set imageMode(value: number);
  131743. /**
  131744. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131745. * @param name Element's name, child elements will append suffixes for their own names.
  131746. * @param urlsOfPhoto defines the url of the photo to display
  131747. * @param options defines an object containing optional or exposed sub element properties
  131748. * @param onError defines a callback called when an error occured while loading the texture
  131749. */
  131750. constructor(name: string, urlOfPhoto: string, options: {
  131751. resolution?: number;
  131752. size?: number;
  131753. useDirectMapping?: boolean;
  131754. faceForward?: boolean;
  131755. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131756. private _onBeforeCameraRenderObserver;
  131757. private _changeImageMode;
  131758. /**
  131759. * Releases resources associated with this node.
  131760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131762. */
  131763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131764. }
  131765. }
  131766. declare module BABYLON {
  131767. /**
  131768. * Class used to host RGBD texture specific utilities
  131769. */
  131770. export class RGBDTextureTools {
  131771. /**
  131772. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131773. * @param texture the texture to expand.
  131774. */
  131775. static ExpandRGBDTexture(texture: Texture): void;
  131776. }
  131777. }
  131778. declare module BABYLON {
  131779. /**
  131780. * Class used to host texture specific utilities
  131781. */
  131782. export class BRDFTextureTools {
  131783. /**
  131784. * Prevents texture cache collision
  131785. */
  131786. private static _instanceNumber;
  131787. /**
  131788. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131789. * @param scene defines the hosting scene
  131790. * @returns the environment BRDF texture
  131791. */
  131792. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131793. private static _environmentBRDFBase64Texture;
  131794. }
  131795. }
  131796. declare module BABYLON {
  131797. /**
  131798. * @hidden
  131799. */
  131800. export interface IMaterialClearCoatDefines {
  131801. CLEARCOAT: boolean;
  131802. CLEARCOAT_DEFAULTIOR: boolean;
  131803. CLEARCOAT_TEXTURE: boolean;
  131804. CLEARCOAT_TEXTUREDIRECTUV: number;
  131805. CLEARCOAT_BUMP: boolean;
  131806. CLEARCOAT_BUMPDIRECTUV: number;
  131807. CLEARCOAT_TINT: boolean;
  131808. CLEARCOAT_TINT_TEXTURE: boolean;
  131809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131810. /** @hidden */
  131811. _areTexturesDirty: boolean;
  131812. }
  131813. /**
  131814. * Define the code related to the clear coat parameters of the pbr material.
  131815. */
  131816. export class PBRClearCoatConfiguration {
  131817. /**
  131818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131819. * The default fits with a polyurethane material.
  131820. */
  131821. private static readonly _DefaultIndexOfRefraction;
  131822. private _isEnabled;
  131823. /**
  131824. * Defines if the clear coat is enabled in the material.
  131825. */
  131826. isEnabled: boolean;
  131827. /**
  131828. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131829. */
  131830. intensity: number;
  131831. /**
  131832. * Defines the clear coat layer roughness.
  131833. */
  131834. roughness: number;
  131835. private _indexOfRefraction;
  131836. /**
  131837. * Defines the index of refraction of the clear coat.
  131838. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131839. * The default fits with a polyurethane material.
  131840. * Changing the default value is more performance intensive.
  131841. */
  131842. indexOfRefraction: number;
  131843. private _texture;
  131844. /**
  131845. * Stores the clear coat values in a texture.
  131846. */
  131847. texture: Nullable<BaseTexture>;
  131848. private _bumpTexture;
  131849. /**
  131850. * Define the clear coat specific bump texture.
  131851. */
  131852. bumpTexture: Nullable<BaseTexture>;
  131853. private _isTintEnabled;
  131854. /**
  131855. * Defines if the clear coat tint is enabled in the material.
  131856. */
  131857. isTintEnabled: boolean;
  131858. /**
  131859. * Defines the clear coat tint of the material.
  131860. * This is only use if tint is enabled
  131861. */
  131862. tintColor: Color3;
  131863. /**
  131864. * Defines the distance at which the tint color should be found in the
  131865. * clear coat media.
  131866. * This is only use if tint is enabled
  131867. */
  131868. tintColorAtDistance: number;
  131869. /**
  131870. * Defines the clear coat layer thickness.
  131871. * This is only use if tint is enabled
  131872. */
  131873. tintThickness: number;
  131874. private _tintTexture;
  131875. /**
  131876. * Stores the clear tint values in a texture.
  131877. * rgb is tint
  131878. * a is a thickness factor
  131879. */
  131880. tintTexture: Nullable<BaseTexture>;
  131881. /** @hidden */
  131882. private _internalMarkAllSubMeshesAsTexturesDirty;
  131883. /** @hidden */
  131884. _markAllSubMeshesAsTexturesDirty(): void;
  131885. /**
  131886. * Instantiate a new istance of clear coat configuration.
  131887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131888. */
  131889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131890. /**
  131891. * Gets wehter the submesh is ready to be used or not.
  131892. * @param defines the list of "defines" to update.
  131893. * @param scene defines the scene the material belongs to.
  131894. * @param engine defines the engine the material belongs to.
  131895. * @param disableBumpMap defines wether the material disables bump or not.
  131896. * @returns - boolean indicating that the submesh is ready or not.
  131897. */
  131898. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131899. /**
  131900. * Checks to see if a texture is used in the material.
  131901. * @param defines the list of "defines" to update.
  131902. * @param scene defines the scene to the material belongs to.
  131903. */
  131904. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131905. /**
  131906. * Binds the material data.
  131907. * @param uniformBuffer defines the Uniform buffer to fill in.
  131908. * @param scene defines the scene the material belongs to.
  131909. * @param engine defines the engine the material belongs to.
  131910. * @param disableBumpMap defines wether the material disables bump or not.
  131911. * @param isFrozen defines wether the material is frozen or not.
  131912. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131913. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131914. */
  131915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131916. /**
  131917. * Checks to see if a texture is used in the material.
  131918. * @param texture - Base texture to use.
  131919. * @returns - Boolean specifying if a texture is used in the material.
  131920. */
  131921. hasTexture(texture: BaseTexture): boolean;
  131922. /**
  131923. * Returns an array of the actively used textures.
  131924. * @param activeTextures Array of BaseTextures
  131925. */
  131926. getActiveTextures(activeTextures: BaseTexture[]): void;
  131927. /**
  131928. * Returns the animatable textures.
  131929. * @param animatables Array of animatable textures.
  131930. */
  131931. getAnimatables(animatables: IAnimatable[]): void;
  131932. /**
  131933. * Disposes the resources of the material.
  131934. * @param forceDisposeTextures - Forces the disposal of all textures.
  131935. */
  131936. dispose(forceDisposeTextures?: boolean): void;
  131937. /**
  131938. * Get the current class name of the texture useful for serialization or dynamic coding.
  131939. * @returns "PBRClearCoatConfiguration"
  131940. */
  131941. getClassName(): string;
  131942. /**
  131943. * Add fallbacks to the effect fallbacks list.
  131944. * @param defines defines the Base texture to use.
  131945. * @param fallbacks defines the current fallback list.
  131946. * @param currentRank defines the current fallback rank.
  131947. * @returns the new fallback rank.
  131948. */
  131949. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131950. /**
  131951. * Add the required uniforms to the current list.
  131952. * @param uniforms defines the current uniform list.
  131953. */
  131954. static AddUniforms(uniforms: string[]): void;
  131955. /**
  131956. * Add the required samplers to the current list.
  131957. * @param samplers defines the current sampler list.
  131958. */
  131959. static AddSamplers(samplers: string[]): void;
  131960. /**
  131961. * Add the required uniforms to the current buffer.
  131962. * @param uniformBuffer defines the current uniform buffer.
  131963. */
  131964. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131965. /**
  131966. * Makes a duplicate of the current configuration into another one.
  131967. * @param clearCoatConfiguration define the config where to copy the info
  131968. */
  131969. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131970. /**
  131971. * Serializes this clear coat configuration.
  131972. * @returns - An object with the serialized config.
  131973. */
  131974. serialize(): any;
  131975. /**
  131976. * Parses a anisotropy Configuration from a serialized object.
  131977. * @param source - Serialized object.
  131978. * @param scene Defines the scene we are parsing for
  131979. * @param rootUrl Defines the rootUrl to load from
  131980. */
  131981. parse(source: any, scene: Scene, rootUrl: string): void;
  131982. }
  131983. }
  131984. declare module BABYLON {
  131985. /**
  131986. * @hidden
  131987. */
  131988. export interface IMaterialAnisotropicDefines {
  131989. ANISOTROPIC: boolean;
  131990. ANISOTROPIC_TEXTURE: boolean;
  131991. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131992. MAINUV1: boolean;
  131993. _areTexturesDirty: boolean;
  131994. _needUVs: boolean;
  131995. }
  131996. /**
  131997. * Define the code related to the anisotropic parameters of the pbr material.
  131998. */
  131999. export class PBRAnisotropicConfiguration {
  132000. private _isEnabled;
  132001. /**
  132002. * Defines if the anisotropy is enabled in the material.
  132003. */
  132004. isEnabled: boolean;
  132005. /**
  132006. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132007. */
  132008. intensity: number;
  132009. /**
  132010. * Defines if the effect is along the tangents, bitangents or in between.
  132011. * By default, the effect is "strectching" the highlights along the tangents.
  132012. */
  132013. direction: Vector2;
  132014. private _texture;
  132015. /**
  132016. * Stores the anisotropy values in a texture.
  132017. * rg is direction (like normal from -1 to 1)
  132018. * b is a intensity
  132019. */
  132020. texture: Nullable<BaseTexture>;
  132021. /** @hidden */
  132022. private _internalMarkAllSubMeshesAsTexturesDirty;
  132023. /** @hidden */
  132024. _markAllSubMeshesAsTexturesDirty(): void;
  132025. /**
  132026. * Instantiate a new istance of anisotropy configuration.
  132027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132028. */
  132029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132030. /**
  132031. * Specifies that the submesh is ready to be used.
  132032. * @param defines the list of "defines" to update.
  132033. * @param scene defines the scene the material belongs to.
  132034. * @returns - boolean indicating that the submesh is ready or not.
  132035. */
  132036. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132037. /**
  132038. * Checks to see if a texture is used in the material.
  132039. * @param defines the list of "defines" to update.
  132040. * @param mesh the mesh we are preparing the defines for.
  132041. * @param scene defines the scene the material belongs to.
  132042. */
  132043. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132044. /**
  132045. * Binds the material data.
  132046. * @param uniformBuffer defines the Uniform buffer to fill in.
  132047. * @param scene defines the scene the material belongs to.
  132048. * @param isFrozen defines wether the material is frozen or not.
  132049. */
  132050. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132051. /**
  132052. * Checks to see if a texture is used in the material.
  132053. * @param texture - Base texture to use.
  132054. * @returns - Boolean specifying if a texture is used in the material.
  132055. */
  132056. hasTexture(texture: BaseTexture): boolean;
  132057. /**
  132058. * Returns an array of the actively used textures.
  132059. * @param activeTextures Array of BaseTextures
  132060. */
  132061. getActiveTextures(activeTextures: BaseTexture[]): void;
  132062. /**
  132063. * Returns the animatable textures.
  132064. * @param animatables Array of animatable textures.
  132065. */
  132066. getAnimatables(animatables: IAnimatable[]): void;
  132067. /**
  132068. * Disposes the resources of the material.
  132069. * @param forceDisposeTextures - Forces the disposal of all textures.
  132070. */
  132071. dispose(forceDisposeTextures?: boolean): void;
  132072. /**
  132073. * Get the current class name of the texture useful for serialization or dynamic coding.
  132074. * @returns "PBRAnisotropicConfiguration"
  132075. */
  132076. getClassName(): string;
  132077. /**
  132078. * Add fallbacks to the effect fallbacks list.
  132079. * @param defines defines the Base texture to use.
  132080. * @param fallbacks defines the current fallback list.
  132081. * @param currentRank defines the current fallback rank.
  132082. * @returns the new fallback rank.
  132083. */
  132084. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132085. /**
  132086. * Add the required uniforms to the current list.
  132087. * @param uniforms defines the current uniform list.
  132088. */
  132089. static AddUniforms(uniforms: string[]): void;
  132090. /**
  132091. * Add the required uniforms to the current buffer.
  132092. * @param uniformBuffer defines the current uniform buffer.
  132093. */
  132094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132095. /**
  132096. * Add the required samplers to the current list.
  132097. * @param samplers defines the current sampler list.
  132098. */
  132099. static AddSamplers(samplers: string[]): void;
  132100. /**
  132101. * Makes a duplicate of the current configuration into another one.
  132102. * @param anisotropicConfiguration define the config where to copy the info
  132103. */
  132104. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132105. /**
  132106. * Serializes this anisotropy configuration.
  132107. * @returns - An object with the serialized config.
  132108. */
  132109. serialize(): any;
  132110. /**
  132111. * Parses a anisotropy Configuration from a serialized object.
  132112. * @param source - Serialized object.
  132113. * @param scene Defines the scene we are parsing for
  132114. * @param rootUrl Defines the rootUrl to load from
  132115. */
  132116. parse(source: any, scene: Scene, rootUrl: string): void;
  132117. }
  132118. }
  132119. declare module BABYLON {
  132120. /**
  132121. * @hidden
  132122. */
  132123. export interface IMaterialBRDFDefines {
  132124. BRDF_V_HEIGHT_CORRELATED: boolean;
  132125. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132126. SPHERICAL_HARMONICS: boolean;
  132127. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132128. /** @hidden */
  132129. _areMiscDirty: boolean;
  132130. }
  132131. /**
  132132. * Define the code related to the BRDF parameters of the pbr material.
  132133. */
  132134. export class PBRBRDFConfiguration {
  132135. /**
  132136. * Default value used for the energy conservation.
  132137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132138. */
  132139. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132140. /**
  132141. * Default value used for the Smith Visibility Height Correlated mode.
  132142. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132143. */
  132144. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132145. /**
  132146. * Default value used for the IBL diffuse part.
  132147. * This can help switching back to the polynomials mode globally which is a tiny bit
  132148. * less GPU intensive at the drawback of a lower quality.
  132149. */
  132150. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132151. /**
  132152. * Default value used for activating energy conservation for the specular workflow.
  132153. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132154. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132155. */
  132156. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132157. private _useEnergyConservation;
  132158. /**
  132159. * Defines if the material uses energy conservation.
  132160. */
  132161. useEnergyConservation: boolean;
  132162. private _useSmithVisibilityHeightCorrelated;
  132163. /**
  132164. * LEGACY Mode set to false
  132165. * Defines if the material uses height smith correlated visibility term.
  132166. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132167. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132168. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132169. * Not relying on height correlated will also disable energy conservation.
  132170. */
  132171. useSmithVisibilityHeightCorrelated: boolean;
  132172. private _useSphericalHarmonics;
  132173. /**
  132174. * LEGACY Mode set to false
  132175. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132176. * diffuse part of the IBL.
  132177. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132178. * to the ground truth.
  132179. */
  132180. useSphericalHarmonics: boolean;
  132181. private _useSpecularGlossinessInputEnergyConservation;
  132182. /**
  132183. * Defines if the material uses energy conservation, when the specular workflow is active.
  132184. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132185. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132186. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132187. */
  132188. useSpecularGlossinessInputEnergyConservation: boolean;
  132189. /** @hidden */
  132190. private _internalMarkAllSubMeshesAsMiscDirty;
  132191. /** @hidden */
  132192. _markAllSubMeshesAsMiscDirty(): void;
  132193. /**
  132194. * Instantiate a new istance of clear coat configuration.
  132195. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132196. */
  132197. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132198. /**
  132199. * Checks to see if a texture is used in the material.
  132200. * @param defines the list of "defines" to update.
  132201. */
  132202. prepareDefines(defines: IMaterialBRDFDefines): void;
  132203. /**
  132204. * Get the current class name of the texture useful for serialization or dynamic coding.
  132205. * @returns "PBRClearCoatConfiguration"
  132206. */
  132207. getClassName(): string;
  132208. /**
  132209. * Makes a duplicate of the current configuration into another one.
  132210. * @param brdfConfiguration define the config where to copy the info
  132211. */
  132212. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132213. /**
  132214. * Serializes this BRDF configuration.
  132215. * @returns - An object with the serialized config.
  132216. */
  132217. serialize(): any;
  132218. /**
  132219. * Parses a anisotropy Configuration from a serialized object.
  132220. * @param source - Serialized object.
  132221. * @param scene Defines the scene we are parsing for
  132222. * @param rootUrl Defines the rootUrl to load from
  132223. */
  132224. parse(source: any, scene: Scene, rootUrl: string): void;
  132225. }
  132226. }
  132227. declare module BABYLON {
  132228. /**
  132229. * @hidden
  132230. */
  132231. export interface IMaterialSheenDefines {
  132232. SHEEN: boolean;
  132233. SHEEN_TEXTURE: boolean;
  132234. SHEEN_TEXTUREDIRECTUV: number;
  132235. SHEEN_LINKWITHALBEDO: boolean;
  132236. SHEEN_ROUGHNESS: boolean;
  132237. SHEEN_ALBEDOSCALING: boolean;
  132238. /** @hidden */
  132239. _areTexturesDirty: boolean;
  132240. }
  132241. /**
  132242. * Define the code related to the Sheen parameters of the pbr material.
  132243. */
  132244. export class PBRSheenConfiguration {
  132245. private _isEnabled;
  132246. /**
  132247. * Defines if the material uses sheen.
  132248. */
  132249. isEnabled: boolean;
  132250. private _linkSheenWithAlbedo;
  132251. /**
  132252. * Defines if the sheen is linked to the sheen color.
  132253. */
  132254. linkSheenWithAlbedo: boolean;
  132255. /**
  132256. * Defines the sheen intensity.
  132257. */
  132258. intensity: number;
  132259. /**
  132260. * Defines the sheen color.
  132261. */
  132262. color: Color3;
  132263. private _texture;
  132264. /**
  132265. * Stores the sheen tint values in a texture.
  132266. * rgb is tint
  132267. * a is a intensity or roughness if roughness has been defined
  132268. */
  132269. texture: Nullable<BaseTexture>;
  132270. private _roughness;
  132271. /**
  132272. * Defines the sheen roughness.
  132273. * It is not taken into account if linkSheenWithAlbedo is true.
  132274. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132275. */
  132276. roughness: Nullable<number>;
  132277. private _albedoScaling;
  132278. /**
  132279. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132280. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132281. * making it easier to setup and tweak the effect
  132282. */
  132283. albedoScaling: boolean;
  132284. /** @hidden */
  132285. private _internalMarkAllSubMeshesAsTexturesDirty;
  132286. /** @hidden */
  132287. _markAllSubMeshesAsTexturesDirty(): void;
  132288. /**
  132289. * Instantiate a new istance of clear coat configuration.
  132290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132291. */
  132292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132293. /**
  132294. * Specifies that the submesh is ready to be used.
  132295. * @param defines the list of "defines" to update.
  132296. * @param scene defines the scene the material belongs to.
  132297. * @returns - boolean indicating that the submesh is ready or not.
  132298. */
  132299. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132300. /**
  132301. * Checks to see if a texture is used in the material.
  132302. * @param defines the list of "defines" to update.
  132303. * @param scene defines the scene the material belongs to.
  132304. */
  132305. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132306. /**
  132307. * Binds the material data.
  132308. * @param uniformBuffer defines the Uniform buffer to fill in.
  132309. * @param scene defines the scene the material belongs to.
  132310. * @param isFrozen defines wether the material is frozen or not.
  132311. */
  132312. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132313. /**
  132314. * Checks to see if a texture is used in the material.
  132315. * @param texture - Base texture to use.
  132316. * @returns - Boolean specifying if a texture is used in the material.
  132317. */
  132318. hasTexture(texture: BaseTexture): boolean;
  132319. /**
  132320. * Returns an array of the actively used textures.
  132321. * @param activeTextures Array of BaseTextures
  132322. */
  132323. getActiveTextures(activeTextures: BaseTexture[]): void;
  132324. /**
  132325. * Returns the animatable textures.
  132326. * @param animatables Array of animatable textures.
  132327. */
  132328. getAnimatables(animatables: IAnimatable[]): void;
  132329. /**
  132330. * Disposes the resources of the material.
  132331. * @param forceDisposeTextures - Forces the disposal of all textures.
  132332. */
  132333. dispose(forceDisposeTextures?: boolean): void;
  132334. /**
  132335. * Get the current class name of the texture useful for serialization or dynamic coding.
  132336. * @returns "PBRSheenConfiguration"
  132337. */
  132338. getClassName(): string;
  132339. /**
  132340. * Add fallbacks to the effect fallbacks list.
  132341. * @param defines defines the Base texture to use.
  132342. * @param fallbacks defines the current fallback list.
  132343. * @param currentRank defines the current fallback rank.
  132344. * @returns the new fallback rank.
  132345. */
  132346. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132347. /**
  132348. * Add the required uniforms to the current list.
  132349. * @param uniforms defines the current uniform list.
  132350. */
  132351. static AddUniforms(uniforms: string[]): void;
  132352. /**
  132353. * Add the required uniforms to the current buffer.
  132354. * @param uniformBuffer defines the current uniform buffer.
  132355. */
  132356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132357. /**
  132358. * Add the required samplers to the current list.
  132359. * @param samplers defines the current sampler list.
  132360. */
  132361. static AddSamplers(samplers: string[]): void;
  132362. /**
  132363. * Makes a duplicate of the current configuration into another one.
  132364. * @param sheenConfiguration define the config where to copy the info
  132365. */
  132366. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132367. /**
  132368. * Serializes this BRDF configuration.
  132369. * @returns - An object with the serialized config.
  132370. */
  132371. serialize(): any;
  132372. /**
  132373. * Parses a anisotropy Configuration from a serialized object.
  132374. * @param source - Serialized object.
  132375. * @param scene Defines the scene we are parsing for
  132376. * @param rootUrl Defines the rootUrl to load from
  132377. */
  132378. parse(source: any, scene: Scene, rootUrl: string): void;
  132379. }
  132380. }
  132381. declare module BABYLON {
  132382. /**
  132383. * @hidden
  132384. */
  132385. export interface IMaterialSubSurfaceDefines {
  132386. SUBSURFACE: boolean;
  132387. SS_REFRACTION: boolean;
  132388. SS_TRANSLUCENCY: boolean;
  132389. SS_SCATTERING: boolean;
  132390. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132391. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132392. SS_REFRACTIONMAP_3D: boolean;
  132393. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132394. SS_LODINREFRACTIONALPHA: boolean;
  132395. SS_GAMMAREFRACTION: boolean;
  132396. SS_RGBDREFRACTION: boolean;
  132397. SS_LINEARSPECULARREFRACTION: boolean;
  132398. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132399. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132400. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132401. /** @hidden */
  132402. _areTexturesDirty: boolean;
  132403. }
  132404. /**
  132405. * Define the code related to the sub surface parameters of the pbr material.
  132406. */
  132407. export class PBRSubSurfaceConfiguration {
  132408. private _isRefractionEnabled;
  132409. /**
  132410. * Defines if the refraction is enabled in the material.
  132411. */
  132412. isRefractionEnabled: boolean;
  132413. private _isTranslucencyEnabled;
  132414. /**
  132415. * Defines if the translucency is enabled in the material.
  132416. */
  132417. isTranslucencyEnabled: boolean;
  132418. private _isScatteringEnabled;
  132419. /**
  132420. * Defines the refraction intensity of the material.
  132421. * The refraction when enabled replaces the Diffuse part of the material.
  132422. * The intensity helps transitionning between diffuse and refraction.
  132423. */
  132424. refractionIntensity: number;
  132425. /**
  132426. * Defines the translucency intensity of the material.
  132427. * When translucency has been enabled, this defines how much of the "translucency"
  132428. * is addded to the diffuse part of the material.
  132429. */
  132430. translucencyIntensity: number;
  132431. /**
  132432. * Defines the scattering intensity of the material.
  132433. * When scattering has been enabled, this defines how much of the "scattered light"
  132434. * is addded to the diffuse part of the material.
  132435. */
  132436. scatteringIntensity: number;
  132437. /**
  132438. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132439. */
  132440. useAlbedoToTintRefraction: boolean;
  132441. private _thicknessTexture;
  132442. /**
  132443. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132444. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132445. * 0 would mean minimumThickness
  132446. * 1 would mean maximumThickness
  132447. * The other channels might be use as a mask to vary the different effects intensity.
  132448. */
  132449. thicknessTexture: Nullable<BaseTexture>;
  132450. private _refractionTexture;
  132451. /**
  132452. * Defines the texture to use for refraction.
  132453. */
  132454. refractionTexture: Nullable<BaseTexture>;
  132455. private _indexOfRefraction;
  132456. /**
  132457. * Index of refraction of the material base layer.
  132458. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132459. *
  132460. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132461. *
  132462. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132463. */
  132464. indexOfRefraction: number;
  132465. private _volumeIndexOfRefraction;
  132466. /**
  132467. * Index of refraction of the material's volume.
  132468. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132469. *
  132470. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132471. * the volume will use the same IOR as the surface.
  132472. */
  132473. get volumeIndexOfRefraction(): number;
  132474. set volumeIndexOfRefraction(value: number);
  132475. private _invertRefractionY;
  132476. /**
  132477. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132478. */
  132479. invertRefractionY: boolean;
  132480. private _linkRefractionWithTransparency;
  132481. /**
  132482. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132483. * Materials half opaque for instance using refraction could benefit from this control.
  132484. */
  132485. linkRefractionWithTransparency: boolean;
  132486. /**
  132487. * Defines the minimum thickness stored in the thickness map.
  132488. * If no thickness map is defined, this value will be used to simulate thickness.
  132489. */
  132490. minimumThickness: number;
  132491. /**
  132492. * Defines the maximum thickness stored in the thickness map.
  132493. */
  132494. maximumThickness: number;
  132495. /**
  132496. * Defines the volume tint of the material.
  132497. * This is used for both translucency and scattering.
  132498. */
  132499. tintColor: Color3;
  132500. /**
  132501. * Defines the distance at which the tint color should be found in the media.
  132502. * This is used for refraction only.
  132503. */
  132504. tintColorAtDistance: number;
  132505. /**
  132506. * Defines how far each channel transmit through the media.
  132507. * It is defined as a color to simplify it selection.
  132508. */
  132509. diffusionDistance: Color3;
  132510. private _useMaskFromThicknessTexture;
  132511. /**
  132512. * Stores the intensity of the different subsurface effects in the thickness texture.
  132513. * * the green channel is the translucency intensity.
  132514. * * the blue channel is the scattering intensity.
  132515. * * the alpha channel is the refraction intensity.
  132516. */
  132517. useMaskFromThicknessTexture: boolean;
  132518. /** @hidden */
  132519. private _internalMarkAllSubMeshesAsTexturesDirty;
  132520. /** @hidden */
  132521. _markAllSubMeshesAsTexturesDirty(): void;
  132522. /**
  132523. * Instantiate a new istance of sub surface configuration.
  132524. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132525. */
  132526. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132527. /**
  132528. * Gets wehter the submesh is ready to be used or not.
  132529. * @param defines the list of "defines" to update.
  132530. * @param scene defines the scene the material belongs to.
  132531. * @returns - boolean indicating that the submesh is ready or not.
  132532. */
  132533. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132534. /**
  132535. * Checks to see if a texture is used in the material.
  132536. * @param defines the list of "defines" to update.
  132537. * @param scene defines the scene to the material belongs to.
  132538. */
  132539. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132540. /**
  132541. * Binds the material data.
  132542. * @param uniformBuffer defines the Uniform buffer to fill in.
  132543. * @param scene defines the scene the material belongs to.
  132544. * @param engine defines the engine the material belongs to.
  132545. * @param isFrozen defines whether the material is frozen or not.
  132546. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132547. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132548. */
  132549. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132550. /**
  132551. * Unbinds the material from the mesh.
  132552. * @param activeEffect defines the effect that should be unbound from.
  132553. * @returns true if unbound, otherwise false
  132554. */
  132555. unbind(activeEffect: Effect): boolean;
  132556. /**
  132557. * Returns the texture used for refraction or null if none is used.
  132558. * @param scene defines the scene the material belongs to.
  132559. * @returns - Refraction texture if present. If no refraction texture and refraction
  132560. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132561. */
  132562. private _getRefractionTexture;
  132563. /**
  132564. * Returns true if alpha blending should be disabled.
  132565. */
  132566. get disableAlphaBlending(): boolean;
  132567. /**
  132568. * Fills the list of render target textures.
  132569. * @param renderTargets the list of render targets to update
  132570. */
  132571. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132572. /**
  132573. * Checks to see if a texture is used in the material.
  132574. * @param texture - Base texture to use.
  132575. * @returns - Boolean specifying if a texture is used in the material.
  132576. */
  132577. hasTexture(texture: BaseTexture): boolean;
  132578. /**
  132579. * Gets a boolean indicating that current material needs to register RTT
  132580. * @returns true if this uses a render target otherwise false.
  132581. */
  132582. hasRenderTargetTextures(): boolean;
  132583. /**
  132584. * Returns an array of the actively used textures.
  132585. * @param activeTextures Array of BaseTextures
  132586. */
  132587. getActiveTextures(activeTextures: BaseTexture[]): void;
  132588. /**
  132589. * Returns the animatable textures.
  132590. * @param animatables Array of animatable textures.
  132591. */
  132592. getAnimatables(animatables: IAnimatable[]): void;
  132593. /**
  132594. * Disposes the resources of the material.
  132595. * @param forceDisposeTextures - Forces the disposal of all textures.
  132596. */
  132597. dispose(forceDisposeTextures?: boolean): void;
  132598. /**
  132599. * Get the current class name of the texture useful for serialization or dynamic coding.
  132600. * @returns "PBRSubSurfaceConfiguration"
  132601. */
  132602. getClassName(): string;
  132603. /**
  132604. * Add fallbacks to the effect fallbacks list.
  132605. * @param defines defines the Base texture to use.
  132606. * @param fallbacks defines the current fallback list.
  132607. * @param currentRank defines the current fallback rank.
  132608. * @returns the new fallback rank.
  132609. */
  132610. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132611. /**
  132612. * Add the required uniforms to the current list.
  132613. * @param uniforms defines the current uniform list.
  132614. */
  132615. static AddUniforms(uniforms: string[]): void;
  132616. /**
  132617. * Add the required samplers to the current list.
  132618. * @param samplers defines the current sampler list.
  132619. */
  132620. static AddSamplers(samplers: string[]): void;
  132621. /**
  132622. * Add the required uniforms to the current buffer.
  132623. * @param uniformBuffer defines the current uniform buffer.
  132624. */
  132625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132626. /**
  132627. * Makes a duplicate of the current configuration into another one.
  132628. * @param configuration define the config where to copy the info
  132629. */
  132630. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132631. /**
  132632. * Serializes this Sub Surface configuration.
  132633. * @returns - An object with the serialized config.
  132634. */
  132635. serialize(): any;
  132636. /**
  132637. * Parses a anisotropy Configuration from a serialized object.
  132638. * @param source - Serialized object.
  132639. * @param scene Defines the scene we are parsing for
  132640. * @param rootUrl Defines the rootUrl to load from
  132641. */
  132642. parse(source: any, scene: Scene, rootUrl: string): void;
  132643. }
  132644. }
  132645. declare module BABYLON {
  132646. /** @hidden */
  132647. export var pbrFragmentDeclaration: {
  132648. name: string;
  132649. shader: string;
  132650. };
  132651. }
  132652. declare module BABYLON {
  132653. /** @hidden */
  132654. export var pbrUboDeclaration: {
  132655. name: string;
  132656. shader: string;
  132657. };
  132658. }
  132659. declare module BABYLON {
  132660. /** @hidden */
  132661. export var pbrFragmentExtraDeclaration: {
  132662. name: string;
  132663. shader: string;
  132664. };
  132665. }
  132666. declare module BABYLON {
  132667. /** @hidden */
  132668. export var pbrFragmentSamplersDeclaration: {
  132669. name: string;
  132670. shader: string;
  132671. };
  132672. }
  132673. declare module BABYLON {
  132674. /** @hidden */
  132675. export var importanceSampling: {
  132676. name: string;
  132677. shader: string;
  132678. };
  132679. }
  132680. declare module BABYLON {
  132681. /** @hidden */
  132682. export var pbrHelperFunctions: {
  132683. name: string;
  132684. shader: string;
  132685. };
  132686. }
  132687. declare module BABYLON {
  132688. /** @hidden */
  132689. export var harmonicsFunctions: {
  132690. name: string;
  132691. shader: string;
  132692. };
  132693. }
  132694. declare module BABYLON {
  132695. /** @hidden */
  132696. export var pbrDirectLightingSetupFunctions: {
  132697. name: string;
  132698. shader: string;
  132699. };
  132700. }
  132701. declare module BABYLON {
  132702. /** @hidden */
  132703. export var pbrDirectLightingFalloffFunctions: {
  132704. name: string;
  132705. shader: string;
  132706. };
  132707. }
  132708. declare module BABYLON {
  132709. /** @hidden */
  132710. export var pbrBRDFFunctions: {
  132711. name: string;
  132712. shader: string;
  132713. };
  132714. }
  132715. declare module BABYLON {
  132716. /** @hidden */
  132717. export var hdrFilteringFunctions: {
  132718. name: string;
  132719. shader: string;
  132720. };
  132721. }
  132722. declare module BABYLON {
  132723. /** @hidden */
  132724. export var pbrDirectLightingFunctions: {
  132725. name: string;
  132726. shader: string;
  132727. };
  132728. }
  132729. declare module BABYLON {
  132730. /** @hidden */
  132731. export var pbrIBLFunctions: {
  132732. name: string;
  132733. shader: string;
  132734. };
  132735. }
  132736. declare module BABYLON {
  132737. /** @hidden */
  132738. export var pbrBlockAlbedoOpacity: {
  132739. name: string;
  132740. shader: string;
  132741. };
  132742. }
  132743. declare module BABYLON {
  132744. /** @hidden */
  132745. export var pbrBlockReflectivity: {
  132746. name: string;
  132747. shader: string;
  132748. };
  132749. }
  132750. declare module BABYLON {
  132751. /** @hidden */
  132752. export var pbrBlockAmbientOcclusion: {
  132753. name: string;
  132754. shader: string;
  132755. };
  132756. }
  132757. declare module BABYLON {
  132758. /** @hidden */
  132759. export var pbrBlockAlphaFresnel: {
  132760. name: string;
  132761. shader: string;
  132762. };
  132763. }
  132764. declare module BABYLON {
  132765. /** @hidden */
  132766. export var pbrBlockAnisotropic: {
  132767. name: string;
  132768. shader: string;
  132769. };
  132770. }
  132771. declare module BABYLON {
  132772. /** @hidden */
  132773. export var pbrBlockReflection: {
  132774. name: string;
  132775. shader: string;
  132776. };
  132777. }
  132778. declare module BABYLON {
  132779. /** @hidden */
  132780. export var pbrBlockSheen: {
  132781. name: string;
  132782. shader: string;
  132783. };
  132784. }
  132785. declare module BABYLON {
  132786. /** @hidden */
  132787. export var pbrBlockClearcoat: {
  132788. name: string;
  132789. shader: string;
  132790. };
  132791. }
  132792. declare module BABYLON {
  132793. /** @hidden */
  132794. export var pbrBlockSubSurface: {
  132795. name: string;
  132796. shader: string;
  132797. };
  132798. }
  132799. declare module BABYLON {
  132800. /** @hidden */
  132801. export var pbrBlockNormalGeometric: {
  132802. name: string;
  132803. shader: string;
  132804. };
  132805. }
  132806. declare module BABYLON {
  132807. /** @hidden */
  132808. export var pbrBlockNormalFinal: {
  132809. name: string;
  132810. shader: string;
  132811. };
  132812. }
  132813. declare module BABYLON {
  132814. /** @hidden */
  132815. export var pbrBlockGeometryInfo: {
  132816. name: string;
  132817. shader: string;
  132818. };
  132819. }
  132820. declare module BABYLON {
  132821. /** @hidden */
  132822. export var pbrBlockReflectance0: {
  132823. name: string;
  132824. shader: string;
  132825. };
  132826. }
  132827. declare module BABYLON {
  132828. /** @hidden */
  132829. export var pbrBlockReflectance: {
  132830. name: string;
  132831. shader: string;
  132832. };
  132833. }
  132834. declare module BABYLON {
  132835. /** @hidden */
  132836. export var pbrBlockDirectLighting: {
  132837. name: string;
  132838. shader: string;
  132839. };
  132840. }
  132841. declare module BABYLON {
  132842. /** @hidden */
  132843. export var pbrBlockFinalLitComponents: {
  132844. name: string;
  132845. shader: string;
  132846. };
  132847. }
  132848. declare module BABYLON {
  132849. /** @hidden */
  132850. export var pbrBlockFinalUnlitComponents: {
  132851. name: string;
  132852. shader: string;
  132853. };
  132854. }
  132855. declare module BABYLON {
  132856. /** @hidden */
  132857. export var pbrBlockFinalColorComposition: {
  132858. name: string;
  132859. shader: string;
  132860. };
  132861. }
  132862. declare module BABYLON {
  132863. /** @hidden */
  132864. export var pbrBlockImageProcessing: {
  132865. name: string;
  132866. shader: string;
  132867. };
  132868. }
  132869. declare module BABYLON {
  132870. /** @hidden */
  132871. export var pbrDebug: {
  132872. name: string;
  132873. shader: string;
  132874. };
  132875. }
  132876. declare module BABYLON {
  132877. /** @hidden */
  132878. export var pbrPixelShader: {
  132879. name: string;
  132880. shader: string;
  132881. };
  132882. }
  132883. declare module BABYLON {
  132884. /** @hidden */
  132885. export var pbrVertexDeclaration: {
  132886. name: string;
  132887. shader: string;
  132888. };
  132889. }
  132890. declare module BABYLON {
  132891. /** @hidden */
  132892. export var pbrVertexShader: {
  132893. name: string;
  132894. shader: string;
  132895. };
  132896. }
  132897. declare module BABYLON {
  132898. /**
  132899. * Manages the defines for the PBR Material.
  132900. * @hidden
  132901. */
  132902. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  132903. PBR: boolean;
  132904. NUM_SAMPLES: string;
  132905. REALTIME_FILTERING: boolean;
  132906. MAINUV1: boolean;
  132907. MAINUV2: boolean;
  132908. UV1: boolean;
  132909. UV2: boolean;
  132910. ALBEDO: boolean;
  132911. GAMMAALBEDO: boolean;
  132912. ALBEDODIRECTUV: number;
  132913. VERTEXCOLOR: boolean;
  132914. DETAIL: boolean;
  132915. DETAILDIRECTUV: number;
  132916. DETAIL_NORMALBLENDMETHOD: number;
  132917. AMBIENT: boolean;
  132918. AMBIENTDIRECTUV: number;
  132919. AMBIENTINGRAYSCALE: boolean;
  132920. OPACITY: boolean;
  132921. VERTEXALPHA: boolean;
  132922. OPACITYDIRECTUV: number;
  132923. OPACITYRGB: boolean;
  132924. ALPHATEST: boolean;
  132925. DEPTHPREPASS: boolean;
  132926. ALPHABLEND: boolean;
  132927. ALPHAFROMALBEDO: boolean;
  132928. ALPHATESTVALUE: string;
  132929. SPECULAROVERALPHA: boolean;
  132930. RADIANCEOVERALPHA: boolean;
  132931. ALPHAFRESNEL: boolean;
  132932. LINEARALPHAFRESNEL: boolean;
  132933. PREMULTIPLYALPHA: boolean;
  132934. EMISSIVE: boolean;
  132935. EMISSIVEDIRECTUV: number;
  132936. REFLECTIVITY: boolean;
  132937. REFLECTIVITYDIRECTUV: number;
  132938. SPECULARTERM: boolean;
  132939. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132940. MICROSURFACEAUTOMATIC: boolean;
  132941. LODBASEDMICROSFURACE: boolean;
  132942. MICROSURFACEMAP: boolean;
  132943. MICROSURFACEMAPDIRECTUV: number;
  132944. METALLICWORKFLOW: boolean;
  132945. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132946. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132947. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132948. AOSTOREINMETALMAPRED: boolean;
  132949. METALLIC_REFLECTANCE: boolean;
  132950. METALLIC_REFLECTANCEDIRECTUV: number;
  132951. ENVIRONMENTBRDF: boolean;
  132952. ENVIRONMENTBRDF_RGBD: boolean;
  132953. NORMAL: boolean;
  132954. TANGENT: boolean;
  132955. BUMP: boolean;
  132956. BUMPDIRECTUV: number;
  132957. OBJECTSPACE_NORMALMAP: boolean;
  132958. PARALLAX: boolean;
  132959. PARALLAXOCCLUSION: boolean;
  132960. NORMALXYSCALE: boolean;
  132961. LIGHTMAP: boolean;
  132962. LIGHTMAPDIRECTUV: number;
  132963. USELIGHTMAPASSHADOWMAP: boolean;
  132964. GAMMALIGHTMAP: boolean;
  132965. RGBDLIGHTMAP: boolean;
  132966. REFLECTION: boolean;
  132967. REFLECTIONMAP_3D: boolean;
  132968. REFLECTIONMAP_SPHERICAL: boolean;
  132969. REFLECTIONMAP_PLANAR: boolean;
  132970. REFLECTIONMAP_CUBIC: boolean;
  132971. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132972. REFLECTIONMAP_PROJECTION: boolean;
  132973. REFLECTIONMAP_SKYBOX: boolean;
  132974. REFLECTIONMAP_EXPLICIT: boolean;
  132975. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132976. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132977. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132978. INVERTCUBICMAP: boolean;
  132979. USESPHERICALFROMREFLECTIONMAP: boolean;
  132980. USEIRRADIANCEMAP: boolean;
  132981. SPHERICAL_HARMONICS: boolean;
  132982. USESPHERICALINVERTEX: boolean;
  132983. REFLECTIONMAP_OPPOSITEZ: boolean;
  132984. LODINREFLECTIONALPHA: boolean;
  132985. GAMMAREFLECTION: boolean;
  132986. RGBDREFLECTION: boolean;
  132987. LINEARSPECULARREFLECTION: boolean;
  132988. RADIANCEOCCLUSION: boolean;
  132989. HORIZONOCCLUSION: boolean;
  132990. INSTANCES: boolean;
  132991. THIN_INSTANCES: boolean;
  132992. NUM_BONE_INFLUENCERS: number;
  132993. BonesPerMesh: number;
  132994. BONETEXTURE: boolean;
  132995. NONUNIFORMSCALING: boolean;
  132996. MORPHTARGETS: boolean;
  132997. MORPHTARGETS_NORMAL: boolean;
  132998. MORPHTARGETS_TANGENT: boolean;
  132999. MORPHTARGETS_UV: boolean;
  133000. NUM_MORPH_INFLUENCERS: number;
  133001. IMAGEPROCESSING: boolean;
  133002. VIGNETTE: boolean;
  133003. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133004. VIGNETTEBLENDMODEOPAQUE: boolean;
  133005. TONEMAPPING: boolean;
  133006. TONEMAPPING_ACES: boolean;
  133007. CONTRAST: boolean;
  133008. COLORCURVES: boolean;
  133009. COLORGRADING: boolean;
  133010. COLORGRADING3D: boolean;
  133011. SAMPLER3DGREENDEPTH: boolean;
  133012. SAMPLER3DBGRMAP: boolean;
  133013. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133014. EXPOSURE: boolean;
  133015. MULTIVIEW: boolean;
  133016. USEPHYSICALLIGHTFALLOFF: boolean;
  133017. USEGLTFLIGHTFALLOFF: boolean;
  133018. TWOSIDEDLIGHTING: boolean;
  133019. SHADOWFLOAT: boolean;
  133020. CLIPPLANE: boolean;
  133021. CLIPPLANE2: boolean;
  133022. CLIPPLANE3: boolean;
  133023. CLIPPLANE4: boolean;
  133024. CLIPPLANE5: boolean;
  133025. CLIPPLANE6: boolean;
  133026. POINTSIZE: boolean;
  133027. FOG: boolean;
  133028. LOGARITHMICDEPTH: boolean;
  133029. FORCENORMALFORWARD: boolean;
  133030. SPECULARAA: boolean;
  133031. CLEARCOAT: boolean;
  133032. CLEARCOAT_DEFAULTIOR: boolean;
  133033. CLEARCOAT_TEXTURE: boolean;
  133034. CLEARCOAT_TEXTUREDIRECTUV: number;
  133035. CLEARCOAT_BUMP: boolean;
  133036. CLEARCOAT_BUMPDIRECTUV: number;
  133037. CLEARCOAT_TINT: boolean;
  133038. CLEARCOAT_TINT_TEXTURE: boolean;
  133039. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133040. ANISOTROPIC: boolean;
  133041. ANISOTROPIC_TEXTURE: boolean;
  133042. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133043. BRDF_V_HEIGHT_CORRELATED: boolean;
  133044. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133045. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133046. SHEEN: boolean;
  133047. SHEEN_TEXTURE: boolean;
  133048. SHEEN_TEXTUREDIRECTUV: number;
  133049. SHEEN_LINKWITHALBEDO: boolean;
  133050. SHEEN_ROUGHNESS: boolean;
  133051. SHEEN_ALBEDOSCALING: boolean;
  133052. SUBSURFACE: boolean;
  133053. SS_REFRACTION: boolean;
  133054. SS_TRANSLUCENCY: boolean;
  133055. SS_SCATTERING: boolean;
  133056. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133057. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133058. SS_REFRACTIONMAP_3D: boolean;
  133059. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133060. SS_LODINREFRACTIONALPHA: boolean;
  133061. SS_GAMMAREFRACTION: boolean;
  133062. SS_RGBDREFRACTION: boolean;
  133063. SS_LINEARSPECULARREFRACTION: boolean;
  133064. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133065. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133066. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133067. UNLIT: boolean;
  133068. DEBUGMODE: number;
  133069. /**
  133070. * Initializes the PBR Material defines.
  133071. */
  133072. constructor();
  133073. /**
  133074. * Resets the PBR Material defines.
  133075. */
  133076. reset(): void;
  133077. }
  133078. /**
  133079. * The Physically based material base class of BJS.
  133080. *
  133081. * This offers the main features of a standard PBR material.
  133082. * For more information, please refer to the documentation :
  133083. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133084. */
  133085. export abstract class PBRBaseMaterial extends PushMaterial {
  133086. /**
  133087. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133088. */
  133089. static readonly PBRMATERIAL_OPAQUE: number;
  133090. /**
  133091. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133092. */
  133093. static readonly PBRMATERIAL_ALPHATEST: number;
  133094. /**
  133095. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133096. */
  133097. static readonly PBRMATERIAL_ALPHABLEND: number;
  133098. /**
  133099. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133100. * They are also discarded below the alpha cutoff threshold to improve performances.
  133101. */
  133102. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133103. /**
  133104. * Defines the default value of how much AO map is occluding the analytical lights
  133105. * (point spot...).
  133106. */
  133107. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133108. /**
  133109. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133110. */
  133111. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133112. /**
  133113. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133114. * to enhance interoperability with other engines.
  133115. */
  133116. static readonly LIGHTFALLOFF_GLTF: number;
  133117. /**
  133118. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133119. * to enhance interoperability with other materials.
  133120. */
  133121. static readonly LIGHTFALLOFF_STANDARD: number;
  133122. /**
  133123. * Intensity of the direct lights e.g. the four lights available in your scene.
  133124. * This impacts both the direct diffuse and specular highlights.
  133125. */
  133126. protected _directIntensity: number;
  133127. /**
  133128. * Intensity of the emissive part of the material.
  133129. * This helps controlling the emissive effect without modifying the emissive color.
  133130. */
  133131. protected _emissiveIntensity: number;
  133132. /**
  133133. * Intensity of the environment e.g. how much the environment will light the object
  133134. * either through harmonics for rough material or through the refelction for shiny ones.
  133135. */
  133136. protected _environmentIntensity: number;
  133137. /**
  133138. * This is a special control allowing the reduction of the specular highlights coming from the
  133139. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133140. */
  133141. protected _specularIntensity: number;
  133142. /**
  133143. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133144. */
  133145. private _lightingInfos;
  133146. /**
  133147. * Debug Control allowing disabling the bump map on this material.
  133148. */
  133149. protected _disableBumpMap: boolean;
  133150. /**
  133151. * AKA Diffuse Texture in standard nomenclature.
  133152. */
  133153. protected _albedoTexture: Nullable<BaseTexture>;
  133154. /**
  133155. * AKA Occlusion Texture in other nomenclature.
  133156. */
  133157. protected _ambientTexture: Nullable<BaseTexture>;
  133158. /**
  133159. * AKA Occlusion Texture Intensity in other nomenclature.
  133160. */
  133161. protected _ambientTextureStrength: number;
  133162. /**
  133163. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133164. * 1 means it completely occludes it
  133165. * 0 mean it has no impact
  133166. */
  133167. protected _ambientTextureImpactOnAnalyticalLights: number;
  133168. /**
  133169. * Stores the alpha values in a texture.
  133170. */
  133171. protected _opacityTexture: Nullable<BaseTexture>;
  133172. /**
  133173. * Stores the reflection values in a texture.
  133174. */
  133175. protected _reflectionTexture: Nullable<BaseTexture>;
  133176. /**
  133177. * Stores the emissive values in a texture.
  133178. */
  133179. protected _emissiveTexture: Nullable<BaseTexture>;
  133180. /**
  133181. * AKA Specular texture in other nomenclature.
  133182. */
  133183. protected _reflectivityTexture: Nullable<BaseTexture>;
  133184. /**
  133185. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133186. */
  133187. protected _metallicTexture: Nullable<BaseTexture>;
  133188. /**
  133189. * Specifies the metallic scalar of the metallic/roughness workflow.
  133190. * Can also be used to scale the metalness values of the metallic texture.
  133191. */
  133192. protected _metallic: Nullable<number>;
  133193. /**
  133194. * Specifies the roughness scalar of the metallic/roughness workflow.
  133195. * Can also be used to scale the roughness values of the metallic texture.
  133196. */
  133197. protected _roughness: Nullable<number>;
  133198. /**
  133199. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133200. * By default the indexOfrefraction is used to compute F0;
  133201. *
  133202. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133203. *
  133204. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133205. * F90 = metallicReflectanceColor;
  133206. */
  133207. protected _metallicF0Factor: number;
  133208. /**
  133209. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133210. * By default the F90 is always 1;
  133211. *
  133212. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133213. *
  133214. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133215. * F90 = metallicReflectanceColor;
  133216. */
  133217. protected _metallicReflectanceColor: Color3;
  133218. /**
  133219. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133220. * This is multiply against the scalar values defined in the material.
  133221. */
  133222. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133223. /**
  133224. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133225. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133226. */
  133227. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133228. /**
  133229. * Stores surface normal data used to displace a mesh in a texture.
  133230. */
  133231. protected _bumpTexture: Nullable<BaseTexture>;
  133232. /**
  133233. * Stores the pre-calculated light information of a mesh in a texture.
  133234. */
  133235. protected _lightmapTexture: Nullable<BaseTexture>;
  133236. /**
  133237. * The color of a material in ambient lighting.
  133238. */
  133239. protected _ambientColor: Color3;
  133240. /**
  133241. * AKA Diffuse Color in other nomenclature.
  133242. */
  133243. protected _albedoColor: Color3;
  133244. /**
  133245. * AKA Specular Color in other nomenclature.
  133246. */
  133247. protected _reflectivityColor: Color3;
  133248. /**
  133249. * The color applied when light is reflected from a material.
  133250. */
  133251. protected _reflectionColor: Color3;
  133252. /**
  133253. * The color applied when light is emitted from a material.
  133254. */
  133255. protected _emissiveColor: Color3;
  133256. /**
  133257. * AKA Glossiness in other nomenclature.
  133258. */
  133259. protected _microSurface: number;
  133260. /**
  133261. * Specifies that the material will use the light map as a show map.
  133262. */
  133263. protected _useLightmapAsShadowmap: boolean;
  133264. /**
  133265. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133266. * makes the reflect vector face the model (under horizon).
  133267. */
  133268. protected _useHorizonOcclusion: boolean;
  133269. /**
  133270. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133271. * too much the area relying on ambient texture to define their ambient occlusion.
  133272. */
  133273. protected _useRadianceOcclusion: boolean;
  133274. /**
  133275. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133276. */
  133277. protected _useAlphaFromAlbedoTexture: boolean;
  133278. /**
  133279. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133281. */
  133282. protected _useSpecularOverAlpha: boolean;
  133283. /**
  133284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133285. */
  133286. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133287. /**
  133288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133289. */
  133290. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133291. /**
  133292. * Specifies if the metallic texture contains the roughness information in its green channel.
  133293. */
  133294. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133295. /**
  133296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133297. */
  133298. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133299. /**
  133300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133301. */
  133302. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133303. /**
  133304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133305. */
  133306. protected _useAmbientInGrayScale: boolean;
  133307. /**
  133308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133309. * The material will try to infer what glossiness each pixel should be.
  133310. */
  133311. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133312. /**
  133313. * Defines the falloff type used in this material.
  133314. * It by default is Physical.
  133315. */
  133316. protected _lightFalloff: number;
  133317. /**
  133318. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133319. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133320. */
  133321. protected _useRadianceOverAlpha: boolean;
  133322. /**
  133323. * Allows using an object space normal map (instead of tangent space).
  133324. */
  133325. protected _useObjectSpaceNormalMap: boolean;
  133326. /**
  133327. * Allows using the bump map in parallax mode.
  133328. */
  133329. protected _useParallax: boolean;
  133330. /**
  133331. * Allows using the bump map in parallax occlusion mode.
  133332. */
  133333. protected _useParallaxOcclusion: boolean;
  133334. /**
  133335. * Controls the scale bias of the parallax mode.
  133336. */
  133337. protected _parallaxScaleBias: number;
  133338. /**
  133339. * If sets to true, disables all the lights affecting the material.
  133340. */
  133341. protected _disableLighting: boolean;
  133342. /**
  133343. * Number of Simultaneous lights allowed on the material.
  133344. */
  133345. protected _maxSimultaneousLights: number;
  133346. /**
  133347. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133348. */
  133349. protected _invertNormalMapX: boolean;
  133350. /**
  133351. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133352. */
  133353. protected _invertNormalMapY: boolean;
  133354. /**
  133355. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133356. */
  133357. protected _twoSidedLighting: boolean;
  133358. /**
  133359. * Defines the alpha limits in alpha test mode.
  133360. */
  133361. protected _alphaCutOff: number;
  133362. /**
  133363. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133364. */
  133365. protected _forceAlphaTest: boolean;
  133366. /**
  133367. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133368. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133369. */
  133370. protected _useAlphaFresnel: boolean;
  133371. /**
  133372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133373. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133374. */
  133375. protected _useLinearAlphaFresnel: boolean;
  133376. /**
  133377. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133378. * from cos thetav and roughness:
  133379. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133380. */
  133381. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133382. /**
  133383. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133384. */
  133385. protected _forceIrradianceInFragment: boolean;
  133386. private _realTimeFiltering;
  133387. /**
  133388. * Enables realtime filtering on the texture.
  133389. */
  133390. get realTimeFiltering(): boolean;
  133391. set realTimeFiltering(b: boolean);
  133392. private _realTimeFilteringQuality;
  133393. /**
  133394. * Quality switch for realtime filtering
  133395. */
  133396. get realTimeFilteringQuality(): number;
  133397. set realTimeFilteringQuality(n: number);
  133398. /**
  133399. * Force normal to face away from face.
  133400. */
  133401. protected _forceNormalForward: boolean;
  133402. /**
  133403. * Enables specular anti aliasing in the PBR shader.
  133404. * It will both interacts on the Geometry for analytical and IBL lighting.
  133405. * It also prefilter the roughness map based on the bump values.
  133406. */
  133407. protected _enableSpecularAntiAliasing: boolean;
  133408. /**
  133409. * Default configuration related to image processing available in the PBR Material.
  133410. */
  133411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133412. /**
  133413. * Keep track of the image processing observer to allow dispose and replace.
  133414. */
  133415. private _imageProcessingObserver;
  133416. /**
  133417. * Attaches a new image processing configuration to the PBR Material.
  133418. * @param configuration
  133419. */
  133420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133421. /**
  133422. * Stores the available render targets.
  133423. */
  133424. private _renderTargets;
  133425. /**
  133426. * Sets the global ambient color for the material used in lighting calculations.
  133427. */
  133428. private _globalAmbientColor;
  133429. /**
  133430. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133431. */
  133432. private _useLogarithmicDepth;
  133433. /**
  133434. * If set to true, no lighting calculations will be applied.
  133435. */
  133436. private _unlit;
  133437. private _debugMode;
  133438. /**
  133439. * @hidden
  133440. * This is reserved for the inspector.
  133441. * Defines the material debug mode.
  133442. * It helps seeing only some components of the material while troubleshooting.
  133443. */
  133444. debugMode: number;
  133445. /**
  133446. * @hidden
  133447. * This is reserved for the inspector.
  133448. * Specify from where on screen the debug mode should start.
  133449. * The value goes from -1 (full screen) to 1 (not visible)
  133450. * It helps with side by side comparison against the final render
  133451. * This defaults to -1
  133452. */
  133453. private debugLimit;
  133454. /**
  133455. * @hidden
  133456. * This is reserved for the inspector.
  133457. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133458. * You can use the factor to better multiply the final value.
  133459. */
  133460. private debugFactor;
  133461. /**
  133462. * Defines the clear coat layer parameters for the material.
  133463. */
  133464. readonly clearCoat: PBRClearCoatConfiguration;
  133465. /**
  133466. * Defines the anisotropic parameters for the material.
  133467. */
  133468. readonly anisotropy: PBRAnisotropicConfiguration;
  133469. /**
  133470. * Defines the BRDF parameters for the material.
  133471. */
  133472. readonly brdf: PBRBRDFConfiguration;
  133473. /**
  133474. * Defines the Sheen parameters for the material.
  133475. */
  133476. readonly sheen: PBRSheenConfiguration;
  133477. /**
  133478. * Defines the SubSurface parameters for the material.
  133479. */
  133480. readonly subSurface: PBRSubSurfaceConfiguration;
  133481. /**
  133482. * Defines the detail map parameters for the material.
  133483. */
  133484. readonly detailMap: DetailMapConfiguration;
  133485. protected _rebuildInParallel: boolean;
  133486. /**
  133487. * Instantiates a new PBRMaterial instance.
  133488. *
  133489. * @param name The material name
  133490. * @param scene The scene the material will be use in.
  133491. */
  133492. constructor(name: string, scene: Scene);
  133493. /**
  133494. * Gets a boolean indicating that current material needs to register RTT
  133495. */
  133496. get hasRenderTargetTextures(): boolean;
  133497. /**
  133498. * Gets the name of the material class.
  133499. */
  133500. getClassName(): string;
  133501. /**
  133502. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133503. */
  133504. get useLogarithmicDepth(): boolean;
  133505. /**
  133506. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133507. */
  133508. set useLogarithmicDepth(value: boolean);
  133509. /**
  133510. * Returns true if alpha blending should be disabled.
  133511. */
  133512. protected get _disableAlphaBlending(): boolean;
  133513. /**
  133514. * Specifies whether or not this material should be rendered in alpha blend mode.
  133515. */
  133516. needAlphaBlending(): boolean;
  133517. /**
  133518. * Specifies whether or not this material should be rendered in alpha test mode.
  133519. */
  133520. needAlphaTesting(): boolean;
  133521. /**
  133522. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133523. */
  133524. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133525. /**
  133526. * Gets the texture used for the alpha test.
  133527. */
  133528. getAlphaTestTexture(): Nullable<BaseTexture>;
  133529. /**
  133530. * Specifies that the submesh is ready to be used.
  133531. * @param mesh - BJS mesh.
  133532. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133533. * @param useInstances - Specifies that instances should be used.
  133534. * @returns - boolean indicating that the submesh is ready or not.
  133535. */
  133536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133537. /**
  133538. * Specifies if the material uses metallic roughness workflow.
  133539. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133540. */
  133541. isMetallicWorkflow(): boolean;
  133542. private _prepareEffect;
  133543. private _prepareDefines;
  133544. /**
  133545. * Force shader compilation
  133546. */
  133547. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133548. /**
  133549. * Initializes the uniform buffer layout for the shader.
  133550. */
  133551. buildUniformLayout(): void;
  133552. /**
  133553. * Unbinds the material from the mesh
  133554. */
  133555. unbind(): void;
  133556. /**
  133557. * Binds the submesh data.
  133558. * @param world - The world matrix.
  133559. * @param mesh - The BJS mesh.
  133560. * @param subMesh - A submesh of the BJS mesh.
  133561. */
  133562. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133563. /**
  133564. * Returns the animatable textures.
  133565. * @returns - Array of animatable textures.
  133566. */
  133567. getAnimatables(): IAnimatable[];
  133568. /**
  133569. * Returns the texture used for reflections.
  133570. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  133571. */
  133572. private _getReflectionTexture;
  133573. /**
  133574. * Returns an array of the actively used textures.
  133575. * @returns - Array of BaseTextures
  133576. */
  133577. getActiveTextures(): BaseTexture[];
  133578. /**
  133579. * Checks to see if a texture is used in the material.
  133580. * @param texture - Base texture to use.
  133581. * @returns - Boolean specifying if a texture is used in the material.
  133582. */
  133583. hasTexture(texture: BaseTexture): boolean;
  133584. /**
  133585. * Disposes the resources of the material.
  133586. * @param forceDisposeEffect - Forces the disposal of effects.
  133587. * @param forceDisposeTextures - Forces the disposal of all textures.
  133588. */
  133589. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133590. }
  133591. }
  133592. declare module BABYLON {
  133593. /**
  133594. * The Physically based material of BJS.
  133595. *
  133596. * This offers the main features of a standard PBR material.
  133597. * For more information, please refer to the documentation :
  133598. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133599. */
  133600. export class PBRMaterial extends PBRBaseMaterial {
  133601. /**
  133602. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133603. */
  133604. static readonly PBRMATERIAL_OPAQUE: number;
  133605. /**
  133606. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133607. */
  133608. static readonly PBRMATERIAL_ALPHATEST: number;
  133609. /**
  133610. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133611. */
  133612. static readonly PBRMATERIAL_ALPHABLEND: number;
  133613. /**
  133614. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133615. * They are also discarded below the alpha cutoff threshold to improve performances.
  133616. */
  133617. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133618. /**
  133619. * Defines the default value of how much AO map is occluding the analytical lights
  133620. * (point spot...).
  133621. */
  133622. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133623. /**
  133624. * Intensity of the direct lights e.g. the four lights available in your scene.
  133625. * This impacts both the direct diffuse and specular highlights.
  133626. */
  133627. directIntensity: number;
  133628. /**
  133629. * Intensity of the emissive part of the material.
  133630. * This helps controlling the emissive effect without modifying the emissive color.
  133631. */
  133632. emissiveIntensity: number;
  133633. /**
  133634. * Intensity of the environment e.g. how much the environment will light the object
  133635. * either through harmonics for rough material or through the refelction for shiny ones.
  133636. */
  133637. environmentIntensity: number;
  133638. /**
  133639. * This is a special control allowing the reduction of the specular highlights coming from the
  133640. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133641. */
  133642. specularIntensity: number;
  133643. /**
  133644. * Debug Control allowing disabling the bump map on this material.
  133645. */
  133646. disableBumpMap: boolean;
  133647. /**
  133648. * AKA Diffuse Texture in standard nomenclature.
  133649. */
  133650. albedoTexture: BaseTexture;
  133651. /**
  133652. * AKA Occlusion Texture in other nomenclature.
  133653. */
  133654. ambientTexture: BaseTexture;
  133655. /**
  133656. * AKA Occlusion Texture Intensity in other nomenclature.
  133657. */
  133658. ambientTextureStrength: number;
  133659. /**
  133660. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133661. * 1 means it completely occludes it
  133662. * 0 mean it has no impact
  133663. */
  133664. ambientTextureImpactOnAnalyticalLights: number;
  133665. /**
  133666. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133667. */
  133668. opacityTexture: BaseTexture;
  133669. /**
  133670. * Stores the reflection values in a texture.
  133671. */
  133672. reflectionTexture: Nullable<BaseTexture>;
  133673. /**
  133674. * Stores the emissive values in a texture.
  133675. */
  133676. emissiveTexture: BaseTexture;
  133677. /**
  133678. * AKA Specular texture in other nomenclature.
  133679. */
  133680. reflectivityTexture: BaseTexture;
  133681. /**
  133682. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133683. */
  133684. metallicTexture: BaseTexture;
  133685. /**
  133686. * Specifies the metallic scalar of the metallic/roughness workflow.
  133687. * Can also be used to scale the metalness values of the metallic texture.
  133688. */
  133689. metallic: Nullable<number>;
  133690. /**
  133691. * Specifies the roughness scalar of the metallic/roughness workflow.
  133692. * Can also be used to scale the roughness values of the metallic texture.
  133693. */
  133694. roughness: Nullable<number>;
  133695. /**
  133696. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133697. * By default the indexOfrefraction is used to compute F0;
  133698. *
  133699. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133700. *
  133701. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133702. * F90 = metallicReflectanceColor;
  133703. */
  133704. metallicF0Factor: number;
  133705. /**
  133706. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133707. * By default the F90 is always 1;
  133708. *
  133709. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133710. *
  133711. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133712. * F90 = metallicReflectanceColor;
  133713. */
  133714. metallicReflectanceColor: Color3;
  133715. /**
  133716. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133717. * This is multiply against the scalar values defined in the material.
  133718. */
  133719. metallicReflectanceTexture: Nullable<BaseTexture>;
  133720. /**
  133721. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133722. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133723. */
  133724. microSurfaceTexture: BaseTexture;
  133725. /**
  133726. * Stores surface normal data used to displace a mesh in a texture.
  133727. */
  133728. bumpTexture: BaseTexture;
  133729. /**
  133730. * Stores the pre-calculated light information of a mesh in a texture.
  133731. */
  133732. lightmapTexture: BaseTexture;
  133733. /**
  133734. * Stores the refracted light information in a texture.
  133735. */
  133736. get refractionTexture(): Nullable<BaseTexture>;
  133737. set refractionTexture(value: Nullable<BaseTexture>);
  133738. /**
  133739. * The color of a material in ambient lighting.
  133740. */
  133741. ambientColor: Color3;
  133742. /**
  133743. * AKA Diffuse Color in other nomenclature.
  133744. */
  133745. albedoColor: Color3;
  133746. /**
  133747. * AKA Specular Color in other nomenclature.
  133748. */
  133749. reflectivityColor: Color3;
  133750. /**
  133751. * The color reflected from the material.
  133752. */
  133753. reflectionColor: Color3;
  133754. /**
  133755. * The color emitted from the material.
  133756. */
  133757. emissiveColor: Color3;
  133758. /**
  133759. * AKA Glossiness in other nomenclature.
  133760. */
  133761. microSurface: number;
  133762. /**
  133763. * Index of refraction of the material base layer.
  133764. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133765. *
  133766. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133767. *
  133768. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133769. */
  133770. get indexOfRefraction(): number;
  133771. set indexOfRefraction(value: number);
  133772. /**
  133773. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133774. */
  133775. get invertRefractionY(): boolean;
  133776. set invertRefractionY(value: boolean);
  133777. /**
  133778. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133779. * Materials half opaque for instance using refraction could benefit from this control.
  133780. */
  133781. get linkRefractionWithTransparency(): boolean;
  133782. set linkRefractionWithTransparency(value: boolean);
  133783. /**
  133784. * If true, the light map contains occlusion information instead of lighting info.
  133785. */
  133786. useLightmapAsShadowmap: boolean;
  133787. /**
  133788. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133789. */
  133790. useAlphaFromAlbedoTexture: boolean;
  133791. /**
  133792. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133793. */
  133794. forceAlphaTest: boolean;
  133795. /**
  133796. * Defines the alpha limits in alpha test mode.
  133797. */
  133798. alphaCutOff: number;
  133799. /**
  133800. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133801. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133802. */
  133803. useSpecularOverAlpha: boolean;
  133804. /**
  133805. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133806. */
  133807. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133808. /**
  133809. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133810. */
  133811. useRoughnessFromMetallicTextureAlpha: boolean;
  133812. /**
  133813. * Specifies if the metallic texture contains the roughness information in its green channel.
  133814. */
  133815. useRoughnessFromMetallicTextureGreen: boolean;
  133816. /**
  133817. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133818. */
  133819. useMetallnessFromMetallicTextureBlue: boolean;
  133820. /**
  133821. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133822. */
  133823. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133824. /**
  133825. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133826. */
  133827. useAmbientInGrayScale: boolean;
  133828. /**
  133829. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133830. * The material will try to infer what glossiness each pixel should be.
  133831. */
  133832. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133833. /**
  133834. * BJS is using an harcoded light falloff based on a manually sets up range.
  133835. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133836. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133837. */
  133838. get usePhysicalLightFalloff(): boolean;
  133839. /**
  133840. * BJS is using an harcoded light falloff based on a manually sets up range.
  133841. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133842. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133843. */
  133844. set usePhysicalLightFalloff(value: boolean);
  133845. /**
  133846. * In order to support the falloff compatibility with gltf, a special mode has been added
  133847. * to reproduce the gltf light falloff.
  133848. */
  133849. get useGLTFLightFalloff(): boolean;
  133850. /**
  133851. * In order to support the falloff compatibility with gltf, a special mode has been added
  133852. * to reproduce the gltf light falloff.
  133853. */
  133854. set useGLTFLightFalloff(value: boolean);
  133855. /**
  133856. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133857. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133858. */
  133859. useRadianceOverAlpha: boolean;
  133860. /**
  133861. * Allows using an object space normal map (instead of tangent space).
  133862. */
  133863. useObjectSpaceNormalMap: boolean;
  133864. /**
  133865. * Allows using the bump map in parallax mode.
  133866. */
  133867. useParallax: boolean;
  133868. /**
  133869. * Allows using the bump map in parallax occlusion mode.
  133870. */
  133871. useParallaxOcclusion: boolean;
  133872. /**
  133873. * Controls the scale bias of the parallax mode.
  133874. */
  133875. parallaxScaleBias: number;
  133876. /**
  133877. * If sets to true, disables all the lights affecting the material.
  133878. */
  133879. disableLighting: boolean;
  133880. /**
  133881. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133882. */
  133883. forceIrradianceInFragment: boolean;
  133884. /**
  133885. * Number of Simultaneous lights allowed on the material.
  133886. */
  133887. maxSimultaneousLights: number;
  133888. /**
  133889. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133890. */
  133891. invertNormalMapX: boolean;
  133892. /**
  133893. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133894. */
  133895. invertNormalMapY: boolean;
  133896. /**
  133897. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133898. */
  133899. twoSidedLighting: boolean;
  133900. /**
  133901. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133902. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133903. */
  133904. useAlphaFresnel: boolean;
  133905. /**
  133906. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133907. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133908. */
  133909. useLinearAlphaFresnel: boolean;
  133910. /**
  133911. * Let user defines the brdf lookup texture used for IBL.
  133912. * A default 8bit version is embedded but you could point at :
  133913. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133914. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133915. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133916. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133917. */
  133918. environmentBRDFTexture: Nullable<BaseTexture>;
  133919. /**
  133920. * Force normal to face away from face.
  133921. */
  133922. forceNormalForward: boolean;
  133923. /**
  133924. * Enables specular anti aliasing in the PBR shader.
  133925. * It will both interacts on the Geometry for analytical and IBL lighting.
  133926. * It also prefilter the roughness map based on the bump values.
  133927. */
  133928. enableSpecularAntiAliasing: boolean;
  133929. /**
  133930. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133931. * makes the reflect vector face the model (under horizon).
  133932. */
  133933. useHorizonOcclusion: boolean;
  133934. /**
  133935. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133936. * too much the area relying on ambient texture to define their ambient occlusion.
  133937. */
  133938. useRadianceOcclusion: boolean;
  133939. /**
  133940. * If set to true, no lighting calculations will be applied.
  133941. */
  133942. unlit: boolean;
  133943. /**
  133944. * Gets the image processing configuration used either in this material.
  133945. */
  133946. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133947. /**
  133948. * Sets the Default image processing configuration used either in the this material.
  133949. *
  133950. * If sets to null, the scene one is in use.
  133951. */
  133952. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133953. /**
  133954. * Gets wether the color curves effect is enabled.
  133955. */
  133956. get cameraColorCurvesEnabled(): boolean;
  133957. /**
  133958. * Sets wether the color curves effect is enabled.
  133959. */
  133960. set cameraColorCurvesEnabled(value: boolean);
  133961. /**
  133962. * Gets wether the color grading effect is enabled.
  133963. */
  133964. get cameraColorGradingEnabled(): boolean;
  133965. /**
  133966. * Gets wether the color grading effect is enabled.
  133967. */
  133968. set cameraColorGradingEnabled(value: boolean);
  133969. /**
  133970. * Gets wether tonemapping is enabled or not.
  133971. */
  133972. get cameraToneMappingEnabled(): boolean;
  133973. /**
  133974. * Sets wether tonemapping is enabled or not
  133975. */
  133976. set cameraToneMappingEnabled(value: boolean);
  133977. /**
  133978. * The camera exposure used on this material.
  133979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133980. * This corresponds to a photographic exposure.
  133981. */
  133982. get cameraExposure(): number;
  133983. /**
  133984. * The camera exposure used on this material.
  133985. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133986. * This corresponds to a photographic exposure.
  133987. */
  133988. set cameraExposure(value: number);
  133989. /**
  133990. * Gets The camera contrast used on this material.
  133991. */
  133992. get cameraContrast(): number;
  133993. /**
  133994. * Sets The camera contrast used on this material.
  133995. */
  133996. set cameraContrast(value: number);
  133997. /**
  133998. * Gets the Color Grading 2D Lookup Texture.
  133999. */
  134000. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134001. /**
  134002. * Sets the Color Grading 2D Lookup Texture.
  134003. */
  134004. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134005. /**
  134006. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134007. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134008. * 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;
  134009. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134010. */
  134011. get cameraColorCurves(): Nullable<ColorCurves>;
  134012. /**
  134013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134015. * 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;
  134016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134017. */
  134018. set cameraColorCurves(value: Nullable<ColorCurves>);
  134019. /**
  134020. * Instantiates a new PBRMaterial instance.
  134021. *
  134022. * @param name The material name
  134023. * @param scene The scene the material will be use in.
  134024. */
  134025. constructor(name: string, scene: Scene);
  134026. /**
  134027. * Returns the name of this material class.
  134028. */
  134029. getClassName(): string;
  134030. /**
  134031. * Makes a duplicate of the current material.
  134032. * @param name - name to use for the new material.
  134033. */
  134034. clone(name: string): PBRMaterial;
  134035. /**
  134036. * Serializes this PBR Material.
  134037. * @returns - An object with the serialized material.
  134038. */
  134039. serialize(): any;
  134040. /**
  134041. * Parses a PBR Material from a serialized object.
  134042. * @param source - Serialized object.
  134043. * @param scene - BJS scene instance.
  134044. * @param rootUrl - url for the scene object
  134045. * @returns - PBRMaterial
  134046. */
  134047. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134048. }
  134049. }
  134050. declare module BABYLON {
  134051. /**
  134052. * Direct draw surface info
  134053. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134054. */
  134055. export interface DDSInfo {
  134056. /**
  134057. * Width of the texture
  134058. */
  134059. width: number;
  134060. /**
  134061. * Width of the texture
  134062. */
  134063. height: number;
  134064. /**
  134065. * Number of Mipmaps for the texture
  134066. * @see https://en.wikipedia.org/wiki/Mipmap
  134067. */
  134068. mipmapCount: number;
  134069. /**
  134070. * If the textures format is a known fourCC format
  134071. * @see https://www.fourcc.org/
  134072. */
  134073. isFourCC: boolean;
  134074. /**
  134075. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134076. */
  134077. isRGB: boolean;
  134078. /**
  134079. * If the texture is a lumincance format
  134080. */
  134081. isLuminance: boolean;
  134082. /**
  134083. * If this is a cube texture
  134084. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134085. */
  134086. isCube: boolean;
  134087. /**
  134088. * If the texture is a compressed format eg. FOURCC_DXT1
  134089. */
  134090. isCompressed: boolean;
  134091. /**
  134092. * The dxgiFormat of the texture
  134093. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134094. */
  134095. dxgiFormat: number;
  134096. /**
  134097. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134098. */
  134099. textureType: number;
  134100. /**
  134101. * Sphericle polynomial created for the dds texture
  134102. */
  134103. sphericalPolynomial?: SphericalPolynomial;
  134104. }
  134105. /**
  134106. * Class used to provide DDS decompression tools
  134107. */
  134108. export class DDSTools {
  134109. /**
  134110. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134111. */
  134112. static StoreLODInAlphaChannel: boolean;
  134113. /**
  134114. * Gets DDS information from an array buffer
  134115. * @param data defines the array buffer view to read data from
  134116. * @returns the DDS information
  134117. */
  134118. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134119. private static _FloatView;
  134120. private static _Int32View;
  134121. private static _ToHalfFloat;
  134122. private static _FromHalfFloat;
  134123. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134124. private static _GetHalfFloatRGBAArrayBuffer;
  134125. private static _GetFloatRGBAArrayBuffer;
  134126. private static _GetFloatAsUIntRGBAArrayBuffer;
  134127. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134128. private static _GetRGBAArrayBuffer;
  134129. private static _ExtractLongWordOrder;
  134130. private static _GetRGBArrayBuffer;
  134131. private static _GetLuminanceArrayBuffer;
  134132. /**
  134133. * Uploads DDS Levels to a Babylon Texture
  134134. * @hidden
  134135. */
  134136. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134137. }
  134138. interface ThinEngine {
  134139. /**
  134140. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134141. * @param rootUrl defines the url where the file to load is located
  134142. * @param scene defines the current scene
  134143. * @param lodScale defines scale to apply to the mip map selection
  134144. * @param lodOffset defines offset to apply to the mip map selection
  134145. * @param onLoad defines an optional callback raised when the texture is loaded
  134146. * @param onError defines an optional callback raised if there is an issue to load the texture
  134147. * @param format defines the format of the data
  134148. * @param forcedExtension defines the extension to use to pick the right loader
  134149. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134150. * @returns the cube texture as an InternalTexture
  134151. */
  134152. 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;
  134153. }
  134154. }
  134155. declare module BABYLON {
  134156. /**
  134157. * Implementation of the DDS Texture Loader.
  134158. * @hidden
  134159. */
  134160. export class _DDSTextureLoader implements IInternalTextureLoader {
  134161. /**
  134162. * Defines wether the loader supports cascade loading the different faces.
  134163. */
  134164. readonly supportCascades: boolean;
  134165. /**
  134166. * This returns if the loader support the current file information.
  134167. * @param extension defines the file extension of the file being loaded
  134168. * @returns true if the loader can load the specified file
  134169. */
  134170. canLoad(extension: string): boolean;
  134171. /**
  134172. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134173. * @param data contains the texture data
  134174. * @param texture defines the BabylonJS internal texture
  134175. * @param createPolynomials will be true if polynomials have been requested
  134176. * @param onLoad defines the callback to trigger once the texture is ready
  134177. * @param onError defines the callback to trigger in case of error
  134178. */
  134179. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134180. /**
  134181. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134182. * @param data contains the texture data
  134183. * @param texture defines the BabylonJS internal texture
  134184. * @param callback defines the method to call once ready to upload
  134185. */
  134186. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134187. }
  134188. }
  134189. declare module BABYLON {
  134190. /**
  134191. * Implementation of the ENV Texture Loader.
  134192. * @hidden
  134193. */
  134194. export class _ENVTextureLoader implements IInternalTextureLoader {
  134195. /**
  134196. * Defines wether the loader supports cascade loading the different faces.
  134197. */
  134198. readonly supportCascades: boolean;
  134199. /**
  134200. * This returns if the loader support the current file information.
  134201. * @param extension defines the file extension of the file being loaded
  134202. * @returns true if the loader can load the specified file
  134203. */
  134204. canLoad(extension: string): boolean;
  134205. /**
  134206. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134207. * @param data contains the texture data
  134208. * @param texture defines the BabylonJS internal texture
  134209. * @param createPolynomials will be true if polynomials have been requested
  134210. * @param onLoad defines the callback to trigger once the texture is ready
  134211. * @param onError defines the callback to trigger in case of error
  134212. */
  134213. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134214. /**
  134215. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134216. * @param data contains the texture data
  134217. * @param texture defines the BabylonJS internal texture
  134218. * @param callback defines the method to call once ready to upload
  134219. */
  134220. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134221. }
  134222. }
  134223. declare module BABYLON {
  134224. /**
  134225. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134226. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134227. */
  134228. export class KhronosTextureContainer {
  134229. /** contents of the KTX container file */
  134230. data: ArrayBufferView;
  134231. private static HEADER_LEN;
  134232. private static COMPRESSED_2D;
  134233. private static COMPRESSED_3D;
  134234. private static TEX_2D;
  134235. private static TEX_3D;
  134236. /**
  134237. * Gets the openGL type
  134238. */
  134239. glType: number;
  134240. /**
  134241. * Gets the openGL type size
  134242. */
  134243. glTypeSize: number;
  134244. /**
  134245. * Gets the openGL format
  134246. */
  134247. glFormat: number;
  134248. /**
  134249. * Gets the openGL internal format
  134250. */
  134251. glInternalFormat: number;
  134252. /**
  134253. * Gets the base internal format
  134254. */
  134255. glBaseInternalFormat: number;
  134256. /**
  134257. * Gets image width in pixel
  134258. */
  134259. pixelWidth: number;
  134260. /**
  134261. * Gets image height in pixel
  134262. */
  134263. pixelHeight: number;
  134264. /**
  134265. * Gets image depth in pixels
  134266. */
  134267. pixelDepth: number;
  134268. /**
  134269. * Gets the number of array elements
  134270. */
  134271. numberOfArrayElements: number;
  134272. /**
  134273. * Gets the number of faces
  134274. */
  134275. numberOfFaces: number;
  134276. /**
  134277. * Gets the number of mipmap levels
  134278. */
  134279. numberOfMipmapLevels: number;
  134280. /**
  134281. * Gets the bytes of key value data
  134282. */
  134283. bytesOfKeyValueData: number;
  134284. /**
  134285. * Gets the load type
  134286. */
  134287. loadType: number;
  134288. /**
  134289. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134290. */
  134291. isInvalid: boolean;
  134292. /**
  134293. * Creates a new KhronosTextureContainer
  134294. * @param data contents of the KTX container file
  134295. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134296. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134297. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134298. */
  134299. constructor(
  134300. /** contents of the KTX container file */
  134301. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134302. /**
  134303. * Uploads KTX content to a Babylon Texture.
  134304. * It is assumed that the texture has already been created & is currently bound
  134305. * @hidden
  134306. */
  134307. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134308. private _upload2DCompressedLevels;
  134309. /**
  134310. * Checks if the given data starts with a KTX file identifier.
  134311. * @param data the data to check
  134312. * @returns true if the data is a KTX file or false otherwise
  134313. */
  134314. static IsValid(data: ArrayBufferView): boolean;
  134315. }
  134316. }
  134317. declare module BABYLON {
  134318. /**
  134319. * Class for loading KTX2 files
  134320. * !!! Experimental Extension Subject to Changes !!!
  134321. * @hidden
  134322. */
  134323. export class KhronosTextureContainer2 {
  134324. private static _ModulePromise;
  134325. private static _TranscodeFormat;
  134326. constructor(engine: ThinEngine);
  134327. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134328. private _determineTranscodeFormat;
  134329. /**
  134330. * Checks if the given data starts with a KTX2 file identifier.
  134331. * @param data the data to check
  134332. * @returns true if the data is a KTX2 file or false otherwise
  134333. */
  134334. static IsValid(data: ArrayBufferView): boolean;
  134335. }
  134336. }
  134337. declare module BABYLON {
  134338. /**
  134339. * Implementation of the KTX Texture Loader.
  134340. * @hidden
  134341. */
  134342. export class _KTXTextureLoader implements IInternalTextureLoader {
  134343. /**
  134344. * Defines wether the loader supports cascade loading the different faces.
  134345. */
  134346. readonly supportCascades: boolean;
  134347. /**
  134348. * This returns if the loader support the current file information.
  134349. * @param extension defines the file extension of the file being loaded
  134350. * @param mimeType defines the optional mime type of the file being loaded
  134351. * @returns true if the loader can load the specified file
  134352. */
  134353. canLoad(extension: string, mimeType?: string): boolean;
  134354. /**
  134355. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134356. * @param data contains the texture data
  134357. * @param texture defines the BabylonJS internal texture
  134358. * @param createPolynomials will be true if polynomials have been requested
  134359. * @param onLoad defines the callback to trigger once the texture is ready
  134360. * @param onError defines the callback to trigger in case of error
  134361. */
  134362. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134363. /**
  134364. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134365. * @param data contains the texture data
  134366. * @param texture defines the BabylonJS internal texture
  134367. * @param callback defines the method to call once ready to upload
  134368. */
  134369. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134370. }
  134371. }
  134372. declare module BABYLON {
  134373. /** @hidden */
  134374. export var _forceSceneHelpersToBundle: boolean;
  134375. interface Scene {
  134376. /**
  134377. * Creates a default light for the scene.
  134378. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134379. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134380. */
  134381. createDefaultLight(replace?: boolean): void;
  134382. /**
  134383. * Creates a default camera for the scene.
  134384. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134385. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134386. * @param replace has default false, when true replaces the active camera in the scene
  134387. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134388. */
  134389. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134390. /**
  134391. * Creates a default camera and a default light.
  134392. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134393. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134394. * @param replace has the default false, when true replaces the active camera/light in the scene
  134395. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134396. */
  134397. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134398. /**
  134399. * Creates a new sky box
  134400. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134401. * @param environmentTexture defines the texture to use as environment texture
  134402. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134403. * @param scale defines the overall scale of the skybox
  134404. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134405. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134406. * @returns a new mesh holding the sky box
  134407. */
  134408. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134409. /**
  134410. * Creates a new environment
  134411. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134412. * @param options defines the options you can use to configure the environment
  134413. * @returns the new EnvironmentHelper
  134414. */
  134415. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134416. /**
  134417. * Creates a new VREXperienceHelper
  134418. * @see http://doc.babylonjs.com/how_to/webvr_helper
  134419. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134420. * @returns a new VREXperienceHelper
  134421. */
  134422. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134423. /**
  134424. * Creates a new WebXRDefaultExperience
  134425. * @see http://doc.babylonjs.com/how_to/webxr
  134426. * @param options experience options
  134427. * @returns a promise for a new WebXRDefaultExperience
  134428. */
  134429. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134430. }
  134431. }
  134432. declare module BABYLON {
  134433. /**
  134434. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134435. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134436. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134437. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134438. */
  134439. export class VideoDome extends TransformNode {
  134440. /**
  134441. * Define the video source as a Monoscopic panoramic 360 video.
  134442. */
  134443. static readonly MODE_MONOSCOPIC: number;
  134444. /**
  134445. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134446. */
  134447. static readonly MODE_TOPBOTTOM: number;
  134448. /**
  134449. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134450. */
  134451. static readonly MODE_SIDEBYSIDE: number;
  134452. private _halfDome;
  134453. private _useDirectMapping;
  134454. /**
  134455. * The video texture being displayed on the sphere
  134456. */
  134457. protected _videoTexture: VideoTexture;
  134458. /**
  134459. * Gets the video texture being displayed on the sphere
  134460. */
  134461. get videoTexture(): VideoTexture;
  134462. /**
  134463. * The skybox material
  134464. */
  134465. protected _material: BackgroundMaterial;
  134466. /**
  134467. * The surface used for the skybox
  134468. */
  134469. protected _mesh: Mesh;
  134470. /**
  134471. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134472. */
  134473. private _halfDomeMask;
  134474. /**
  134475. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134476. * Also see the options.resolution property.
  134477. */
  134478. get fovMultiplier(): number;
  134479. set fovMultiplier(value: number);
  134480. private _videoMode;
  134481. /**
  134482. * Gets or set the current video mode for the video. It can be:
  134483. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134484. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134485. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134486. */
  134487. get videoMode(): number;
  134488. set videoMode(value: number);
  134489. /**
  134490. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134491. *
  134492. */
  134493. get halfDome(): boolean;
  134494. /**
  134495. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134496. */
  134497. set halfDome(enabled: boolean);
  134498. /**
  134499. * Oberserver used in Stereoscopic VR Mode.
  134500. */
  134501. private _onBeforeCameraRenderObserver;
  134502. /**
  134503. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134504. * @param name Element's name, child elements will append suffixes for their own names.
  134505. * @param urlsOrVideo defines the url(s) or the video element to use
  134506. * @param options An object containing optional or exposed sub element properties
  134507. */
  134508. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134509. resolution?: number;
  134510. clickToPlay?: boolean;
  134511. autoPlay?: boolean;
  134512. loop?: boolean;
  134513. size?: number;
  134514. poster?: string;
  134515. faceForward?: boolean;
  134516. useDirectMapping?: boolean;
  134517. halfDomeMode?: boolean;
  134518. }, scene: Scene);
  134519. private _changeVideoMode;
  134520. /**
  134521. * Releases resources associated with this node.
  134522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134524. */
  134525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134526. }
  134527. }
  134528. declare module BABYLON {
  134529. /**
  134530. * This class can be used to get instrumentation data from a Babylon engine
  134531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134532. */
  134533. export class EngineInstrumentation implements IDisposable {
  134534. /**
  134535. * Define the instrumented engine.
  134536. */
  134537. engine: Engine;
  134538. private _captureGPUFrameTime;
  134539. private _gpuFrameTimeToken;
  134540. private _gpuFrameTime;
  134541. private _captureShaderCompilationTime;
  134542. private _shaderCompilationTime;
  134543. private _onBeginFrameObserver;
  134544. private _onEndFrameObserver;
  134545. private _onBeforeShaderCompilationObserver;
  134546. private _onAfterShaderCompilationObserver;
  134547. /**
  134548. * Gets the perf counter used for GPU frame time
  134549. */
  134550. get gpuFrameTimeCounter(): PerfCounter;
  134551. /**
  134552. * Gets the GPU frame time capture status
  134553. */
  134554. get captureGPUFrameTime(): boolean;
  134555. /**
  134556. * Enable or disable the GPU frame time capture
  134557. */
  134558. set captureGPUFrameTime(value: boolean);
  134559. /**
  134560. * Gets the perf counter used for shader compilation time
  134561. */
  134562. get shaderCompilationTimeCounter(): PerfCounter;
  134563. /**
  134564. * Gets the shader compilation time capture status
  134565. */
  134566. get captureShaderCompilationTime(): boolean;
  134567. /**
  134568. * Enable or disable the shader compilation time capture
  134569. */
  134570. set captureShaderCompilationTime(value: boolean);
  134571. /**
  134572. * Instantiates a new engine instrumentation.
  134573. * This class can be used to get instrumentation data from a Babylon engine
  134574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134575. * @param engine Defines the engine to instrument
  134576. */
  134577. constructor(
  134578. /**
  134579. * Define the instrumented engine.
  134580. */
  134581. engine: Engine);
  134582. /**
  134583. * Dispose and release associated resources.
  134584. */
  134585. dispose(): void;
  134586. }
  134587. }
  134588. declare module BABYLON {
  134589. /**
  134590. * This class can be used to get instrumentation data from a Babylon engine
  134591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134592. */
  134593. export class SceneInstrumentation implements IDisposable {
  134594. /**
  134595. * Defines the scene to instrument
  134596. */
  134597. scene: Scene;
  134598. private _captureActiveMeshesEvaluationTime;
  134599. private _activeMeshesEvaluationTime;
  134600. private _captureRenderTargetsRenderTime;
  134601. private _renderTargetsRenderTime;
  134602. private _captureFrameTime;
  134603. private _frameTime;
  134604. private _captureRenderTime;
  134605. private _renderTime;
  134606. private _captureInterFrameTime;
  134607. private _interFrameTime;
  134608. private _captureParticlesRenderTime;
  134609. private _particlesRenderTime;
  134610. private _captureSpritesRenderTime;
  134611. private _spritesRenderTime;
  134612. private _capturePhysicsTime;
  134613. private _physicsTime;
  134614. private _captureAnimationsTime;
  134615. private _animationsTime;
  134616. private _captureCameraRenderTime;
  134617. private _cameraRenderTime;
  134618. private _onBeforeActiveMeshesEvaluationObserver;
  134619. private _onAfterActiveMeshesEvaluationObserver;
  134620. private _onBeforeRenderTargetsRenderObserver;
  134621. private _onAfterRenderTargetsRenderObserver;
  134622. private _onAfterRenderObserver;
  134623. private _onBeforeDrawPhaseObserver;
  134624. private _onAfterDrawPhaseObserver;
  134625. private _onBeforeAnimationsObserver;
  134626. private _onBeforeParticlesRenderingObserver;
  134627. private _onAfterParticlesRenderingObserver;
  134628. private _onBeforeSpritesRenderingObserver;
  134629. private _onAfterSpritesRenderingObserver;
  134630. private _onBeforePhysicsObserver;
  134631. private _onAfterPhysicsObserver;
  134632. private _onAfterAnimationsObserver;
  134633. private _onBeforeCameraRenderObserver;
  134634. private _onAfterCameraRenderObserver;
  134635. /**
  134636. * Gets the perf counter used for active meshes evaluation time
  134637. */
  134638. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134639. /**
  134640. * Gets the active meshes evaluation time capture status
  134641. */
  134642. get captureActiveMeshesEvaluationTime(): boolean;
  134643. /**
  134644. * Enable or disable the active meshes evaluation time capture
  134645. */
  134646. set captureActiveMeshesEvaluationTime(value: boolean);
  134647. /**
  134648. * Gets the perf counter used for render targets render time
  134649. */
  134650. get renderTargetsRenderTimeCounter(): PerfCounter;
  134651. /**
  134652. * Gets the render targets render time capture status
  134653. */
  134654. get captureRenderTargetsRenderTime(): boolean;
  134655. /**
  134656. * Enable or disable the render targets render time capture
  134657. */
  134658. set captureRenderTargetsRenderTime(value: boolean);
  134659. /**
  134660. * Gets the perf counter used for particles render time
  134661. */
  134662. get particlesRenderTimeCounter(): PerfCounter;
  134663. /**
  134664. * Gets the particles render time capture status
  134665. */
  134666. get captureParticlesRenderTime(): boolean;
  134667. /**
  134668. * Enable or disable the particles render time capture
  134669. */
  134670. set captureParticlesRenderTime(value: boolean);
  134671. /**
  134672. * Gets the perf counter used for sprites render time
  134673. */
  134674. get spritesRenderTimeCounter(): PerfCounter;
  134675. /**
  134676. * Gets the sprites render time capture status
  134677. */
  134678. get captureSpritesRenderTime(): boolean;
  134679. /**
  134680. * Enable or disable the sprites render time capture
  134681. */
  134682. set captureSpritesRenderTime(value: boolean);
  134683. /**
  134684. * Gets the perf counter used for physics time
  134685. */
  134686. get physicsTimeCounter(): PerfCounter;
  134687. /**
  134688. * Gets the physics time capture status
  134689. */
  134690. get capturePhysicsTime(): boolean;
  134691. /**
  134692. * Enable or disable the physics time capture
  134693. */
  134694. set capturePhysicsTime(value: boolean);
  134695. /**
  134696. * Gets the perf counter used for animations time
  134697. */
  134698. get animationsTimeCounter(): PerfCounter;
  134699. /**
  134700. * Gets the animations time capture status
  134701. */
  134702. get captureAnimationsTime(): boolean;
  134703. /**
  134704. * Enable or disable the animations time capture
  134705. */
  134706. set captureAnimationsTime(value: boolean);
  134707. /**
  134708. * Gets the perf counter used for frame time capture
  134709. */
  134710. get frameTimeCounter(): PerfCounter;
  134711. /**
  134712. * Gets the frame time capture status
  134713. */
  134714. get captureFrameTime(): boolean;
  134715. /**
  134716. * Enable or disable the frame time capture
  134717. */
  134718. set captureFrameTime(value: boolean);
  134719. /**
  134720. * Gets the perf counter used for inter-frames time capture
  134721. */
  134722. get interFrameTimeCounter(): PerfCounter;
  134723. /**
  134724. * Gets the inter-frames time capture status
  134725. */
  134726. get captureInterFrameTime(): boolean;
  134727. /**
  134728. * Enable or disable the inter-frames time capture
  134729. */
  134730. set captureInterFrameTime(value: boolean);
  134731. /**
  134732. * Gets the perf counter used for render time capture
  134733. */
  134734. get renderTimeCounter(): PerfCounter;
  134735. /**
  134736. * Gets the render time capture status
  134737. */
  134738. get captureRenderTime(): boolean;
  134739. /**
  134740. * Enable or disable the render time capture
  134741. */
  134742. set captureRenderTime(value: boolean);
  134743. /**
  134744. * Gets the perf counter used for camera render time capture
  134745. */
  134746. get cameraRenderTimeCounter(): PerfCounter;
  134747. /**
  134748. * Gets the camera render time capture status
  134749. */
  134750. get captureCameraRenderTime(): boolean;
  134751. /**
  134752. * Enable or disable the camera render time capture
  134753. */
  134754. set captureCameraRenderTime(value: boolean);
  134755. /**
  134756. * Gets the perf counter used for draw calls
  134757. */
  134758. get drawCallsCounter(): PerfCounter;
  134759. /**
  134760. * Instantiates a new scene instrumentation.
  134761. * This class can be used to get instrumentation data from a Babylon engine
  134762. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134763. * @param scene Defines the scene to instrument
  134764. */
  134765. constructor(
  134766. /**
  134767. * Defines the scene to instrument
  134768. */
  134769. scene: Scene);
  134770. /**
  134771. * Dispose and release associated resources.
  134772. */
  134773. dispose(): void;
  134774. }
  134775. }
  134776. declare module BABYLON {
  134777. /** @hidden */
  134778. export var glowMapGenerationPixelShader: {
  134779. name: string;
  134780. shader: string;
  134781. };
  134782. }
  134783. declare module BABYLON {
  134784. /** @hidden */
  134785. export var glowMapGenerationVertexShader: {
  134786. name: string;
  134787. shader: string;
  134788. };
  134789. }
  134790. declare module BABYLON {
  134791. /**
  134792. * Effect layer options. This helps customizing the behaviour
  134793. * of the effect layer.
  134794. */
  134795. export interface IEffectLayerOptions {
  134796. /**
  134797. * Multiplication factor apply to the canvas size to compute the render target size
  134798. * used to generated the objects (the smaller the faster).
  134799. */
  134800. mainTextureRatio: number;
  134801. /**
  134802. * Enforces a fixed size texture to ensure effect stability across devices.
  134803. */
  134804. mainTextureFixedSize?: number;
  134805. /**
  134806. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134807. */
  134808. alphaBlendingMode: number;
  134809. /**
  134810. * The camera attached to the layer.
  134811. */
  134812. camera: Nullable<Camera>;
  134813. /**
  134814. * The rendering group to draw the layer in.
  134815. */
  134816. renderingGroupId: number;
  134817. }
  134818. /**
  134819. * The effect layer Helps adding post process effect blended with the main pass.
  134820. *
  134821. * This can be for instance use to generate glow or higlight effects on the scene.
  134822. *
  134823. * The effect layer class can not be used directly and is intented to inherited from to be
  134824. * customized per effects.
  134825. */
  134826. export abstract class EffectLayer {
  134827. private _vertexBuffers;
  134828. private _indexBuffer;
  134829. private _cachedDefines;
  134830. private _effectLayerMapGenerationEffect;
  134831. private _effectLayerOptions;
  134832. private _mergeEffect;
  134833. protected _scene: Scene;
  134834. protected _engine: Engine;
  134835. protected _maxSize: number;
  134836. protected _mainTextureDesiredSize: ISize;
  134837. protected _mainTexture: RenderTargetTexture;
  134838. protected _shouldRender: boolean;
  134839. protected _postProcesses: PostProcess[];
  134840. protected _textures: BaseTexture[];
  134841. protected _emissiveTextureAndColor: {
  134842. texture: Nullable<BaseTexture>;
  134843. color: Color4;
  134844. };
  134845. /**
  134846. * The name of the layer
  134847. */
  134848. name: string;
  134849. /**
  134850. * The clear color of the texture used to generate the glow map.
  134851. */
  134852. neutralColor: Color4;
  134853. /**
  134854. * Specifies whether the highlight layer is enabled or not.
  134855. */
  134856. isEnabled: boolean;
  134857. /**
  134858. * Gets the camera attached to the layer.
  134859. */
  134860. get camera(): Nullable<Camera>;
  134861. /**
  134862. * Gets the rendering group id the layer should render in.
  134863. */
  134864. get renderingGroupId(): number;
  134865. set renderingGroupId(renderingGroupId: number);
  134866. /**
  134867. * An event triggered when the effect layer has been disposed.
  134868. */
  134869. onDisposeObservable: Observable<EffectLayer>;
  134870. /**
  134871. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134872. */
  134873. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134874. /**
  134875. * An event triggered when the generated texture is being merged in the scene.
  134876. */
  134877. onBeforeComposeObservable: Observable<EffectLayer>;
  134878. /**
  134879. * An event triggered when the mesh is rendered into the effect render target.
  134880. */
  134881. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134882. /**
  134883. * An event triggered after the mesh has been rendered into the effect render target.
  134884. */
  134885. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134886. /**
  134887. * An event triggered when the generated texture has been merged in the scene.
  134888. */
  134889. onAfterComposeObservable: Observable<EffectLayer>;
  134890. /**
  134891. * An event triggered when the efffect layer changes its size.
  134892. */
  134893. onSizeChangedObservable: Observable<EffectLayer>;
  134894. /** @hidden */
  134895. static _SceneComponentInitialization: (scene: Scene) => void;
  134896. /**
  134897. * Instantiates a new effect Layer and references it in the scene.
  134898. * @param name The name of the layer
  134899. * @param scene The scene to use the layer in
  134900. */
  134901. constructor(
  134902. /** The Friendly of the effect in the scene */
  134903. name: string, scene: Scene);
  134904. /**
  134905. * Get the effect name of the layer.
  134906. * @return The effect name
  134907. */
  134908. abstract getEffectName(): string;
  134909. /**
  134910. * Checks for the readiness of the element composing the layer.
  134911. * @param subMesh the mesh to check for
  134912. * @param useInstances specify whether or not to use instances to render the mesh
  134913. * @return true if ready otherwise, false
  134914. */
  134915. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134916. /**
  134917. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134918. * @returns true if the effect requires stencil during the main canvas render pass.
  134919. */
  134920. abstract needStencil(): boolean;
  134921. /**
  134922. * Create the merge effect. This is the shader use to blit the information back
  134923. * to the main canvas at the end of the scene rendering.
  134924. * @returns The effect containing the shader used to merge the effect on the main canvas
  134925. */
  134926. protected abstract _createMergeEffect(): Effect;
  134927. /**
  134928. * Creates the render target textures and post processes used in the effect layer.
  134929. */
  134930. protected abstract _createTextureAndPostProcesses(): void;
  134931. /**
  134932. * Implementation specific of rendering the generating effect on the main canvas.
  134933. * @param effect The effect used to render through
  134934. */
  134935. protected abstract _internalRender(effect: Effect): void;
  134936. /**
  134937. * Sets the required values for both the emissive texture and and the main color.
  134938. */
  134939. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134940. /**
  134941. * Free any resources and references associated to a mesh.
  134942. * Internal use
  134943. * @param mesh The mesh to free.
  134944. */
  134945. abstract _disposeMesh(mesh: Mesh): void;
  134946. /**
  134947. * Serializes this layer (Glow or Highlight for example)
  134948. * @returns a serialized layer object
  134949. */
  134950. abstract serialize?(): any;
  134951. /**
  134952. * Initializes the effect layer with the required options.
  134953. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134954. */
  134955. protected _init(options: Partial<IEffectLayerOptions>): void;
  134956. /**
  134957. * Generates the index buffer of the full screen quad blending to the main canvas.
  134958. */
  134959. private _generateIndexBuffer;
  134960. /**
  134961. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134962. */
  134963. private _generateVertexBuffer;
  134964. /**
  134965. * Sets the main texture desired size which is the closest power of two
  134966. * of the engine canvas size.
  134967. */
  134968. private _setMainTextureSize;
  134969. /**
  134970. * Creates the main texture for the effect layer.
  134971. */
  134972. protected _createMainTexture(): void;
  134973. /**
  134974. * Adds specific effects defines.
  134975. * @param defines The defines to add specifics to.
  134976. */
  134977. protected _addCustomEffectDefines(defines: string[]): void;
  134978. /**
  134979. * Checks for the readiness of the element composing the layer.
  134980. * @param subMesh the mesh to check for
  134981. * @param useInstances specify whether or not to use instances to render the mesh
  134982. * @param emissiveTexture the associated emissive texture used to generate the glow
  134983. * @return true if ready otherwise, false
  134984. */
  134985. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134986. /**
  134987. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134988. */
  134989. render(): void;
  134990. /**
  134991. * Determine if a given mesh will be used in the current effect.
  134992. * @param mesh mesh to test
  134993. * @returns true if the mesh will be used
  134994. */
  134995. hasMesh(mesh: AbstractMesh): boolean;
  134996. /**
  134997. * Returns true if the layer contains information to display, otherwise false.
  134998. * @returns true if the glow layer should be rendered
  134999. */
  135000. shouldRender(): boolean;
  135001. /**
  135002. * Returns true if the mesh should render, otherwise false.
  135003. * @param mesh The mesh to render
  135004. * @returns true if it should render otherwise false
  135005. */
  135006. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135007. /**
  135008. * Returns true if the mesh can be rendered, otherwise false.
  135009. * @param mesh The mesh to render
  135010. * @param material The material used on the mesh
  135011. * @returns true if it can be rendered otherwise false
  135012. */
  135013. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135014. /**
  135015. * Returns true if the mesh should render, otherwise false.
  135016. * @param mesh The mesh to render
  135017. * @returns true if it should render otherwise false
  135018. */
  135019. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135020. /**
  135021. * Renders the submesh passed in parameter to the generation map.
  135022. */
  135023. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135024. /**
  135025. * Defines whether the current material of the mesh should be use to render the effect.
  135026. * @param mesh defines the current mesh to render
  135027. */
  135028. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135029. /**
  135030. * Rebuild the required buffers.
  135031. * @hidden Internal use only.
  135032. */
  135033. _rebuild(): void;
  135034. /**
  135035. * Dispose only the render target textures and post process.
  135036. */
  135037. private _disposeTextureAndPostProcesses;
  135038. /**
  135039. * Dispose the highlight layer and free resources.
  135040. */
  135041. dispose(): void;
  135042. /**
  135043. * Gets the class name of the effect layer
  135044. * @returns the string with the class name of the effect layer
  135045. */
  135046. getClassName(): string;
  135047. /**
  135048. * Creates an effect layer from parsed effect layer data
  135049. * @param parsedEffectLayer defines effect layer data
  135050. * @param scene defines the current scene
  135051. * @param rootUrl defines the root URL containing the effect layer information
  135052. * @returns a parsed effect Layer
  135053. */
  135054. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135055. }
  135056. }
  135057. declare module BABYLON {
  135058. interface AbstractScene {
  135059. /**
  135060. * The list of effect layers (highlights/glow) added to the scene
  135061. * @see http://doc.babylonjs.com/how_to/highlight_layer
  135062. * @see http://doc.babylonjs.com/how_to/glow_layer
  135063. */
  135064. effectLayers: Array<EffectLayer>;
  135065. /**
  135066. * Removes the given effect layer from this scene.
  135067. * @param toRemove defines the effect layer to remove
  135068. * @returns the index of the removed effect layer
  135069. */
  135070. removeEffectLayer(toRemove: EffectLayer): number;
  135071. /**
  135072. * Adds the given effect layer to this scene
  135073. * @param newEffectLayer defines the effect layer to add
  135074. */
  135075. addEffectLayer(newEffectLayer: EffectLayer): void;
  135076. }
  135077. /**
  135078. * Defines the layer scene component responsible to manage any effect layers
  135079. * in a given scene.
  135080. */
  135081. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135082. /**
  135083. * The component name helpfull to identify the component in the list of scene components.
  135084. */
  135085. readonly name: string;
  135086. /**
  135087. * The scene the component belongs to.
  135088. */
  135089. scene: Scene;
  135090. private _engine;
  135091. private _renderEffects;
  135092. private _needStencil;
  135093. private _previousStencilState;
  135094. /**
  135095. * Creates a new instance of the component for the given scene
  135096. * @param scene Defines the scene to register the component in
  135097. */
  135098. constructor(scene: Scene);
  135099. /**
  135100. * Registers the component in a given scene
  135101. */
  135102. register(): void;
  135103. /**
  135104. * Rebuilds the elements related to this component in case of
  135105. * context lost for instance.
  135106. */
  135107. rebuild(): void;
  135108. /**
  135109. * Serializes the component data to the specified json object
  135110. * @param serializationObject The object to serialize to
  135111. */
  135112. serialize(serializationObject: any): void;
  135113. /**
  135114. * Adds all the elements from the container to the scene
  135115. * @param container the container holding the elements
  135116. */
  135117. addFromContainer(container: AbstractScene): void;
  135118. /**
  135119. * Removes all the elements in the container from the scene
  135120. * @param container contains the elements to remove
  135121. * @param dispose if the removed element should be disposed (default: false)
  135122. */
  135123. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135124. /**
  135125. * Disposes the component and the associated ressources.
  135126. */
  135127. dispose(): void;
  135128. private _isReadyForMesh;
  135129. private _renderMainTexture;
  135130. private _setStencil;
  135131. private _setStencilBack;
  135132. private _draw;
  135133. private _drawCamera;
  135134. private _drawRenderingGroup;
  135135. }
  135136. }
  135137. declare module BABYLON {
  135138. /** @hidden */
  135139. export var glowMapMergePixelShader: {
  135140. name: string;
  135141. shader: string;
  135142. };
  135143. }
  135144. declare module BABYLON {
  135145. /** @hidden */
  135146. export var glowMapMergeVertexShader: {
  135147. name: string;
  135148. shader: string;
  135149. };
  135150. }
  135151. declare module BABYLON {
  135152. interface AbstractScene {
  135153. /**
  135154. * Return a the first highlight layer of the scene with a given name.
  135155. * @param name The name of the highlight layer to look for.
  135156. * @return The highlight layer if found otherwise null.
  135157. */
  135158. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135159. }
  135160. /**
  135161. * Glow layer options. This helps customizing the behaviour
  135162. * of the glow layer.
  135163. */
  135164. export interface IGlowLayerOptions {
  135165. /**
  135166. * Multiplication factor apply to the canvas size to compute the render target size
  135167. * used to generated the glowing objects (the smaller the faster).
  135168. */
  135169. mainTextureRatio: number;
  135170. /**
  135171. * Enforces a fixed size texture to ensure resize independant blur.
  135172. */
  135173. mainTextureFixedSize?: number;
  135174. /**
  135175. * How big is the kernel of the blur texture.
  135176. */
  135177. blurKernelSize: number;
  135178. /**
  135179. * The camera attached to the layer.
  135180. */
  135181. camera: Nullable<Camera>;
  135182. /**
  135183. * Enable MSAA by chosing the number of samples.
  135184. */
  135185. mainTextureSamples?: number;
  135186. /**
  135187. * The rendering group to draw the layer in.
  135188. */
  135189. renderingGroupId: number;
  135190. }
  135191. /**
  135192. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135193. *
  135194. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135195. *
  135196. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135197. */
  135198. export class GlowLayer extends EffectLayer {
  135199. /**
  135200. * Effect Name of the layer.
  135201. */
  135202. static readonly EffectName: string;
  135203. /**
  135204. * The default blur kernel size used for the glow.
  135205. */
  135206. static DefaultBlurKernelSize: number;
  135207. /**
  135208. * The default texture size ratio used for the glow.
  135209. */
  135210. static DefaultTextureRatio: number;
  135211. /**
  135212. * Sets the kernel size of the blur.
  135213. */
  135214. set blurKernelSize(value: number);
  135215. /**
  135216. * Gets the kernel size of the blur.
  135217. */
  135218. get blurKernelSize(): number;
  135219. /**
  135220. * Sets the glow intensity.
  135221. */
  135222. set intensity(value: number);
  135223. /**
  135224. * Gets the glow intensity.
  135225. */
  135226. get intensity(): number;
  135227. private _options;
  135228. private _intensity;
  135229. private _horizontalBlurPostprocess1;
  135230. private _verticalBlurPostprocess1;
  135231. private _horizontalBlurPostprocess2;
  135232. private _verticalBlurPostprocess2;
  135233. private _blurTexture1;
  135234. private _blurTexture2;
  135235. private _postProcesses1;
  135236. private _postProcesses2;
  135237. private _includedOnlyMeshes;
  135238. private _excludedMeshes;
  135239. private _meshesUsingTheirOwnMaterials;
  135240. /**
  135241. * Callback used to let the user override the color selection on a per mesh basis
  135242. */
  135243. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135244. /**
  135245. * Callback used to let the user override the texture selection on a per mesh basis
  135246. */
  135247. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135248. /**
  135249. * Instantiates a new glow Layer and references it to the scene.
  135250. * @param name The name of the layer
  135251. * @param scene The scene to use the layer in
  135252. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135253. */
  135254. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135255. /**
  135256. * Get the effect name of the layer.
  135257. * @return The effect name
  135258. */
  135259. getEffectName(): string;
  135260. /**
  135261. * Create the merge effect. This is the shader use to blit the information back
  135262. * to the main canvas at the end of the scene rendering.
  135263. */
  135264. protected _createMergeEffect(): Effect;
  135265. /**
  135266. * Creates the render target textures and post processes used in the glow layer.
  135267. */
  135268. protected _createTextureAndPostProcesses(): void;
  135269. /**
  135270. * Checks for the readiness of the element composing the layer.
  135271. * @param subMesh the mesh to check for
  135272. * @param useInstances specify wether or not to use instances to render the mesh
  135273. * @param emissiveTexture the associated emissive texture used to generate the glow
  135274. * @return true if ready otherwise, false
  135275. */
  135276. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135277. /**
  135278. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135279. */
  135280. needStencil(): boolean;
  135281. /**
  135282. * Returns true if the mesh can be rendered, otherwise false.
  135283. * @param mesh The mesh to render
  135284. * @param material The material used on the mesh
  135285. * @returns true if it can be rendered otherwise false
  135286. */
  135287. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135288. /**
  135289. * Implementation specific of rendering the generating effect on the main canvas.
  135290. * @param effect The effect used to render through
  135291. */
  135292. protected _internalRender(effect: Effect): void;
  135293. /**
  135294. * Sets the required values for both the emissive texture and and the main color.
  135295. */
  135296. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135297. /**
  135298. * Returns true if the mesh should render, otherwise false.
  135299. * @param mesh The mesh to render
  135300. * @returns true if it should render otherwise false
  135301. */
  135302. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135303. /**
  135304. * Adds specific effects defines.
  135305. * @param defines The defines to add specifics to.
  135306. */
  135307. protected _addCustomEffectDefines(defines: string[]): void;
  135308. /**
  135309. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135310. * @param mesh The mesh to exclude from the glow layer
  135311. */
  135312. addExcludedMesh(mesh: Mesh): void;
  135313. /**
  135314. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135315. * @param mesh The mesh to remove
  135316. */
  135317. removeExcludedMesh(mesh: Mesh): void;
  135318. /**
  135319. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135320. * @param mesh The mesh to include in the glow layer
  135321. */
  135322. addIncludedOnlyMesh(mesh: Mesh): void;
  135323. /**
  135324. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135325. * @param mesh The mesh to remove
  135326. */
  135327. removeIncludedOnlyMesh(mesh: Mesh): void;
  135328. /**
  135329. * Determine if a given mesh will be used in the glow layer
  135330. * @param mesh The mesh to test
  135331. * @returns true if the mesh will be highlighted by the current glow layer
  135332. */
  135333. hasMesh(mesh: AbstractMesh): boolean;
  135334. /**
  135335. * Defines whether the current material of the mesh should be use to render the effect.
  135336. * @param mesh defines the current mesh to render
  135337. */
  135338. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135339. /**
  135340. * Add a mesh to be rendered through its own material and not with emissive only.
  135341. * @param mesh The mesh for which we need to use its material
  135342. */
  135343. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135344. /**
  135345. * Remove a mesh from being rendered through its own material and not with emissive only.
  135346. * @param mesh The mesh for which we need to not use its material
  135347. */
  135348. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135349. /**
  135350. * Free any resources and references associated to a mesh.
  135351. * Internal use
  135352. * @param mesh The mesh to free.
  135353. * @hidden
  135354. */
  135355. _disposeMesh(mesh: Mesh): void;
  135356. /**
  135357. * Gets the class name of the effect layer
  135358. * @returns the string with the class name of the effect layer
  135359. */
  135360. getClassName(): string;
  135361. /**
  135362. * Serializes this glow layer
  135363. * @returns a serialized glow layer object
  135364. */
  135365. serialize(): any;
  135366. /**
  135367. * Creates a Glow Layer from parsed glow layer data
  135368. * @param parsedGlowLayer defines glow layer data
  135369. * @param scene defines the current scene
  135370. * @param rootUrl defines the root URL containing the glow layer information
  135371. * @returns a parsed Glow Layer
  135372. */
  135373. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135374. }
  135375. }
  135376. declare module BABYLON {
  135377. /** @hidden */
  135378. export var glowBlurPostProcessPixelShader: {
  135379. name: string;
  135380. shader: string;
  135381. };
  135382. }
  135383. declare module BABYLON {
  135384. interface AbstractScene {
  135385. /**
  135386. * Return a the first highlight layer of the scene with a given name.
  135387. * @param name The name of the highlight layer to look for.
  135388. * @return The highlight layer if found otherwise null.
  135389. */
  135390. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135391. }
  135392. /**
  135393. * Highlight layer options. This helps customizing the behaviour
  135394. * of the highlight layer.
  135395. */
  135396. export interface IHighlightLayerOptions {
  135397. /**
  135398. * Multiplication factor apply to the canvas size to compute the render target size
  135399. * used to generated the glowing objects (the smaller the faster).
  135400. */
  135401. mainTextureRatio: number;
  135402. /**
  135403. * Enforces a fixed size texture to ensure resize independant blur.
  135404. */
  135405. mainTextureFixedSize?: number;
  135406. /**
  135407. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135408. * of the picture to blur (the smaller the faster).
  135409. */
  135410. blurTextureSizeRatio: number;
  135411. /**
  135412. * How big in texel of the blur texture is the vertical blur.
  135413. */
  135414. blurVerticalSize: number;
  135415. /**
  135416. * How big in texel of the blur texture is the horizontal blur.
  135417. */
  135418. blurHorizontalSize: number;
  135419. /**
  135420. * Alpha blending mode used to apply the blur. Default is combine.
  135421. */
  135422. alphaBlendingMode: number;
  135423. /**
  135424. * The camera attached to the layer.
  135425. */
  135426. camera: Nullable<Camera>;
  135427. /**
  135428. * Should we display highlight as a solid stroke?
  135429. */
  135430. isStroke?: boolean;
  135431. /**
  135432. * The rendering group to draw the layer in.
  135433. */
  135434. renderingGroupId: number;
  135435. }
  135436. /**
  135437. * The highlight layer Helps adding a glow effect around a mesh.
  135438. *
  135439. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135440. * glowy meshes to your scene.
  135441. *
  135442. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135443. */
  135444. export class HighlightLayer extends EffectLayer {
  135445. name: string;
  135446. /**
  135447. * Effect Name of the highlight layer.
  135448. */
  135449. static readonly EffectName: string;
  135450. /**
  135451. * The neutral color used during the preparation of the glow effect.
  135452. * This is black by default as the blend operation is a blend operation.
  135453. */
  135454. static NeutralColor: Color4;
  135455. /**
  135456. * Stencil value used for glowing meshes.
  135457. */
  135458. static GlowingMeshStencilReference: number;
  135459. /**
  135460. * Stencil value used for the other meshes in the scene.
  135461. */
  135462. static NormalMeshStencilReference: number;
  135463. /**
  135464. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135465. */
  135466. innerGlow: boolean;
  135467. /**
  135468. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135469. */
  135470. outerGlow: boolean;
  135471. /**
  135472. * Specifies the horizontal size of the blur.
  135473. */
  135474. set blurHorizontalSize(value: number);
  135475. /**
  135476. * Specifies the vertical size of the blur.
  135477. */
  135478. set blurVerticalSize(value: number);
  135479. /**
  135480. * Gets the horizontal size of the blur.
  135481. */
  135482. get blurHorizontalSize(): number;
  135483. /**
  135484. * Gets the vertical size of the blur.
  135485. */
  135486. get blurVerticalSize(): number;
  135487. /**
  135488. * An event triggered when the highlight layer is being blurred.
  135489. */
  135490. onBeforeBlurObservable: Observable<HighlightLayer>;
  135491. /**
  135492. * An event triggered when the highlight layer has been blurred.
  135493. */
  135494. onAfterBlurObservable: Observable<HighlightLayer>;
  135495. private _instanceGlowingMeshStencilReference;
  135496. private _options;
  135497. private _downSamplePostprocess;
  135498. private _horizontalBlurPostprocess;
  135499. private _verticalBlurPostprocess;
  135500. private _blurTexture;
  135501. private _meshes;
  135502. private _excludedMeshes;
  135503. /**
  135504. * Instantiates a new highlight Layer and references it to the scene..
  135505. * @param name The name of the layer
  135506. * @param scene The scene to use the layer in
  135507. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135508. */
  135509. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135510. /**
  135511. * Get the effect name of the layer.
  135512. * @return The effect name
  135513. */
  135514. getEffectName(): string;
  135515. /**
  135516. * Create the merge effect. This is the shader use to blit the information back
  135517. * to the main canvas at the end of the scene rendering.
  135518. */
  135519. protected _createMergeEffect(): Effect;
  135520. /**
  135521. * Creates the render target textures and post processes used in the highlight layer.
  135522. */
  135523. protected _createTextureAndPostProcesses(): void;
  135524. /**
  135525. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135526. */
  135527. needStencil(): boolean;
  135528. /**
  135529. * Checks for the readiness of the element composing the layer.
  135530. * @param subMesh the mesh to check for
  135531. * @param useInstances specify wether or not to use instances to render the mesh
  135532. * @param emissiveTexture the associated emissive texture used to generate the glow
  135533. * @return true if ready otherwise, false
  135534. */
  135535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135536. /**
  135537. * Implementation specific of rendering the generating effect on the main canvas.
  135538. * @param effect The effect used to render through
  135539. */
  135540. protected _internalRender(effect: Effect): void;
  135541. /**
  135542. * Returns true if the layer contains information to display, otherwise false.
  135543. */
  135544. shouldRender(): boolean;
  135545. /**
  135546. * Returns true if the mesh should render, otherwise false.
  135547. * @param mesh The mesh to render
  135548. * @returns true if it should render otherwise false
  135549. */
  135550. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135551. /**
  135552. * Returns true if the mesh can be rendered, otherwise false.
  135553. * @param mesh The mesh to render
  135554. * @param material The material used on the mesh
  135555. * @returns true if it can be rendered otherwise false
  135556. */
  135557. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135558. /**
  135559. * Adds specific effects defines.
  135560. * @param defines The defines to add specifics to.
  135561. */
  135562. protected _addCustomEffectDefines(defines: string[]): void;
  135563. /**
  135564. * Sets the required values for both the emissive texture and and the main color.
  135565. */
  135566. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135567. /**
  135568. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  135569. * @param mesh The mesh to exclude from the highlight layer
  135570. */
  135571. addExcludedMesh(mesh: Mesh): void;
  135572. /**
  135573. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  135574. * @param mesh The mesh to highlight
  135575. */
  135576. removeExcludedMesh(mesh: Mesh): void;
  135577. /**
  135578. * Determine if a given mesh will be highlighted by the current HighlightLayer
  135579. * @param mesh mesh to test
  135580. * @returns true if the mesh will be highlighted by the current HighlightLayer
  135581. */
  135582. hasMesh(mesh: AbstractMesh): boolean;
  135583. /**
  135584. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  135585. * @param mesh The mesh to highlight
  135586. * @param color The color of the highlight
  135587. * @param glowEmissiveOnly Extract the glow from the emissive texture
  135588. */
  135589. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  135590. /**
  135591. * Remove a mesh from the highlight layer in order to make it stop glowing.
  135592. * @param mesh The mesh to highlight
  135593. */
  135594. removeMesh(mesh: Mesh): void;
  135595. /**
  135596. * Remove all the meshes currently referenced in the highlight layer
  135597. */
  135598. removeAllMeshes(): void;
  135599. /**
  135600. * Force the stencil to the normal expected value for none glowing parts
  135601. */
  135602. private _defaultStencilReference;
  135603. /**
  135604. * Free any resources and references associated to a mesh.
  135605. * Internal use
  135606. * @param mesh The mesh to free.
  135607. * @hidden
  135608. */
  135609. _disposeMesh(mesh: Mesh): void;
  135610. /**
  135611. * Dispose the highlight layer and free resources.
  135612. */
  135613. dispose(): void;
  135614. /**
  135615. * Gets the class name of the effect layer
  135616. * @returns the string with the class name of the effect layer
  135617. */
  135618. getClassName(): string;
  135619. /**
  135620. * Serializes this Highlight layer
  135621. * @returns a serialized Highlight layer object
  135622. */
  135623. serialize(): any;
  135624. /**
  135625. * Creates a Highlight layer from parsed Highlight layer data
  135626. * @param parsedHightlightLayer defines the Highlight layer data
  135627. * @param scene defines the current scene
  135628. * @param rootUrl defines the root URL containing the Highlight layer information
  135629. * @returns a parsed Highlight layer
  135630. */
  135631. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135632. }
  135633. }
  135634. declare module BABYLON {
  135635. interface AbstractScene {
  135636. /**
  135637. * The list of layers (background and foreground) of the scene
  135638. */
  135639. layers: Array<Layer>;
  135640. }
  135641. /**
  135642. * Defines the layer scene component responsible to manage any layers
  135643. * in a given scene.
  135644. */
  135645. export class LayerSceneComponent implements ISceneComponent {
  135646. /**
  135647. * The component name helpfull to identify the component in the list of scene components.
  135648. */
  135649. readonly name: string;
  135650. /**
  135651. * The scene the component belongs to.
  135652. */
  135653. scene: Scene;
  135654. private _engine;
  135655. /**
  135656. * Creates a new instance of the component for the given scene
  135657. * @param scene Defines the scene to register the component in
  135658. */
  135659. constructor(scene: Scene);
  135660. /**
  135661. * Registers the component in a given scene
  135662. */
  135663. register(): void;
  135664. /**
  135665. * Rebuilds the elements related to this component in case of
  135666. * context lost for instance.
  135667. */
  135668. rebuild(): void;
  135669. /**
  135670. * Disposes the component and the associated ressources.
  135671. */
  135672. dispose(): void;
  135673. private _draw;
  135674. private _drawCameraPredicate;
  135675. private _drawCameraBackground;
  135676. private _drawCameraForeground;
  135677. private _drawRenderTargetPredicate;
  135678. private _drawRenderTargetBackground;
  135679. private _drawRenderTargetForeground;
  135680. /**
  135681. * Adds all the elements from the container to the scene
  135682. * @param container the container holding the elements
  135683. */
  135684. addFromContainer(container: AbstractScene): void;
  135685. /**
  135686. * Removes all the elements in the container from the scene
  135687. * @param container contains the elements to remove
  135688. * @param dispose if the removed element should be disposed (default: false)
  135689. */
  135690. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135691. }
  135692. }
  135693. declare module BABYLON {
  135694. /** @hidden */
  135695. export var layerPixelShader: {
  135696. name: string;
  135697. shader: string;
  135698. };
  135699. }
  135700. declare module BABYLON {
  135701. /** @hidden */
  135702. export var layerVertexShader: {
  135703. name: string;
  135704. shader: string;
  135705. };
  135706. }
  135707. declare module BABYLON {
  135708. /**
  135709. * This represents a full screen 2d layer.
  135710. * This can be useful to display a picture in the background of your scene for instance.
  135711. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135712. */
  135713. export class Layer {
  135714. /**
  135715. * Define the name of the layer.
  135716. */
  135717. name: string;
  135718. /**
  135719. * Define the texture the layer should display.
  135720. */
  135721. texture: Nullable<Texture>;
  135722. /**
  135723. * Is the layer in background or foreground.
  135724. */
  135725. isBackground: boolean;
  135726. /**
  135727. * Define the color of the layer (instead of texture).
  135728. */
  135729. color: Color4;
  135730. /**
  135731. * Define the scale of the layer in order to zoom in out of the texture.
  135732. */
  135733. scale: Vector2;
  135734. /**
  135735. * Define an offset for the layer in order to shift the texture.
  135736. */
  135737. offset: Vector2;
  135738. /**
  135739. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135740. */
  135741. alphaBlendingMode: number;
  135742. /**
  135743. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135744. * Alpha test will not mix with the background color in case of transparency.
  135745. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135746. */
  135747. alphaTest: boolean;
  135748. /**
  135749. * Define a mask to restrict the layer to only some of the scene cameras.
  135750. */
  135751. layerMask: number;
  135752. /**
  135753. * Define the list of render target the layer is visible into.
  135754. */
  135755. renderTargetTextures: RenderTargetTexture[];
  135756. /**
  135757. * Define if the layer is only used in renderTarget or if it also
  135758. * renders in the main frame buffer of the canvas.
  135759. */
  135760. renderOnlyInRenderTargetTextures: boolean;
  135761. private _scene;
  135762. private _vertexBuffers;
  135763. private _indexBuffer;
  135764. private _effect;
  135765. private _previousDefines;
  135766. /**
  135767. * An event triggered when the layer is disposed.
  135768. */
  135769. onDisposeObservable: Observable<Layer>;
  135770. private _onDisposeObserver;
  135771. /**
  135772. * Back compatibility with callback before the onDisposeObservable existed.
  135773. * The set callback will be triggered when the layer has been disposed.
  135774. */
  135775. set onDispose(callback: () => void);
  135776. /**
  135777. * An event triggered before rendering the scene
  135778. */
  135779. onBeforeRenderObservable: Observable<Layer>;
  135780. private _onBeforeRenderObserver;
  135781. /**
  135782. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135783. * The set callback will be triggered just before rendering the layer.
  135784. */
  135785. set onBeforeRender(callback: () => void);
  135786. /**
  135787. * An event triggered after rendering the scene
  135788. */
  135789. onAfterRenderObservable: Observable<Layer>;
  135790. private _onAfterRenderObserver;
  135791. /**
  135792. * Back compatibility with callback before the onAfterRenderObservable existed.
  135793. * The set callback will be triggered just after rendering the layer.
  135794. */
  135795. set onAfterRender(callback: () => void);
  135796. /**
  135797. * Instantiates a new layer.
  135798. * This represents a full screen 2d layer.
  135799. * This can be useful to display a picture in the background of your scene for instance.
  135800. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135801. * @param name Define the name of the layer in the scene
  135802. * @param imgUrl Define the url of the texture to display in the layer
  135803. * @param scene Define the scene the layer belongs to
  135804. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135805. * @param color Defines a color for the layer
  135806. */
  135807. constructor(
  135808. /**
  135809. * Define the name of the layer.
  135810. */
  135811. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135812. private _createIndexBuffer;
  135813. /** @hidden */
  135814. _rebuild(): void;
  135815. /**
  135816. * Renders the layer in the scene.
  135817. */
  135818. render(): void;
  135819. /**
  135820. * Disposes and releases the associated ressources.
  135821. */
  135822. dispose(): void;
  135823. }
  135824. }
  135825. declare module BABYLON {
  135826. /** @hidden */
  135827. export var lensFlarePixelShader: {
  135828. name: string;
  135829. shader: string;
  135830. };
  135831. }
  135832. declare module BABYLON {
  135833. /** @hidden */
  135834. export var lensFlareVertexShader: {
  135835. name: string;
  135836. shader: string;
  135837. };
  135838. }
  135839. declare module BABYLON {
  135840. /**
  135841. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135842. * It is usually composed of several `lensFlare`.
  135843. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135844. */
  135845. export class LensFlareSystem {
  135846. /**
  135847. * Define the name of the lens flare system
  135848. */
  135849. name: string;
  135850. /**
  135851. * List of lens flares used in this system.
  135852. */
  135853. lensFlares: LensFlare[];
  135854. /**
  135855. * Define a limit from the border the lens flare can be visible.
  135856. */
  135857. borderLimit: number;
  135858. /**
  135859. * Define a viewport border we do not want to see the lens flare in.
  135860. */
  135861. viewportBorder: number;
  135862. /**
  135863. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135864. */
  135865. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135866. /**
  135867. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135868. */
  135869. layerMask: number;
  135870. /**
  135871. * Define the id of the lens flare system in the scene.
  135872. * (equal to name by default)
  135873. */
  135874. id: string;
  135875. private _scene;
  135876. private _emitter;
  135877. private _vertexBuffers;
  135878. private _indexBuffer;
  135879. private _effect;
  135880. private _positionX;
  135881. private _positionY;
  135882. private _isEnabled;
  135883. /** @hidden */
  135884. static _SceneComponentInitialization: (scene: Scene) => void;
  135885. /**
  135886. * Instantiates a lens flare system.
  135887. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135888. * It is usually composed of several `lensFlare`.
  135889. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135890. * @param name Define the name of the lens flare system in the scene
  135891. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135892. * @param scene Define the scene the lens flare system belongs to
  135893. */
  135894. constructor(
  135895. /**
  135896. * Define the name of the lens flare system
  135897. */
  135898. name: string, emitter: any, scene: Scene);
  135899. /**
  135900. * Define if the lens flare system is enabled.
  135901. */
  135902. get isEnabled(): boolean;
  135903. set isEnabled(value: boolean);
  135904. /**
  135905. * Get the scene the effects belongs to.
  135906. * @returns the scene holding the lens flare system
  135907. */
  135908. getScene(): Scene;
  135909. /**
  135910. * Get the emitter of the lens flare system.
  135911. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135912. * @returns the emitter of the lens flare system
  135913. */
  135914. getEmitter(): any;
  135915. /**
  135916. * Set the emitter of the lens flare system.
  135917. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135918. * @param newEmitter Define the new emitter of the system
  135919. */
  135920. setEmitter(newEmitter: any): void;
  135921. /**
  135922. * Get the lens flare system emitter position.
  135923. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135924. * @returns the position
  135925. */
  135926. getEmitterPosition(): Vector3;
  135927. /**
  135928. * @hidden
  135929. */
  135930. computeEffectivePosition(globalViewport: Viewport): boolean;
  135931. /** @hidden */
  135932. _isVisible(): boolean;
  135933. /**
  135934. * @hidden
  135935. */
  135936. render(): boolean;
  135937. /**
  135938. * Dispose and release the lens flare with its associated resources.
  135939. */
  135940. dispose(): void;
  135941. /**
  135942. * Parse a lens flare system from a JSON repressentation
  135943. * @param parsedLensFlareSystem Define the JSON to parse
  135944. * @param scene Define the scene the parsed system should be instantiated in
  135945. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135946. * @returns the parsed system
  135947. */
  135948. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135949. /**
  135950. * Serialize the current Lens Flare System into a JSON representation.
  135951. * @returns the serialized JSON
  135952. */
  135953. serialize(): any;
  135954. }
  135955. }
  135956. declare module BABYLON {
  135957. /**
  135958. * This represents one of the lens effect in a `lensFlareSystem`.
  135959. * It controls one of the indiviual texture used in the effect.
  135960. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135961. */
  135962. export class LensFlare {
  135963. /**
  135964. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135965. */
  135966. size: number;
  135967. /**
  135968. * 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.
  135969. */
  135970. position: number;
  135971. /**
  135972. * Define the lens color.
  135973. */
  135974. color: Color3;
  135975. /**
  135976. * Define the lens texture.
  135977. */
  135978. texture: Nullable<Texture>;
  135979. /**
  135980. * Define the alpha mode to render this particular lens.
  135981. */
  135982. alphaMode: number;
  135983. private _system;
  135984. /**
  135985. * Creates a new Lens Flare.
  135986. * This represents one of the lens effect in a `lensFlareSystem`.
  135987. * It controls one of the indiviual texture used in the effect.
  135988. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135989. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135990. * @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.
  135991. * @param color Define the lens color
  135992. * @param imgUrl Define the lens texture url
  135993. * @param system Define the `lensFlareSystem` this flare is part of
  135994. * @returns The newly created Lens Flare
  135995. */
  135996. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135997. /**
  135998. * Instantiates a new Lens Flare.
  135999. * This represents one of the lens effect in a `lensFlareSystem`.
  136000. * It controls one of the indiviual texture used in the effect.
  136001. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136002. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136003. * @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.
  136004. * @param color Define the lens color
  136005. * @param imgUrl Define the lens texture url
  136006. * @param system Define the `lensFlareSystem` this flare is part of
  136007. */
  136008. constructor(
  136009. /**
  136010. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136011. */
  136012. size: number,
  136013. /**
  136014. * 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.
  136015. */
  136016. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136017. /**
  136018. * Dispose and release the lens flare with its associated resources.
  136019. */
  136020. dispose(): void;
  136021. }
  136022. }
  136023. declare module BABYLON {
  136024. interface AbstractScene {
  136025. /**
  136026. * The list of lens flare system added to the scene
  136027. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136028. */
  136029. lensFlareSystems: Array<LensFlareSystem>;
  136030. /**
  136031. * Removes the given lens flare system from this scene.
  136032. * @param toRemove The lens flare system to remove
  136033. * @returns The index of the removed lens flare system
  136034. */
  136035. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136036. /**
  136037. * Adds the given lens flare system to this scene
  136038. * @param newLensFlareSystem The lens flare system to add
  136039. */
  136040. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136041. /**
  136042. * Gets a lens flare system using its name
  136043. * @param name defines the name to look for
  136044. * @returns the lens flare system or null if not found
  136045. */
  136046. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136047. /**
  136048. * Gets a lens flare system using its id
  136049. * @param id defines the id to look for
  136050. * @returns the lens flare system or null if not found
  136051. */
  136052. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136053. }
  136054. /**
  136055. * Defines the lens flare scene component responsible to manage any lens flares
  136056. * in a given scene.
  136057. */
  136058. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136059. /**
  136060. * The component name helpfull to identify the component in the list of scene components.
  136061. */
  136062. readonly name: string;
  136063. /**
  136064. * The scene the component belongs to.
  136065. */
  136066. scene: Scene;
  136067. /**
  136068. * Creates a new instance of the component for the given scene
  136069. * @param scene Defines the scene to register the component in
  136070. */
  136071. constructor(scene: Scene);
  136072. /**
  136073. * Registers the component in a given scene
  136074. */
  136075. register(): void;
  136076. /**
  136077. * Rebuilds the elements related to this component in case of
  136078. * context lost for instance.
  136079. */
  136080. rebuild(): void;
  136081. /**
  136082. * Adds all the elements from the container to the scene
  136083. * @param container the container holding the elements
  136084. */
  136085. addFromContainer(container: AbstractScene): void;
  136086. /**
  136087. * Removes all the elements in the container from the scene
  136088. * @param container contains the elements to remove
  136089. * @param dispose if the removed element should be disposed (default: false)
  136090. */
  136091. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136092. /**
  136093. * Serializes the component data to the specified json object
  136094. * @param serializationObject The object to serialize to
  136095. */
  136096. serialize(serializationObject: any): void;
  136097. /**
  136098. * Disposes the component and the associated ressources.
  136099. */
  136100. dispose(): void;
  136101. private _draw;
  136102. }
  136103. }
  136104. declare module BABYLON {
  136105. /** @hidden */
  136106. export var depthPixelShader: {
  136107. name: string;
  136108. shader: string;
  136109. };
  136110. }
  136111. declare module BABYLON {
  136112. /** @hidden */
  136113. export var depthVertexShader: {
  136114. name: string;
  136115. shader: string;
  136116. };
  136117. }
  136118. declare module BABYLON {
  136119. /**
  136120. * This represents a depth renderer in Babylon.
  136121. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136122. */
  136123. export class DepthRenderer {
  136124. private _scene;
  136125. private _depthMap;
  136126. private _effect;
  136127. private readonly _storeNonLinearDepth;
  136128. private readonly _clearColor;
  136129. /** Get if the depth renderer is using packed depth or not */
  136130. readonly isPacked: boolean;
  136131. private _cachedDefines;
  136132. private _camera;
  136133. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136134. enabled: boolean;
  136135. /**
  136136. * Specifiess that the depth renderer will only be used within
  136137. * the camera it is created for.
  136138. * This can help forcing its rendering during the camera processing.
  136139. */
  136140. useOnlyInActiveCamera: boolean;
  136141. /** @hidden */
  136142. static _SceneComponentInitialization: (scene: Scene) => void;
  136143. /**
  136144. * Instantiates a depth renderer
  136145. * @param scene The scene the renderer belongs to
  136146. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136147. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136148. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136149. */
  136150. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136151. /**
  136152. * Creates the depth rendering effect and checks if the effect is ready.
  136153. * @param subMesh The submesh to be used to render the depth map of
  136154. * @param useInstances If multiple world instances should be used
  136155. * @returns if the depth renderer is ready to render the depth map
  136156. */
  136157. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136158. /**
  136159. * Gets the texture which the depth map will be written to.
  136160. * @returns The depth map texture
  136161. */
  136162. getDepthMap(): RenderTargetTexture;
  136163. /**
  136164. * Disposes of the depth renderer.
  136165. */
  136166. dispose(): void;
  136167. }
  136168. }
  136169. declare module BABYLON {
  136170. /** @hidden */
  136171. export var minmaxReduxPixelShader: {
  136172. name: string;
  136173. shader: string;
  136174. };
  136175. }
  136176. declare module BABYLON {
  136177. /**
  136178. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136179. * and maximum values from all values of the texture.
  136180. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136181. * The source values are read from the red channel of the texture.
  136182. */
  136183. export class MinMaxReducer {
  136184. /**
  136185. * Observable triggered when the computation has been performed
  136186. */
  136187. onAfterReductionPerformed: Observable<{
  136188. min: number;
  136189. max: number;
  136190. }>;
  136191. protected _camera: Camera;
  136192. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136193. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136194. protected _postProcessManager: PostProcessManager;
  136195. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136196. protected _forceFullscreenViewport: boolean;
  136197. /**
  136198. * Creates a min/max reducer
  136199. * @param camera The camera to use for the post processes
  136200. */
  136201. constructor(camera: Camera);
  136202. /**
  136203. * Gets the texture used to read the values from.
  136204. */
  136205. get sourceTexture(): Nullable<RenderTargetTexture>;
  136206. /**
  136207. * Sets the source texture to read the values from.
  136208. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136209. * because in such textures '1' value must not be taken into account to compute the maximum
  136210. * as this value is used to clear the texture.
  136211. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136212. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136213. * @param depthRedux Indicates if the texture is a depth texture or not
  136214. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136215. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136216. */
  136217. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136218. /**
  136219. * Defines the refresh rate of the computation.
  136220. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136221. */
  136222. get refreshRate(): number;
  136223. set refreshRate(value: number);
  136224. protected _activated: boolean;
  136225. /**
  136226. * Gets the activation status of the reducer
  136227. */
  136228. get activated(): boolean;
  136229. /**
  136230. * Activates the reduction computation.
  136231. * When activated, the observers registered in onAfterReductionPerformed are
  136232. * called after the compuation is performed
  136233. */
  136234. activate(): void;
  136235. /**
  136236. * Deactivates the reduction computation.
  136237. */
  136238. deactivate(): void;
  136239. /**
  136240. * Disposes the min/max reducer
  136241. * @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.
  136242. */
  136243. dispose(disposeAll?: boolean): void;
  136244. }
  136245. }
  136246. declare module BABYLON {
  136247. /**
  136248. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136249. */
  136250. export class DepthReducer extends MinMaxReducer {
  136251. private _depthRenderer;
  136252. private _depthRendererId;
  136253. /**
  136254. * Gets the depth renderer used for the computation.
  136255. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136256. */
  136257. get depthRenderer(): Nullable<DepthRenderer>;
  136258. /**
  136259. * Creates a depth reducer
  136260. * @param camera The camera used to render the depth texture
  136261. */
  136262. constructor(camera: Camera);
  136263. /**
  136264. * Sets the depth renderer to use to generate the depth map
  136265. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136266. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136267. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136268. */
  136269. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136270. /** @hidden */
  136271. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136272. /**
  136273. * Activates the reduction computation.
  136274. * When activated, the observers registered in onAfterReductionPerformed are
  136275. * called after the compuation is performed
  136276. */
  136277. activate(): void;
  136278. /**
  136279. * Deactivates the reduction computation.
  136280. */
  136281. deactivate(): void;
  136282. /**
  136283. * Disposes the depth reducer
  136284. * @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.
  136285. */
  136286. dispose(disposeAll?: boolean): void;
  136287. }
  136288. }
  136289. declare module BABYLON {
  136290. /**
  136291. * A CSM implementation allowing casting shadows on large scenes.
  136292. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136293. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136294. */
  136295. export class CascadedShadowGenerator extends ShadowGenerator {
  136296. private static readonly frustumCornersNDCSpace;
  136297. /**
  136298. * Name of the CSM class
  136299. */
  136300. static CLASSNAME: string;
  136301. /**
  136302. * Defines the default number of cascades used by the CSM.
  136303. */
  136304. static readonly DEFAULT_CASCADES_COUNT: number;
  136305. /**
  136306. * Defines the minimum number of cascades used by the CSM.
  136307. */
  136308. static readonly MIN_CASCADES_COUNT: number;
  136309. /**
  136310. * Defines the maximum number of cascades used by the CSM.
  136311. */
  136312. static readonly MAX_CASCADES_COUNT: number;
  136313. protected _validateFilter(filter: number): number;
  136314. /**
  136315. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136316. */
  136317. penumbraDarkness: number;
  136318. private _numCascades;
  136319. /**
  136320. * Gets or set the number of cascades used by the CSM.
  136321. */
  136322. get numCascades(): number;
  136323. set numCascades(value: number);
  136324. /**
  136325. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136326. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136327. */
  136328. stabilizeCascades: boolean;
  136329. private _freezeShadowCastersBoundingInfo;
  136330. private _freezeShadowCastersBoundingInfoObservable;
  136331. /**
  136332. * Enables or disables the shadow casters bounding info computation.
  136333. * If your shadow casters don't move, you can disable this feature.
  136334. * If it is enabled, the bounding box computation is done every frame.
  136335. */
  136336. get freezeShadowCastersBoundingInfo(): boolean;
  136337. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136338. private _scbiMin;
  136339. private _scbiMax;
  136340. protected _computeShadowCastersBoundingInfo(): void;
  136341. protected _shadowCastersBoundingInfo: BoundingInfo;
  136342. /**
  136343. * Gets or sets the shadow casters bounding info.
  136344. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136345. * so that the system won't overwrite the bounds you provide
  136346. */
  136347. get shadowCastersBoundingInfo(): BoundingInfo;
  136348. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136349. protected _breaksAreDirty: boolean;
  136350. protected _minDistance: number;
  136351. protected _maxDistance: number;
  136352. /**
  136353. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136354. *
  136355. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136356. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136357. * @param min minimal distance for the breaks (default to 0.)
  136358. * @param max maximal distance for the breaks (default to 1.)
  136359. */
  136360. setMinMaxDistance(min: number, max: number): void;
  136361. /** Gets the minimal distance used in the cascade break computation */
  136362. get minDistance(): number;
  136363. /** Gets the maximal distance used in the cascade break computation */
  136364. get maxDistance(): number;
  136365. /**
  136366. * Gets the class name of that object
  136367. * @returns "CascadedShadowGenerator"
  136368. */
  136369. getClassName(): string;
  136370. private _cascadeMinExtents;
  136371. private _cascadeMaxExtents;
  136372. /**
  136373. * Gets a cascade minimum extents
  136374. * @param cascadeIndex index of the cascade
  136375. * @returns the minimum cascade extents
  136376. */
  136377. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136378. /**
  136379. * Gets a cascade maximum extents
  136380. * @param cascadeIndex index of the cascade
  136381. * @returns the maximum cascade extents
  136382. */
  136383. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136384. private _cascades;
  136385. private _currentLayer;
  136386. private _viewSpaceFrustumsZ;
  136387. private _viewMatrices;
  136388. private _projectionMatrices;
  136389. private _transformMatrices;
  136390. private _transformMatricesAsArray;
  136391. private _frustumLengths;
  136392. private _lightSizeUVCorrection;
  136393. private _depthCorrection;
  136394. private _frustumCornersWorldSpace;
  136395. private _frustumCenter;
  136396. private _shadowCameraPos;
  136397. private _shadowMaxZ;
  136398. /**
  136399. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136400. * It defaults to camera.maxZ
  136401. */
  136402. get shadowMaxZ(): number;
  136403. /**
  136404. * Sets the shadow max z distance.
  136405. */
  136406. set shadowMaxZ(value: number);
  136407. protected _debug: boolean;
  136408. /**
  136409. * Gets or sets the debug flag.
  136410. * When enabled, the cascades are materialized by different colors on the screen.
  136411. */
  136412. get debug(): boolean;
  136413. set debug(dbg: boolean);
  136414. private _depthClamp;
  136415. /**
  136416. * Gets or sets the depth clamping value.
  136417. *
  136418. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136419. * to account for the shadow casters far away.
  136420. *
  136421. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136422. */
  136423. get depthClamp(): boolean;
  136424. set depthClamp(value: boolean);
  136425. private _cascadeBlendPercentage;
  136426. /**
  136427. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136428. * It defaults to 0.1 (10% blending).
  136429. */
  136430. get cascadeBlendPercentage(): number;
  136431. set cascadeBlendPercentage(value: number);
  136432. private _lambda;
  136433. /**
  136434. * Gets or set the lambda parameter.
  136435. * This parameter is used to split the camera frustum and create the cascades.
  136436. * 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.
  136437. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136438. */
  136439. get lambda(): number;
  136440. set lambda(value: number);
  136441. /**
  136442. * Gets the view matrix corresponding to a given cascade
  136443. * @param cascadeNum cascade to retrieve the view matrix from
  136444. * @returns the cascade view matrix
  136445. */
  136446. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136447. /**
  136448. * Gets the projection matrix corresponding to a given cascade
  136449. * @param cascadeNum cascade to retrieve the projection matrix from
  136450. * @returns the cascade projection matrix
  136451. */
  136452. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136453. /**
  136454. * Gets the transformation matrix corresponding to a given cascade
  136455. * @param cascadeNum cascade to retrieve the transformation matrix from
  136456. * @returns the cascade transformation matrix
  136457. */
  136458. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136459. private _depthRenderer;
  136460. /**
  136461. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136462. *
  136463. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136464. *
  136465. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136466. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136467. * @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
  136468. */
  136469. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136470. private _depthReducer;
  136471. private _autoCalcDepthBounds;
  136472. /**
  136473. * Gets or sets the autoCalcDepthBounds property.
  136474. *
  136475. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136476. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136477. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136478. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136479. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136480. */
  136481. get autoCalcDepthBounds(): boolean;
  136482. set autoCalcDepthBounds(value: boolean);
  136483. /**
  136484. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136485. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136486. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136487. * for setting the refresh rate on the renderer yourself!
  136488. */
  136489. get autoCalcDepthBoundsRefreshRate(): number;
  136490. set autoCalcDepthBoundsRefreshRate(value: number);
  136491. /**
  136492. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136493. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136494. * you change the camera near/far planes!
  136495. */
  136496. splitFrustum(): void;
  136497. private _splitFrustum;
  136498. private _computeMatrices;
  136499. private _computeFrustumInWorldSpace;
  136500. private _computeCascadeFrustum;
  136501. /**
  136502. * Support test.
  136503. */
  136504. static get IsSupported(): boolean;
  136505. /** @hidden */
  136506. static _SceneComponentInitialization: (scene: Scene) => void;
  136507. /**
  136508. * Creates a Cascaded Shadow Generator object.
  136509. * A ShadowGenerator is the required tool to use the shadows.
  136510. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136511. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136512. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136513. * @param light The directional light object generating the shadows.
  136514. * @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.
  136515. */
  136516. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136517. protected _initializeGenerator(): void;
  136518. protected _createTargetRenderTexture(): void;
  136519. protected _initializeShadowMap(): void;
  136520. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136521. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136522. /**
  136523. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136524. * @param defines Defines of the material we want to update
  136525. * @param lightIndex Index of the light in the enabled light list of the material
  136526. */
  136527. prepareDefines(defines: any, lightIndex: number): void;
  136528. /**
  136529. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136530. * defined in the generator but impacting the effect).
  136531. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136532. * @param effect The effect we are binfing the information for
  136533. */
  136534. bindShadowLight(lightIndex: string, effect: Effect): void;
  136535. /**
  136536. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136537. * (eq to view projection * shadow projection matrices)
  136538. * @returns The transform matrix used to create the shadow map
  136539. */
  136540. getTransformMatrix(): Matrix;
  136541. /**
  136542. * Disposes the ShadowGenerator.
  136543. * Returns nothing.
  136544. */
  136545. dispose(): void;
  136546. /**
  136547. * Serializes the shadow generator setup to a json object.
  136548. * @returns The serialized JSON object
  136549. */
  136550. serialize(): any;
  136551. /**
  136552. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136553. * @param parsedShadowGenerator The JSON object to parse
  136554. * @param scene The scene to create the shadow map for
  136555. * @returns The parsed shadow generator
  136556. */
  136557. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  136558. }
  136559. }
  136560. declare module BABYLON {
  136561. /**
  136562. * Defines the shadow generator component responsible to manage any shadow generators
  136563. * in a given scene.
  136564. */
  136565. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  136566. /**
  136567. * The component name helpfull to identify the component in the list of scene components.
  136568. */
  136569. readonly name: string;
  136570. /**
  136571. * The scene the component belongs to.
  136572. */
  136573. scene: Scene;
  136574. /**
  136575. * Creates a new instance of the component for the given scene
  136576. * @param scene Defines the scene to register the component in
  136577. */
  136578. constructor(scene: Scene);
  136579. /**
  136580. * Registers the component in a given scene
  136581. */
  136582. register(): void;
  136583. /**
  136584. * Rebuilds the elements related to this component in case of
  136585. * context lost for instance.
  136586. */
  136587. rebuild(): void;
  136588. /**
  136589. * Serializes the component data to the specified json object
  136590. * @param serializationObject The object to serialize to
  136591. */
  136592. serialize(serializationObject: any): void;
  136593. /**
  136594. * Adds all the elements from the container to the scene
  136595. * @param container the container holding the elements
  136596. */
  136597. addFromContainer(container: AbstractScene): void;
  136598. /**
  136599. * Removes all the elements in the container from the scene
  136600. * @param container contains the elements to remove
  136601. * @param dispose if the removed element should be disposed (default: false)
  136602. */
  136603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136604. /**
  136605. * Rebuilds the elements related to this component in case of
  136606. * context lost for instance.
  136607. */
  136608. dispose(): void;
  136609. private _gatherRenderTargets;
  136610. }
  136611. }
  136612. declare module BABYLON {
  136613. /**
  136614. * A point light is a light defined by an unique point in world space.
  136615. * The light is emitted in every direction from this point.
  136616. * A good example of a point light is a standard light bulb.
  136617. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136618. */
  136619. export class PointLight extends ShadowLight {
  136620. private _shadowAngle;
  136621. /**
  136622. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136623. * This specifies what angle the shadow will use to be created.
  136624. *
  136625. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136626. */
  136627. get shadowAngle(): number;
  136628. /**
  136629. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136630. * This specifies what angle the shadow will use to be created.
  136631. *
  136632. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136633. */
  136634. set shadowAngle(value: number);
  136635. /**
  136636. * Gets the direction if it has been set.
  136637. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136638. */
  136639. get direction(): Vector3;
  136640. /**
  136641. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136642. */
  136643. set direction(value: Vector3);
  136644. /**
  136645. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136646. * A PointLight emits the light in every direction.
  136647. * It can cast shadows.
  136648. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136649. * ```javascript
  136650. * var pointLight = new PointLight("pl", camera.position, scene);
  136651. * ```
  136652. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136653. * @param name The light friendly name
  136654. * @param position The position of the point light in the scene
  136655. * @param scene The scene the lights belongs to
  136656. */
  136657. constructor(name: string, position: Vector3, scene: Scene);
  136658. /**
  136659. * Returns the string "PointLight"
  136660. * @returns the class name
  136661. */
  136662. getClassName(): string;
  136663. /**
  136664. * Returns the integer 0.
  136665. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136666. */
  136667. getTypeID(): number;
  136668. /**
  136669. * Specifies wether or not the shadowmap should be a cube texture.
  136670. * @returns true if the shadowmap needs to be a cube texture.
  136671. */
  136672. needCube(): boolean;
  136673. /**
  136674. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136675. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136676. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136677. */
  136678. getShadowDirection(faceIndex?: number): Vector3;
  136679. /**
  136680. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136681. * - fov = PI / 2
  136682. * - aspect ratio : 1.0
  136683. * - z-near and far equal to the active camera minZ and maxZ.
  136684. * Returns the PointLight.
  136685. */
  136686. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136687. protected _buildUniformLayout(): void;
  136688. /**
  136689. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136690. * @param effect The effect to update
  136691. * @param lightIndex The index of the light in the effect to update
  136692. * @returns The point light
  136693. */
  136694. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136695. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136696. /**
  136697. * Prepares the list of defines specific to the light type.
  136698. * @param defines the list of defines
  136699. * @param lightIndex defines the index of the light for the effect
  136700. */
  136701. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136702. }
  136703. }
  136704. declare module BABYLON {
  136705. /**
  136706. * Header information of HDR texture files.
  136707. */
  136708. export interface HDRInfo {
  136709. /**
  136710. * The height of the texture in pixels.
  136711. */
  136712. height: number;
  136713. /**
  136714. * The width of the texture in pixels.
  136715. */
  136716. width: number;
  136717. /**
  136718. * The index of the beginning of the data in the binary file.
  136719. */
  136720. dataPosition: number;
  136721. }
  136722. /**
  136723. * This groups tools to convert HDR texture to native colors array.
  136724. */
  136725. export class HDRTools {
  136726. private static Ldexp;
  136727. private static Rgbe2float;
  136728. private static readStringLine;
  136729. /**
  136730. * Reads header information from an RGBE texture stored in a native array.
  136731. * More information on this format are available here:
  136732. * https://en.wikipedia.org/wiki/RGBE_image_format
  136733. *
  136734. * @param uint8array The binary file stored in native array.
  136735. * @return The header information.
  136736. */
  136737. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136738. /**
  136739. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136740. * This RGBE texture needs to store the information as a panorama.
  136741. *
  136742. * More information on this format are available here:
  136743. * https://en.wikipedia.org/wiki/RGBE_image_format
  136744. *
  136745. * @param buffer The binary file stored in an array buffer.
  136746. * @param size The expected size of the extracted cubemap.
  136747. * @return The Cube Map information.
  136748. */
  136749. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136750. /**
  136751. * Returns the pixels data extracted from an RGBE texture.
  136752. * This pixels will be stored left to right up to down in the R G B order in one array.
  136753. *
  136754. * More information on this format are available here:
  136755. * https://en.wikipedia.org/wiki/RGBE_image_format
  136756. *
  136757. * @param uint8array The binary file stored in an array buffer.
  136758. * @param hdrInfo The header information of the file.
  136759. * @return The pixels data in RGB right to left up to down order.
  136760. */
  136761. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136762. private static RGBE_ReadPixels_RLE;
  136763. }
  136764. }
  136765. declare module BABYLON {
  136766. /**
  136767. * Effect Render Options
  136768. */
  136769. export interface IEffectRendererOptions {
  136770. /**
  136771. * Defines the vertices positions.
  136772. */
  136773. positions?: number[];
  136774. /**
  136775. * Defines the indices.
  136776. */
  136777. indices?: number[];
  136778. }
  136779. /**
  136780. * Helper class to render one or more effects.
  136781. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136782. */
  136783. export class EffectRenderer {
  136784. private engine;
  136785. private static _DefaultOptions;
  136786. private _vertexBuffers;
  136787. private _indexBuffer;
  136788. private _fullscreenViewport;
  136789. /**
  136790. * Creates an effect renderer
  136791. * @param engine the engine to use for rendering
  136792. * @param options defines the options of the effect renderer
  136793. */
  136794. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136795. /**
  136796. * Sets the current viewport in normalized coordinates 0-1
  136797. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136798. */
  136799. setViewport(viewport?: Viewport): void;
  136800. /**
  136801. * Binds the embedded attributes buffer to the effect.
  136802. * @param effect Defines the effect to bind the attributes for
  136803. */
  136804. bindBuffers(effect: Effect): void;
  136805. /**
  136806. * Sets the current effect wrapper to use during draw.
  136807. * The effect needs to be ready before calling this api.
  136808. * This also sets the default full screen position attribute.
  136809. * @param effectWrapper Defines the effect to draw with
  136810. */
  136811. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136812. /**
  136813. * Restores engine states
  136814. */
  136815. restoreStates(): void;
  136816. /**
  136817. * Draws a full screen quad.
  136818. */
  136819. draw(): void;
  136820. private isRenderTargetTexture;
  136821. /**
  136822. * renders one or more effects to a specified texture
  136823. * @param effectWrapper the effect to renderer
  136824. * @param outputTexture texture to draw to, if null it will render to the screen.
  136825. */
  136826. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136827. /**
  136828. * Disposes of the effect renderer
  136829. */
  136830. dispose(): void;
  136831. }
  136832. /**
  136833. * Options to create an EffectWrapper
  136834. */
  136835. interface EffectWrapperCreationOptions {
  136836. /**
  136837. * Engine to use to create the effect
  136838. */
  136839. engine: ThinEngine;
  136840. /**
  136841. * Fragment shader for the effect
  136842. */
  136843. fragmentShader: string;
  136844. /**
  136845. * Use the shader store instead of direct source code
  136846. */
  136847. useShaderStore?: boolean;
  136848. /**
  136849. * Vertex shader for the effect
  136850. */
  136851. vertexShader?: string;
  136852. /**
  136853. * Attributes to use in the shader
  136854. */
  136855. attributeNames?: Array<string>;
  136856. /**
  136857. * Uniforms to use in the shader
  136858. */
  136859. uniformNames?: Array<string>;
  136860. /**
  136861. * Texture sampler names to use in the shader
  136862. */
  136863. samplerNames?: Array<string>;
  136864. /**
  136865. * Defines to use in the shader
  136866. */
  136867. defines?: Array<string>;
  136868. /**
  136869. * Callback when effect is compiled
  136870. */
  136871. onCompiled?: Nullable<(effect: Effect) => void>;
  136872. /**
  136873. * The friendly name of the effect displayed in Spector.
  136874. */
  136875. name?: string;
  136876. }
  136877. /**
  136878. * Wraps an effect to be used for rendering
  136879. */
  136880. export class EffectWrapper {
  136881. /**
  136882. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136883. */
  136884. onApplyObservable: Observable<{}>;
  136885. /**
  136886. * The underlying effect
  136887. */
  136888. effect: Effect;
  136889. /**
  136890. * Creates an effect to be renderer
  136891. * @param creationOptions options to create the effect
  136892. */
  136893. constructor(creationOptions: EffectWrapperCreationOptions);
  136894. /**
  136895. * Disposes of the effect wrapper
  136896. */
  136897. dispose(): void;
  136898. }
  136899. }
  136900. declare module BABYLON {
  136901. /** @hidden */
  136902. export var hdrFilteringVertexShader: {
  136903. name: string;
  136904. shader: string;
  136905. };
  136906. }
  136907. declare module BABYLON {
  136908. /** @hidden */
  136909. export var hdrFilteringPixelShader: {
  136910. name: string;
  136911. shader: string;
  136912. };
  136913. }
  136914. declare module BABYLON {
  136915. /**
  136916. * Options for texture filtering
  136917. */
  136918. interface IHDRFilteringOptions {
  136919. /**
  136920. * Scales pixel intensity for the input HDR map.
  136921. */
  136922. hdrScale?: number;
  136923. /**
  136924. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136925. */
  136926. quality?: number;
  136927. }
  136928. /**
  136929. * Filters HDR maps to get correct renderings of PBR reflections
  136930. */
  136931. export class HDRFiltering {
  136932. private _engine;
  136933. private _effectRenderer;
  136934. private _effectWrapper;
  136935. private _lodGenerationOffset;
  136936. private _lodGenerationScale;
  136937. /**
  136938. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136939. * you care about baking speed.
  136940. */
  136941. quality: number;
  136942. /**
  136943. * Scales pixel intensity for the input HDR map.
  136944. */
  136945. hdrScale: number;
  136946. /**
  136947. * Instantiates HDR filter for reflection maps
  136948. *
  136949. * @param engine Thin engine
  136950. * @param options Options
  136951. */
  136952. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136953. private _createRenderTarget;
  136954. private _prefilterInternal;
  136955. private _createEffect;
  136956. /**
  136957. * Get a value indicating if the filter is ready to be used
  136958. * @param texture Texture to filter
  136959. * @returns true if the filter is ready
  136960. */
  136961. isReady(texture: BaseTexture): boolean;
  136962. /**
  136963. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136964. * Prefiltering will be invoked at the end of next rendering pass.
  136965. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136966. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136967. * @param texture Texture to filter
  136968. * @param onFinished Callback when filtering is done
  136969. * @return Promise called when prefiltering is done
  136970. */
  136971. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136972. }
  136973. }
  136974. declare module BABYLON {
  136975. /**
  136976. * This represents a texture coming from an HDR input.
  136977. *
  136978. * The only supported format is currently panorama picture stored in RGBE format.
  136979. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136980. */
  136981. export class HDRCubeTexture extends BaseTexture {
  136982. private static _facesMapping;
  136983. private _generateHarmonics;
  136984. private _noMipmap;
  136985. private _prefilterOnLoad;
  136986. private _textureMatrix;
  136987. private _size;
  136988. private _onLoad;
  136989. private _onError;
  136990. /**
  136991. * The texture URL.
  136992. */
  136993. url: string;
  136994. /**
  136995. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136996. */
  136997. coordinatesMode: number;
  136998. protected _isBlocking: boolean;
  136999. /**
  137000. * Sets wether or not the texture is blocking during loading.
  137001. */
  137002. set isBlocking(value: boolean);
  137003. /**
  137004. * Gets wether or not the texture is blocking during loading.
  137005. */
  137006. get isBlocking(): boolean;
  137007. protected _rotationY: number;
  137008. /**
  137009. * Sets texture matrix rotation angle around Y axis in radians.
  137010. */
  137011. set rotationY(value: number);
  137012. /**
  137013. * Gets texture matrix rotation angle around Y axis radians.
  137014. */
  137015. get rotationY(): number;
  137016. /**
  137017. * Gets or sets the center of the bounding box associated with the cube texture
  137018. * It must define where the camera used to render the texture was set
  137019. */
  137020. boundingBoxPosition: Vector3;
  137021. private _boundingBoxSize;
  137022. /**
  137023. * Gets or sets the size of the bounding box associated with the cube texture
  137024. * When defined, the cubemap will switch to local mode
  137025. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137026. * @example https://www.babylonjs-playground.com/#RNASML
  137027. */
  137028. set boundingBoxSize(value: Vector3);
  137029. get boundingBoxSize(): Vector3;
  137030. /**
  137031. * Instantiates an HDRTexture from the following parameters.
  137032. *
  137033. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137034. * @param sceneOrEngine The scene or engine the texture will be used in
  137035. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137036. * @param noMipmap Forces to not generate the mipmap if true
  137037. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137038. * @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)
  137039. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137040. */
  137041. 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>);
  137042. /**
  137043. * Get the current class name of the texture useful for serialization or dynamic coding.
  137044. * @returns "HDRCubeTexture"
  137045. */
  137046. getClassName(): string;
  137047. /**
  137048. * Occurs when the file is raw .hdr file.
  137049. */
  137050. private loadTexture;
  137051. clone(): HDRCubeTexture;
  137052. delayLoad(): void;
  137053. /**
  137054. * Get the texture reflection matrix used to rotate/transform the reflection.
  137055. * @returns the reflection matrix
  137056. */
  137057. getReflectionTextureMatrix(): Matrix;
  137058. /**
  137059. * Set the texture reflection matrix used to rotate/transform the reflection.
  137060. * @param value Define the reflection matrix to set
  137061. */
  137062. setReflectionTextureMatrix(value: Matrix): void;
  137063. /**
  137064. * Parses a JSON representation of an HDR Texture in order to create the texture
  137065. * @param parsedTexture Define the JSON representation
  137066. * @param scene Define the scene the texture should be created in
  137067. * @param rootUrl Define the root url in case we need to load relative dependencies
  137068. * @returns the newly created texture after parsing
  137069. */
  137070. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137071. serialize(): any;
  137072. }
  137073. }
  137074. declare module BABYLON {
  137075. /**
  137076. * Class used to control physics engine
  137077. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  137078. */
  137079. export class PhysicsEngine implements IPhysicsEngine {
  137080. private _physicsPlugin;
  137081. /**
  137082. * Global value used to control the smallest number supported by the simulation
  137083. */
  137084. static Epsilon: number;
  137085. private _impostors;
  137086. private _joints;
  137087. private _subTimeStep;
  137088. /**
  137089. * Gets the gravity vector used by the simulation
  137090. */
  137091. gravity: Vector3;
  137092. /**
  137093. * Factory used to create the default physics plugin.
  137094. * @returns The default physics plugin
  137095. */
  137096. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137097. /**
  137098. * Creates a new Physics Engine
  137099. * @param gravity defines the gravity vector used by the simulation
  137100. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137101. */
  137102. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137103. /**
  137104. * Sets the gravity vector used by the simulation
  137105. * @param gravity defines the gravity vector to use
  137106. */
  137107. setGravity(gravity: Vector3): void;
  137108. /**
  137109. * Set the time step of the physics engine.
  137110. * Default is 1/60.
  137111. * To slow it down, enter 1/600 for example.
  137112. * To speed it up, 1/30
  137113. * @param newTimeStep defines the new timestep to apply to this world.
  137114. */
  137115. setTimeStep(newTimeStep?: number): void;
  137116. /**
  137117. * Get the time step of the physics engine.
  137118. * @returns the current time step
  137119. */
  137120. getTimeStep(): number;
  137121. /**
  137122. * Set the sub time step of the physics engine.
  137123. * Default is 0 meaning there is no sub steps
  137124. * To increase physics resolution precision, set a small value (like 1 ms)
  137125. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137126. */
  137127. setSubTimeStep(subTimeStep?: number): void;
  137128. /**
  137129. * Get the sub time step of the physics engine.
  137130. * @returns the current sub time step
  137131. */
  137132. getSubTimeStep(): number;
  137133. /**
  137134. * Release all resources
  137135. */
  137136. dispose(): void;
  137137. /**
  137138. * Gets the name of the current physics plugin
  137139. * @returns the name of the plugin
  137140. */
  137141. getPhysicsPluginName(): string;
  137142. /**
  137143. * Adding a new impostor for the impostor tracking.
  137144. * This will be done by the impostor itself.
  137145. * @param impostor the impostor to add
  137146. */
  137147. addImpostor(impostor: PhysicsImpostor): void;
  137148. /**
  137149. * Remove an impostor from the engine.
  137150. * This impostor and its mesh will not longer be updated by the physics engine.
  137151. * @param impostor the impostor to remove
  137152. */
  137153. removeImpostor(impostor: PhysicsImpostor): void;
  137154. /**
  137155. * Add a joint to the physics engine
  137156. * @param mainImpostor defines the main impostor to which the joint is added.
  137157. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137158. * @param joint defines the joint that will connect both impostors.
  137159. */
  137160. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137161. /**
  137162. * Removes a joint from the simulation
  137163. * @param mainImpostor defines the impostor used with the joint
  137164. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137165. * @param joint defines the joint to remove
  137166. */
  137167. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137168. /**
  137169. * Called by the scene. No need to call it.
  137170. * @param delta defines the timespam between frames
  137171. */
  137172. _step(delta: number): void;
  137173. /**
  137174. * Gets the current plugin used to run the simulation
  137175. * @returns current plugin
  137176. */
  137177. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137178. /**
  137179. * Gets the list of physic impostors
  137180. * @returns an array of PhysicsImpostor
  137181. */
  137182. getImpostors(): Array<PhysicsImpostor>;
  137183. /**
  137184. * Gets the impostor for a physics enabled object
  137185. * @param object defines the object impersonated by the impostor
  137186. * @returns the PhysicsImpostor or null if not found
  137187. */
  137188. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137189. /**
  137190. * Gets the impostor for a physics body object
  137191. * @param body defines physics body used by the impostor
  137192. * @returns the PhysicsImpostor or null if not found
  137193. */
  137194. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137195. /**
  137196. * Does a raycast in the physics world
  137197. * @param from when should the ray start?
  137198. * @param to when should the ray end?
  137199. * @returns PhysicsRaycastResult
  137200. */
  137201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137202. }
  137203. }
  137204. declare module BABYLON {
  137205. /** @hidden */
  137206. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137207. private _useDeltaForWorldStep;
  137208. world: any;
  137209. name: string;
  137210. private _physicsMaterials;
  137211. private _fixedTimeStep;
  137212. private _cannonRaycastResult;
  137213. private _raycastResult;
  137214. private _physicsBodysToRemoveAfterStep;
  137215. private _firstFrame;
  137216. BJSCANNON: any;
  137217. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137218. setGravity(gravity: Vector3): void;
  137219. setTimeStep(timeStep: number): void;
  137220. getTimeStep(): number;
  137221. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137222. private _removeMarkedPhysicsBodiesFromWorld;
  137223. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137226. private _processChildMeshes;
  137227. removePhysicsBody(impostor: PhysicsImpostor): void;
  137228. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137229. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137230. private _addMaterial;
  137231. private _checkWithEpsilon;
  137232. private _createShape;
  137233. private _createHeightmap;
  137234. private _minus90X;
  137235. private _plus90X;
  137236. private _tmpPosition;
  137237. private _tmpDeltaPosition;
  137238. private _tmpUnityRotation;
  137239. private _updatePhysicsBodyTransformation;
  137240. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137242. isSupported(): boolean;
  137243. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137244. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137245. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137246. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137247. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137248. getBodyMass(impostor: PhysicsImpostor): number;
  137249. getBodyFriction(impostor: PhysicsImpostor): number;
  137250. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137251. getBodyRestitution(impostor: PhysicsImpostor): number;
  137252. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137253. sleepBody(impostor: PhysicsImpostor): void;
  137254. wakeUpBody(impostor: PhysicsImpostor): void;
  137255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137256. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137257. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137258. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137259. getRadius(impostor: PhysicsImpostor): number;
  137260. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137261. dispose(): void;
  137262. private _extendNamespace;
  137263. /**
  137264. * Does a raycast in the physics world
  137265. * @param from when should the ray start?
  137266. * @param to when should the ray end?
  137267. * @returns PhysicsRaycastResult
  137268. */
  137269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137270. }
  137271. }
  137272. declare module BABYLON {
  137273. /** @hidden */
  137274. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137275. private _useDeltaForWorldStep;
  137276. world: any;
  137277. name: string;
  137278. BJSOIMO: any;
  137279. private _raycastResult;
  137280. private _fixedTimeStep;
  137281. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137282. setGravity(gravity: Vector3): void;
  137283. setTimeStep(timeStep: number): void;
  137284. getTimeStep(): number;
  137285. private _tmpImpostorsArray;
  137286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137290. private _tmpPositionVector;
  137291. removePhysicsBody(impostor: PhysicsImpostor): void;
  137292. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137293. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137294. isSupported(): boolean;
  137295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137302. getBodyMass(impostor: PhysicsImpostor): number;
  137303. getBodyFriction(impostor: PhysicsImpostor): number;
  137304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137305. getBodyRestitution(impostor: PhysicsImpostor): number;
  137306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137307. sleepBody(impostor: PhysicsImpostor): void;
  137308. wakeUpBody(impostor: PhysicsImpostor): void;
  137309. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137310. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137312. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137313. getRadius(impostor: PhysicsImpostor): number;
  137314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137315. dispose(): void;
  137316. /**
  137317. * Does a raycast in the physics world
  137318. * @param from when should the ray start?
  137319. * @param to when should the ray end?
  137320. * @returns PhysicsRaycastResult
  137321. */
  137322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /**
  137327. * Class containing static functions to help procedurally build meshes
  137328. */
  137329. export class RibbonBuilder {
  137330. /**
  137331. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137332. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137333. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137334. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137335. * * 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
  137336. * * 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
  137337. * * 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
  137338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137341. * * 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
  137342. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137343. * * 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
  137344. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137346. * @param name defines the name of the mesh
  137347. * @param options defines the options used to create the mesh
  137348. * @param scene defines the hosting scene
  137349. * @returns the ribbon mesh
  137350. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137352. */
  137353. static CreateRibbon(name: string, options: {
  137354. pathArray: Vector3[][];
  137355. closeArray?: boolean;
  137356. closePath?: boolean;
  137357. offset?: number;
  137358. updatable?: boolean;
  137359. sideOrientation?: number;
  137360. frontUVs?: Vector4;
  137361. backUVs?: Vector4;
  137362. instance?: Mesh;
  137363. invertUV?: boolean;
  137364. uvs?: Vector2[];
  137365. colors?: Color4[];
  137366. }, scene?: Nullable<Scene>): Mesh;
  137367. }
  137368. }
  137369. declare module BABYLON {
  137370. /**
  137371. * Class containing static functions to help procedurally build meshes
  137372. */
  137373. export class ShapeBuilder {
  137374. /**
  137375. * 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.
  137376. * * 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.
  137377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137378. * * 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.
  137379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137380. * * 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
  137381. * * 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
  137382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137387. * @param name defines the name of the mesh
  137388. * @param options defines the options used to create the mesh
  137389. * @param scene defines the hosting scene
  137390. * @returns the extruded shape mesh
  137391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137393. */
  137394. static ExtrudeShape(name: string, options: {
  137395. shape: Vector3[];
  137396. path: Vector3[];
  137397. scale?: number;
  137398. rotation?: number;
  137399. cap?: number;
  137400. updatable?: boolean;
  137401. sideOrientation?: number;
  137402. frontUVs?: Vector4;
  137403. backUVs?: Vector4;
  137404. instance?: Mesh;
  137405. invertUV?: boolean;
  137406. }, scene?: Nullable<Scene>): Mesh;
  137407. /**
  137408. * Creates an custom extruded shape mesh.
  137409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137410. * * 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.
  137411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137412. * * 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
  137413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137414. * * 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
  137415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137418. * * 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
  137419. * * 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
  137420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137425. * @param name defines the name of the mesh
  137426. * @param options defines the options used to create the mesh
  137427. * @param scene defines the hosting scene
  137428. * @returns the custom extruded shape mesh
  137429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137432. */
  137433. static ExtrudeShapeCustom(name: string, options: {
  137434. shape: Vector3[];
  137435. path: Vector3[];
  137436. scaleFunction?: any;
  137437. rotationFunction?: any;
  137438. ribbonCloseArray?: boolean;
  137439. ribbonClosePath?: boolean;
  137440. cap?: number;
  137441. updatable?: boolean;
  137442. sideOrientation?: number;
  137443. frontUVs?: Vector4;
  137444. backUVs?: Vector4;
  137445. instance?: Mesh;
  137446. invertUV?: boolean;
  137447. }, scene?: Nullable<Scene>): Mesh;
  137448. private static _ExtrudeShapeGeneric;
  137449. }
  137450. }
  137451. declare module BABYLON {
  137452. /**
  137453. * AmmoJS Physics plugin
  137454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137455. * @see https://github.com/kripken/ammo.js/
  137456. */
  137457. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137458. private _useDeltaForWorldStep;
  137459. /**
  137460. * Reference to the Ammo library
  137461. */
  137462. bjsAMMO: any;
  137463. /**
  137464. * Created ammoJS world which physics bodies are added to
  137465. */
  137466. world: any;
  137467. /**
  137468. * Name of the plugin
  137469. */
  137470. name: string;
  137471. private _timeStep;
  137472. private _fixedTimeStep;
  137473. private _maxSteps;
  137474. private _tmpQuaternion;
  137475. private _tmpAmmoTransform;
  137476. private _tmpAmmoQuaternion;
  137477. private _tmpAmmoConcreteContactResultCallback;
  137478. private _collisionConfiguration;
  137479. private _dispatcher;
  137480. private _overlappingPairCache;
  137481. private _solver;
  137482. private _softBodySolver;
  137483. private _tmpAmmoVectorA;
  137484. private _tmpAmmoVectorB;
  137485. private _tmpAmmoVectorC;
  137486. private _tmpAmmoVectorD;
  137487. private _tmpContactCallbackResult;
  137488. private _tmpAmmoVectorRCA;
  137489. private _tmpAmmoVectorRCB;
  137490. private _raycastResult;
  137491. private static readonly DISABLE_COLLISION_FLAG;
  137492. private static readonly KINEMATIC_FLAG;
  137493. private static readonly DISABLE_DEACTIVATION_FLAG;
  137494. /**
  137495. * Initializes the ammoJS plugin
  137496. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137497. * @param ammoInjection can be used to inject your own ammo reference
  137498. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137499. */
  137500. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137501. /**
  137502. * Sets the gravity of the physics world (m/(s^2))
  137503. * @param gravity Gravity to set
  137504. */
  137505. setGravity(gravity: Vector3): void;
  137506. /**
  137507. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137508. * @param timeStep timestep to use in seconds
  137509. */
  137510. setTimeStep(timeStep: number): void;
  137511. /**
  137512. * 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)
  137513. * @param fixedTimeStep fixedTimeStep to use in seconds
  137514. */
  137515. setFixedTimeStep(fixedTimeStep: number): void;
  137516. /**
  137517. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137518. * @param maxSteps the maximum number of steps by the physics engine per frame
  137519. */
  137520. setMaxSteps(maxSteps: number): void;
  137521. /**
  137522. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137523. * @returns the current timestep in seconds
  137524. */
  137525. getTimeStep(): number;
  137526. /**
  137527. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137528. */
  137529. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137530. private _isImpostorInContact;
  137531. private _isImpostorPairInContact;
  137532. private _stepSimulation;
  137533. /**
  137534. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137535. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137536. * After the step the babylon meshes are set to the position of the physics imposters
  137537. * @param delta amount of time to step forward
  137538. * @param impostors array of imposters to update before/after the step
  137539. */
  137540. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137541. /**
  137542. * Update babylon mesh to match physics world object
  137543. * @param impostor imposter to match
  137544. */
  137545. private _afterSoftStep;
  137546. /**
  137547. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137548. * @param impostor imposter to match
  137549. */
  137550. private _ropeStep;
  137551. /**
  137552. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137553. * @param impostor imposter to match
  137554. */
  137555. private _softbodyOrClothStep;
  137556. private _tmpMatrix;
  137557. /**
  137558. * Applies an impulse on the imposter
  137559. * @param impostor imposter to apply impulse to
  137560. * @param force amount of force to be applied to the imposter
  137561. * @param contactPoint the location to apply the impulse on the imposter
  137562. */
  137563. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137564. /**
  137565. * Applies a force on the imposter
  137566. * @param impostor imposter to apply force
  137567. * @param force amount of force to be applied to the imposter
  137568. * @param contactPoint the location to apply the force on the imposter
  137569. */
  137570. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137571. /**
  137572. * Creates a physics body using the plugin
  137573. * @param impostor the imposter to create the physics body on
  137574. */
  137575. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137576. /**
  137577. * Removes the physics body from the imposter and disposes of the body's memory
  137578. * @param impostor imposter to remove the physics body from
  137579. */
  137580. removePhysicsBody(impostor: PhysicsImpostor): void;
  137581. /**
  137582. * Generates a joint
  137583. * @param impostorJoint the imposter joint to create the joint with
  137584. */
  137585. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137586. /**
  137587. * Removes a joint
  137588. * @param impostorJoint the imposter joint to remove the joint from
  137589. */
  137590. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137591. private _addMeshVerts;
  137592. /**
  137593. * Initialise the soft body vertices to match its object's (mesh) vertices
  137594. * Softbody vertices (nodes) are in world space and to match this
  137595. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  137596. * @param impostor to create the softbody for
  137597. */
  137598. private _softVertexData;
  137599. /**
  137600. * Create an impostor's soft body
  137601. * @param impostor to create the softbody for
  137602. */
  137603. private _createSoftbody;
  137604. /**
  137605. * Create cloth for an impostor
  137606. * @param impostor to create the softbody for
  137607. */
  137608. private _createCloth;
  137609. /**
  137610. * Create rope for an impostor
  137611. * @param impostor to create the softbody for
  137612. */
  137613. private _createRope;
  137614. /**
  137615. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137616. * @param impostor to create the custom physics shape for
  137617. */
  137618. private _createCustom;
  137619. private _addHullVerts;
  137620. private _createShape;
  137621. /**
  137622. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137623. * @param impostor imposter containing the physics body and babylon object
  137624. */
  137625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137626. /**
  137627. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137628. * @param impostor imposter containing the physics body and babylon object
  137629. * @param newPosition new position
  137630. * @param newRotation new rotation
  137631. */
  137632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137633. /**
  137634. * If this plugin is supported
  137635. * @returns true if its supported
  137636. */
  137637. isSupported(): boolean;
  137638. /**
  137639. * Sets the linear velocity of the physics body
  137640. * @param impostor imposter to set the velocity on
  137641. * @param velocity velocity to set
  137642. */
  137643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137644. /**
  137645. * Sets the angular velocity of the physics body
  137646. * @param impostor imposter to set the velocity on
  137647. * @param velocity velocity to set
  137648. */
  137649. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137650. /**
  137651. * gets the linear velocity
  137652. * @param impostor imposter to get linear velocity from
  137653. * @returns linear velocity
  137654. */
  137655. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137656. /**
  137657. * gets the angular velocity
  137658. * @param impostor imposter to get angular velocity from
  137659. * @returns angular velocity
  137660. */
  137661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137662. /**
  137663. * Sets the mass of physics body
  137664. * @param impostor imposter to set the mass on
  137665. * @param mass mass to set
  137666. */
  137667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137668. /**
  137669. * Gets the mass of the physics body
  137670. * @param impostor imposter to get the mass from
  137671. * @returns mass
  137672. */
  137673. getBodyMass(impostor: PhysicsImpostor): number;
  137674. /**
  137675. * Gets friction of the impostor
  137676. * @param impostor impostor to get friction from
  137677. * @returns friction value
  137678. */
  137679. getBodyFriction(impostor: PhysicsImpostor): number;
  137680. /**
  137681. * Sets friction of the impostor
  137682. * @param impostor impostor to set friction on
  137683. * @param friction friction value
  137684. */
  137685. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137686. /**
  137687. * Gets restitution of the impostor
  137688. * @param impostor impostor to get restitution from
  137689. * @returns restitution value
  137690. */
  137691. getBodyRestitution(impostor: PhysicsImpostor): number;
  137692. /**
  137693. * Sets resitution of the impostor
  137694. * @param impostor impostor to set resitution on
  137695. * @param restitution resitution value
  137696. */
  137697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137698. /**
  137699. * Gets pressure inside the impostor
  137700. * @param impostor impostor to get pressure from
  137701. * @returns pressure value
  137702. */
  137703. getBodyPressure(impostor: PhysicsImpostor): number;
  137704. /**
  137705. * Sets pressure inside a soft body impostor
  137706. * Cloth and rope must remain 0 pressure
  137707. * @param impostor impostor to set pressure on
  137708. * @param pressure pressure value
  137709. */
  137710. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137711. /**
  137712. * Gets stiffness of the impostor
  137713. * @param impostor impostor to get stiffness from
  137714. * @returns pressure value
  137715. */
  137716. getBodyStiffness(impostor: PhysicsImpostor): number;
  137717. /**
  137718. * Sets stiffness of the impostor
  137719. * @param impostor impostor to set stiffness on
  137720. * @param stiffness stiffness value from 0 to 1
  137721. */
  137722. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137723. /**
  137724. * Gets velocityIterations of the impostor
  137725. * @param impostor impostor to get velocity iterations from
  137726. * @returns velocityIterations value
  137727. */
  137728. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137729. /**
  137730. * Sets velocityIterations of the impostor
  137731. * @param impostor impostor to set velocity iterations on
  137732. * @param velocityIterations velocityIterations value
  137733. */
  137734. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137735. /**
  137736. * Gets positionIterations of the impostor
  137737. * @param impostor impostor to get position iterations from
  137738. * @returns positionIterations value
  137739. */
  137740. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137741. /**
  137742. * Sets positionIterations of the impostor
  137743. * @param impostor impostor to set position on
  137744. * @param positionIterations positionIterations value
  137745. */
  137746. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137747. /**
  137748. * Append an anchor to a cloth object
  137749. * @param impostor is the cloth impostor to add anchor to
  137750. * @param otherImpostor is the rigid impostor to anchor to
  137751. * @param width ratio across width from 0 to 1
  137752. * @param height ratio up height from 0 to 1
  137753. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137754. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137755. */
  137756. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137757. /**
  137758. * Append an hook to a rope object
  137759. * @param impostor is the rope impostor to add hook to
  137760. * @param otherImpostor is the rigid impostor to hook to
  137761. * @param length ratio along the rope from 0 to 1
  137762. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137763. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137764. */
  137765. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137766. /**
  137767. * Sleeps the physics body and stops it from being active
  137768. * @param impostor impostor to sleep
  137769. */
  137770. sleepBody(impostor: PhysicsImpostor): void;
  137771. /**
  137772. * Activates the physics body
  137773. * @param impostor impostor to activate
  137774. */
  137775. wakeUpBody(impostor: PhysicsImpostor): void;
  137776. /**
  137777. * Updates the distance parameters of the joint
  137778. * @param joint joint to update
  137779. * @param maxDistance maximum distance of the joint
  137780. * @param minDistance minimum distance of the joint
  137781. */
  137782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137783. /**
  137784. * Sets a motor on the joint
  137785. * @param joint joint to set motor on
  137786. * @param speed speed of the motor
  137787. * @param maxForce maximum force of the motor
  137788. * @param motorIndex index of the motor
  137789. */
  137790. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137791. /**
  137792. * Sets the motors limit
  137793. * @param joint joint to set limit on
  137794. * @param upperLimit upper limit
  137795. * @param lowerLimit lower limit
  137796. */
  137797. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137798. /**
  137799. * Syncs the position and rotation of a mesh with the impostor
  137800. * @param mesh mesh to sync
  137801. * @param impostor impostor to update the mesh with
  137802. */
  137803. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137804. /**
  137805. * Gets the radius of the impostor
  137806. * @param impostor impostor to get radius from
  137807. * @returns the radius
  137808. */
  137809. getRadius(impostor: PhysicsImpostor): number;
  137810. /**
  137811. * Gets the box size of the impostor
  137812. * @param impostor impostor to get box size from
  137813. * @param result the resulting box size
  137814. */
  137815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137816. /**
  137817. * Disposes of the impostor
  137818. */
  137819. dispose(): void;
  137820. /**
  137821. * Does a raycast in the physics world
  137822. * @param from when should the ray start?
  137823. * @param to when should the ray end?
  137824. * @returns PhysicsRaycastResult
  137825. */
  137826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137827. }
  137828. }
  137829. declare module BABYLON {
  137830. interface AbstractScene {
  137831. /**
  137832. * The list of reflection probes added to the scene
  137833. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137834. */
  137835. reflectionProbes: Array<ReflectionProbe>;
  137836. /**
  137837. * Removes the given reflection probe from this scene.
  137838. * @param toRemove The reflection probe to remove
  137839. * @returns The index of the removed reflection probe
  137840. */
  137841. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137842. /**
  137843. * Adds the given reflection probe to this scene.
  137844. * @param newReflectionProbe The reflection probe to add
  137845. */
  137846. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137847. }
  137848. /**
  137849. * Class used to generate realtime reflection / refraction cube textures
  137850. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137851. */
  137852. export class ReflectionProbe {
  137853. /** defines the name of the probe */
  137854. name: string;
  137855. private _scene;
  137856. private _renderTargetTexture;
  137857. private _projectionMatrix;
  137858. private _viewMatrix;
  137859. private _target;
  137860. private _add;
  137861. private _attachedMesh;
  137862. private _invertYAxis;
  137863. /** Gets or sets probe position (center of the cube map) */
  137864. position: Vector3;
  137865. /**
  137866. * Creates a new reflection probe
  137867. * @param name defines the name of the probe
  137868. * @param size defines the texture resolution (for each face)
  137869. * @param scene defines the hosting scene
  137870. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137871. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137872. */
  137873. constructor(
  137874. /** defines the name of the probe */
  137875. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137876. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137877. get samples(): number;
  137878. set samples(value: number);
  137879. /** Gets or sets the refresh rate to use (on every frame by default) */
  137880. get refreshRate(): number;
  137881. set refreshRate(value: number);
  137882. /**
  137883. * Gets the hosting scene
  137884. * @returns a Scene
  137885. */
  137886. getScene(): Scene;
  137887. /** Gets the internal CubeTexture used to render to */
  137888. get cubeTexture(): RenderTargetTexture;
  137889. /** Gets the list of meshes to render */
  137890. get renderList(): Nullable<AbstractMesh[]>;
  137891. /**
  137892. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137893. * @param mesh defines the mesh to attach to
  137894. */
  137895. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137896. /**
  137897. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137898. * @param renderingGroupId The rendering group id corresponding to its index
  137899. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137900. */
  137901. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137902. /**
  137903. * Clean all associated resources
  137904. */
  137905. dispose(): void;
  137906. /**
  137907. * Converts the reflection probe information to a readable string for debug purpose.
  137908. * @param fullDetails Supports for multiple levels of logging within scene loading
  137909. * @returns the human readable reflection probe info
  137910. */
  137911. toString(fullDetails?: boolean): string;
  137912. /**
  137913. * Get the class name of the relfection probe.
  137914. * @returns "ReflectionProbe"
  137915. */
  137916. getClassName(): string;
  137917. /**
  137918. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137919. * @returns The JSON representation of the texture
  137920. */
  137921. serialize(): any;
  137922. /**
  137923. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137924. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137925. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137926. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137927. * @returns The parsed reflection probe if successful
  137928. */
  137929. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137930. }
  137931. }
  137932. declare module BABYLON {
  137933. /** @hidden */
  137934. export var _BabylonLoaderRegistered: boolean;
  137935. /**
  137936. * Helps setting up some configuration for the babylon file loader.
  137937. */
  137938. export class BabylonFileLoaderConfiguration {
  137939. /**
  137940. * The loader does not allow injecting custom physix engine into the plugins.
  137941. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137942. * So you could set this variable to your engine import to make it work.
  137943. */
  137944. static LoaderInjectedPhysicsEngine: any;
  137945. }
  137946. }
  137947. declare module BABYLON {
  137948. /**
  137949. * The Physically based simple base material of BJS.
  137950. *
  137951. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137952. * It is used as the base class for both the specGloss and metalRough conventions.
  137953. */
  137954. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137955. /**
  137956. * Number of Simultaneous lights allowed on the material.
  137957. */
  137958. maxSimultaneousLights: number;
  137959. /**
  137960. * If sets to true, disables all the lights affecting the material.
  137961. */
  137962. disableLighting: boolean;
  137963. /**
  137964. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137965. */
  137966. environmentTexture: BaseTexture;
  137967. /**
  137968. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137969. */
  137970. invertNormalMapX: boolean;
  137971. /**
  137972. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137973. */
  137974. invertNormalMapY: boolean;
  137975. /**
  137976. * Normal map used in the model.
  137977. */
  137978. normalTexture: BaseTexture;
  137979. /**
  137980. * Emissivie color used to self-illuminate the model.
  137981. */
  137982. emissiveColor: Color3;
  137983. /**
  137984. * Emissivie texture used to self-illuminate the model.
  137985. */
  137986. emissiveTexture: BaseTexture;
  137987. /**
  137988. * Occlusion Channel Strenght.
  137989. */
  137990. occlusionStrength: number;
  137991. /**
  137992. * Occlusion Texture of the material (adding extra occlusion effects).
  137993. */
  137994. occlusionTexture: BaseTexture;
  137995. /**
  137996. * Defines the alpha limits in alpha test mode.
  137997. */
  137998. alphaCutOff: number;
  137999. /**
  138000. * Gets the current double sided mode.
  138001. */
  138002. get doubleSided(): boolean;
  138003. /**
  138004. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138005. */
  138006. set doubleSided(value: boolean);
  138007. /**
  138008. * Stores the pre-calculated light information of a mesh in a texture.
  138009. */
  138010. lightmapTexture: BaseTexture;
  138011. /**
  138012. * If true, the light map contains occlusion information instead of lighting info.
  138013. */
  138014. useLightmapAsShadowmap: boolean;
  138015. /**
  138016. * Instantiates a new PBRMaterial instance.
  138017. *
  138018. * @param name The material name
  138019. * @param scene The scene the material will be use in.
  138020. */
  138021. constructor(name: string, scene: Scene);
  138022. getClassName(): string;
  138023. }
  138024. }
  138025. declare module BABYLON {
  138026. /**
  138027. * The PBR material of BJS following the metal roughness convention.
  138028. *
  138029. * This fits to the PBR convention in the GLTF definition:
  138030. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138031. */
  138032. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138033. /**
  138034. * The base color has two different interpretations depending on the value of metalness.
  138035. * When the material is a metal, the base color is the specific measured reflectance value
  138036. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138037. * of the material.
  138038. */
  138039. baseColor: Color3;
  138040. /**
  138041. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138042. * well as opacity information in the alpha channel.
  138043. */
  138044. baseTexture: BaseTexture;
  138045. /**
  138046. * Specifies the metallic scalar value of the material.
  138047. * Can also be used to scale the metalness values of the metallic texture.
  138048. */
  138049. metallic: number;
  138050. /**
  138051. * Specifies the roughness scalar value of the material.
  138052. * Can also be used to scale the roughness values of the metallic texture.
  138053. */
  138054. roughness: number;
  138055. /**
  138056. * Texture containing both the metallic value in the B channel and the
  138057. * roughness value in the G channel to keep better precision.
  138058. */
  138059. metallicRoughnessTexture: BaseTexture;
  138060. /**
  138061. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138062. *
  138063. * @param name The material name
  138064. * @param scene The scene the material will be use in.
  138065. */
  138066. constructor(name: string, scene: Scene);
  138067. /**
  138068. * Return the currrent class name of the material.
  138069. */
  138070. getClassName(): string;
  138071. /**
  138072. * Makes a duplicate of the current material.
  138073. * @param name - name to use for the new material.
  138074. */
  138075. clone(name: string): PBRMetallicRoughnessMaterial;
  138076. /**
  138077. * Serialize the material to a parsable JSON object.
  138078. */
  138079. serialize(): any;
  138080. /**
  138081. * Parses a JSON object correponding to the serialize function.
  138082. */
  138083. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138084. }
  138085. }
  138086. declare module BABYLON {
  138087. /**
  138088. * The PBR material of BJS following the specular glossiness convention.
  138089. *
  138090. * This fits to the PBR convention in the GLTF definition:
  138091. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138092. */
  138093. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138094. /**
  138095. * Specifies the diffuse color of the material.
  138096. */
  138097. diffuseColor: Color3;
  138098. /**
  138099. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138100. * channel.
  138101. */
  138102. diffuseTexture: BaseTexture;
  138103. /**
  138104. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138105. */
  138106. specularColor: Color3;
  138107. /**
  138108. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138109. */
  138110. glossiness: number;
  138111. /**
  138112. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138113. */
  138114. specularGlossinessTexture: BaseTexture;
  138115. /**
  138116. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138117. *
  138118. * @param name The material name
  138119. * @param scene The scene the material will be use in.
  138120. */
  138121. constructor(name: string, scene: Scene);
  138122. /**
  138123. * Return the currrent class name of the material.
  138124. */
  138125. getClassName(): string;
  138126. /**
  138127. * Makes a duplicate of the current material.
  138128. * @param name - name to use for the new material.
  138129. */
  138130. clone(name: string): PBRSpecularGlossinessMaterial;
  138131. /**
  138132. * Serialize the material to a parsable JSON object.
  138133. */
  138134. serialize(): any;
  138135. /**
  138136. * Parses a JSON object correponding to the serialize function.
  138137. */
  138138. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138139. }
  138140. }
  138141. declare module BABYLON {
  138142. /**
  138143. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138144. * It can help converting any input color in a desired output one. This can then be used to create effects
  138145. * from sepia, black and white to sixties or futuristic rendering...
  138146. *
  138147. * The only supported format is currently 3dl.
  138148. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138149. */
  138150. export class ColorGradingTexture extends BaseTexture {
  138151. /**
  138152. * The texture URL.
  138153. */
  138154. url: string;
  138155. /**
  138156. * Empty line regex stored for GC.
  138157. */
  138158. private static _noneEmptyLineRegex;
  138159. private _textureMatrix;
  138160. private _onLoad;
  138161. /**
  138162. * Instantiates a ColorGradingTexture from the following parameters.
  138163. *
  138164. * @param url The location of the color gradind data (currently only supporting 3dl)
  138165. * @param sceneOrEngine The scene or engine the texture will be used in
  138166. * @param onLoad defines a callback triggered when the texture has been loaded
  138167. */
  138168. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138169. /**
  138170. * Fires the onload event from the constructor if requested.
  138171. */
  138172. private _triggerOnLoad;
  138173. /**
  138174. * Returns the texture matrix used in most of the material.
  138175. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138176. */
  138177. getTextureMatrix(): Matrix;
  138178. /**
  138179. * Occurs when the file being loaded is a .3dl LUT file.
  138180. */
  138181. private load3dlTexture;
  138182. /**
  138183. * Starts the loading process of the texture.
  138184. */
  138185. private loadTexture;
  138186. /**
  138187. * Clones the color gradind texture.
  138188. */
  138189. clone(): ColorGradingTexture;
  138190. /**
  138191. * Called during delayed load for textures.
  138192. */
  138193. delayLoad(): void;
  138194. /**
  138195. * Parses a color grading texture serialized by Babylon.
  138196. * @param parsedTexture The texture information being parsedTexture
  138197. * @param scene The scene to load the texture in
  138198. * @param rootUrl The root url of the data assets to load
  138199. * @return A color gradind texture
  138200. */
  138201. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138202. /**
  138203. * Serializes the LUT texture to json format.
  138204. */
  138205. serialize(): any;
  138206. }
  138207. }
  138208. declare module BABYLON {
  138209. /**
  138210. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138211. */
  138212. export class EquiRectangularCubeTexture extends BaseTexture {
  138213. /** The six faces of the cube. */
  138214. private static _FacesMapping;
  138215. private _noMipmap;
  138216. private _onLoad;
  138217. private _onError;
  138218. /** The size of the cubemap. */
  138219. private _size;
  138220. /** The buffer of the image. */
  138221. private _buffer;
  138222. /** The width of the input image. */
  138223. private _width;
  138224. /** The height of the input image. */
  138225. private _height;
  138226. /** The URL to the image. */
  138227. url: string;
  138228. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138229. coordinatesMode: number;
  138230. /**
  138231. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138232. * @param url The location of the image
  138233. * @param scene The scene the texture will be used in
  138234. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138235. * @param noMipmap Forces to not generate the mipmap if true
  138236. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138237. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138238. * @param onLoad — defines a callback called when texture is loaded
  138239. * @param onError — defines a callback called if there is an error
  138240. */
  138241. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138242. /**
  138243. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138244. */
  138245. private loadImage;
  138246. /**
  138247. * Convert the image buffer into a cubemap and create a CubeTexture.
  138248. */
  138249. private loadTexture;
  138250. /**
  138251. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138252. * @param buffer The ArrayBuffer that should be converted.
  138253. * @returns The buffer as Float32Array.
  138254. */
  138255. private getFloat32ArrayFromArrayBuffer;
  138256. /**
  138257. * Get the current class name of the texture useful for serialization or dynamic coding.
  138258. * @returns "EquiRectangularCubeTexture"
  138259. */
  138260. getClassName(): string;
  138261. /**
  138262. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138263. * @returns A clone of the current EquiRectangularCubeTexture.
  138264. */
  138265. clone(): EquiRectangularCubeTexture;
  138266. }
  138267. }
  138268. declare module BABYLON {
  138269. /**
  138270. * Defines the options related to the creation of an HtmlElementTexture
  138271. */
  138272. export interface IHtmlElementTextureOptions {
  138273. /**
  138274. * Defines wether mip maps should be created or not.
  138275. */
  138276. generateMipMaps?: boolean;
  138277. /**
  138278. * Defines the sampling mode of the texture.
  138279. */
  138280. samplingMode?: number;
  138281. /**
  138282. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138283. */
  138284. engine: Nullable<ThinEngine>;
  138285. /**
  138286. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138287. */
  138288. scene: Nullable<Scene>;
  138289. }
  138290. /**
  138291. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138292. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138293. * is automatically managed.
  138294. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138295. * in your application.
  138296. *
  138297. * As the update is not automatic, you need to call them manually.
  138298. */
  138299. export class HtmlElementTexture extends BaseTexture {
  138300. /**
  138301. * The texture URL.
  138302. */
  138303. element: HTMLVideoElement | HTMLCanvasElement;
  138304. private static readonly DefaultOptions;
  138305. private _textureMatrix;
  138306. private _isVideo;
  138307. private _generateMipMaps;
  138308. private _samplingMode;
  138309. /**
  138310. * Instantiates a HtmlElementTexture from the following parameters.
  138311. *
  138312. * @param name Defines the name of the texture
  138313. * @param element Defines the video or canvas the texture is filled with
  138314. * @param options Defines the other none mandatory texture creation options
  138315. */
  138316. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138317. private _createInternalTexture;
  138318. /**
  138319. * Returns the texture matrix used in most of the material.
  138320. */
  138321. getTextureMatrix(): Matrix;
  138322. /**
  138323. * Updates the content of the texture.
  138324. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138325. */
  138326. update(invertY?: Nullable<boolean>): void;
  138327. }
  138328. }
  138329. declare module BABYLON {
  138330. /**
  138331. * Based on jsTGALoader - Javascript loader for TGA file
  138332. * By Vincent Thibault
  138333. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138334. */
  138335. export class TGATools {
  138336. private static _TYPE_INDEXED;
  138337. private static _TYPE_RGB;
  138338. private static _TYPE_GREY;
  138339. private static _TYPE_RLE_INDEXED;
  138340. private static _TYPE_RLE_RGB;
  138341. private static _TYPE_RLE_GREY;
  138342. private static _ORIGIN_MASK;
  138343. private static _ORIGIN_SHIFT;
  138344. private static _ORIGIN_BL;
  138345. private static _ORIGIN_BR;
  138346. private static _ORIGIN_UL;
  138347. private static _ORIGIN_UR;
  138348. /**
  138349. * Gets the header of a TGA file
  138350. * @param data defines the TGA data
  138351. * @returns the header
  138352. */
  138353. static GetTGAHeader(data: Uint8Array): any;
  138354. /**
  138355. * Uploads TGA content to a Babylon Texture
  138356. * @hidden
  138357. */
  138358. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138359. /** @hidden */
  138360. 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;
  138361. /** @hidden */
  138362. 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;
  138363. /** @hidden */
  138364. 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;
  138365. /** @hidden */
  138366. 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;
  138367. /** @hidden */
  138368. 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;
  138369. /** @hidden */
  138370. 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;
  138371. }
  138372. }
  138373. declare module BABYLON {
  138374. /**
  138375. * Implementation of the TGA Texture Loader.
  138376. * @hidden
  138377. */
  138378. export class _TGATextureLoader implements IInternalTextureLoader {
  138379. /**
  138380. * Defines wether the loader supports cascade loading the different faces.
  138381. */
  138382. readonly supportCascades: boolean;
  138383. /**
  138384. * This returns if the loader support the current file information.
  138385. * @param extension defines the file extension of the file being loaded
  138386. * @returns true if the loader can load the specified file
  138387. */
  138388. canLoad(extension: string): boolean;
  138389. /**
  138390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138391. * @param data contains the texture data
  138392. * @param texture defines the BabylonJS internal texture
  138393. * @param createPolynomials will be true if polynomials have been requested
  138394. * @param onLoad defines the callback to trigger once the texture is ready
  138395. * @param onError defines the callback to trigger in case of error
  138396. */
  138397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138398. /**
  138399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138400. * @param data contains the texture data
  138401. * @param texture defines the BabylonJS internal texture
  138402. * @param callback defines the method to call once ready to upload
  138403. */
  138404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138405. }
  138406. }
  138407. declare module BABYLON {
  138408. /**
  138409. * Info about the .basis files
  138410. */
  138411. class BasisFileInfo {
  138412. /**
  138413. * If the file has alpha
  138414. */
  138415. hasAlpha: boolean;
  138416. /**
  138417. * Info about each image of the basis file
  138418. */
  138419. images: Array<{
  138420. levels: Array<{
  138421. width: number;
  138422. height: number;
  138423. transcodedPixels: ArrayBufferView;
  138424. }>;
  138425. }>;
  138426. }
  138427. /**
  138428. * Result of transcoding a basis file
  138429. */
  138430. class TranscodeResult {
  138431. /**
  138432. * Info about the .basis file
  138433. */
  138434. fileInfo: BasisFileInfo;
  138435. /**
  138436. * Format to use when loading the file
  138437. */
  138438. format: number;
  138439. }
  138440. /**
  138441. * Configuration options for the Basis transcoder
  138442. */
  138443. export class BasisTranscodeConfiguration {
  138444. /**
  138445. * Supported compression formats used to determine the supported output format of the transcoder
  138446. */
  138447. supportedCompressionFormats?: {
  138448. /**
  138449. * etc1 compression format
  138450. */
  138451. etc1?: boolean;
  138452. /**
  138453. * s3tc compression format
  138454. */
  138455. s3tc?: boolean;
  138456. /**
  138457. * pvrtc compression format
  138458. */
  138459. pvrtc?: boolean;
  138460. /**
  138461. * etc2 compression format
  138462. */
  138463. etc2?: boolean;
  138464. };
  138465. /**
  138466. * If mipmap levels should be loaded for transcoded images (Default: true)
  138467. */
  138468. loadMipmapLevels?: boolean;
  138469. /**
  138470. * Index of a single image to load (Default: all images)
  138471. */
  138472. loadSingleImage?: number;
  138473. }
  138474. /**
  138475. * Used to load .Basis files
  138476. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138477. */
  138478. export class BasisTools {
  138479. private static _IgnoreSupportedFormats;
  138480. /**
  138481. * URL to use when loading the basis transcoder
  138482. */
  138483. static JSModuleURL: string;
  138484. /**
  138485. * URL to use when loading the wasm module for the transcoder
  138486. */
  138487. static WasmModuleURL: string;
  138488. /**
  138489. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138490. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138491. * @returns internal format corresponding to the Basis format
  138492. */
  138493. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138494. private static _WorkerPromise;
  138495. private static _Worker;
  138496. private static _actionId;
  138497. private static _CreateWorkerAsync;
  138498. /**
  138499. * Transcodes a loaded image file to compressed pixel data
  138500. * @param data image data to transcode
  138501. * @param config configuration options for the transcoding
  138502. * @returns a promise resulting in the transcoded image
  138503. */
  138504. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138505. /**
  138506. * Loads a texture from the transcode result
  138507. * @param texture texture load to
  138508. * @param transcodeResult the result of transcoding the basis file to load from
  138509. */
  138510. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138511. }
  138512. }
  138513. declare module BABYLON {
  138514. /**
  138515. * Loader for .basis file format
  138516. */
  138517. export class _BasisTextureLoader implements IInternalTextureLoader {
  138518. /**
  138519. * Defines whether the loader supports cascade loading the different faces.
  138520. */
  138521. readonly supportCascades: boolean;
  138522. /**
  138523. * This returns if the loader support the current file information.
  138524. * @param extension defines the file extension of the file being loaded
  138525. * @returns true if the loader can load the specified file
  138526. */
  138527. canLoad(extension: string): boolean;
  138528. /**
  138529. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138530. * @param data contains the texture data
  138531. * @param texture defines the BabylonJS internal texture
  138532. * @param createPolynomials will be true if polynomials have been requested
  138533. * @param onLoad defines the callback to trigger once the texture is ready
  138534. * @param onError defines the callback to trigger in case of error
  138535. */
  138536. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138537. /**
  138538. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138539. * @param data contains the texture data
  138540. * @param texture defines the BabylonJS internal texture
  138541. * @param callback defines the method to call once ready to upload
  138542. */
  138543. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138544. }
  138545. }
  138546. declare module BABYLON {
  138547. /**
  138548. * Defines the basic options interface of a TexturePacker Frame
  138549. */
  138550. export interface ITexturePackerFrame {
  138551. /**
  138552. * The frame ID
  138553. */
  138554. id: number;
  138555. /**
  138556. * The frames Scale
  138557. */
  138558. scale: Vector2;
  138559. /**
  138560. * The Frames offset
  138561. */
  138562. offset: Vector2;
  138563. }
  138564. /**
  138565. * This is a support class for frame Data on texture packer sets.
  138566. */
  138567. export class TexturePackerFrame implements ITexturePackerFrame {
  138568. /**
  138569. * The frame ID
  138570. */
  138571. id: number;
  138572. /**
  138573. * The frames Scale
  138574. */
  138575. scale: Vector2;
  138576. /**
  138577. * The Frames offset
  138578. */
  138579. offset: Vector2;
  138580. /**
  138581. * Initializes a texture package frame.
  138582. * @param id The numerical frame identifier
  138583. * @param scale Scalar Vector2 for UV frame
  138584. * @param offset Vector2 for the frame position in UV units.
  138585. * @returns TexturePackerFrame
  138586. */
  138587. constructor(id: number, scale: Vector2, offset: Vector2);
  138588. }
  138589. }
  138590. declare module BABYLON {
  138591. /**
  138592. * Defines the basic options interface of a TexturePacker
  138593. */
  138594. export interface ITexturePackerOptions {
  138595. /**
  138596. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  138597. */
  138598. map?: string[];
  138599. /**
  138600. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138601. */
  138602. uvsIn?: string;
  138603. /**
  138604. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138605. */
  138606. uvsOut?: string;
  138607. /**
  138608. * number representing the layout style. Defaults to LAYOUT_STRIP
  138609. */
  138610. layout?: number;
  138611. /**
  138612. * number of columns if using custom column count layout(2). This defaults to 4.
  138613. */
  138614. colnum?: number;
  138615. /**
  138616. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138617. */
  138618. updateInputMeshes?: boolean;
  138619. /**
  138620. * boolean flag to dispose all the source textures. Defaults to true.
  138621. */
  138622. disposeSources?: boolean;
  138623. /**
  138624. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138625. */
  138626. fillBlanks?: boolean;
  138627. /**
  138628. * string value representing the context fill style color. Defaults to 'black'.
  138629. */
  138630. customFillColor?: string;
  138631. /**
  138632. * Width and Height Value of each Frame in the TexturePacker Sets
  138633. */
  138634. frameSize?: number;
  138635. /**
  138636. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138637. */
  138638. paddingRatio?: number;
  138639. /**
  138640. * Number that declares the fill method for the padding gutter.
  138641. */
  138642. paddingMode?: number;
  138643. /**
  138644. * If in SUBUV_COLOR padding mode what color to use.
  138645. */
  138646. paddingColor?: Color3 | Color4;
  138647. }
  138648. /**
  138649. * Defines the basic interface of a TexturePacker JSON File
  138650. */
  138651. export interface ITexturePackerJSON {
  138652. /**
  138653. * The frame ID
  138654. */
  138655. name: string;
  138656. /**
  138657. * The base64 channel data
  138658. */
  138659. sets: any;
  138660. /**
  138661. * The options of the Packer
  138662. */
  138663. options: ITexturePackerOptions;
  138664. /**
  138665. * The frame data of the Packer
  138666. */
  138667. frames: Array<number>;
  138668. }
  138669. /**
  138670. * This is a support class that generates a series of packed texture sets.
  138671. * @see https://doc.babylonjs.com/babylon101/materials
  138672. */
  138673. export class TexturePacker {
  138674. /** Packer Layout Constant 0 */
  138675. static readonly LAYOUT_STRIP: number;
  138676. /** Packer Layout Constant 1 */
  138677. static readonly LAYOUT_POWER2: number;
  138678. /** Packer Layout Constant 2 */
  138679. static readonly LAYOUT_COLNUM: number;
  138680. /** Packer Layout Constant 0 */
  138681. static readonly SUBUV_WRAP: number;
  138682. /** Packer Layout Constant 1 */
  138683. static readonly SUBUV_EXTEND: number;
  138684. /** Packer Layout Constant 2 */
  138685. static readonly SUBUV_COLOR: number;
  138686. /** The Name of the Texture Package */
  138687. name: string;
  138688. /** The scene scope of the TexturePacker */
  138689. scene: Scene;
  138690. /** The Meshes to target */
  138691. meshes: AbstractMesh[];
  138692. /** Arguments passed with the Constructor */
  138693. options: ITexturePackerOptions;
  138694. /** The promise that is started upon initialization */
  138695. promise: Nullable<Promise<TexturePacker | string>>;
  138696. /** The Container object for the channel sets that are generated */
  138697. sets: object;
  138698. /** The Container array for the frames that are generated */
  138699. frames: TexturePackerFrame[];
  138700. /** The expected number of textures the system is parsing. */
  138701. private _expecting;
  138702. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138703. private _paddingValue;
  138704. /**
  138705. * Initializes a texture package series from an array of meshes or a single mesh.
  138706. * @param name The name of the package
  138707. * @param meshes The target meshes to compose the package from
  138708. * @param options The arguments that texture packer should follow while building.
  138709. * @param scene The scene which the textures are scoped to.
  138710. * @returns TexturePacker
  138711. */
  138712. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138713. /**
  138714. * Starts the package process
  138715. * @param resolve The promises resolution function
  138716. * @returns TexturePacker
  138717. */
  138718. private _createFrames;
  138719. /**
  138720. * Calculates the Size of the Channel Sets
  138721. * @returns Vector2
  138722. */
  138723. private _calculateSize;
  138724. /**
  138725. * Calculates the UV data for the frames.
  138726. * @param baseSize the base frameSize
  138727. * @param padding the base frame padding
  138728. * @param dtSize size of the Dynamic Texture for that channel
  138729. * @param dtUnits is 1/dtSize
  138730. * @param update flag to update the input meshes
  138731. */
  138732. private _calculateMeshUVFrames;
  138733. /**
  138734. * Calculates the frames Offset.
  138735. * @param index of the frame
  138736. * @returns Vector2
  138737. */
  138738. private _getFrameOffset;
  138739. /**
  138740. * Updates a Mesh to the frame data
  138741. * @param mesh that is the target
  138742. * @param frameID or the frame index
  138743. */
  138744. private _updateMeshUV;
  138745. /**
  138746. * Updates a Meshes materials to use the texture packer channels
  138747. * @param m is the mesh to target
  138748. * @param force all channels on the packer to be set.
  138749. */
  138750. private _updateTextureReferences;
  138751. /**
  138752. * Public method to set a Mesh to a frame
  138753. * @param m that is the target
  138754. * @param frameID or the frame index
  138755. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138756. */
  138757. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138758. /**
  138759. * Starts the async promise to compile the texture packer.
  138760. * @returns Promise<void>
  138761. */
  138762. processAsync(): Promise<void>;
  138763. /**
  138764. * Disposes all textures associated with this packer
  138765. */
  138766. dispose(): void;
  138767. /**
  138768. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138769. * @param imageType is the image type to use.
  138770. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138771. */
  138772. download(imageType?: string, quality?: number): void;
  138773. /**
  138774. * Public method to load a texturePacker JSON file.
  138775. * @param data of the JSON file in string format.
  138776. */
  138777. updateFromJSON(data: string): void;
  138778. }
  138779. }
  138780. declare module BABYLON {
  138781. /**
  138782. * 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.
  138783. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138784. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138785. */
  138786. export class CustomProceduralTexture extends ProceduralTexture {
  138787. private _animate;
  138788. private _time;
  138789. private _config;
  138790. private _texturePath;
  138791. /**
  138792. * Instantiates a new Custom Procedural Texture.
  138793. * 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.
  138794. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138795. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138796. * @param name Define the name of the texture
  138797. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138798. * @param size Define the size of the texture to create
  138799. * @param scene Define the scene the texture belongs to
  138800. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138801. * @param generateMipMaps Define if the texture should creates mip maps or not
  138802. */
  138803. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138804. private _loadJson;
  138805. /**
  138806. * Is the texture ready to be used ? (rendered at least once)
  138807. * @returns true if ready, otherwise, false.
  138808. */
  138809. isReady(): boolean;
  138810. /**
  138811. * Render the texture to its associated render target.
  138812. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138813. */
  138814. render(useCameraPostProcess?: boolean): void;
  138815. /**
  138816. * Update the list of dependant textures samplers in the shader.
  138817. */
  138818. updateTextures(): void;
  138819. /**
  138820. * Update the uniform values of the procedural texture in the shader.
  138821. */
  138822. updateShaderUniforms(): void;
  138823. /**
  138824. * Define if the texture animates or not.
  138825. */
  138826. get animate(): boolean;
  138827. set animate(value: boolean);
  138828. }
  138829. }
  138830. declare module BABYLON {
  138831. /** @hidden */
  138832. export var noisePixelShader: {
  138833. name: string;
  138834. shader: string;
  138835. };
  138836. }
  138837. declare module BABYLON {
  138838. /**
  138839. * Class used to generate noise procedural textures
  138840. */
  138841. export class NoiseProceduralTexture extends ProceduralTexture {
  138842. private _time;
  138843. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138844. brightness: number;
  138845. /** Defines the number of octaves to process */
  138846. octaves: number;
  138847. /** Defines the level of persistence (0.8 by default) */
  138848. persistence: number;
  138849. /** Gets or sets animation speed factor (default is 1) */
  138850. animationSpeedFactor: number;
  138851. /**
  138852. * Creates a new NoiseProceduralTexture
  138853. * @param name defines the name fo the texture
  138854. * @param size defines the size of the texture (default is 256)
  138855. * @param scene defines the hosting scene
  138856. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138857. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138858. */
  138859. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138860. private _updateShaderUniforms;
  138861. protected _getDefines(): string;
  138862. /** Generate the current state of the procedural texture */
  138863. render(useCameraPostProcess?: boolean): void;
  138864. /**
  138865. * Serializes this noise procedural texture
  138866. * @returns a serialized noise procedural texture object
  138867. */
  138868. serialize(): any;
  138869. /**
  138870. * Clone the texture.
  138871. * @returns the cloned texture
  138872. */
  138873. clone(): NoiseProceduralTexture;
  138874. /**
  138875. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138876. * @param parsedTexture defines parsed texture data
  138877. * @param scene defines the current scene
  138878. * @param rootUrl defines the root URL containing noise procedural texture information
  138879. * @returns a parsed NoiseProceduralTexture
  138880. */
  138881. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138882. }
  138883. }
  138884. declare module BABYLON {
  138885. /**
  138886. * Raw cube texture where the raw buffers are passed in
  138887. */
  138888. export class RawCubeTexture extends CubeTexture {
  138889. /**
  138890. * Creates a cube texture where the raw buffers are passed in.
  138891. * @param scene defines the scene the texture is attached to
  138892. * @param data defines the array of data to use to create each face
  138893. * @param size defines the size of the textures
  138894. * @param format defines the format of the data
  138895. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138896. * @param generateMipMaps defines if the engine should generate the mip levels
  138897. * @param invertY defines if data must be stored with Y axis inverted
  138898. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138899. * @param compression defines the compression used (null by default)
  138900. */
  138901. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138902. /**
  138903. * Updates the raw cube texture.
  138904. * @param data defines the data to store
  138905. * @param format defines the data format
  138906. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138907. * @param invertY defines if data must be stored with Y axis inverted
  138908. * @param compression defines the compression used (null by default)
  138909. * @param level defines which level of the texture to update
  138910. */
  138911. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138912. /**
  138913. * Updates a raw cube texture with RGBD encoded data.
  138914. * @param data defines the array of data [mipmap][face] to use to create each face
  138915. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138916. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138917. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138918. * @returns a promsie that resolves when the operation is complete
  138919. */
  138920. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138921. /**
  138922. * Clones the raw cube texture.
  138923. * @return a new cube texture
  138924. */
  138925. clone(): CubeTexture;
  138926. /** @hidden */
  138927. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138928. }
  138929. }
  138930. declare module BABYLON {
  138931. /**
  138932. * Class used to store 2D array textures containing user data
  138933. */
  138934. export class RawTexture2DArray extends Texture {
  138935. /** Gets or sets the texture format to use */
  138936. format: number;
  138937. /**
  138938. * Create a new RawTexture2DArray
  138939. * @param data defines the data of the texture
  138940. * @param width defines the width of the texture
  138941. * @param height defines the height of the texture
  138942. * @param depth defines the number of layers of the texture
  138943. * @param format defines the texture format to use
  138944. * @param scene defines the hosting scene
  138945. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138946. * @param invertY defines if texture must be stored with Y axis inverted
  138947. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138948. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138949. */
  138950. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138951. /** Gets or sets the texture format to use */
  138952. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138953. /**
  138954. * Update the texture with new data
  138955. * @param data defines the data to store in the texture
  138956. */
  138957. update(data: ArrayBufferView): void;
  138958. }
  138959. }
  138960. declare module BABYLON {
  138961. /**
  138962. * Class used to store 3D textures containing user data
  138963. */
  138964. export class RawTexture3D extends Texture {
  138965. /** Gets or sets the texture format to use */
  138966. format: number;
  138967. /**
  138968. * Create a new RawTexture3D
  138969. * @param data defines the data of the texture
  138970. * @param width defines the width of the texture
  138971. * @param height defines the height of the texture
  138972. * @param depth defines the depth of the texture
  138973. * @param format defines the texture format to use
  138974. * @param scene defines the hosting scene
  138975. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138976. * @param invertY defines if texture must be stored with Y axis inverted
  138977. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138978. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138979. */
  138980. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138981. /** Gets or sets the texture format to use */
  138982. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138983. /**
  138984. * Update the texture with new data
  138985. * @param data defines the data to store in the texture
  138986. */
  138987. update(data: ArrayBufferView): void;
  138988. }
  138989. }
  138990. declare module BABYLON {
  138991. /**
  138992. * Creates a refraction texture used by refraction channel of the standard material.
  138993. * It is like a mirror but to see through a material.
  138994. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138995. */
  138996. export class RefractionTexture extends RenderTargetTexture {
  138997. /**
  138998. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138999. * 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.
  139000. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139001. */
  139002. refractionPlane: Plane;
  139003. /**
  139004. * Define how deep under the surface we should see.
  139005. */
  139006. depth: number;
  139007. /**
  139008. * Creates a refraction texture used by refraction channel of the standard material.
  139009. * It is like a mirror but to see through a material.
  139010. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139011. * @param name Define the texture name
  139012. * @param size Define the size of the underlying texture
  139013. * @param scene Define the scene the refraction belongs to
  139014. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139015. */
  139016. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139017. /**
  139018. * Clone the refraction texture.
  139019. * @returns the cloned texture
  139020. */
  139021. clone(): RefractionTexture;
  139022. /**
  139023. * Serialize the texture to a JSON representation you could use in Parse later on
  139024. * @returns the serialized JSON representation
  139025. */
  139026. serialize(): any;
  139027. }
  139028. }
  139029. declare module BABYLON {
  139030. /**
  139031. * Block used to add support for vertex skinning (bones)
  139032. */
  139033. export class BonesBlock extends NodeMaterialBlock {
  139034. /**
  139035. * Creates a new BonesBlock
  139036. * @param name defines the block name
  139037. */
  139038. constructor(name: string);
  139039. /**
  139040. * Initialize the block and prepare the context for build
  139041. * @param state defines the state that will be used for the build
  139042. */
  139043. initialize(state: NodeMaterialBuildState): void;
  139044. /**
  139045. * Gets the current class name
  139046. * @returns the class name
  139047. */
  139048. getClassName(): string;
  139049. /**
  139050. * Gets the matrix indices input component
  139051. */
  139052. get matricesIndices(): NodeMaterialConnectionPoint;
  139053. /**
  139054. * Gets the matrix weights input component
  139055. */
  139056. get matricesWeights(): NodeMaterialConnectionPoint;
  139057. /**
  139058. * Gets the extra matrix indices input component
  139059. */
  139060. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139061. /**
  139062. * Gets the extra matrix weights input component
  139063. */
  139064. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139065. /**
  139066. * Gets the world input component
  139067. */
  139068. get world(): NodeMaterialConnectionPoint;
  139069. /**
  139070. * Gets the output component
  139071. */
  139072. get output(): NodeMaterialConnectionPoint;
  139073. autoConfigure(material: NodeMaterial): void;
  139074. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139077. protected _buildBlock(state: NodeMaterialBuildState): this;
  139078. }
  139079. }
  139080. declare module BABYLON {
  139081. /**
  139082. * Block used to add support for instances
  139083. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139084. */
  139085. export class InstancesBlock extends NodeMaterialBlock {
  139086. /**
  139087. * Creates a new InstancesBlock
  139088. * @param name defines the block name
  139089. */
  139090. constructor(name: string);
  139091. /**
  139092. * Gets the current class name
  139093. * @returns the class name
  139094. */
  139095. getClassName(): string;
  139096. /**
  139097. * Gets the first world row input component
  139098. */
  139099. get world0(): NodeMaterialConnectionPoint;
  139100. /**
  139101. * Gets the second world row input component
  139102. */
  139103. get world1(): NodeMaterialConnectionPoint;
  139104. /**
  139105. * Gets the third world row input component
  139106. */
  139107. get world2(): NodeMaterialConnectionPoint;
  139108. /**
  139109. * Gets the forth world row input component
  139110. */
  139111. get world3(): NodeMaterialConnectionPoint;
  139112. /**
  139113. * Gets the world input component
  139114. */
  139115. get world(): NodeMaterialConnectionPoint;
  139116. /**
  139117. * Gets the output component
  139118. */
  139119. get output(): NodeMaterialConnectionPoint;
  139120. /**
  139121. * Gets the isntanceID component
  139122. */
  139123. get instanceID(): NodeMaterialConnectionPoint;
  139124. autoConfigure(material: NodeMaterial): void;
  139125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139126. protected _buildBlock(state: NodeMaterialBuildState): this;
  139127. }
  139128. }
  139129. declare module BABYLON {
  139130. /**
  139131. * Block used to add morph targets support to vertex shader
  139132. */
  139133. export class MorphTargetsBlock extends NodeMaterialBlock {
  139134. private _repeatableContentAnchor;
  139135. /**
  139136. * Create a new MorphTargetsBlock
  139137. * @param name defines the block name
  139138. */
  139139. constructor(name: string);
  139140. /**
  139141. * Gets the current class name
  139142. * @returns the class name
  139143. */
  139144. getClassName(): string;
  139145. /**
  139146. * Gets the position input component
  139147. */
  139148. get position(): NodeMaterialConnectionPoint;
  139149. /**
  139150. * Gets the normal input component
  139151. */
  139152. get normal(): NodeMaterialConnectionPoint;
  139153. /**
  139154. * Gets the tangent input component
  139155. */
  139156. get tangent(): NodeMaterialConnectionPoint;
  139157. /**
  139158. * Gets the tangent input component
  139159. */
  139160. get uv(): NodeMaterialConnectionPoint;
  139161. /**
  139162. * Gets the position output component
  139163. */
  139164. get positionOutput(): NodeMaterialConnectionPoint;
  139165. /**
  139166. * Gets the normal output component
  139167. */
  139168. get normalOutput(): NodeMaterialConnectionPoint;
  139169. /**
  139170. * Gets the tangent output component
  139171. */
  139172. get tangentOutput(): NodeMaterialConnectionPoint;
  139173. /**
  139174. * Gets the tangent output component
  139175. */
  139176. get uvOutput(): NodeMaterialConnectionPoint;
  139177. initialize(state: NodeMaterialBuildState): void;
  139178. autoConfigure(material: NodeMaterial): void;
  139179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139181. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139182. protected _buildBlock(state: NodeMaterialBuildState): this;
  139183. }
  139184. }
  139185. declare module BABYLON {
  139186. /**
  139187. * Block used to get data information from a light
  139188. */
  139189. export class LightInformationBlock extends NodeMaterialBlock {
  139190. private _lightDataUniformName;
  139191. private _lightColorUniformName;
  139192. private _lightTypeDefineName;
  139193. /**
  139194. * Gets or sets the light associated with this block
  139195. */
  139196. light: Nullable<Light>;
  139197. /**
  139198. * Creates a new LightInformationBlock
  139199. * @param name defines the block name
  139200. */
  139201. constructor(name: string);
  139202. /**
  139203. * Gets the current class name
  139204. * @returns the class name
  139205. */
  139206. getClassName(): string;
  139207. /**
  139208. * Gets the world position input component
  139209. */
  139210. get worldPosition(): NodeMaterialConnectionPoint;
  139211. /**
  139212. * Gets the direction output component
  139213. */
  139214. get direction(): NodeMaterialConnectionPoint;
  139215. /**
  139216. * Gets the direction output component
  139217. */
  139218. get color(): NodeMaterialConnectionPoint;
  139219. /**
  139220. * Gets the direction output component
  139221. */
  139222. get intensity(): NodeMaterialConnectionPoint;
  139223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139225. protected _buildBlock(state: NodeMaterialBuildState): this;
  139226. serialize(): any;
  139227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139228. }
  139229. }
  139230. declare module BABYLON {
  139231. /**
  139232. * Block used to add image processing support to fragment shader
  139233. */
  139234. export class ImageProcessingBlock extends NodeMaterialBlock {
  139235. /**
  139236. * Create a new ImageProcessingBlock
  139237. * @param name defines the block name
  139238. */
  139239. constructor(name: string);
  139240. /**
  139241. * Gets the current class name
  139242. * @returns the class name
  139243. */
  139244. getClassName(): string;
  139245. /**
  139246. * Gets the color input component
  139247. */
  139248. get color(): NodeMaterialConnectionPoint;
  139249. /**
  139250. * Gets the output component
  139251. */
  139252. get output(): NodeMaterialConnectionPoint;
  139253. /**
  139254. * Initialize the block and prepare the context for build
  139255. * @param state defines the state that will be used for the build
  139256. */
  139257. initialize(state: NodeMaterialBuildState): void;
  139258. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139261. protected _buildBlock(state: NodeMaterialBuildState): this;
  139262. }
  139263. }
  139264. declare module BABYLON {
  139265. /**
  139266. * Block used to pertub normals based on a normal map
  139267. */
  139268. export class PerturbNormalBlock extends NodeMaterialBlock {
  139269. private _tangentSpaceParameterName;
  139270. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139271. invertX: boolean;
  139272. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139273. invertY: boolean;
  139274. /**
  139275. * Create a new PerturbNormalBlock
  139276. * @param name defines the block name
  139277. */
  139278. constructor(name: string);
  139279. /**
  139280. * Gets the current class name
  139281. * @returns the class name
  139282. */
  139283. getClassName(): string;
  139284. /**
  139285. * Gets the world position input component
  139286. */
  139287. get worldPosition(): NodeMaterialConnectionPoint;
  139288. /**
  139289. * Gets the world normal input component
  139290. */
  139291. get worldNormal(): NodeMaterialConnectionPoint;
  139292. /**
  139293. * Gets the world tangent input component
  139294. */
  139295. get worldTangent(): NodeMaterialConnectionPoint;
  139296. /**
  139297. * Gets the uv input component
  139298. */
  139299. get uv(): NodeMaterialConnectionPoint;
  139300. /**
  139301. * Gets the normal map color input component
  139302. */
  139303. get normalMapColor(): NodeMaterialConnectionPoint;
  139304. /**
  139305. * Gets the strength input component
  139306. */
  139307. get strength(): NodeMaterialConnectionPoint;
  139308. /**
  139309. * Gets the output component
  139310. */
  139311. get output(): NodeMaterialConnectionPoint;
  139312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139314. autoConfigure(material: NodeMaterial): void;
  139315. protected _buildBlock(state: NodeMaterialBuildState): this;
  139316. protected _dumpPropertiesCode(): string;
  139317. serialize(): any;
  139318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139319. }
  139320. }
  139321. declare module BABYLON {
  139322. /**
  139323. * Block used to discard a pixel if a value is smaller than a cutoff
  139324. */
  139325. export class DiscardBlock extends NodeMaterialBlock {
  139326. /**
  139327. * Create a new DiscardBlock
  139328. * @param name defines the block name
  139329. */
  139330. constructor(name: string);
  139331. /**
  139332. * Gets the current class name
  139333. * @returns the class name
  139334. */
  139335. getClassName(): string;
  139336. /**
  139337. * Gets the color input component
  139338. */
  139339. get value(): NodeMaterialConnectionPoint;
  139340. /**
  139341. * Gets the cutoff input component
  139342. */
  139343. get cutoff(): NodeMaterialConnectionPoint;
  139344. protected _buildBlock(state: NodeMaterialBuildState): this;
  139345. }
  139346. }
  139347. declare module BABYLON {
  139348. /**
  139349. * Block used to test if the fragment shader is front facing
  139350. */
  139351. export class FrontFacingBlock extends NodeMaterialBlock {
  139352. /**
  139353. * Creates a new FrontFacingBlock
  139354. * @param name defines the block name
  139355. */
  139356. constructor(name: string);
  139357. /**
  139358. * Gets the current class name
  139359. * @returns the class name
  139360. */
  139361. getClassName(): string;
  139362. /**
  139363. * Gets the output component
  139364. */
  139365. get output(): NodeMaterialConnectionPoint;
  139366. protected _buildBlock(state: NodeMaterialBuildState): this;
  139367. }
  139368. }
  139369. declare module BABYLON {
  139370. /**
  139371. * Block used to get the derivative value on x and y of a given input
  139372. */
  139373. export class DerivativeBlock extends NodeMaterialBlock {
  139374. /**
  139375. * Create a new DerivativeBlock
  139376. * @param name defines the block name
  139377. */
  139378. constructor(name: string);
  139379. /**
  139380. * Gets the current class name
  139381. * @returns the class name
  139382. */
  139383. getClassName(): string;
  139384. /**
  139385. * Gets the input component
  139386. */
  139387. get input(): NodeMaterialConnectionPoint;
  139388. /**
  139389. * Gets the derivative output on x
  139390. */
  139391. get dx(): NodeMaterialConnectionPoint;
  139392. /**
  139393. * Gets the derivative output on y
  139394. */
  139395. get dy(): NodeMaterialConnectionPoint;
  139396. protected _buildBlock(state: NodeMaterialBuildState): this;
  139397. }
  139398. }
  139399. declare module BABYLON {
  139400. /**
  139401. * Block used to make gl_FragCoord available
  139402. */
  139403. export class FragCoordBlock extends NodeMaterialBlock {
  139404. /**
  139405. * Creates a new FragCoordBlock
  139406. * @param name defines the block name
  139407. */
  139408. constructor(name: string);
  139409. /**
  139410. * Gets the current class name
  139411. * @returns the class name
  139412. */
  139413. getClassName(): string;
  139414. /**
  139415. * Gets the xy component
  139416. */
  139417. get xy(): NodeMaterialConnectionPoint;
  139418. /**
  139419. * Gets the xyz component
  139420. */
  139421. get xyz(): NodeMaterialConnectionPoint;
  139422. /**
  139423. * Gets the xyzw component
  139424. */
  139425. get xyzw(): NodeMaterialConnectionPoint;
  139426. /**
  139427. * Gets the x component
  139428. */
  139429. get x(): NodeMaterialConnectionPoint;
  139430. /**
  139431. * Gets the y component
  139432. */
  139433. get y(): NodeMaterialConnectionPoint;
  139434. /**
  139435. * Gets the z component
  139436. */
  139437. get z(): NodeMaterialConnectionPoint;
  139438. /**
  139439. * Gets the w component
  139440. */
  139441. get output(): NodeMaterialConnectionPoint;
  139442. protected writeOutputs(state: NodeMaterialBuildState): string;
  139443. protected _buildBlock(state: NodeMaterialBuildState): this;
  139444. }
  139445. }
  139446. declare module BABYLON {
  139447. /**
  139448. * Block used to get the screen sizes
  139449. */
  139450. export class ScreenSizeBlock extends NodeMaterialBlock {
  139451. private _varName;
  139452. private _scene;
  139453. /**
  139454. * Creates a new ScreenSizeBlock
  139455. * @param name defines the block name
  139456. */
  139457. constructor(name: string);
  139458. /**
  139459. * Gets the current class name
  139460. * @returns the class name
  139461. */
  139462. getClassName(): string;
  139463. /**
  139464. * Gets the xy component
  139465. */
  139466. get xy(): NodeMaterialConnectionPoint;
  139467. /**
  139468. * Gets the x component
  139469. */
  139470. get x(): NodeMaterialConnectionPoint;
  139471. /**
  139472. * Gets the y component
  139473. */
  139474. get y(): NodeMaterialConnectionPoint;
  139475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139476. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139477. protected _buildBlock(state: NodeMaterialBuildState): this;
  139478. }
  139479. }
  139480. declare module BABYLON {
  139481. /**
  139482. * Block used to add support for scene fog
  139483. */
  139484. export class FogBlock extends NodeMaterialBlock {
  139485. private _fogDistanceName;
  139486. private _fogParameters;
  139487. /**
  139488. * Create a new FogBlock
  139489. * @param name defines the block name
  139490. */
  139491. constructor(name: string);
  139492. /**
  139493. * Gets the current class name
  139494. * @returns the class name
  139495. */
  139496. getClassName(): string;
  139497. /**
  139498. * Gets the world position input component
  139499. */
  139500. get worldPosition(): NodeMaterialConnectionPoint;
  139501. /**
  139502. * Gets the view input component
  139503. */
  139504. get view(): NodeMaterialConnectionPoint;
  139505. /**
  139506. * Gets the color input component
  139507. */
  139508. get input(): NodeMaterialConnectionPoint;
  139509. /**
  139510. * Gets the fog color input component
  139511. */
  139512. get fogColor(): NodeMaterialConnectionPoint;
  139513. /**
  139514. * Gets the output component
  139515. */
  139516. get output(): NodeMaterialConnectionPoint;
  139517. autoConfigure(material: NodeMaterial): void;
  139518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139519. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139520. protected _buildBlock(state: NodeMaterialBuildState): this;
  139521. }
  139522. }
  139523. declare module BABYLON {
  139524. /**
  139525. * Block used to add light in the fragment shader
  139526. */
  139527. export class LightBlock extends NodeMaterialBlock {
  139528. private _lightId;
  139529. /**
  139530. * Gets or sets the light associated with this block
  139531. */
  139532. light: Nullable<Light>;
  139533. /**
  139534. * Create a new LightBlock
  139535. * @param name defines the block name
  139536. */
  139537. constructor(name: string);
  139538. /**
  139539. * Gets the current class name
  139540. * @returns the class name
  139541. */
  139542. getClassName(): string;
  139543. /**
  139544. * Gets the world position input component
  139545. */
  139546. get worldPosition(): NodeMaterialConnectionPoint;
  139547. /**
  139548. * Gets the world normal input component
  139549. */
  139550. get worldNormal(): NodeMaterialConnectionPoint;
  139551. /**
  139552. * Gets the camera (or eye) position component
  139553. */
  139554. get cameraPosition(): NodeMaterialConnectionPoint;
  139555. /**
  139556. * Gets the glossiness component
  139557. */
  139558. get glossiness(): NodeMaterialConnectionPoint;
  139559. /**
  139560. * Gets the glossinness power component
  139561. */
  139562. get glossPower(): NodeMaterialConnectionPoint;
  139563. /**
  139564. * Gets the diffuse color component
  139565. */
  139566. get diffuseColor(): NodeMaterialConnectionPoint;
  139567. /**
  139568. * Gets the specular color component
  139569. */
  139570. get specularColor(): NodeMaterialConnectionPoint;
  139571. /**
  139572. * Gets the diffuse output component
  139573. */
  139574. get diffuseOutput(): NodeMaterialConnectionPoint;
  139575. /**
  139576. * Gets the specular output component
  139577. */
  139578. get specularOutput(): NodeMaterialConnectionPoint;
  139579. /**
  139580. * Gets the shadow output component
  139581. */
  139582. get shadow(): NodeMaterialConnectionPoint;
  139583. autoConfigure(material: NodeMaterial): void;
  139584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139585. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  139586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139587. private _injectVertexCode;
  139588. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139589. serialize(): any;
  139590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139591. }
  139592. }
  139593. declare module BABYLON {
  139594. /**
  139595. * Block used to read a reflection texture from a sampler
  139596. */
  139597. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  139598. /**
  139599. * Create a new ReflectionTextureBlock
  139600. * @param name defines the block name
  139601. */
  139602. constructor(name: string);
  139603. /**
  139604. * Gets the current class name
  139605. * @returns the class name
  139606. */
  139607. getClassName(): string;
  139608. /**
  139609. * Gets the world position input component
  139610. */
  139611. get position(): NodeMaterialConnectionPoint;
  139612. /**
  139613. * Gets the world position input component
  139614. */
  139615. get worldPosition(): NodeMaterialConnectionPoint;
  139616. /**
  139617. * Gets the world normal input component
  139618. */
  139619. get worldNormal(): NodeMaterialConnectionPoint;
  139620. /**
  139621. * Gets the world input component
  139622. */
  139623. get world(): NodeMaterialConnectionPoint;
  139624. /**
  139625. * Gets the camera (or eye) position component
  139626. */
  139627. get cameraPosition(): NodeMaterialConnectionPoint;
  139628. /**
  139629. * Gets the view input component
  139630. */
  139631. get view(): NodeMaterialConnectionPoint;
  139632. /**
  139633. * Gets the rgb output component
  139634. */
  139635. get rgb(): NodeMaterialConnectionPoint;
  139636. /**
  139637. * Gets the rgba output component
  139638. */
  139639. get rgba(): NodeMaterialConnectionPoint;
  139640. /**
  139641. * Gets the r output component
  139642. */
  139643. get r(): NodeMaterialConnectionPoint;
  139644. /**
  139645. * Gets the g output component
  139646. */
  139647. get g(): NodeMaterialConnectionPoint;
  139648. /**
  139649. * Gets the b output component
  139650. */
  139651. get b(): NodeMaterialConnectionPoint;
  139652. /**
  139653. * Gets the a output component
  139654. */
  139655. get a(): NodeMaterialConnectionPoint;
  139656. autoConfigure(material: NodeMaterial): void;
  139657. protected _buildBlock(state: NodeMaterialBuildState): this;
  139658. }
  139659. }
  139660. declare module BABYLON {
  139661. /**
  139662. * Block used to add 2 vectors
  139663. */
  139664. export class AddBlock extends NodeMaterialBlock {
  139665. /**
  139666. * Creates a new AddBlock
  139667. * @param name defines the block name
  139668. */
  139669. constructor(name: string);
  139670. /**
  139671. * Gets the current class name
  139672. * @returns the class name
  139673. */
  139674. getClassName(): string;
  139675. /**
  139676. * Gets the left operand input component
  139677. */
  139678. get left(): NodeMaterialConnectionPoint;
  139679. /**
  139680. * Gets the right operand input component
  139681. */
  139682. get right(): NodeMaterialConnectionPoint;
  139683. /**
  139684. * Gets the output component
  139685. */
  139686. get output(): NodeMaterialConnectionPoint;
  139687. protected _buildBlock(state: NodeMaterialBuildState): this;
  139688. }
  139689. }
  139690. declare module BABYLON {
  139691. /**
  139692. * Block used to scale a vector by a float
  139693. */
  139694. export class ScaleBlock extends NodeMaterialBlock {
  139695. /**
  139696. * Creates a new ScaleBlock
  139697. * @param name defines the block name
  139698. */
  139699. constructor(name: string);
  139700. /**
  139701. * Gets the current class name
  139702. * @returns the class name
  139703. */
  139704. getClassName(): string;
  139705. /**
  139706. * Gets the input component
  139707. */
  139708. get input(): NodeMaterialConnectionPoint;
  139709. /**
  139710. * Gets the factor input component
  139711. */
  139712. get factor(): NodeMaterialConnectionPoint;
  139713. /**
  139714. * Gets the output component
  139715. */
  139716. get output(): NodeMaterialConnectionPoint;
  139717. protected _buildBlock(state: NodeMaterialBuildState): this;
  139718. }
  139719. }
  139720. declare module BABYLON {
  139721. /**
  139722. * Block used to clamp a float
  139723. */
  139724. export class ClampBlock extends NodeMaterialBlock {
  139725. /** Gets or sets the minimum range */
  139726. minimum: number;
  139727. /** Gets or sets the maximum range */
  139728. maximum: number;
  139729. /**
  139730. * Creates a new ClampBlock
  139731. * @param name defines the block name
  139732. */
  139733. constructor(name: string);
  139734. /**
  139735. * Gets the current class name
  139736. * @returns the class name
  139737. */
  139738. getClassName(): string;
  139739. /**
  139740. * Gets the value input component
  139741. */
  139742. get value(): NodeMaterialConnectionPoint;
  139743. /**
  139744. * Gets the output component
  139745. */
  139746. get output(): NodeMaterialConnectionPoint;
  139747. protected _buildBlock(state: NodeMaterialBuildState): this;
  139748. protected _dumpPropertiesCode(): string;
  139749. serialize(): any;
  139750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139751. }
  139752. }
  139753. declare module BABYLON {
  139754. /**
  139755. * Block used to apply a cross product between 2 vectors
  139756. */
  139757. export class CrossBlock extends NodeMaterialBlock {
  139758. /**
  139759. * Creates a new CrossBlock
  139760. * @param name defines the block name
  139761. */
  139762. constructor(name: string);
  139763. /**
  139764. * Gets the current class name
  139765. * @returns the class name
  139766. */
  139767. getClassName(): string;
  139768. /**
  139769. * Gets the left operand input component
  139770. */
  139771. get left(): NodeMaterialConnectionPoint;
  139772. /**
  139773. * Gets the right operand input component
  139774. */
  139775. get right(): NodeMaterialConnectionPoint;
  139776. /**
  139777. * Gets the output component
  139778. */
  139779. get output(): NodeMaterialConnectionPoint;
  139780. protected _buildBlock(state: NodeMaterialBuildState): this;
  139781. }
  139782. }
  139783. declare module BABYLON {
  139784. /**
  139785. * Block used to apply a dot product between 2 vectors
  139786. */
  139787. export class DotBlock extends NodeMaterialBlock {
  139788. /**
  139789. * Creates a new DotBlock
  139790. * @param name defines the block name
  139791. */
  139792. constructor(name: string);
  139793. /**
  139794. * Gets the current class name
  139795. * @returns the class name
  139796. */
  139797. getClassName(): string;
  139798. /**
  139799. * Gets the left operand input component
  139800. */
  139801. get left(): NodeMaterialConnectionPoint;
  139802. /**
  139803. * Gets the right operand input component
  139804. */
  139805. get right(): NodeMaterialConnectionPoint;
  139806. /**
  139807. * Gets the output component
  139808. */
  139809. get output(): NodeMaterialConnectionPoint;
  139810. protected _buildBlock(state: NodeMaterialBuildState): this;
  139811. }
  139812. }
  139813. declare module BABYLON {
  139814. /**
  139815. * Block used to normalize a vector
  139816. */
  139817. export class NormalizeBlock extends NodeMaterialBlock {
  139818. /**
  139819. * Creates a new NormalizeBlock
  139820. * @param name defines the block name
  139821. */
  139822. constructor(name: string);
  139823. /**
  139824. * Gets the current class name
  139825. * @returns the class name
  139826. */
  139827. getClassName(): string;
  139828. /**
  139829. * Gets the input component
  139830. */
  139831. get input(): NodeMaterialConnectionPoint;
  139832. /**
  139833. * Gets the output component
  139834. */
  139835. get output(): NodeMaterialConnectionPoint;
  139836. protected _buildBlock(state: NodeMaterialBuildState): this;
  139837. }
  139838. }
  139839. declare module BABYLON {
  139840. /**
  139841. * Operations supported by the Trigonometry block
  139842. */
  139843. export enum TrigonometryBlockOperations {
  139844. /** Cos */
  139845. Cos = 0,
  139846. /** Sin */
  139847. Sin = 1,
  139848. /** Abs */
  139849. Abs = 2,
  139850. /** Exp */
  139851. Exp = 3,
  139852. /** Exp2 */
  139853. Exp2 = 4,
  139854. /** Round */
  139855. Round = 5,
  139856. /** Floor */
  139857. Floor = 6,
  139858. /** Ceiling */
  139859. Ceiling = 7,
  139860. /** Square root */
  139861. Sqrt = 8,
  139862. /** Log */
  139863. Log = 9,
  139864. /** Tangent */
  139865. Tan = 10,
  139866. /** Arc tangent */
  139867. ArcTan = 11,
  139868. /** Arc cosinus */
  139869. ArcCos = 12,
  139870. /** Arc sinus */
  139871. ArcSin = 13,
  139872. /** Fraction */
  139873. Fract = 14,
  139874. /** Sign */
  139875. Sign = 15,
  139876. /** To radians (from degrees) */
  139877. Radians = 16,
  139878. /** To degrees (from radians) */
  139879. Degrees = 17
  139880. }
  139881. /**
  139882. * Block used to apply trigonometry operation to floats
  139883. */
  139884. export class TrigonometryBlock extends NodeMaterialBlock {
  139885. /**
  139886. * Gets or sets the operation applied by the block
  139887. */
  139888. operation: TrigonometryBlockOperations;
  139889. /**
  139890. * Creates a new TrigonometryBlock
  139891. * @param name defines the block name
  139892. */
  139893. constructor(name: string);
  139894. /**
  139895. * Gets the current class name
  139896. * @returns the class name
  139897. */
  139898. getClassName(): string;
  139899. /**
  139900. * Gets the input component
  139901. */
  139902. get input(): NodeMaterialConnectionPoint;
  139903. /**
  139904. * Gets the output component
  139905. */
  139906. get output(): NodeMaterialConnectionPoint;
  139907. protected _buildBlock(state: NodeMaterialBuildState): this;
  139908. serialize(): any;
  139909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139910. protected _dumpPropertiesCode(): string;
  139911. }
  139912. }
  139913. declare module BABYLON {
  139914. /**
  139915. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139916. */
  139917. export class ColorMergerBlock extends NodeMaterialBlock {
  139918. /**
  139919. * Create a new ColorMergerBlock
  139920. * @param name defines the block name
  139921. */
  139922. constructor(name: string);
  139923. /**
  139924. * Gets the current class name
  139925. * @returns the class name
  139926. */
  139927. getClassName(): string;
  139928. /**
  139929. * Gets the rgb component (input)
  139930. */
  139931. get rgbIn(): NodeMaterialConnectionPoint;
  139932. /**
  139933. * Gets the r component (input)
  139934. */
  139935. get r(): NodeMaterialConnectionPoint;
  139936. /**
  139937. * Gets the g component (input)
  139938. */
  139939. get g(): NodeMaterialConnectionPoint;
  139940. /**
  139941. * Gets the b component (input)
  139942. */
  139943. get b(): NodeMaterialConnectionPoint;
  139944. /**
  139945. * Gets the a component (input)
  139946. */
  139947. get a(): NodeMaterialConnectionPoint;
  139948. /**
  139949. * Gets the rgba component (output)
  139950. */
  139951. get rgba(): NodeMaterialConnectionPoint;
  139952. /**
  139953. * Gets the rgb component (output)
  139954. */
  139955. get rgbOut(): NodeMaterialConnectionPoint;
  139956. /**
  139957. * Gets the rgb component (output)
  139958. * @deprecated Please use rgbOut instead.
  139959. */
  139960. get rgb(): NodeMaterialConnectionPoint;
  139961. protected _buildBlock(state: NodeMaterialBuildState): this;
  139962. }
  139963. }
  139964. declare module BABYLON {
  139965. /**
  139966. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139967. */
  139968. export class VectorSplitterBlock extends NodeMaterialBlock {
  139969. /**
  139970. * Create a new VectorSplitterBlock
  139971. * @param name defines the block name
  139972. */
  139973. constructor(name: string);
  139974. /**
  139975. * Gets the current class name
  139976. * @returns the class name
  139977. */
  139978. getClassName(): string;
  139979. /**
  139980. * Gets the xyzw component (input)
  139981. */
  139982. get xyzw(): NodeMaterialConnectionPoint;
  139983. /**
  139984. * Gets the xyz component (input)
  139985. */
  139986. get xyzIn(): NodeMaterialConnectionPoint;
  139987. /**
  139988. * Gets the xy component (input)
  139989. */
  139990. get xyIn(): NodeMaterialConnectionPoint;
  139991. /**
  139992. * Gets the xyz component (output)
  139993. */
  139994. get xyzOut(): NodeMaterialConnectionPoint;
  139995. /**
  139996. * Gets the xy component (output)
  139997. */
  139998. get xyOut(): NodeMaterialConnectionPoint;
  139999. /**
  140000. * Gets the x component (output)
  140001. */
  140002. get x(): NodeMaterialConnectionPoint;
  140003. /**
  140004. * Gets the y component (output)
  140005. */
  140006. get y(): NodeMaterialConnectionPoint;
  140007. /**
  140008. * Gets the z component (output)
  140009. */
  140010. get z(): NodeMaterialConnectionPoint;
  140011. /**
  140012. * Gets the w component (output)
  140013. */
  140014. get w(): NodeMaterialConnectionPoint;
  140015. protected _inputRename(name: string): string;
  140016. protected _outputRename(name: string): string;
  140017. protected _buildBlock(state: NodeMaterialBuildState): this;
  140018. }
  140019. }
  140020. declare module BABYLON {
  140021. /**
  140022. * Block used to lerp between 2 values
  140023. */
  140024. export class LerpBlock extends NodeMaterialBlock {
  140025. /**
  140026. * Creates a new LerpBlock
  140027. * @param name defines the block name
  140028. */
  140029. constructor(name: string);
  140030. /**
  140031. * Gets the current class name
  140032. * @returns the class name
  140033. */
  140034. getClassName(): string;
  140035. /**
  140036. * Gets the left operand input component
  140037. */
  140038. get left(): NodeMaterialConnectionPoint;
  140039. /**
  140040. * Gets the right operand input component
  140041. */
  140042. get right(): NodeMaterialConnectionPoint;
  140043. /**
  140044. * Gets the gradient operand input component
  140045. */
  140046. get gradient(): NodeMaterialConnectionPoint;
  140047. /**
  140048. * Gets the output component
  140049. */
  140050. get output(): NodeMaterialConnectionPoint;
  140051. protected _buildBlock(state: NodeMaterialBuildState): this;
  140052. }
  140053. }
  140054. declare module BABYLON {
  140055. /**
  140056. * Block used to divide 2 vectors
  140057. */
  140058. export class DivideBlock extends NodeMaterialBlock {
  140059. /**
  140060. * Creates a new DivideBlock
  140061. * @param name defines the block name
  140062. */
  140063. constructor(name: string);
  140064. /**
  140065. * Gets the current class name
  140066. * @returns the class name
  140067. */
  140068. getClassName(): string;
  140069. /**
  140070. * Gets the left operand input component
  140071. */
  140072. get left(): NodeMaterialConnectionPoint;
  140073. /**
  140074. * Gets the right operand input component
  140075. */
  140076. get right(): NodeMaterialConnectionPoint;
  140077. /**
  140078. * Gets the output component
  140079. */
  140080. get output(): NodeMaterialConnectionPoint;
  140081. protected _buildBlock(state: NodeMaterialBuildState): this;
  140082. }
  140083. }
  140084. declare module BABYLON {
  140085. /**
  140086. * Block used to subtract 2 vectors
  140087. */
  140088. export class SubtractBlock extends NodeMaterialBlock {
  140089. /**
  140090. * Creates a new SubtractBlock
  140091. * @param name defines the block name
  140092. */
  140093. constructor(name: string);
  140094. /**
  140095. * Gets the current class name
  140096. * @returns the class name
  140097. */
  140098. getClassName(): string;
  140099. /**
  140100. * Gets the left operand input component
  140101. */
  140102. get left(): NodeMaterialConnectionPoint;
  140103. /**
  140104. * Gets the right operand input component
  140105. */
  140106. get right(): NodeMaterialConnectionPoint;
  140107. /**
  140108. * Gets the output component
  140109. */
  140110. get output(): NodeMaterialConnectionPoint;
  140111. protected _buildBlock(state: NodeMaterialBuildState): this;
  140112. }
  140113. }
  140114. declare module BABYLON {
  140115. /**
  140116. * Block used to step a value
  140117. */
  140118. export class StepBlock extends NodeMaterialBlock {
  140119. /**
  140120. * Creates a new StepBlock
  140121. * @param name defines the block name
  140122. */
  140123. constructor(name: string);
  140124. /**
  140125. * Gets the current class name
  140126. * @returns the class name
  140127. */
  140128. getClassName(): string;
  140129. /**
  140130. * Gets the value operand input component
  140131. */
  140132. get value(): NodeMaterialConnectionPoint;
  140133. /**
  140134. * Gets the edge operand input component
  140135. */
  140136. get edge(): NodeMaterialConnectionPoint;
  140137. /**
  140138. * Gets the output component
  140139. */
  140140. get output(): NodeMaterialConnectionPoint;
  140141. protected _buildBlock(state: NodeMaterialBuildState): this;
  140142. }
  140143. }
  140144. declare module BABYLON {
  140145. /**
  140146. * Block used to get the opposite (1 - x) of a value
  140147. */
  140148. export class OneMinusBlock extends NodeMaterialBlock {
  140149. /**
  140150. * Creates a new OneMinusBlock
  140151. * @param name defines the block name
  140152. */
  140153. constructor(name: string);
  140154. /**
  140155. * Gets the current class name
  140156. * @returns the class name
  140157. */
  140158. getClassName(): string;
  140159. /**
  140160. * Gets the input component
  140161. */
  140162. get input(): NodeMaterialConnectionPoint;
  140163. /**
  140164. * Gets the output component
  140165. */
  140166. get output(): NodeMaterialConnectionPoint;
  140167. protected _buildBlock(state: NodeMaterialBuildState): this;
  140168. }
  140169. }
  140170. declare module BABYLON {
  140171. /**
  140172. * Block used to get the view direction
  140173. */
  140174. export class ViewDirectionBlock extends NodeMaterialBlock {
  140175. /**
  140176. * Creates a new ViewDirectionBlock
  140177. * @param name defines the block name
  140178. */
  140179. constructor(name: string);
  140180. /**
  140181. * Gets the current class name
  140182. * @returns the class name
  140183. */
  140184. getClassName(): string;
  140185. /**
  140186. * Gets the world position component
  140187. */
  140188. get worldPosition(): NodeMaterialConnectionPoint;
  140189. /**
  140190. * Gets the camera position component
  140191. */
  140192. get cameraPosition(): NodeMaterialConnectionPoint;
  140193. /**
  140194. * Gets the output component
  140195. */
  140196. get output(): NodeMaterialConnectionPoint;
  140197. autoConfigure(material: NodeMaterial): void;
  140198. protected _buildBlock(state: NodeMaterialBuildState): this;
  140199. }
  140200. }
  140201. declare module BABYLON {
  140202. /**
  140203. * Block used to compute fresnel value
  140204. */
  140205. export class FresnelBlock extends NodeMaterialBlock {
  140206. /**
  140207. * Create a new FresnelBlock
  140208. * @param name defines the block name
  140209. */
  140210. constructor(name: string);
  140211. /**
  140212. * Gets the current class name
  140213. * @returns the class name
  140214. */
  140215. getClassName(): string;
  140216. /**
  140217. * Gets the world normal input component
  140218. */
  140219. get worldNormal(): NodeMaterialConnectionPoint;
  140220. /**
  140221. * Gets the view direction input component
  140222. */
  140223. get viewDirection(): NodeMaterialConnectionPoint;
  140224. /**
  140225. * Gets the bias input component
  140226. */
  140227. get bias(): NodeMaterialConnectionPoint;
  140228. /**
  140229. * Gets the camera (or eye) position component
  140230. */
  140231. get power(): NodeMaterialConnectionPoint;
  140232. /**
  140233. * Gets the fresnel output component
  140234. */
  140235. get fresnel(): NodeMaterialConnectionPoint;
  140236. autoConfigure(material: NodeMaterial): void;
  140237. protected _buildBlock(state: NodeMaterialBuildState): this;
  140238. }
  140239. }
  140240. declare module BABYLON {
  140241. /**
  140242. * Block used to get the max of 2 values
  140243. */
  140244. export class MaxBlock extends NodeMaterialBlock {
  140245. /**
  140246. * Creates a new MaxBlock
  140247. * @param name defines the block name
  140248. */
  140249. constructor(name: string);
  140250. /**
  140251. * Gets the current class name
  140252. * @returns the class name
  140253. */
  140254. getClassName(): string;
  140255. /**
  140256. * Gets the left operand input component
  140257. */
  140258. get left(): NodeMaterialConnectionPoint;
  140259. /**
  140260. * Gets the right operand input component
  140261. */
  140262. get right(): NodeMaterialConnectionPoint;
  140263. /**
  140264. * Gets the output component
  140265. */
  140266. get output(): NodeMaterialConnectionPoint;
  140267. protected _buildBlock(state: NodeMaterialBuildState): this;
  140268. }
  140269. }
  140270. declare module BABYLON {
  140271. /**
  140272. * Block used to get the min of 2 values
  140273. */
  140274. export class MinBlock extends NodeMaterialBlock {
  140275. /**
  140276. * Creates a new MinBlock
  140277. * @param name defines the block name
  140278. */
  140279. constructor(name: string);
  140280. /**
  140281. * Gets the current class name
  140282. * @returns the class name
  140283. */
  140284. getClassName(): string;
  140285. /**
  140286. * Gets the left operand input component
  140287. */
  140288. get left(): NodeMaterialConnectionPoint;
  140289. /**
  140290. * Gets the right operand input component
  140291. */
  140292. get right(): NodeMaterialConnectionPoint;
  140293. /**
  140294. * Gets the output component
  140295. */
  140296. get output(): NodeMaterialConnectionPoint;
  140297. protected _buildBlock(state: NodeMaterialBuildState): this;
  140298. }
  140299. }
  140300. declare module BABYLON {
  140301. /**
  140302. * Block used to get the distance between 2 values
  140303. */
  140304. export class DistanceBlock extends NodeMaterialBlock {
  140305. /**
  140306. * Creates a new DistanceBlock
  140307. * @param name defines the block name
  140308. */
  140309. constructor(name: string);
  140310. /**
  140311. * Gets the current class name
  140312. * @returns the class name
  140313. */
  140314. getClassName(): string;
  140315. /**
  140316. * Gets the left operand input component
  140317. */
  140318. get left(): NodeMaterialConnectionPoint;
  140319. /**
  140320. * Gets the right operand input component
  140321. */
  140322. get right(): NodeMaterialConnectionPoint;
  140323. /**
  140324. * Gets the output component
  140325. */
  140326. get output(): NodeMaterialConnectionPoint;
  140327. protected _buildBlock(state: NodeMaterialBuildState): this;
  140328. }
  140329. }
  140330. declare module BABYLON {
  140331. /**
  140332. * Block used to get the length of a vector
  140333. */
  140334. export class LengthBlock extends NodeMaterialBlock {
  140335. /**
  140336. * Creates a new LengthBlock
  140337. * @param name defines the block name
  140338. */
  140339. constructor(name: string);
  140340. /**
  140341. * Gets the current class name
  140342. * @returns the class name
  140343. */
  140344. getClassName(): string;
  140345. /**
  140346. * Gets the value input component
  140347. */
  140348. get value(): NodeMaterialConnectionPoint;
  140349. /**
  140350. * Gets the output component
  140351. */
  140352. get output(): NodeMaterialConnectionPoint;
  140353. protected _buildBlock(state: NodeMaterialBuildState): this;
  140354. }
  140355. }
  140356. declare module BABYLON {
  140357. /**
  140358. * Block used to get negative version of a value (i.e. x * -1)
  140359. */
  140360. export class NegateBlock extends NodeMaterialBlock {
  140361. /**
  140362. * Creates a new NegateBlock
  140363. * @param name defines the block name
  140364. */
  140365. constructor(name: string);
  140366. /**
  140367. * Gets the current class name
  140368. * @returns the class name
  140369. */
  140370. getClassName(): string;
  140371. /**
  140372. * Gets the value input component
  140373. */
  140374. get value(): NodeMaterialConnectionPoint;
  140375. /**
  140376. * Gets the output component
  140377. */
  140378. get output(): NodeMaterialConnectionPoint;
  140379. protected _buildBlock(state: NodeMaterialBuildState): this;
  140380. }
  140381. }
  140382. declare module BABYLON {
  140383. /**
  140384. * Block used to get the value of the first parameter raised to the power of the second
  140385. */
  140386. export class PowBlock extends NodeMaterialBlock {
  140387. /**
  140388. * Creates a new PowBlock
  140389. * @param name defines the block name
  140390. */
  140391. constructor(name: string);
  140392. /**
  140393. * Gets the current class name
  140394. * @returns the class name
  140395. */
  140396. getClassName(): string;
  140397. /**
  140398. * Gets the value operand input component
  140399. */
  140400. get value(): NodeMaterialConnectionPoint;
  140401. /**
  140402. * Gets the power operand input component
  140403. */
  140404. get power(): NodeMaterialConnectionPoint;
  140405. /**
  140406. * Gets the output component
  140407. */
  140408. get output(): NodeMaterialConnectionPoint;
  140409. protected _buildBlock(state: NodeMaterialBuildState): this;
  140410. }
  140411. }
  140412. declare module BABYLON {
  140413. /**
  140414. * Block used to get a random number
  140415. */
  140416. export class RandomNumberBlock extends NodeMaterialBlock {
  140417. /**
  140418. * Creates a new RandomNumberBlock
  140419. * @param name defines the block name
  140420. */
  140421. constructor(name: string);
  140422. /**
  140423. * Gets the current class name
  140424. * @returns the class name
  140425. */
  140426. getClassName(): string;
  140427. /**
  140428. * Gets the seed input component
  140429. */
  140430. get seed(): NodeMaterialConnectionPoint;
  140431. /**
  140432. * Gets the output component
  140433. */
  140434. get output(): NodeMaterialConnectionPoint;
  140435. protected _buildBlock(state: NodeMaterialBuildState): this;
  140436. }
  140437. }
  140438. declare module BABYLON {
  140439. /**
  140440. * Block used to compute arc tangent of 2 values
  140441. */
  140442. export class ArcTan2Block extends NodeMaterialBlock {
  140443. /**
  140444. * Creates a new ArcTan2Block
  140445. * @param name defines the block name
  140446. */
  140447. constructor(name: string);
  140448. /**
  140449. * Gets the current class name
  140450. * @returns the class name
  140451. */
  140452. getClassName(): string;
  140453. /**
  140454. * Gets the x operand input component
  140455. */
  140456. get x(): NodeMaterialConnectionPoint;
  140457. /**
  140458. * Gets the y operand input component
  140459. */
  140460. get y(): NodeMaterialConnectionPoint;
  140461. /**
  140462. * Gets the output component
  140463. */
  140464. get output(): NodeMaterialConnectionPoint;
  140465. protected _buildBlock(state: NodeMaterialBuildState): this;
  140466. }
  140467. }
  140468. declare module BABYLON {
  140469. /**
  140470. * Block used to smooth step a value
  140471. */
  140472. export class SmoothStepBlock extends NodeMaterialBlock {
  140473. /**
  140474. * Creates a new SmoothStepBlock
  140475. * @param name defines the block name
  140476. */
  140477. constructor(name: string);
  140478. /**
  140479. * Gets the current class name
  140480. * @returns the class name
  140481. */
  140482. getClassName(): string;
  140483. /**
  140484. * Gets the value operand input component
  140485. */
  140486. get value(): NodeMaterialConnectionPoint;
  140487. /**
  140488. * Gets the first edge operand input component
  140489. */
  140490. get edge0(): NodeMaterialConnectionPoint;
  140491. /**
  140492. * Gets the second edge operand input component
  140493. */
  140494. get edge1(): NodeMaterialConnectionPoint;
  140495. /**
  140496. * Gets the output component
  140497. */
  140498. get output(): NodeMaterialConnectionPoint;
  140499. protected _buildBlock(state: NodeMaterialBuildState): this;
  140500. }
  140501. }
  140502. declare module BABYLON {
  140503. /**
  140504. * Block used to get the reciprocal (1 / x) of a value
  140505. */
  140506. export class ReciprocalBlock extends NodeMaterialBlock {
  140507. /**
  140508. * Creates a new ReciprocalBlock
  140509. * @param name defines the block name
  140510. */
  140511. constructor(name: string);
  140512. /**
  140513. * Gets the current class name
  140514. * @returns the class name
  140515. */
  140516. getClassName(): string;
  140517. /**
  140518. * Gets the input component
  140519. */
  140520. get input(): NodeMaterialConnectionPoint;
  140521. /**
  140522. * Gets the output component
  140523. */
  140524. get output(): NodeMaterialConnectionPoint;
  140525. protected _buildBlock(state: NodeMaterialBuildState): this;
  140526. }
  140527. }
  140528. declare module BABYLON {
  140529. /**
  140530. * Block used to replace a color by another one
  140531. */
  140532. export class ReplaceColorBlock extends NodeMaterialBlock {
  140533. /**
  140534. * Creates a new ReplaceColorBlock
  140535. * @param name defines the block name
  140536. */
  140537. constructor(name: string);
  140538. /**
  140539. * Gets the current class name
  140540. * @returns the class name
  140541. */
  140542. getClassName(): string;
  140543. /**
  140544. * Gets the value input component
  140545. */
  140546. get value(): NodeMaterialConnectionPoint;
  140547. /**
  140548. * Gets the reference input component
  140549. */
  140550. get reference(): NodeMaterialConnectionPoint;
  140551. /**
  140552. * Gets the distance input component
  140553. */
  140554. get distance(): NodeMaterialConnectionPoint;
  140555. /**
  140556. * Gets the replacement input component
  140557. */
  140558. get replacement(): NodeMaterialConnectionPoint;
  140559. /**
  140560. * Gets the output component
  140561. */
  140562. get output(): NodeMaterialConnectionPoint;
  140563. protected _buildBlock(state: NodeMaterialBuildState): this;
  140564. }
  140565. }
  140566. declare module BABYLON {
  140567. /**
  140568. * Block used to posterize a value
  140569. * @see https://en.wikipedia.org/wiki/Posterization
  140570. */
  140571. export class PosterizeBlock extends NodeMaterialBlock {
  140572. /**
  140573. * Creates a new PosterizeBlock
  140574. * @param name defines the block name
  140575. */
  140576. constructor(name: string);
  140577. /**
  140578. * Gets the current class name
  140579. * @returns the class name
  140580. */
  140581. getClassName(): string;
  140582. /**
  140583. * Gets the value input component
  140584. */
  140585. get value(): NodeMaterialConnectionPoint;
  140586. /**
  140587. * Gets the steps input component
  140588. */
  140589. get steps(): NodeMaterialConnectionPoint;
  140590. /**
  140591. * Gets the output component
  140592. */
  140593. get output(): NodeMaterialConnectionPoint;
  140594. protected _buildBlock(state: NodeMaterialBuildState): this;
  140595. }
  140596. }
  140597. declare module BABYLON {
  140598. /**
  140599. * Operations supported by the Wave block
  140600. */
  140601. export enum WaveBlockKind {
  140602. /** SawTooth */
  140603. SawTooth = 0,
  140604. /** Square */
  140605. Square = 1,
  140606. /** Triangle */
  140607. Triangle = 2
  140608. }
  140609. /**
  140610. * Block used to apply wave operation to floats
  140611. */
  140612. export class WaveBlock extends NodeMaterialBlock {
  140613. /**
  140614. * Gets or sets the kibnd of wave to be applied by the block
  140615. */
  140616. kind: WaveBlockKind;
  140617. /**
  140618. * Creates a new WaveBlock
  140619. * @param name defines the block name
  140620. */
  140621. constructor(name: string);
  140622. /**
  140623. * Gets the current class name
  140624. * @returns the class name
  140625. */
  140626. getClassName(): string;
  140627. /**
  140628. * Gets the input component
  140629. */
  140630. get input(): NodeMaterialConnectionPoint;
  140631. /**
  140632. * Gets the output component
  140633. */
  140634. get output(): NodeMaterialConnectionPoint;
  140635. protected _buildBlock(state: NodeMaterialBuildState): this;
  140636. serialize(): any;
  140637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140638. }
  140639. }
  140640. declare module BABYLON {
  140641. /**
  140642. * Class used to store a color step for the GradientBlock
  140643. */
  140644. export class GradientBlockColorStep {
  140645. /**
  140646. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140647. */
  140648. step: number;
  140649. /**
  140650. * Gets or sets the color associated with this step
  140651. */
  140652. color: Color3;
  140653. /**
  140654. * Creates a new GradientBlockColorStep
  140655. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140656. * @param color defines the color associated with this step
  140657. */
  140658. constructor(
  140659. /**
  140660. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140661. */
  140662. step: number,
  140663. /**
  140664. * Gets or sets the color associated with this step
  140665. */
  140666. color: Color3);
  140667. }
  140668. /**
  140669. * Block used to return a color from a gradient based on an input value between 0 and 1
  140670. */
  140671. export class GradientBlock extends NodeMaterialBlock {
  140672. /**
  140673. * Gets or sets the list of color steps
  140674. */
  140675. colorSteps: GradientBlockColorStep[];
  140676. /**
  140677. * Creates a new GradientBlock
  140678. * @param name defines the block name
  140679. */
  140680. constructor(name: string);
  140681. /**
  140682. * Gets the current class name
  140683. * @returns the class name
  140684. */
  140685. getClassName(): string;
  140686. /**
  140687. * Gets the gradient input component
  140688. */
  140689. get gradient(): NodeMaterialConnectionPoint;
  140690. /**
  140691. * Gets the output component
  140692. */
  140693. get output(): NodeMaterialConnectionPoint;
  140694. private _writeColorConstant;
  140695. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140696. serialize(): any;
  140697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140698. protected _dumpPropertiesCode(): string;
  140699. }
  140700. }
  140701. declare module BABYLON {
  140702. /**
  140703. * Block used to normalize lerp between 2 values
  140704. */
  140705. export class NLerpBlock extends NodeMaterialBlock {
  140706. /**
  140707. * Creates a new NLerpBlock
  140708. * @param name defines the block name
  140709. */
  140710. constructor(name: string);
  140711. /**
  140712. * Gets the current class name
  140713. * @returns the class name
  140714. */
  140715. getClassName(): string;
  140716. /**
  140717. * Gets the left operand input component
  140718. */
  140719. get left(): NodeMaterialConnectionPoint;
  140720. /**
  140721. * Gets the right operand input component
  140722. */
  140723. get right(): NodeMaterialConnectionPoint;
  140724. /**
  140725. * Gets the gradient operand input component
  140726. */
  140727. get gradient(): NodeMaterialConnectionPoint;
  140728. /**
  140729. * Gets the output component
  140730. */
  140731. get output(): NodeMaterialConnectionPoint;
  140732. protected _buildBlock(state: NodeMaterialBuildState): this;
  140733. }
  140734. }
  140735. declare module BABYLON {
  140736. /**
  140737. * block used to Generate a Worley Noise 3D Noise Pattern
  140738. */
  140739. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140740. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140741. manhattanDistance: boolean;
  140742. /**
  140743. * Creates a new WorleyNoise3DBlock
  140744. * @param name defines the block name
  140745. */
  140746. constructor(name: string);
  140747. /**
  140748. * Gets the current class name
  140749. * @returns the class name
  140750. */
  140751. getClassName(): string;
  140752. /**
  140753. * Gets the seed input component
  140754. */
  140755. get seed(): NodeMaterialConnectionPoint;
  140756. /**
  140757. * Gets the jitter input component
  140758. */
  140759. get jitter(): NodeMaterialConnectionPoint;
  140760. /**
  140761. * Gets the output component
  140762. */
  140763. get output(): NodeMaterialConnectionPoint;
  140764. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140765. /**
  140766. * Exposes the properties to the UI?
  140767. */
  140768. protected _dumpPropertiesCode(): string;
  140769. /**
  140770. * Exposes the properties to the Seralize?
  140771. */
  140772. serialize(): any;
  140773. /**
  140774. * Exposes the properties to the deseralize?
  140775. */
  140776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140777. }
  140778. }
  140779. declare module BABYLON {
  140780. /**
  140781. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140782. */
  140783. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140784. /**
  140785. * Creates a new SimplexPerlin3DBlock
  140786. * @param name defines the block name
  140787. */
  140788. constructor(name: string);
  140789. /**
  140790. * Gets the current class name
  140791. * @returns the class name
  140792. */
  140793. getClassName(): string;
  140794. /**
  140795. * Gets the seed operand input component
  140796. */
  140797. get seed(): NodeMaterialConnectionPoint;
  140798. /**
  140799. * Gets the output component
  140800. */
  140801. get output(): NodeMaterialConnectionPoint;
  140802. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140803. }
  140804. }
  140805. declare module BABYLON {
  140806. /**
  140807. * Block used to blend normals
  140808. */
  140809. export class NormalBlendBlock extends NodeMaterialBlock {
  140810. /**
  140811. * Creates a new NormalBlendBlock
  140812. * @param name defines the block name
  140813. */
  140814. constructor(name: string);
  140815. /**
  140816. * Gets the current class name
  140817. * @returns the class name
  140818. */
  140819. getClassName(): string;
  140820. /**
  140821. * Gets the first input component
  140822. */
  140823. get normalMap0(): NodeMaterialConnectionPoint;
  140824. /**
  140825. * Gets the second input component
  140826. */
  140827. get normalMap1(): NodeMaterialConnectionPoint;
  140828. /**
  140829. * Gets the output component
  140830. */
  140831. get output(): NodeMaterialConnectionPoint;
  140832. protected _buildBlock(state: NodeMaterialBuildState): this;
  140833. }
  140834. }
  140835. declare module BABYLON {
  140836. /**
  140837. * Block used to rotate a 2d vector by a given angle
  140838. */
  140839. export class Rotate2dBlock extends NodeMaterialBlock {
  140840. /**
  140841. * Creates a new Rotate2dBlock
  140842. * @param name defines the block name
  140843. */
  140844. constructor(name: string);
  140845. /**
  140846. * Gets the current class name
  140847. * @returns the class name
  140848. */
  140849. getClassName(): string;
  140850. /**
  140851. * Gets the input vector
  140852. */
  140853. get input(): NodeMaterialConnectionPoint;
  140854. /**
  140855. * Gets the input angle
  140856. */
  140857. get angle(): NodeMaterialConnectionPoint;
  140858. /**
  140859. * Gets the output component
  140860. */
  140861. get output(): NodeMaterialConnectionPoint;
  140862. autoConfigure(material: NodeMaterial): void;
  140863. protected _buildBlock(state: NodeMaterialBuildState): this;
  140864. }
  140865. }
  140866. declare module BABYLON {
  140867. /**
  140868. * Block used to get the reflected vector from a direction and a normal
  140869. */
  140870. export class ReflectBlock extends NodeMaterialBlock {
  140871. /**
  140872. * Creates a new ReflectBlock
  140873. * @param name defines the block name
  140874. */
  140875. constructor(name: string);
  140876. /**
  140877. * Gets the current class name
  140878. * @returns the class name
  140879. */
  140880. getClassName(): string;
  140881. /**
  140882. * Gets the incident component
  140883. */
  140884. get incident(): NodeMaterialConnectionPoint;
  140885. /**
  140886. * Gets the normal component
  140887. */
  140888. get normal(): NodeMaterialConnectionPoint;
  140889. /**
  140890. * Gets the output component
  140891. */
  140892. get output(): NodeMaterialConnectionPoint;
  140893. protected _buildBlock(state: NodeMaterialBuildState): this;
  140894. }
  140895. }
  140896. declare module BABYLON {
  140897. /**
  140898. * Block used to get the refracted vector from a direction and a normal
  140899. */
  140900. export class RefractBlock extends NodeMaterialBlock {
  140901. /**
  140902. * Creates a new RefractBlock
  140903. * @param name defines the block name
  140904. */
  140905. constructor(name: string);
  140906. /**
  140907. * Gets the current class name
  140908. * @returns the class name
  140909. */
  140910. getClassName(): string;
  140911. /**
  140912. * Gets the incident component
  140913. */
  140914. get incident(): NodeMaterialConnectionPoint;
  140915. /**
  140916. * Gets the normal component
  140917. */
  140918. get normal(): NodeMaterialConnectionPoint;
  140919. /**
  140920. * Gets the index of refraction component
  140921. */
  140922. get ior(): NodeMaterialConnectionPoint;
  140923. /**
  140924. * Gets the output component
  140925. */
  140926. get output(): NodeMaterialConnectionPoint;
  140927. protected _buildBlock(state: NodeMaterialBuildState): this;
  140928. }
  140929. }
  140930. declare module BABYLON {
  140931. /**
  140932. * Block used to desaturate a color
  140933. */
  140934. export class DesaturateBlock extends NodeMaterialBlock {
  140935. /**
  140936. * Creates a new DesaturateBlock
  140937. * @param name defines the block name
  140938. */
  140939. constructor(name: string);
  140940. /**
  140941. * Gets the current class name
  140942. * @returns the class name
  140943. */
  140944. getClassName(): string;
  140945. /**
  140946. * Gets the color operand input component
  140947. */
  140948. get color(): NodeMaterialConnectionPoint;
  140949. /**
  140950. * Gets the level operand input component
  140951. */
  140952. get level(): NodeMaterialConnectionPoint;
  140953. /**
  140954. * Gets the output component
  140955. */
  140956. get output(): NodeMaterialConnectionPoint;
  140957. protected _buildBlock(state: NodeMaterialBuildState): this;
  140958. }
  140959. }
  140960. declare module BABYLON {
  140961. /**
  140962. * Block used to implement the ambient occlusion module of the PBR material
  140963. */
  140964. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140965. /**
  140966. * Create a new AmbientOcclusionBlock
  140967. * @param name defines the block name
  140968. */
  140969. constructor(name: string);
  140970. /**
  140971. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140972. */
  140973. useAmbientInGrayScale: boolean;
  140974. /**
  140975. * Initialize the block and prepare the context for build
  140976. * @param state defines the state that will be used for the build
  140977. */
  140978. initialize(state: NodeMaterialBuildState): void;
  140979. /**
  140980. * Gets the current class name
  140981. * @returns the class name
  140982. */
  140983. getClassName(): string;
  140984. /**
  140985. * Gets the texture input component
  140986. */
  140987. get texture(): NodeMaterialConnectionPoint;
  140988. /**
  140989. * Gets the texture intensity component
  140990. */
  140991. get intensity(): NodeMaterialConnectionPoint;
  140992. /**
  140993. * Gets the direct light intensity input component
  140994. */
  140995. get directLightIntensity(): NodeMaterialConnectionPoint;
  140996. /**
  140997. * Gets the ambient occlusion object output component
  140998. */
  140999. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141000. /**
  141001. * Gets the main code of the block (fragment side)
  141002. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141003. * @returns the shader code
  141004. */
  141005. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141007. protected _buildBlock(state: NodeMaterialBuildState): this;
  141008. protected _dumpPropertiesCode(): string;
  141009. serialize(): any;
  141010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141011. }
  141012. }
  141013. declare module BABYLON {
  141014. /**
  141015. * Block used to implement the reflection module of the PBR material
  141016. */
  141017. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141018. /** @hidden */
  141019. _defineLODReflectionAlpha: string;
  141020. /** @hidden */
  141021. _defineLinearSpecularReflection: string;
  141022. private _vEnvironmentIrradianceName;
  141023. /** @hidden */
  141024. _vReflectionMicrosurfaceInfosName: string;
  141025. /** @hidden */
  141026. _vReflectionInfosName: string;
  141027. /** @hidden */
  141028. _vReflectionFilteringInfoName: string;
  141029. private _scene;
  141030. /**
  141031. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141032. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141033. * It's less burden on the user side in the editor part.
  141034. */
  141035. /** @hidden */
  141036. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141037. /** @hidden */
  141038. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141039. /** @hidden */
  141040. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141041. /**
  141042. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141043. * diffuse part of the IBL.
  141044. */
  141045. useSphericalHarmonics: boolean;
  141046. /**
  141047. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141048. */
  141049. forceIrradianceInFragment: boolean;
  141050. /**
  141051. * Create a new ReflectionBlock
  141052. * @param name defines the block name
  141053. */
  141054. constructor(name: string);
  141055. /**
  141056. * Gets the current class name
  141057. * @returns the class name
  141058. */
  141059. getClassName(): string;
  141060. /**
  141061. * Gets the position input component
  141062. */
  141063. get position(): NodeMaterialConnectionPoint;
  141064. /**
  141065. * Gets the world position input component
  141066. */
  141067. get worldPosition(): NodeMaterialConnectionPoint;
  141068. /**
  141069. * Gets the world normal input component
  141070. */
  141071. get worldNormal(): NodeMaterialConnectionPoint;
  141072. /**
  141073. * Gets the world input component
  141074. */
  141075. get world(): NodeMaterialConnectionPoint;
  141076. /**
  141077. * Gets the camera (or eye) position component
  141078. */
  141079. get cameraPosition(): NodeMaterialConnectionPoint;
  141080. /**
  141081. * Gets the view input component
  141082. */
  141083. get view(): NodeMaterialConnectionPoint;
  141084. /**
  141085. * Gets the color input component
  141086. */
  141087. get color(): NodeMaterialConnectionPoint;
  141088. /**
  141089. * Gets the reflection object output component
  141090. */
  141091. get reflection(): NodeMaterialConnectionPoint;
  141092. /**
  141093. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141094. */
  141095. get hasTexture(): boolean;
  141096. /**
  141097. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141098. */
  141099. get reflectionColor(): string;
  141100. protected _getTexture(): Nullable<BaseTexture>;
  141101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141102. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141103. /**
  141104. * Gets the code to inject in the vertex shader
  141105. * @param state current state of the node material building
  141106. * @returns the shader code
  141107. */
  141108. handleVertexSide(state: NodeMaterialBuildState): string;
  141109. /**
  141110. * Gets the main code of the block (fragment side)
  141111. * @param state current state of the node material building
  141112. * @param normalVarName name of the existing variable corresponding to the normal
  141113. * @returns the shader code
  141114. */
  141115. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141116. protected _buildBlock(state: NodeMaterialBuildState): this;
  141117. protected _dumpPropertiesCode(): string;
  141118. serialize(): any;
  141119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141120. }
  141121. }
  141122. declare module BABYLON {
  141123. /**
  141124. * Block used to implement the sheen module of the PBR material
  141125. */
  141126. export class SheenBlock extends NodeMaterialBlock {
  141127. /**
  141128. * Create a new SheenBlock
  141129. * @param name defines the block name
  141130. */
  141131. constructor(name: string);
  141132. /**
  141133. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141134. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141135. * making it easier to setup and tweak the effect
  141136. */
  141137. albedoScaling: boolean;
  141138. /**
  141139. * Defines if the sheen is linked to the sheen color.
  141140. */
  141141. linkSheenWithAlbedo: boolean;
  141142. /**
  141143. * Initialize the block and prepare the context for build
  141144. * @param state defines the state that will be used for the build
  141145. */
  141146. initialize(state: NodeMaterialBuildState): void;
  141147. /**
  141148. * Gets the current class name
  141149. * @returns the class name
  141150. */
  141151. getClassName(): string;
  141152. /**
  141153. * Gets the intensity input component
  141154. */
  141155. get intensity(): NodeMaterialConnectionPoint;
  141156. /**
  141157. * Gets the color input component
  141158. */
  141159. get color(): NodeMaterialConnectionPoint;
  141160. /**
  141161. * Gets the roughness input component
  141162. */
  141163. get roughness(): NodeMaterialConnectionPoint;
  141164. /**
  141165. * Gets the sheen object output component
  141166. */
  141167. get sheen(): NodeMaterialConnectionPoint;
  141168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141169. /**
  141170. * Gets the main code of the block (fragment side)
  141171. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141172. * @returns the shader code
  141173. */
  141174. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141175. protected _buildBlock(state: NodeMaterialBuildState): this;
  141176. protected _dumpPropertiesCode(): string;
  141177. serialize(): any;
  141178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141179. }
  141180. }
  141181. declare module BABYLON {
  141182. /**
  141183. * Block used to implement the reflectivity module of the PBR material
  141184. */
  141185. export class ReflectivityBlock extends NodeMaterialBlock {
  141186. private _metallicReflectanceColor;
  141187. private _metallicF0Factor;
  141188. /** @hidden */
  141189. _vMetallicReflectanceFactorsName: string;
  141190. /**
  141191. * The property below is set by the main PBR block prior to calling methods of this class.
  141192. */
  141193. /** @hidden */
  141194. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141195. /**
  141196. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141197. */
  141198. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141199. /**
  141200. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141201. */
  141202. useMetallnessFromMetallicTextureBlue: boolean;
  141203. /**
  141204. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141205. */
  141206. useRoughnessFromMetallicTextureAlpha: boolean;
  141207. /**
  141208. * Specifies if the metallic texture contains the roughness information in its green channel.
  141209. */
  141210. useRoughnessFromMetallicTextureGreen: boolean;
  141211. /**
  141212. * Create a new ReflectivityBlock
  141213. * @param name defines the block name
  141214. */
  141215. constructor(name: string);
  141216. /**
  141217. * Initialize the block and prepare the context for build
  141218. * @param state defines the state that will be used for the build
  141219. */
  141220. initialize(state: NodeMaterialBuildState): void;
  141221. /**
  141222. * Gets the current class name
  141223. * @returns the class name
  141224. */
  141225. getClassName(): string;
  141226. /**
  141227. * Gets the metallic input component
  141228. */
  141229. get metallic(): NodeMaterialConnectionPoint;
  141230. /**
  141231. * Gets the roughness input component
  141232. */
  141233. get roughness(): NodeMaterialConnectionPoint;
  141234. /**
  141235. * Gets the texture input component
  141236. */
  141237. get texture(): NodeMaterialConnectionPoint;
  141238. /**
  141239. * Gets the reflectivity object output component
  141240. */
  141241. get reflectivity(): NodeMaterialConnectionPoint;
  141242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141243. /**
  141244. * Gets the main code of the block (fragment side)
  141245. * @param state current state of the node material building
  141246. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141247. * @returns the shader code
  141248. */
  141249. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141250. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141251. protected _buildBlock(state: NodeMaterialBuildState): this;
  141252. protected _dumpPropertiesCode(): string;
  141253. serialize(): any;
  141254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141255. }
  141256. }
  141257. declare module BABYLON {
  141258. /**
  141259. * Block used to implement the anisotropy module of the PBR material
  141260. */
  141261. export class AnisotropyBlock extends NodeMaterialBlock {
  141262. /**
  141263. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141264. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141265. * It's less burden on the user side in the editor part.
  141266. */
  141267. /** @hidden */
  141268. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141269. /** @hidden */
  141270. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141271. /**
  141272. * Create a new AnisotropyBlock
  141273. * @param name defines the block name
  141274. */
  141275. constructor(name: string);
  141276. /**
  141277. * Initialize the block and prepare the context for build
  141278. * @param state defines the state that will be used for the build
  141279. */
  141280. initialize(state: NodeMaterialBuildState): void;
  141281. /**
  141282. * Gets the current class name
  141283. * @returns the class name
  141284. */
  141285. getClassName(): string;
  141286. /**
  141287. * Gets the intensity input component
  141288. */
  141289. get intensity(): NodeMaterialConnectionPoint;
  141290. /**
  141291. * Gets the direction input component
  141292. */
  141293. get direction(): NodeMaterialConnectionPoint;
  141294. /**
  141295. * Gets the texture input component
  141296. */
  141297. get texture(): NodeMaterialConnectionPoint;
  141298. /**
  141299. * Gets the uv input component
  141300. */
  141301. get uv(): NodeMaterialConnectionPoint;
  141302. /**
  141303. * Gets the worldTangent input component
  141304. */
  141305. get worldTangent(): NodeMaterialConnectionPoint;
  141306. /**
  141307. * Gets the anisotropy object output component
  141308. */
  141309. get anisotropy(): NodeMaterialConnectionPoint;
  141310. private _generateTBNSpace;
  141311. /**
  141312. * Gets the main code of the block (fragment side)
  141313. * @param state current state of the node material building
  141314. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141315. * @returns the shader code
  141316. */
  141317. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141319. protected _buildBlock(state: NodeMaterialBuildState): this;
  141320. }
  141321. }
  141322. declare module BABYLON {
  141323. /**
  141324. * Block used to implement the clear coat module of the PBR material
  141325. */
  141326. export class ClearCoatBlock extends NodeMaterialBlock {
  141327. private _scene;
  141328. /**
  141329. * Create a new ClearCoatBlock
  141330. * @param name defines the block name
  141331. */
  141332. constructor(name: string);
  141333. /**
  141334. * Initialize the block and prepare the context for build
  141335. * @param state defines the state that will be used for the build
  141336. */
  141337. initialize(state: NodeMaterialBuildState): void;
  141338. /**
  141339. * Gets the current class name
  141340. * @returns the class name
  141341. */
  141342. getClassName(): string;
  141343. /**
  141344. * Gets the intensity input component
  141345. */
  141346. get intensity(): NodeMaterialConnectionPoint;
  141347. /**
  141348. * Gets the roughness input component
  141349. */
  141350. get roughness(): NodeMaterialConnectionPoint;
  141351. /**
  141352. * Gets the ior input component
  141353. */
  141354. get ior(): NodeMaterialConnectionPoint;
  141355. /**
  141356. * Gets the texture input component
  141357. */
  141358. get texture(): NodeMaterialConnectionPoint;
  141359. /**
  141360. * Gets the bump texture input component
  141361. */
  141362. get bumpTexture(): NodeMaterialConnectionPoint;
  141363. /**
  141364. * Gets the uv input component
  141365. */
  141366. get uv(): NodeMaterialConnectionPoint;
  141367. /**
  141368. * Gets the tint color input component
  141369. */
  141370. get tintColor(): NodeMaterialConnectionPoint;
  141371. /**
  141372. * Gets the tint "at distance" input component
  141373. */
  141374. get tintAtDistance(): NodeMaterialConnectionPoint;
  141375. /**
  141376. * Gets the tint thickness input component
  141377. */
  141378. get tintThickness(): NodeMaterialConnectionPoint;
  141379. /**
  141380. * Gets the world tangent input component
  141381. */
  141382. get worldTangent(): NodeMaterialConnectionPoint;
  141383. /**
  141384. * Gets the clear coat object output component
  141385. */
  141386. get clearcoat(): NodeMaterialConnectionPoint;
  141387. autoConfigure(material: NodeMaterial): void;
  141388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141390. private _generateTBNSpace;
  141391. /**
  141392. * Gets the main code of the block (fragment side)
  141393. * @param state current state of the node material building
  141394. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141395. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141396. * @param worldPosVarName name of the variable holding the world position
  141397. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141398. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141399. * @param worldNormalVarName name of the variable holding the world normal
  141400. * @returns the shader code
  141401. */
  141402. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141403. protected _buildBlock(state: NodeMaterialBuildState): this;
  141404. }
  141405. }
  141406. declare module BABYLON {
  141407. /**
  141408. * Block used to implement the sub surface module of the PBR material
  141409. */
  141410. export class SubSurfaceBlock extends NodeMaterialBlock {
  141411. /**
  141412. * Create a new SubSurfaceBlock
  141413. * @param name defines the block name
  141414. */
  141415. constructor(name: string);
  141416. /**
  141417. * Stores the intensity of the different subsurface effects in the thickness texture.
  141418. * * the green channel is the translucency intensity.
  141419. * * the blue channel is the scattering intensity.
  141420. * * the alpha channel is the refraction intensity.
  141421. */
  141422. useMaskFromThicknessTexture: boolean;
  141423. /**
  141424. * Initialize the block and prepare the context for build
  141425. * @param state defines the state that will be used for the build
  141426. */
  141427. initialize(state: NodeMaterialBuildState): void;
  141428. /**
  141429. * Gets the current class name
  141430. * @returns the class name
  141431. */
  141432. getClassName(): string;
  141433. /**
  141434. * Gets the min thickness input component
  141435. */
  141436. get minThickness(): NodeMaterialConnectionPoint;
  141437. /**
  141438. * Gets the max thickness input component
  141439. */
  141440. get maxThickness(): NodeMaterialConnectionPoint;
  141441. /**
  141442. * Gets the thickness texture component
  141443. */
  141444. get thicknessTexture(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the tint color input component
  141447. */
  141448. get tintColor(): NodeMaterialConnectionPoint;
  141449. /**
  141450. * Gets the translucency intensity input component
  141451. */
  141452. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141453. /**
  141454. * Gets the translucency diffusion distance input component
  141455. */
  141456. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141457. /**
  141458. * Gets the refraction object parameters
  141459. */
  141460. get refraction(): NodeMaterialConnectionPoint;
  141461. /**
  141462. * Gets the sub surface object output component
  141463. */
  141464. get subsurface(): NodeMaterialConnectionPoint;
  141465. autoConfigure(material: NodeMaterial): void;
  141466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141467. /**
  141468. * Gets the main code of the block (fragment side)
  141469. * @param state current state of the node material building
  141470. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141471. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141472. * @param worldPosVarName name of the variable holding the world position
  141473. * @returns the shader code
  141474. */
  141475. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141476. protected _buildBlock(state: NodeMaterialBuildState): this;
  141477. }
  141478. }
  141479. declare module BABYLON {
  141480. /**
  141481. * Block used to implement the PBR metallic/roughness model
  141482. */
  141483. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141484. /**
  141485. * Gets or sets the light associated with this block
  141486. */
  141487. light: Nullable<Light>;
  141488. private _lightId;
  141489. private _scene;
  141490. private _environmentBRDFTexture;
  141491. private _environmentBrdfSamplerName;
  141492. private _vNormalWName;
  141493. private _invertNormalName;
  141494. /**
  141495. * Create a new ReflectionBlock
  141496. * @param name defines the block name
  141497. */
  141498. constructor(name: string);
  141499. /**
  141500. * Intensity of the direct lights e.g. the four lights available in your scene.
  141501. * This impacts both the direct diffuse and specular highlights.
  141502. */
  141503. directIntensity: number;
  141504. /**
  141505. * Intensity of the environment e.g. how much the environment will light the object
  141506. * either through harmonics for rough material or through the refelction for shiny ones.
  141507. */
  141508. environmentIntensity: number;
  141509. /**
  141510. * This is a special control allowing the reduction of the specular highlights coming from the
  141511. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141512. */
  141513. specularIntensity: number;
  141514. /**
  141515. * Defines the falloff type used in this material.
  141516. * It by default is Physical.
  141517. */
  141518. lightFalloff: number;
  141519. /**
  141520. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141521. */
  141522. useAlphaFromAlbedoTexture: boolean;
  141523. /**
  141524. * Specifies that alpha test should be used
  141525. */
  141526. useAlphaTest: boolean;
  141527. /**
  141528. * Defines the alpha limits in alpha test mode.
  141529. */
  141530. alphaTestCutoff: number;
  141531. /**
  141532. * Specifies that alpha blending should be used
  141533. */
  141534. useAlphaBlending: boolean;
  141535. /**
  141536. * Defines if the alpha value should be determined via the rgb values.
  141537. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141538. */
  141539. opacityRGB: boolean;
  141540. /**
  141541. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141542. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141543. */
  141544. useRadianceOverAlpha: boolean;
  141545. /**
  141546. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141547. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141548. */
  141549. useSpecularOverAlpha: boolean;
  141550. /**
  141551. * Enables specular anti aliasing in the PBR shader.
  141552. * It will both interacts on the Geometry for analytical and IBL lighting.
  141553. * It also prefilter the roughness map based on the bump values.
  141554. */
  141555. enableSpecularAntiAliasing: boolean;
  141556. /**
  141557. * Enables realtime filtering on the texture.
  141558. */
  141559. realTimeFiltering: boolean;
  141560. /**
  141561. * Quality switch for realtime filtering
  141562. */
  141563. realTimeFilteringQuality: number;
  141564. /**
  141565. * Defines if the material uses energy conservation.
  141566. */
  141567. useEnergyConservation: boolean;
  141568. /**
  141569. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  141570. * too much the area relying on ambient texture to define their ambient occlusion.
  141571. */
  141572. useRadianceOcclusion: boolean;
  141573. /**
  141574. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  141575. * makes the reflect vector face the model (under horizon).
  141576. */
  141577. useHorizonOcclusion: boolean;
  141578. /**
  141579. * If set to true, no lighting calculations will be applied.
  141580. */
  141581. unlit: boolean;
  141582. /**
  141583. * Force normal to face away from face.
  141584. */
  141585. forceNormalForward: boolean;
  141586. /**
  141587. * Defines the material debug mode.
  141588. * It helps seeing only some components of the material while troubleshooting.
  141589. */
  141590. debugMode: number;
  141591. /**
  141592. * Specify from where on screen the debug mode should start.
  141593. * The value goes from -1 (full screen) to 1 (not visible)
  141594. * It helps with side by side comparison against the final render
  141595. * This defaults to 0
  141596. */
  141597. debugLimit: number;
  141598. /**
  141599. * As the default viewing range might not be enough (if the ambient is really small for instance)
  141600. * You can use the factor to better multiply the final value.
  141601. */
  141602. debugFactor: number;
  141603. /**
  141604. * Initialize the block and prepare the context for build
  141605. * @param state defines the state that will be used for the build
  141606. */
  141607. initialize(state: NodeMaterialBuildState): void;
  141608. /**
  141609. * Gets the current class name
  141610. * @returns the class name
  141611. */
  141612. getClassName(): string;
  141613. /**
  141614. * Gets the world position input component
  141615. */
  141616. get worldPosition(): NodeMaterialConnectionPoint;
  141617. /**
  141618. * Gets the world normal input component
  141619. */
  141620. get worldNormal(): NodeMaterialConnectionPoint;
  141621. /**
  141622. * Gets the perturbed normal input component
  141623. */
  141624. get perturbedNormal(): NodeMaterialConnectionPoint;
  141625. /**
  141626. * Gets the camera position input component
  141627. */
  141628. get cameraPosition(): NodeMaterialConnectionPoint;
  141629. /**
  141630. * Gets the base color input component
  141631. */
  141632. get baseColor(): NodeMaterialConnectionPoint;
  141633. /**
  141634. * Gets the opacity texture input component
  141635. */
  141636. get opacityTexture(): NodeMaterialConnectionPoint;
  141637. /**
  141638. * Gets the ambient color input component
  141639. */
  141640. get ambientColor(): NodeMaterialConnectionPoint;
  141641. /**
  141642. * Gets the reflectivity object parameters
  141643. */
  141644. get reflectivity(): NodeMaterialConnectionPoint;
  141645. /**
  141646. * Gets the ambient occlusion object parameters
  141647. */
  141648. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141649. /**
  141650. * Gets the reflection object parameters
  141651. */
  141652. get reflection(): NodeMaterialConnectionPoint;
  141653. /**
  141654. * Gets the sheen object parameters
  141655. */
  141656. get sheen(): NodeMaterialConnectionPoint;
  141657. /**
  141658. * Gets the clear coat object parameters
  141659. */
  141660. get clearcoat(): NodeMaterialConnectionPoint;
  141661. /**
  141662. * Gets the sub surface object parameters
  141663. */
  141664. get subsurface(): NodeMaterialConnectionPoint;
  141665. /**
  141666. * Gets the anisotropy object parameters
  141667. */
  141668. get anisotropy(): NodeMaterialConnectionPoint;
  141669. /**
  141670. * Gets the ambient output component
  141671. */
  141672. get ambient(): NodeMaterialConnectionPoint;
  141673. /**
  141674. * Gets the diffuse output component
  141675. */
  141676. get diffuse(): NodeMaterialConnectionPoint;
  141677. /**
  141678. * Gets the specular output component
  141679. */
  141680. get specular(): NodeMaterialConnectionPoint;
  141681. /**
  141682. * Gets the sheen output component
  141683. */
  141684. get sheenDir(): NodeMaterialConnectionPoint;
  141685. /**
  141686. * Gets the clear coat output component
  141687. */
  141688. get clearcoatDir(): NodeMaterialConnectionPoint;
  141689. /**
  141690. * Gets the indirect diffuse output component
  141691. */
  141692. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141693. /**
  141694. * Gets the indirect specular output component
  141695. */
  141696. get specularIndirect(): NodeMaterialConnectionPoint;
  141697. /**
  141698. * Gets the indirect sheen output component
  141699. */
  141700. get sheenIndirect(): NodeMaterialConnectionPoint;
  141701. /**
  141702. * Gets the indirect clear coat output component
  141703. */
  141704. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141705. /**
  141706. * Gets the refraction output component
  141707. */
  141708. get refraction(): NodeMaterialConnectionPoint;
  141709. /**
  141710. * Gets the global lighting output component
  141711. */
  141712. get lighting(): NodeMaterialConnectionPoint;
  141713. /**
  141714. * Gets the shadow output component
  141715. */
  141716. get shadow(): NodeMaterialConnectionPoint;
  141717. /**
  141718. * Gets the alpha output component
  141719. */
  141720. get alpha(): NodeMaterialConnectionPoint;
  141721. autoConfigure(material: NodeMaterial): void;
  141722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141723. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141724. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141725. private _injectVertexCode;
  141726. /**
  141727. * Gets the code corresponding to the albedo/opacity module
  141728. * @returns the shader code
  141729. */
  141730. getAlbedoOpacityCode(): string;
  141731. protected _buildBlock(state: NodeMaterialBuildState): this;
  141732. protected _dumpPropertiesCode(): string;
  141733. serialize(): any;
  141734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141735. }
  141736. }
  141737. declare module BABYLON {
  141738. /**
  141739. * Block used to compute value of one parameter modulo another
  141740. */
  141741. export class ModBlock extends NodeMaterialBlock {
  141742. /**
  141743. * Creates a new ModBlock
  141744. * @param name defines the block name
  141745. */
  141746. constructor(name: string);
  141747. /**
  141748. * Gets the current class name
  141749. * @returns the class name
  141750. */
  141751. getClassName(): string;
  141752. /**
  141753. * Gets the left operand input component
  141754. */
  141755. get left(): NodeMaterialConnectionPoint;
  141756. /**
  141757. * Gets the right operand input component
  141758. */
  141759. get right(): NodeMaterialConnectionPoint;
  141760. /**
  141761. * Gets the output component
  141762. */
  141763. get output(): NodeMaterialConnectionPoint;
  141764. protected _buildBlock(state: NodeMaterialBuildState): this;
  141765. }
  141766. }
  141767. declare module BABYLON {
  141768. /**
  141769. * Helper class to push actions to a pool of workers.
  141770. */
  141771. export class WorkerPool implements IDisposable {
  141772. private _workerInfos;
  141773. private _pendingActions;
  141774. /**
  141775. * Constructor
  141776. * @param workers Array of workers to use for actions
  141777. */
  141778. constructor(workers: Array<Worker>);
  141779. /**
  141780. * Terminates all workers and clears any pending actions.
  141781. */
  141782. dispose(): void;
  141783. /**
  141784. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141785. * pended until a worker has completed its action.
  141786. * @param action The action to perform. Call onComplete when the action is complete.
  141787. */
  141788. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141789. private _execute;
  141790. }
  141791. }
  141792. declare module BABYLON {
  141793. /**
  141794. * Configuration for Draco compression
  141795. */
  141796. export interface IDracoCompressionConfiguration {
  141797. /**
  141798. * Configuration for the decoder.
  141799. */
  141800. decoder: {
  141801. /**
  141802. * The url to the WebAssembly module.
  141803. */
  141804. wasmUrl?: string;
  141805. /**
  141806. * The url to the WebAssembly binary.
  141807. */
  141808. wasmBinaryUrl?: string;
  141809. /**
  141810. * The url to the fallback JavaScript module.
  141811. */
  141812. fallbackUrl?: string;
  141813. };
  141814. }
  141815. /**
  141816. * Draco compression (https://google.github.io/draco/)
  141817. *
  141818. * This class wraps the Draco module.
  141819. *
  141820. * **Encoder**
  141821. *
  141822. * The encoder is not currently implemented.
  141823. *
  141824. * **Decoder**
  141825. *
  141826. * 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.
  141827. *
  141828. * To update the configuration, use the following code:
  141829. * ```javascript
  141830. * DracoCompression.Configuration = {
  141831. * decoder: {
  141832. * wasmUrl: "<url to the WebAssembly library>",
  141833. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141834. * fallbackUrl: "<url to the fallback JavaScript library>",
  141835. * }
  141836. * };
  141837. * ```
  141838. *
  141839. * 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.
  141840. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141841. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141842. *
  141843. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141844. * ```javascript
  141845. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141846. * ```
  141847. *
  141848. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141849. */
  141850. export class DracoCompression implements IDisposable {
  141851. private _workerPoolPromise?;
  141852. private _decoderModulePromise?;
  141853. /**
  141854. * The configuration. Defaults to the following urls:
  141855. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141856. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141857. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141858. */
  141859. static Configuration: IDracoCompressionConfiguration;
  141860. /**
  141861. * Returns true if the decoder configuration is available.
  141862. */
  141863. static get DecoderAvailable(): boolean;
  141864. /**
  141865. * Default number of workers to create when creating the draco compression object.
  141866. */
  141867. static DefaultNumWorkers: number;
  141868. private static GetDefaultNumWorkers;
  141869. private static _Default;
  141870. /**
  141871. * Default instance for the draco compression object.
  141872. */
  141873. static get Default(): DracoCompression;
  141874. /**
  141875. * Constructor
  141876. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141877. */
  141878. constructor(numWorkers?: number);
  141879. /**
  141880. * Stop all async operations and release resources.
  141881. */
  141882. dispose(): void;
  141883. /**
  141884. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141885. * @returns a promise that resolves when ready
  141886. */
  141887. whenReadyAsync(): Promise<void>;
  141888. /**
  141889. * Decode Draco compressed mesh data to vertex data.
  141890. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141891. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141892. * @returns A promise that resolves with the decoded vertex data
  141893. */
  141894. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141895. [kind: string]: number;
  141896. }): Promise<VertexData>;
  141897. }
  141898. }
  141899. declare module BABYLON {
  141900. /**
  141901. * Class for building Constructive Solid Geometry
  141902. */
  141903. export class CSG {
  141904. private polygons;
  141905. /**
  141906. * The world matrix
  141907. */
  141908. matrix: Matrix;
  141909. /**
  141910. * Stores the position
  141911. */
  141912. position: Vector3;
  141913. /**
  141914. * Stores the rotation
  141915. */
  141916. rotation: Vector3;
  141917. /**
  141918. * Stores the rotation quaternion
  141919. */
  141920. rotationQuaternion: Nullable<Quaternion>;
  141921. /**
  141922. * Stores the scaling vector
  141923. */
  141924. scaling: Vector3;
  141925. /**
  141926. * Convert the Mesh to CSG
  141927. * @param mesh The Mesh to convert to CSG
  141928. * @returns A new CSG from the Mesh
  141929. */
  141930. static FromMesh(mesh: Mesh): CSG;
  141931. /**
  141932. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141933. * @param polygons Polygons used to construct a CSG solid
  141934. */
  141935. private static FromPolygons;
  141936. /**
  141937. * Clones, or makes a deep copy, of the CSG
  141938. * @returns A new CSG
  141939. */
  141940. clone(): CSG;
  141941. /**
  141942. * Unions this CSG with another CSG
  141943. * @param csg The CSG to union against this CSG
  141944. * @returns The unioned CSG
  141945. */
  141946. union(csg: CSG): CSG;
  141947. /**
  141948. * Unions this CSG with another CSG in place
  141949. * @param csg The CSG to union against this CSG
  141950. */
  141951. unionInPlace(csg: CSG): void;
  141952. /**
  141953. * Subtracts this CSG with another CSG
  141954. * @param csg The CSG to subtract against this CSG
  141955. * @returns A new CSG
  141956. */
  141957. subtract(csg: CSG): CSG;
  141958. /**
  141959. * Subtracts this CSG with another CSG in place
  141960. * @param csg The CSG to subtact against this CSG
  141961. */
  141962. subtractInPlace(csg: CSG): void;
  141963. /**
  141964. * Intersect this CSG with another CSG
  141965. * @param csg The CSG to intersect against this CSG
  141966. * @returns A new CSG
  141967. */
  141968. intersect(csg: CSG): CSG;
  141969. /**
  141970. * Intersects this CSG with another CSG in place
  141971. * @param csg The CSG to intersect against this CSG
  141972. */
  141973. intersectInPlace(csg: CSG): void;
  141974. /**
  141975. * Return a new CSG solid with solid and empty space switched. This solid is
  141976. * not modified.
  141977. * @returns A new CSG solid with solid and empty space switched
  141978. */
  141979. inverse(): CSG;
  141980. /**
  141981. * Inverses the CSG in place
  141982. */
  141983. inverseInPlace(): void;
  141984. /**
  141985. * This is used to keep meshes transformations so they can be restored
  141986. * when we build back a Babylon Mesh
  141987. * NB : All CSG operations are performed in world coordinates
  141988. * @param csg The CSG to copy the transform attributes from
  141989. * @returns This CSG
  141990. */
  141991. copyTransformAttributes(csg: CSG): CSG;
  141992. /**
  141993. * Build Raw mesh from CSG
  141994. * Coordinates here are in world space
  141995. * @param name The name of the mesh geometry
  141996. * @param scene The Scene
  141997. * @param keepSubMeshes Specifies if the submeshes should be kept
  141998. * @returns A new Mesh
  141999. */
  142000. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142001. /**
  142002. * Build Mesh from CSG taking material and transforms into account
  142003. * @param name The name of the Mesh
  142004. * @param material The material of the Mesh
  142005. * @param scene The Scene
  142006. * @param keepSubMeshes Specifies if submeshes should be kept
  142007. * @returns The new Mesh
  142008. */
  142009. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142010. }
  142011. }
  142012. declare module BABYLON {
  142013. /**
  142014. * Class used to create a trail following a mesh
  142015. */
  142016. export class TrailMesh extends Mesh {
  142017. private _generator;
  142018. private _autoStart;
  142019. private _running;
  142020. private _diameter;
  142021. private _length;
  142022. private _sectionPolygonPointsCount;
  142023. private _sectionVectors;
  142024. private _sectionNormalVectors;
  142025. private _beforeRenderObserver;
  142026. /**
  142027. * @constructor
  142028. * @param name The value used by scene.getMeshByName() to do a lookup.
  142029. * @param generator The mesh or transform node to generate a trail.
  142030. * @param scene The scene to add this mesh to.
  142031. * @param diameter Diameter of trailing mesh. Default is 1.
  142032. * @param length Length of trailing mesh. Default is 60.
  142033. * @param autoStart Automatically start trailing mesh. Default true.
  142034. */
  142035. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142036. /**
  142037. * "TrailMesh"
  142038. * @returns "TrailMesh"
  142039. */
  142040. getClassName(): string;
  142041. private _createMesh;
  142042. /**
  142043. * Start trailing mesh.
  142044. */
  142045. start(): void;
  142046. /**
  142047. * Stop trailing mesh.
  142048. */
  142049. stop(): void;
  142050. /**
  142051. * Update trailing mesh geometry.
  142052. */
  142053. update(): void;
  142054. /**
  142055. * Returns a new TrailMesh object.
  142056. * @param name is a string, the name given to the new mesh
  142057. * @param newGenerator use new generator object for cloned trail mesh
  142058. * @returns a new mesh
  142059. */
  142060. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142061. /**
  142062. * Serializes this trail mesh
  142063. * @param serializationObject object to write serialization to
  142064. */
  142065. serialize(serializationObject: any): void;
  142066. /**
  142067. * Parses a serialized trail mesh
  142068. * @param parsedMesh the serialized mesh
  142069. * @param scene the scene to create the trail mesh in
  142070. * @returns the created trail mesh
  142071. */
  142072. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. /**
  142077. * Class containing static functions to help procedurally build meshes
  142078. */
  142079. export class TiledBoxBuilder {
  142080. /**
  142081. * Creates a box mesh
  142082. * 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)
  142083. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142087. * @param name defines the name of the mesh
  142088. * @param options defines the options used to create the mesh
  142089. * @param scene defines the hosting scene
  142090. * @returns the box mesh
  142091. */
  142092. static CreateTiledBox(name: string, options: {
  142093. pattern?: number;
  142094. width?: number;
  142095. height?: number;
  142096. depth?: number;
  142097. tileSize?: number;
  142098. tileWidth?: number;
  142099. tileHeight?: number;
  142100. alignHorizontal?: number;
  142101. alignVertical?: number;
  142102. faceUV?: Vector4[];
  142103. faceColors?: Color4[];
  142104. sideOrientation?: number;
  142105. updatable?: boolean;
  142106. }, scene?: Nullable<Scene>): Mesh;
  142107. }
  142108. }
  142109. declare module BABYLON {
  142110. /**
  142111. * Class containing static functions to help procedurally build meshes
  142112. */
  142113. export class TorusKnotBuilder {
  142114. /**
  142115. * Creates a torus knot mesh
  142116. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142117. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142118. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142119. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142123. * @param name defines the name of the mesh
  142124. * @param options defines the options used to create the mesh
  142125. * @param scene defines the hosting scene
  142126. * @returns the torus knot mesh
  142127. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142128. */
  142129. static CreateTorusKnot(name: string, options: {
  142130. radius?: number;
  142131. tube?: number;
  142132. radialSegments?: number;
  142133. tubularSegments?: number;
  142134. p?: number;
  142135. q?: number;
  142136. updatable?: boolean;
  142137. sideOrientation?: number;
  142138. frontUVs?: Vector4;
  142139. backUVs?: Vector4;
  142140. }, scene: any): Mesh;
  142141. }
  142142. }
  142143. declare module BABYLON {
  142144. /**
  142145. * Polygon
  142146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142147. */
  142148. export class Polygon {
  142149. /**
  142150. * Creates a rectangle
  142151. * @param xmin bottom X coord
  142152. * @param ymin bottom Y coord
  142153. * @param xmax top X coord
  142154. * @param ymax top Y coord
  142155. * @returns points that make the resulting rectation
  142156. */
  142157. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142158. /**
  142159. * Creates a circle
  142160. * @param radius radius of circle
  142161. * @param cx scale in x
  142162. * @param cy scale in y
  142163. * @param numberOfSides number of sides that make up the circle
  142164. * @returns points that make the resulting circle
  142165. */
  142166. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142167. /**
  142168. * Creates a polygon from input string
  142169. * @param input Input polygon data
  142170. * @returns the parsed points
  142171. */
  142172. static Parse(input: string): Vector2[];
  142173. /**
  142174. * Starts building a polygon from x and y coordinates
  142175. * @param x x coordinate
  142176. * @param y y coordinate
  142177. * @returns the started path2
  142178. */
  142179. static StartingAt(x: number, y: number): Path2;
  142180. }
  142181. /**
  142182. * Builds a polygon
  142183. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142184. */
  142185. export class PolygonMeshBuilder {
  142186. private _points;
  142187. private _outlinepoints;
  142188. private _holes;
  142189. private _name;
  142190. private _scene;
  142191. private _epoints;
  142192. private _eholes;
  142193. private _addToepoint;
  142194. /**
  142195. * Babylon reference to the earcut plugin.
  142196. */
  142197. bjsEarcut: any;
  142198. /**
  142199. * Creates a PolygonMeshBuilder
  142200. * @param name name of the builder
  142201. * @param contours Path of the polygon
  142202. * @param scene scene to add to when creating the mesh
  142203. * @param earcutInjection can be used to inject your own earcut reference
  142204. */
  142205. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142206. /**
  142207. * Adds a whole within the polygon
  142208. * @param hole Array of points defining the hole
  142209. * @returns this
  142210. */
  142211. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142212. /**
  142213. * Creates the polygon
  142214. * @param updatable If the mesh should be updatable
  142215. * @param depth The depth of the mesh created
  142216. * @returns the created mesh
  142217. */
  142218. build(updatable?: boolean, depth?: number): Mesh;
  142219. /**
  142220. * Creates the polygon
  142221. * @param depth The depth of the mesh created
  142222. * @returns the created VertexData
  142223. */
  142224. buildVertexData(depth?: number): VertexData;
  142225. /**
  142226. * Adds a side to the polygon
  142227. * @param positions points that make the polygon
  142228. * @param normals normals of the polygon
  142229. * @param uvs uvs of the polygon
  142230. * @param indices indices of the polygon
  142231. * @param bounds bounds of the polygon
  142232. * @param points points of the polygon
  142233. * @param depth depth of the polygon
  142234. * @param flip flip of the polygon
  142235. */
  142236. private addSide;
  142237. }
  142238. }
  142239. declare module BABYLON {
  142240. /**
  142241. * Class containing static functions to help procedurally build meshes
  142242. */
  142243. export class PolygonBuilder {
  142244. /**
  142245. * Creates a polygon mesh
  142246. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142247. * * 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
  142248. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142251. * * Remember you can only change the shape positions, not their number when updating a polygon
  142252. * @param name defines the name of the mesh
  142253. * @param options defines the options used to create the mesh
  142254. * @param scene defines the hosting scene
  142255. * @param earcutInjection can be used to inject your own earcut reference
  142256. * @returns the polygon mesh
  142257. */
  142258. static CreatePolygon(name: string, options: {
  142259. shape: Vector3[];
  142260. holes?: Vector3[][];
  142261. depth?: number;
  142262. faceUV?: Vector4[];
  142263. faceColors?: Color4[];
  142264. updatable?: boolean;
  142265. sideOrientation?: number;
  142266. frontUVs?: Vector4;
  142267. backUVs?: Vector4;
  142268. wrap?: boolean;
  142269. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142270. /**
  142271. * Creates an extruded polygon mesh, with depth in the Y direction.
  142272. * * 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)
  142273. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142274. * @param name defines the name of the mesh
  142275. * @param options defines the options used to create the mesh
  142276. * @param scene defines the hosting scene
  142277. * @param earcutInjection can be used to inject your own earcut reference
  142278. * @returns the polygon mesh
  142279. */
  142280. static ExtrudePolygon(name: string, options: {
  142281. shape: Vector3[];
  142282. holes?: Vector3[][];
  142283. depth?: number;
  142284. faceUV?: Vector4[];
  142285. faceColors?: Color4[];
  142286. updatable?: boolean;
  142287. sideOrientation?: number;
  142288. frontUVs?: Vector4;
  142289. backUVs?: Vector4;
  142290. wrap?: boolean;
  142291. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142292. }
  142293. }
  142294. declare module BABYLON {
  142295. /**
  142296. * Class containing static functions to help procedurally build meshes
  142297. */
  142298. export class LatheBuilder {
  142299. /**
  142300. * Creates lathe mesh.
  142301. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142302. * * 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
  142303. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142304. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142305. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142306. * * 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
  142307. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142308. * * 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
  142309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142313. * @param name defines the name of the mesh
  142314. * @param options defines the options used to create the mesh
  142315. * @param scene defines the hosting scene
  142316. * @returns the lathe mesh
  142317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142318. */
  142319. static CreateLathe(name: string, options: {
  142320. shape: Vector3[];
  142321. radius?: number;
  142322. tessellation?: number;
  142323. clip?: number;
  142324. arc?: number;
  142325. closed?: boolean;
  142326. updatable?: boolean;
  142327. sideOrientation?: number;
  142328. frontUVs?: Vector4;
  142329. backUVs?: Vector4;
  142330. cap?: number;
  142331. invertUV?: boolean;
  142332. }, scene?: Nullable<Scene>): Mesh;
  142333. }
  142334. }
  142335. declare module BABYLON {
  142336. /**
  142337. * Class containing static functions to help procedurally build meshes
  142338. */
  142339. export class TiledPlaneBuilder {
  142340. /**
  142341. * Creates a tiled plane mesh
  142342. * * The parameter `pattern` will, depending on value, do nothing or
  142343. * * * flip (reflect about central vertical) alternate tiles across and up
  142344. * * * flip every tile on alternate rows
  142345. * * * rotate (180 degs) alternate tiles across and up
  142346. * * * rotate every tile on alternate rows
  142347. * * * flip and rotate alternate tiles across and up
  142348. * * * flip and rotate every tile on alternate rows
  142349. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142350. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142352. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142353. * * 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)
  142354. * * 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)
  142355. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142356. * @param name defines the name of the mesh
  142357. * @param options defines the options used to create the mesh
  142358. * @param scene defines the hosting scene
  142359. * @returns the box mesh
  142360. */
  142361. static CreateTiledPlane(name: string, options: {
  142362. pattern?: number;
  142363. tileSize?: number;
  142364. tileWidth?: number;
  142365. tileHeight?: number;
  142366. size?: number;
  142367. width?: number;
  142368. height?: number;
  142369. alignHorizontal?: number;
  142370. alignVertical?: number;
  142371. sideOrientation?: number;
  142372. frontUVs?: Vector4;
  142373. backUVs?: Vector4;
  142374. updatable?: boolean;
  142375. }, scene?: Nullable<Scene>): Mesh;
  142376. }
  142377. }
  142378. declare module BABYLON {
  142379. /**
  142380. * Class containing static functions to help procedurally build meshes
  142381. */
  142382. export class TubeBuilder {
  142383. /**
  142384. * Creates a tube mesh.
  142385. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142386. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142387. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142388. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142389. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142390. * * 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)
  142391. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142392. * * 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
  142393. * * 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
  142394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142398. * @param name defines the name of the mesh
  142399. * @param options defines the options used to create the mesh
  142400. * @param scene defines the hosting scene
  142401. * @returns the tube mesh
  142402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142403. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142404. */
  142405. static CreateTube(name: string, options: {
  142406. path: Vector3[];
  142407. radius?: number;
  142408. tessellation?: number;
  142409. radiusFunction?: {
  142410. (i: number, distance: number): number;
  142411. };
  142412. cap?: number;
  142413. arc?: number;
  142414. updatable?: boolean;
  142415. sideOrientation?: number;
  142416. frontUVs?: Vector4;
  142417. backUVs?: Vector4;
  142418. instance?: Mesh;
  142419. invertUV?: boolean;
  142420. }, scene?: Nullable<Scene>): Mesh;
  142421. }
  142422. }
  142423. declare module BABYLON {
  142424. /**
  142425. * Class containing static functions to help procedurally build meshes
  142426. */
  142427. export class IcoSphereBuilder {
  142428. /**
  142429. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142430. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142431. * * 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`)
  142432. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142433. * * 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
  142434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142437. * @param name defines the name of the mesh
  142438. * @param options defines the options used to create the mesh
  142439. * @param scene defines the hosting scene
  142440. * @returns the icosahedron mesh
  142441. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142442. */
  142443. static CreateIcoSphere(name: string, options: {
  142444. radius?: number;
  142445. radiusX?: number;
  142446. radiusY?: number;
  142447. radiusZ?: number;
  142448. flat?: boolean;
  142449. subdivisions?: number;
  142450. sideOrientation?: number;
  142451. frontUVs?: Vector4;
  142452. backUVs?: Vector4;
  142453. updatable?: boolean;
  142454. }, scene?: Nullable<Scene>): Mesh;
  142455. }
  142456. }
  142457. declare module BABYLON {
  142458. /**
  142459. * Class containing static functions to help procedurally build meshes
  142460. */
  142461. export class DecalBuilder {
  142462. /**
  142463. * Creates a decal mesh.
  142464. * 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
  142465. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142466. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142467. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142468. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142469. * @param name defines the name of the mesh
  142470. * @param sourceMesh defines the mesh where the decal must be applied
  142471. * @param options defines the options used to create the mesh
  142472. * @param scene defines the hosting scene
  142473. * @returns the decal mesh
  142474. * @see https://doc.babylonjs.com/how_to/decals
  142475. */
  142476. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142477. position?: Vector3;
  142478. normal?: Vector3;
  142479. size?: Vector3;
  142480. angle?: number;
  142481. }): Mesh;
  142482. }
  142483. }
  142484. declare module BABYLON {
  142485. /**
  142486. * Class containing static functions to help procedurally build meshes
  142487. */
  142488. export class MeshBuilder {
  142489. /**
  142490. * Creates a box mesh
  142491. * * The parameter `size` sets the size (float) of each box side (default 1)
  142492. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142493. * * 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)
  142494. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142498. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142499. * @param name defines the name of the mesh
  142500. * @param options defines the options used to create the mesh
  142501. * @param scene defines the hosting scene
  142502. * @returns the box mesh
  142503. */
  142504. static CreateBox(name: string, options: {
  142505. size?: number;
  142506. width?: number;
  142507. height?: number;
  142508. depth?: number;
  142509. faceUV?: Vector4[];
  142510. faceColors?: Color4[];
  142511. sideOrientation?: number;
  142512. frontUVs?: Vector4;
  142513. backUVs?: Vector4;
  142514. wrap?: boolean;
  142515. topBaseAt?: number;
  142516. bottomBaseAt?: number;
  142517. updatable?: boolean;
  142518. }, scene?: Nullable<Scene>): Mesh;
  142519. /**
  142520. * Creates a tiled box mesh
  142521. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142523. * @param name defines the name of the mesh
  142524. * @param options defines the options used to create the mesh
  142525. * @param scene defines the hosting scene
  142526. * @returns the tiled box mesh
  142527. */
  142528. static CreateTiledBox(name: string, options: {
  142529. pattern?: number;
  142530. size?: number;
  142531. width?: number;
  142532. height?: number;
  142533. depth: number;
  142534. tileSize?: number;
  142535. tileWidth?: number;
  142536. tileHeight?: number;
  142537. faceUV?: Vector4[];
  142538. faceColors?: Color4[];
  142539. alignHorizontal?: number;
  142540. alignVertical?: number;
  142541. sideOrientation?: number;
  142542. updatable?: boolean;
  142543. }, scene?: Nullable<Scene>): Mesh;
  142544. /**
  142545. * Creates a sphere mesh
  142546. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142547. * * 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`)
  142548. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142549. * * 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
  142550. * * 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)
  142551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142554. * @param name defines the name of the mesh
  142555. * @param options defines the options used to create the mesh
  142556. * @param scene defines the hosting scene
  142557. * @returns the sphere mesh
  142558. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  142559. */
  142560. static CreateSphere(name: string, options: {
  142561. segments?: number;
  142562. diameter?: number;
  142563. diameterX?: number;
  142564. diameterY?: number;
  142565. diameterZ?: number;
  142566. arc?: number;
  142567. slice?: number;
  142568. sideOrientation?: number;
  142569. frontUVs?: Vector4;
  142570. backUVs?: Vector4;
  142571. updatable?: boolean;
  142572. }, scene?: Nullable<Scene>): Mesh;
  142573. /**
  142574. * Creates a plane polygonal mesh. By default, this is a disc
  142575. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  142576. * * 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
  142577. * * 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
  142578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142581. * @param name defines the name of the mesh
  142582. * @param options defines the options used to create the mesh
  142583. * @param scene defines the hosting scene
  142584. * @returns the plane polygonal mesh
  142585. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  142586. */
  142587. static CreateDisc(name: string, options: {
  142588. radius?: number;
  142589. tessellation?: number;
  142590. arc?: number;
  142591. updatable?: boolean;
  142592. sideOrientation?: number;
  142593. frontUVs?: Vector4;
  142594. backUVs?: Vector4;
  142595. }, scene?: Nullable<Scene>): Mesh;
  142596. /**
  142597. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142598. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142599. * * 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`)
  142600. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142601. * * 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
  142602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142605. * @param name defines the name of the mesh
  142606. * @param options defines the options used to create the mesh
  142607. * @param scene defines the hosting scene
  142608. * @returns the icosahedron mesh
  142609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142610. */
  142611. static CreateIcoSphere(name: string, options: {
  142612. radius?: number;
  142613. radiusX?: number;
  142614. radiusY?: number;
  142615. radiusZ?: number;
  142616. flat?: boolean;
  142617. subdivisions?: number;
  142618. sideOrientation?: number;
  142619. frontUVs?: Vector4;
  142620. backUVs?: Vector4;
  142621. updatable?: boolean;
  142622. }, scene?: Nullable<Scene>): Mesh;
  142623. /**
  142624. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142625. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142626. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142627. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142628. * * 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
  142629. * * 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
  142630. * * 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
  142631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142634. * * 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
  142635. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142636. * * 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
  142637. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142639. * @param name defines the name of the mesh
  142640. * @param options defines the options used to create the mesh
  142641. * @param scene defines the hosting scene
  142642. * @returns the ribbon mesh
  142643. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142644. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142645. */
  142646. static CreateRibbon(name: string, options: {
  142647. pathArray: Vector3[][];
  142648. closeArray?: boolean;
  142649. closePath?: boolean;
  142650. offset?: number;
  142651. updatable?: boolean;
  142652. sideOrientation?: number;
  142653. frontUVs?: Vector4;
  142654. backUVs?: Vector4;
  142655. instance?: Mesh;
  142656. invertUV?: boolean;
  142657. uvs?: Vector2[];
  142658. colors?: Color4[];
  142659. }, scene?: Nullable<Scene>): Mesh;
  142660. /**
  142661. * Creates a cylinder or a cone mesh
  142662. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142663. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142664. * * 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.
  142665. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142666. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142667. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142668. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142669. * * 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).
  142670. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142671. * * 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).
  142672. * * 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
  142673. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142674. * * 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
  142675. * * 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.
  142676. * * If `enclose` is false, a ring surface is one element.
  142677. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142678. * * 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
  142679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142682. * @param name defines the name of the mesh
  142683. * @param options defines the options used to create the mesh
  142684. * @param scene defines the hosting scene
  142685. * @returns the cylinder mesh
  142686. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142687. */
  142688. static CreateCylinder(name: string, options: {
  142689. height?: number;
  142690. diameterTop?: number;
  142691. diameterBottom?: number;
  142692. diameter?: number;
  142693. tessellation?: number;
  142694. subdivisions?: number;
  142695. arc?: number;
  142696. faceColors?: Color4[];
  142697. faceUV?: Vector4[];
  142698. updatable?: boolean;
  142699. hasRings?: boolean;
  142700. enclose?: boolean;
  142701. cap?: number;
  142702. sideOrientation?: number;
  142703. frontUVs?: Vector4;
  142704. backUVs?: Vector4;
  142705. }, scene?: Nullable<Scene>): Mesh;
  142706. /**
  142707. * Creates a torus mesh
  142708. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142709. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142710. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142714. * @param name defines the name of the mesh
  142715. * @param options defines the options used to create the mesh
  142716. * @param scene defines the hosting scene
  142717. * @returns the torus mesh
  142718. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142719. */
  142720. static CreateTorus(name: string, options: {
  142721. diameter?: number;
  142722. thickness?: number;
  142723. tessellation?: number;
  142724. updatable?: boolean;
  142725. sideOrientation?: number;
  142726. frontUVs?: Vector4;
  142727. backUVs?: Vector4;
  142728. }, scene?: Nullable<Scene>): Mesh;
  142729. /**
  142730. * Creates a torus knot mesh
  142731. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142732. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142733. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142734. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142738. * @param name defines the name of the mesh
  142739. * @param options defines the options used to create the mesh
  142740. * @param scene defines the hosting scene
  142741. * @returns the torus knot mesh
  142742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142743. */
  142744. static CreateTorusKnot(name: string, options: {
  142745. radius?: number;
  142746. tube?: number;
  142747. radialSegments?: number;
  142748. tubularSegments?: number;
  142749. p?: number;
  142750. q?: number;
  142751. updatable?: boolean;
  142752. sideOrientation?: number;
  142753. frontUVs?: Vector4;
  142754. backUVs?: Vector4;
  142755. }, scene?: Nullable<Scene>): Mesh;
  142756. /**
  142757. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142758. * * 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
  142759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142760. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142761. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142762. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142764. * * 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
  142765. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142768. * @param name defines the name of the new line system
  142769. * @param options defines the options used to create the line system
  142770. * @param scene defines the hosting scene
  142771. * @returns a new line system mesh
  142772. */
  142773. static CreateLineSystem(name: string, options: {
  142774. lines: Vector3[][];
  142775. updatable?: boolean;
  142776. instance?: Nullable<LinesMesh>;
  142777. colors?: Nullable<Color4[][]>;
  142778. useVertexAlpha?: boolean;
  142779. }, scene: Nullable<Scene>): LinesMesh;
  142780. /**
  142781. * Creates a line mesh
  142782. * 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
  142783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142784. * * The parameter `points` is an array successive Vector3
  142785. * * 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
  142786. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142788. * * When updating an instance, remember that only point positions can change, not the number of points
  142789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142791. * @param name defines the name of the new line system
  142792. * @param options defines the options used to create the line system
  142793. * @param scene defines the hosting scene
  142794. * @returns a new line mesh
  142795. */
  142796. static CreateLines(name: string, options: {
  142797. points: Vector3[];
  142798. updatable?: boolean;
  142799. instance?: Nullable<LinesMesh>;
  142800. colors?: Color4[];
  142801. useVertexAlpha?: boolean;
  142802. }, scene?: Nullable<Scene>): LinesMesh;
  142803. /**
  142804. * Creates a dashed line mesh
  142805. * * 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
  142806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142807. * * The parameter `points` is an array successive Vector3
  142808. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142809. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142810. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142811. * * 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
  142812. * * When updating an instance, remember that only point positions can change, not the number of points
  142813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142814. * @param name defines the name of the mesh
  142815. * @param options defines the options used to create the mesh
  142816. * @param scene defines the hosting scene
  142817. * @returns the dashed line mesh
  142818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142819. */
  142820. static CreateDashedLines(name: string, options: {
  142821. points: Vector3[];
  142822. dashSize?: number;
  142823. gapSize?: number;
  142824. dashNb?: number;
  142825. updatable?: boolean;
  142826. instance?: LinesMesh;
  142827. }, scene?: Nullable<Scene>): LinesMesh;
  142828. /**
  142829. * 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.
  142830. * * 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.
  142831. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142832. * * 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.
  142833. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142834. * * 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
  142835. * * 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
  142836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142841. * @param name defines the name of the mesh
  142842. * @param options defines the options used to create the mesh
  142843. * @param scene defines the hosting scene
  142844. * @returns the extruded shape mesh
  142845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142847. */
  142848. static ExtrudeShape(name: string, options: {
  142849. shape: Vector3[];
  142850. path: Vector3[];
  142851. scale?: number;
  142852. rotation?: number;
  142853. cap?: number;
  142854. updatable?: boolean;
  142855. sideOrientation?: number;
  142856. frontUVs?: Vector4;
  142857. backUVs?: Vector4;
  142858. instance?: Mesh;
  142859. invertUV?: boolean;
  142860. }, scene?: Nullable<Scene>): Mesh;
  142861. /**
  142862. * Creates an custom extruded shape mesh.
  142863. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142864. * * 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.
  142865. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142866. * * 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
  142867. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142868. * * 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
  142869. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142870. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142871. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142872. * * 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
  142873. * * 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
  142874. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142879. * @param name defines the name of the mesh
  142880. * @param options defines the options used to create the mesh
  142881. * @param scene defines the hosting scene
  142882. * @returns the custom extruded shape mesh
  142883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142886. */
  142887. static ExtrudeShapeCustom(name: string, options: {
  142888. shape: Vector3[];
  142889. path: Vector3[];
  142890. scaleFunction?: any;
  142891. rotationFunction?: any;
  142892. ribbonCloseArray?: boolean;
  142893. ribbonClosePath?: boolean;
  142894. cap?: number;
  142895. updatable?: boolean;
  142896. sideOrientation?: number;
  142897. frontUVs?: Vector4;
  142898. backUVs?: Vector4;
  142899. instance?: Mesh;
  142900. invertUV?: boolean;
  142901. }, scene?: Nullable<Scene>): Mesh;
  142902. /**
  142903. * Creates lathe mesh.
  142904. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142905. * * 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
  142906. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142907. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142908. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142909. * * 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
  142910. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142911. * * 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
  142912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142914. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142916. * @param name defines the name of the mesh
  142917. * @param options defines the options used to create the mesh
  142918. * @param scene defines the hosting scene
  142919. * @returns the lathe mesh
  142920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142921. */
  142922. static CreateLathe(name: string, options: {
  142923. shape: Vector3[];
  142924. radius?: number;
  142925. tessellation?: number;
  142926. clip?: number;
  142927. arc?: number;
  142928. closed?: boolean;
  142929. updatable?: boolean;
  142930. sideOrientation?: number;
  142931. frontUVs?: Vector4;
  142932. backUVs?: Vector4;
  142933. cap?: number;
  142934. invertUV?: boolean;
  142935. }, scene?: Nullable<Scene>): Mesh;
  142936. /**
  142937. * Creates a tiled plane mesh
  142938. * * You can set a limited pattern arrangement with the tiles
  142939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142942. * @param name defines the name of the mesh
  142943. * @param options defines the options used to create the mesh
  142944. * @param scene defines the hosting scene
  142945. * @returns the plane mesh
  142946. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142947. */
  142948. static CreateTiledPlane(name: string, options: {
  142949. pattern?: number;
  142950. tileSize?: number;
  142951. tileWidth?: number;
  142952. tileHeight?: number;
  142953. size?: number;
  142954. width?: number;
  142955. height?: number;
  142956. alignHorizontal?: number;
  142957. alignVertical?: number;
  142958. sideOrientation?: number;
  142959. frontUVs?: Vector4;
  142960. backUVs?: Vector4;
  142961. updatable?: boolean;
  142962. }, scene?: Nullable<Scene>): Mesh;
  142963. /**
  142964. * Creates a plane mesh
  142965. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142966. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142967. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142971. * @param name defines the name of the mesh
  142972. * @param options defines the options used to create the mesh
  142973. * @param scene defines the hosting scene
  142974. * @returns the plane mesh
  142975. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142976. */
  142977. static CreatePlane(name: string, options: {
  142978. size?: number;
  142979. width?: number;
  142980. height?: number;
  142981. sideOrientation?: number;
  142982. frontUVs?: Vector4;
  142983. backUVs?: Vector4;
  142984. updatable?: boolean;
  142985. sourcePlane?: Plane;
  142986. }, scene?: Nullable<Scene>): Mesh;
  142987. /**
  142988. * Creates a ground mesh
  142989. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142990. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142992. * @param name defines the name of the mesh
  142993. * @param options defines the options used to create the mesh
  142994. * @param scene defines the hosting scene
  142995. * @returns the ground mesh
  142996. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142997. */
  142998. static CreateGround(name: string, options: {
  142999. width?: number;
  143000. height?: number;
  143001. subdivisions?: number;
  143002. subdivisionsX?: number;
  143003. subdivisionsY?: number;
  143004. updatable?: boolean;
  143005. }, scene?: Nullable<Scene>): Mesh;
  143006. /**
  143007. * Creates a tiled ground mesh
  143008. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143009. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143010. * * 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
  143011. * * 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
  143012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143013. * @param name defines the name of the mesh
  143014. * @param options defines the options used to create the mesh
  143015. * @param scene defines the hosting scene
  143016. * @returns the tiled ground mesh
  143017. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143018. */
  143019. static CreateTiledGround(name: string, options: {
  143020. xmin: number;
  143021. zmin: number;
  143022. xmax: number;
  143023. zmax: number;
  143024. subdivisions?: {
  143025. w: number;
  143026. h: number;
  143027. };
  143028. precision?: {
  143029. w: number;
  143030. h: number;
  143031. };
  143032. updatable?: boolean;
  143033. }, scene?: Nullable<Scene>): Mesh;
  143034. /**
  143035. * Creates a ground mesh from a height map
  143036. * * The parameter `url` sets the URL of the height map image resource.
  143037. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143038. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143039. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143040. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143041. * * 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.
  143042. * * 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).
  143043. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143045. * @param name defines the name of the mesh
  143046. * @param url defines the url to the height map
  143047. * @param options defines the options used to create the mesh
  143048. * @param scene defines the hosting scene
  143049. * @returns the ground mesh
  143050. * @see https://doc.babylonjs.com/babylon101/height_map
  143051. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143052. */
  143053. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143054. width?: number;
  143055. height?: number;
  143056. subdivisions?: number;
  143057. minHeight?: number;
  143058. maxHeight?: number;
  143059. colorFilter?: Color3;
  143060. alphaFilter?: number;
  143061. updatable?: boolean;
  143062. onReady?: (mesh: GroundMesh) => void;
  143063. }, scene?: Nullable<Scene>): GroundMesh;
  143064. /**
  143065. * Creates a polygon mesh
  143066. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143067. * * 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
  143068. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143071. * * Remember you can only change the shape positions, not their number when updating a polygon
  143072. * @param name defines the name of the mesh
  143073. * @param options defines the options used to create the mesh
  143074. * @param scene defines the hosting scene
  143075. * @param earcutInjection can be used to inject your own earcut reference
  143076. * @returns the polygon mesh
  143077. */
  143078. static CreatePolygon(name: string, options: {
  143079. shape: Vector3[];
  143080. holes?: Vector3[][];
  143081. depth?: number;
  143082. faceUV?: Vector4[];
  143083. faceColors?: Color4[];
  143084. updatable?: boolean;
  143085. sideOrientation?: number;
  143086. frontUVs?: Vector4;
  143087. backUVs?: Vector4;
  143088. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143089. /**
  143090. * Creates an extruded polygon mesh, with depth in the Y direction.
  143091. * * 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)
  143092. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143093. * @param name defines the name of the mesh
  143094. * @param options defines the options used to create the mesh
  143095. * @param scene defines the hosting scene
  143096. * @param earcutInjection can be used to inject your own earcut reference
  143097. * @returns the polygon mesh
  143098. */
  143099. static ExtrudePolygon(name: string, options: {
  143100. shape: Vector3[];
  143101. holes?: Vector3[][];
  143102. depth?: number;
  143103. faceUV?: Vector4[];
  143104. faceColors?: Color4[];
  143105. updatable?: boolean;
  143106. sideOrientation?: number;
  143107. frontUVs?: Vector4;
  143108. backUVs?: Vector4;
  143109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143110. /**
  143111. * Creates a tube mesh.
  143112. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143113. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143114. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143115. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143116. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143117. * * 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)
  143118. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143119. * * 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
  143120. * * 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
  143121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143123. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143125. * @param name defines the name of the mesh
  143126. * @param options defines the options used to create the mesh
  143127. * @param scene defines the hosting scene
  143128. * @returns the tube mesh
  143129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143130. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143131. */
  143132. static CreateTube(name: string, options: {
  143133. path: Vector3[];
  143134. radius?: number;
  143135. tessellation?: number;
  143136. radiusFunction?: {
  143137. (i: number, distance: number): number;
  143138. };
  143139. cap?: number;
  143140. arc?: number;
  143141. updatable?: boolean;
  143142. sideOrientation?: number;
  143143. frontUVs?: Vector4;
  143144. backUVs?: Vector4;
  143145. instance?: Mesh;
  143146. invertUV?: boolean;
  143147. }, scene?: Nullable<Scene>): Mesh;
  143148. /**
  143149. * Creates a polyhedron mesh
  143150. * * 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
  143151. * * The parameter `size` (positive float, default 1) sets the polygon size
  143152. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143153. * * 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`
  143154. * * 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
  143155. * * 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)`)
  143156. * * 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
  143157. * * 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
  143158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143161. * @param name defines the name of the mesh
  143162. * @param options defines the options used to create the mesh
  143163. * @param scene defines the hosting scene
  143164. * @returns the polyhedron mesh
  143165. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143166. */
  143167. static CreatePolyhedron(name: string, options: {
  143168. type?: number;
  143169. size?: number;
  143170. sizeX?: number;
  143171. sizeY?: number;
  143172. sizeZ?: number;
  143173. custom?: any;
  143174. faceUV?: Vector4[];
  143175. faceColors?: Color4[];
  143176. flat?: boolean;
  143177. updatable?: boolean;
  143178. sideOrientation?: number;
  143179. frontUVs?: Vector4;
  143180. backUVs?: Vector4;
  143181. }, scene?: Nullable<Scene>): Mesh;
  143182. /**
  143183. * Creates a decal mesh.
  143184. * 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
  143185. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143186. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143187. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143188. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143189. * @param name defines the name of the mesh
  143190. * @param sourceMesh defines the mesh where the decal must be applied
  143191. * @param options defines the options used to create the mesh
  143192. * @param scene defines the hosting scene
  143193. * @returns the decal mesh
  143194. * @see https://doc.babylonjs.com/how_to/decals
  143195. */
  143196. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143197. position?: Vector3;
  143198. normal?: Vector3;
  143199. size?: Vector3;
  143200. angle?: number;
  143201. }): Mesh;
  143202. }
  143203. }
  143204. declare module BABYLON {
  143205. /**
  143206. * A simplifier interface for future simplification implementations
  143207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143208. */
  143209. export interface ISimplifier {
  143210. /**
  143211. * Simplification of a given mesh according to the given settings.
  143212. * Since this requires computation, it is assumed that the function runs async.
  143213. * @param settings The settings of the simplification, including quality and distance
  143214. * @param successCallback A callback that will be called after the mesh was simplified.
  143215. * @param errorCallback in case of an error, this callback will be called. optional.
  143216. */
  143217. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143218. }
  143219. /**
  143220. * Expected simplification settings.
  143221. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143222. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143223. */
  143224. export interface ISimplificationSettings {
  143225. /**
  143226. * Gets or sets the expected quality
  143227. */
  143228. quality: number;
  143229. /**
  143230. * Gets or sets the distance when this optimized version should be used
  143231. */
  143232. distance: number;
  143233. /**
  143234. * Gets an already optimized mesh
  143235. */
  143236. optimizeMesh?: boolean;
  143237. }
  143238. /**
  143239. * Class used to specify simplification options
  143240. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143241. */
  143242. export class SimplificationSettings implements ISimplificationSettings {
  143243. /** expected quality */
  143244. quality: number;
  143245. /** distance when this optimized version should be used */
  143246. distance: number;
  143247. /** already optimized mesh */
  143248. optimizeMesh?: boolean | undefined;
  143249. /**
  143250. * Creates a SimplificationSettings
  143251. * @param quality expected quality
  143252. * @param distance distance when this optimized version should be used
  143253. * @param optimizeMesh already optimized mesh
  143254. */
  143255. constructor(
  143256. /** expected quality */
  143257. quality: number,
  143258. /** distance when this optimized version should be used */
  143259. distance: number,
  143260. /** already optimized mesh */
  143261. optimizeMesh?: boolean | undefined);
  143262. }
  143263. /**
  143264. * Interface used to define a simplification task
  143265. */
  143266. export interface ISimplificationTask {
  143267. /**
  143268. * Array of settings
  143269. */
  143270. settings: Array<ISimplificationSettings>;
  143271. /**
  143272. * Simplification type
  143273. */
  143274. simplificationType: SimplificationType;
  143275. /**
  143276. * Mesh to simplify
  143277. */
  143278. mesh: Mesh;
  143279. /**
  143280. * Callback called on success
  143281. */
  143282. successCallback?: () => void;
  143283. /**
  143284. * Defines if parallel processing can be used
  143285. */
  143286. parallelProcessing: boolean;
  143287. }
  143288. /**
  143289. * Queue used to order the simplification tasks
  143290. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143291. */
  143292. export class SimplificationQueue {
  143293. private _simplificationArray;
  143294. /**
  143295. * Gets a boolean indicating that the process is still running
  143296. */
  143297. running: boolean;
  143298. /**
  143299. * Creates a new queue
  143300. */
  143301. constructor();
  143302. /**
  143303. * Adds a new simplification task
  143304. * @param task defines a task to add
  143305. */
  143306. addTask(task: ISimplificationTask): void;
  143307. /**
  143308. * Execute next task
  143309. */
  143310. executeNext(): void;
  143311. /**
  143312. * Execute a simplification task
  143313. * @param task defines the task to run
  143314. */
  143315. runSimplification(task: ISimplificationTask): void;
  143316. private getSimplifier;
  143317. }
  143318. /**
  143319. * The implemented types of simplification
  143320. * At the moment only Quadratic Error Decimation is implemented
  143321. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143322. */
  143323. export enum SimplificationType {
  143324. /** Quadratic error decimation */
  143325. QUADRATIC = 0
  143326. }
  143327. /**
  143328. * An implementation of the Quadratic Error simplification algorithm.
  143329. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143330. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143331. * @author RaananW
  143332. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143333. */
  143334. export class QuadraticErrorSimplification implements ISimplifier {
  143335. private _mesh;
  143336. private triangles;
  143337. private vertices;
  143338. private references;
  143339. private _reconstructedMesh;
  143340. /** Gets or sets the number pf sync interations */
  143341. syncIterations: number;
  143342. /** Gets or sets the aggressiveness of the simplifier */
  143343. aggressiveness: number;
  143344. /** Gets or sets the number of allowed iterations for decimation */
  143345. decimationIterations: number;
  143346. /** Gets or sets the espilon to use for bounding box computation */
  143347. boundingBoxEpsilon: number;
  143348. /**
  143349. * Creates a new QuadraticErrorSimplification
  143350. * @param _mesh defines the target mesh
  143351. */
  143352. constructor(_mesh: Mesh);
  143353. /**
  143354. * Simplification of a given mesh according to the given settings.
  143355. * Since this requires computation, it is assumed that the function runs async.
  143356. * @param settings The settings of the simplification, including quality and distance
  143357. * @param successCallback A callback that will be called after the mesh was simplified.
  143358. */
  143359. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143360. private runDecimation;
  143361. private initWithMesh;
  143362. private init;
  143363. private reconstructMesh;
  143364. private initDecimatedMesh;
  143365. private isFlipped;
  143366. private updateTriangles;
  143367. private identifyBorder;
  143368. private updateMesh;
  143369. private vertexError;
  143370. private calculateError;
  143371. }
  143372. }
  143373. declare module BABYLON {
  143374. interface Scene {
  143375. /** @hidden (Backing field) */
  143376. _simplificationQueue: SimplificationQueue;
  143377. /**
  143378. * Gets or sets the simplification queue attached to the scene
  143379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143380. */
  143381. simplificationQueue: SimplificationQueue;
  143382. }
  143383. interface Mesh {
  143384. /**
  143385. * Simplify the mesh according to the given array of settings.
  143386. * Function will return immediately and will simplify async
  143387. * @param settings a collection of simplification settings
  143388. * @param parallelProcessing should all levels calculate parallel or one after the other
  143389. * @param simplificationType the type of simplification to run
  143390. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143391. * @returns the current mesh
  143392. */
  143393. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143394. }
  143395. /**
  143396. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143397. * created in a scene
  143398. */
  143399. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143400. /**
  143401. * The component name helpfull to identify the component in the list of scene components.
  143402. */
  143403. readonly name: string;
  143404. /**
  143405. * The scene the component belongs to.
  143406. */
  143407. scene: Scene;
  143408. /**
  143409. * Creates a new instance of the component for the given scene
  143410. * @param scene Defines the scene to register the component in
  143411. */
  143412. constructor(scene: Scene);
  143413. /**
  143414. * Registers the component in a given scene
  143415. */
  143416. register(): void;
  143417. /**
  143418. * Rebuilds the elements related to this component in case of
  143419. * context lost for instance.
  143420. */
  143421. rebuild(): void;
  143422. /**
  143423. * Disposes the component and the associated ressources
  143424. */
  143425. dispose(): void;
  143426. private _beforeCameraUpdate;
  143427. }
  143428. }
  143429. declare module BABYLON {
  143430. interface Mesh {
  143431. /**
  143432. * Creates a new thin instance
  143433. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143434. * @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
  143435. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143436. */
  143437. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143438. /**
  143439. * Adds the transformation (matrix) of the current mesh as a thin instance
  143440. * @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
  143441. * @returns the thin instance index number
  143442. */
  143443. thinInstanceAddSelf(refresh: boolean): number;
  143444. /**
  143445. * Registers a custom attribute to be used with thin instances
  143446. * @param kind name of the attribute
  143447. * @param stride size in floats of the attribute
  143448. */
  143449. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143450. /**
  143451. * Sets the matrix of a thin instance
  143452. * @param index index of the thin instance
  143453. * @param matrix matrix to set
  143454. * @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
  143455. */
  143456. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143457. /**
  143458. * Sets the value of a custom attribute for a thin instance
  143459. * @param kind name of the attribute
  143460. * @param index index of the thin instance
  143461. * @param value value to set
  143462. * @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
  143463. */
  143464. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143465. /**
  143466. * 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.
  143467. */
  143468. thinInstanceCount: number;
  143469. /**
  143470. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143471. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143472. * @param buffer buffer to set
  143473. * @param stride size in floats of each value of the buffer
  143474. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143475. */
  143476. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143477. /**
  143478. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143479. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143480. */
  143481. thinInstanceBufferUpdated(kind: string): void;
  143482. /**
  143483. * Refreshes the bounding info, taking into account all the thin instances defined
  143484. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143485. */
  143486. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143487. /** @hidden */
  143488. _thinInstanceInitializeUserStorage(): void;
  143489. /** @hidden */
  143490. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143491. /** @hidden */
  143492. _userThinInstanceBuffersStorage: {
  143493. data: {
  143494. [key: string]: Float32Array;
  143495. };
  143496. sizes: {
  143497. [key: string]: number;
  143498. };
  143499. vertexBuffers: {
  143500. [key: string]: Nullable<VertexBuffer>;
  143501. };
  143502. strides: {
  143503. [key: string]: number;
  143504. };
  143505. };
  143506. }
  143507. }
  143508. declare module BABYLON {
  143509. /**
  143510. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143511. */
  143512. export interface INavigationEnginePlugin {
  143513. /**
  143514. * plugin name
  143515. */
  143516. name: string;
  143517. /**
  143518. * Creates a navigation mesh
  143519. * @param meshes array of all the geometry used to compute the navigatio mesh
  143520. * @param parameters bunch of parameters used to filter geometry
  143521. */
  143522. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143523. /**
  143524. * Create a navigation mesh debug mesh
  143525. * @param scene is where the mesh will be added
  143526. * @returns debug display mesh
  143527. */
  143528. createDebugNavMesh(scene: Scene): Mesh;
  143529. /**
  143530. * Get a navigation mesh constrained position, closest to the parameter position
  143531. * @param position world position
  143532. * @returns the closest point to position constrained by the navigation mesh
  143533. */
  143534. getClosestPoint(position: Vector3): Vector3;
  143535. /**
  143536. * Get a navigation mesh constrained position, closest to the parameter position
  143537. * @param position world position
  143538. * @param result output the closest point to position constrained by the navigation mesh
  143539. */
  143540. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143541. /**
  143542. * Get a navigation mesh constrained position, within a particular radius
  143543. * @param position world position
  143544. * @param maxRadius the maximum distance to the constrained world position
  143545. * @returns the closest point to position constrained by the navigation mesh
  143546. */
  143547. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143548. /**
  143549. * Get a navigation mesh constrained position, within a particular radius
  143550. * @param position world position
  143551. * @param maxRadius the maximum distance to the constrained world position
  143552. * @param result output the closest point to position constrained by the navigation mesh
  143553. */
  143554. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143555. /**
  143556. * Compute the final position from a segment made of destination-position
  143557. * @param position world position
  143558. * @param destination world position
  143559. * @returns the resulting point along the navmesh
  143560. */
  143561. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143562. /**
  143563. * Compute the final position from a segment made of destination-position
  143564. * @param position world position
  143565. * @param destination world position
  143566. * @param result output the resulting point along the navmesh
  143567. */
  143568. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143569. /**
  143570. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143571. * @param start world position
  143572. * @param end world position
  143573. * @returns array containing world position composing the path
  143574. */
  143575. computePath(start: Vector3, end: Vector3): Vector3[];
  143576. /**
  143577. * If this plugin is supported
  143578. * @returns true if plugin is supported
  143579. */
  143580. isSupported(): boolean;
  143581. /**
  143582. * Create a new Crowd so you can add agents
  143583. * @param maxAgents the maximum agent count in the crowd
  143584. * @param maxAgentRadius the maximum radius an agent can have
  143585. * @param scene to attach the crowd to
  143586. * @returns the crowd you can add agents to
  143587. */
  143588. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143589. /**
  143590. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143591. * The queries will try to find a solution within those bounds
  143592. * default is (1,1,1)
  143593. * @param extent x,y,z value that define the extent around the queries point of reference
  143594. */
  143595. setDefaultQueryExtent(extent: Vector3): void;
  143596. /**
  143597. * Get the Bounding box extent specified by setDefaultQueryExtent
  143598. * @returns the box extent values
  143599. */
  143600. getDefaultQueryExtent(): Vector3;
  143601. /**
  143602. * build the navmesh from a previously saved state using getNavmeshData
  143603. * @param data the Uint8Array returned by getNavmeshData
  143604. */
  143605. buildFromNavmeshData(data: Uint8Array): void;
  143606. /**
  143607. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143608. * @returns data the Uint8Array that can be saved and reused
  143609. */
  143610. getNavmeshData(): Uint8Array;
  143611. /**
  143612. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143613. * @param result output the box extent values
  143614. */
  143615. getDefaultQueryExtentToRef(result: Vector3): void;
  143616. /**
  143617. * Release all resources
  143618. */
  143619. dispose(): void;
  143620. }
  143621. /**
  143622. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143623. */
  143624. export interface ICrowd {
  143625. /**
  143626. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143627. * You can attach anything to that node. The node position is updated in the scene update tick.
  143628. * @param pos world position that will be constrained by the navigation mesh
  143629. * @param parameters agent parameters
  143630. * @param transform hooked to the agent that will be update by the scene
  143631. * @returns agent index
  143632. */
  143633. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143634. /**
  143635. * Returns the agent position in world space
  143636. * @param index agent index returned by addAgent
  143637. * @returns world space position
  143638. */
  143639. getAgentPosition(index: number): Vector3;
  143640. /**
  143641. * Gets the agent position result in world space
  143642. * @param index agent index returned by addAgent
  143643. * @param result output world space position
  143644. */
  143645. getAgentPositionToRef(index: number, result: Vector3): void;
  143646. /**
  143647. * Gets the agent velocity in world space
  143648. * @param index agent index returned by addAgent
  143649. * @returns world space velocity
  143650. */
  143651. getAgentVelocity(index: number): Vector3;
  143652. /**
  143653. * Gets the agent velocity result in world space
  143654. * @param index agent index returned by addAgent
  143655. * @param result output world space velocity
  143656. */
  143657. getAgentVelocityToRef(index: number, result: Vector3): void;
  143658. /**
  143659. * remove a particular agent previously created
  143660. * @param index agent index returned by addAgent
  143661. */
  143662. removeAgent(index: number): void;
  143663. /**
  143664. * get the list of all agents attached to this crowd
  143665. * @returns list of agent indices
  143666. */
  143667. getAgents(): number[];
  143668. /**
  143669. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143670. * @param deltaTime in seconds
  143671. */
  143672. update(deltaTime: number): void;
  143673. /**
  143674. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143675. * @param index agent index returned by addAgent
  143676. * @param destination targeted world position
  143677. */
  143678. agentGoto(index: number, destination: Vector3): void;
  143679. /**
  143680. * Teleport the agent to a new position
  143681. * @param index agent index returned by addAgent
  143682. * @param destination targeted world position
  143683. */
  143684. agentTeleport(index: number, destination: Vector3): void;
  143685. /**
  143686. * Update agent parameters
  143687. * @param index agent index returned by addAgent
  143688. * @param parameters agent parameters
  143689. */
  143690. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143691. /**
  143692. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143693. * The queries will try to find a solution within those bounds
  143694. * default is (1,1,1)
  143695. * @param extent x,y,z value that define the extent around the queries point of reference
  143696. */
  143697. setDefaultQueryExtent(extent: Vector3): void;
  143698. /**
  143699. * Get the Bounding box extent specified by setDefaultQueryExtent
  143700. * @returns the box extent values
  143701. */
  143702. getDefaultQueryExtent(): Vector3;
  143703. /**
  143704. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143705. * @param result output the box extent values
  143706. */
  143707. getDefaultQueryExtentToRef(result: Vector3): void;
  143708. /**
  143709. * Release all resources
  143710. */
  143711. dispose(): void;
  143712. }
  143713. /**
  143714. * Configures an agent
  143715. */
  143716. export interface IAgentParameters {
  143717. /**
  143718. * Agent radius. [Limit: >= 0]
  143719. */
  143720. radius: number;
  143721. /**
  143722. * Agent height. [Limit: > 0]
  143723. */
  143724. height: number;
  143725. /**
  143726. * Maximum allowed acceleration. [Limit: >= 0]
  143727. */
  143728. maxAcceleration: number;
  143729. /**
  143730. * Maximum allowed speed. [Limit: >= 0]
  143731. */
  143732. maxSpeed: number;
  143733. /**
  143734. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143735. */
  143736. collisionQueryRange: number;
  143737. /**
  143738. * The path visibility optimization range. [Limit: > 0]
  143739. */
  143740. pathOptimizationRange: number;
  143741. /**
  143742. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143743. */
  143744. separationWeight: number;
  143745. }
  143746. /**
  143747. * Configures the navigation mesh creation
  143748. */
  143749. export interface INavMeshParameters {
  143750. /**
  143751. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143752. */
  143753. cs: number;
  143754. /**
  143755. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143756. */
  143757. ch: number;
  143758. /**
  143759. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143760. */
  143761. walkableSlopeAngle: number;
  143762. /**
  143763. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143764. * be considered walkable. [Limit: >= 3] [Units: vx]
  143765. */
  143766. walkableHeight: number;
  143767. /**
  143768. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143769. */
  143770. walkableClimb: number;
  143771. /**
  143772. * The distance to erode/shrink the walkable area of the heightfield away from
  143773. * obstructions. [Limit: >=0] [Units: vx]
  143774. */
  143775. walkableRadius: number;
  143776. /**
  143777. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143778. */
  143779. maxEdgeLen: number;
  143780. /**
  143781. * The maximum distance a simplfied contour's border edges should deviate
  143782. * the original raw contour. [Limit: >=0] [Units: vx]
  143783. */
  143784. maxSimplificationError: number;
  143785. /**
  143786. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143787. */
  143788. minRegionArea: number;
  143789. /**
  143790. * Any regions with a span count smaller than this value will, if possible,
  143791. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143792. */
  143793. mergeRegionArea: number;
  143794. /**
  143795. * The maximum number of vertices allowed for polygons generated during the
  143796. * contour to polygon conversion process. [Limit: >= 3]
  143797. */
  143798. maxVertsPerPoly: number;
  143799. /**
  143800. * Sets the sampling distance to use when generating the detail mesh.
  143801. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143802. */
  143803. detailSampleDist: number;
  143804. /**
  143805. * The maximum distance the detail mesh surface should deviate from heightfield
  143806. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143807. */
  143808. detailSampleMaxError: number;
  143809. }
  143810. }
  143811. declare module BABYLON {
  143812. /**
  143813. * RecastJS navigation plugin
  143814. */
  143815. export class RecastJSPlugin implements INavigationEnginePlugin {
  143816. /**
  143817. * Reference to the Recast library
  143818. */
  143819. bjsRECAST: any;
  143820. /**
  143821. * plugin name
  143822. */
  143823. name: string;
  143824. /**
  143825. * the first navmesh created. We might extend this to support multiple navmeshes
  143826. */
  143827. navMesh: any;
  143828. /**
  143829. * Initializes the recastJS plugin
  143830. * @param recastInjection can be used to inject your own recast reference
  143831. */
  143832. constructor(recastInjection?: any);
  143833. /**
  143834. * Creates a navigation mesh
  143835. * @param meshes array of all the geometry used to compute the navigatio mesh
  143836. * @param parameters bunch of parameters used to filter geometry
  143837. */
  143838. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143839. /**
  143840. * Create a navigation mesh debug mesh
  143841. * @param scene is where the mesh will be added
  143842. * @returns debug display mesh
  143843. */
  143844. createDebugNavMesh(scene: Scene): Mesh;
  143845. /**
  143846. * Get a navigation mesh constrained position, closest to the parameter position
  143847. * @param position world position
  143848. * @returns the closest point to position constrained by the navigation mesh
  143849. */
  143850. getClosestPoint(position: Vector3): Vector3;
  143851. /**
  143852. * Get a navigation mesh constrained position, closest to the parameter position
  143853. * @param position world position
  143854. * @param result output the closest point to position constrained by the navigation mesh
  143855. */
  143856. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143857. /**
  143858. * Get a navigation mesh constrained position, within a particular radius
  143859. * @param position world position
  143860. * @param maxRadius the maximum distance to the constrained world position
  143861. * @returns the closest point to position constrained by the navigation mesh
  143862. */
  143863. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143864. /**
  143865. * Get a navigation mesh constrained position, within a particular radius
  143866. * @param position world position
  143867. * @param maxRadius the maximum distance to the constrained world position
  143868. * @param result output the closest point to position constrained by the navigation mesh
  143869. */
  143870. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143871. /**
  143872. * Compute the final position from a segment made of destination-position
  143873. * @param position world position
  143874. * @param destination world position
  143875. * @returns the resulting point along the navmesh
  143876. */
  143877. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143878. /**
  143879. * Compute the final position from a segment made of destination-position
  143880. * @param position world position
  143881. * @param destination world position
  143882. * @param result output the resulting point along the navmesh
  143883. */
  143884. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143885. /**
  143886. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143887. * @param start world position
  143888. * @param end world position
  143889. * @returns array containing world position composing the path
  143890. */
  143891. computePath(start: Vector3, end: Vector3): Vector3[];
  143892. /**
  143893. * Create a new Crowd so you can add agents
  143894. * @param maxAgents the maximum agent count in the crowd
  143895. * @param maxAgentRadius the maximum radius an agent can have
  143896. * @param scene to attach the crowd to
  143897. * @returns the crowd you can add agents to
  143898. */
  143899. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143900. /**
  143901. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143902. * The queries will try to find a solution within those bounds
  143903. * default is (1,1,1)
  143904. * @param extent x,y,z value that define the extent around the queries point of reference
  143905. */
  143906. setDefaultQueryExtent(extent: Vector3): void;
  143907. /**
  143908. * Get the Bounding box extent specified by setDefaultQueryExtent
  143909. * @returns the box extent values
  143910. */
  143911. getDefaultQueryExtent(): Vector3;
  143912. /**
  143913. * build the navmesh from a previously saved state using getNavmeshData
  143914. * @param data the Uint8Array returned by getNavmeshData
  143915. */
  143916. buildFromNavmeshData(data: Uint8Array): void;
  143917. /**
  143918. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143919. * @returns data the Uint8Array that can be saved and reused
  143920. */
  143921. getNavmeshData(): Uint8Array;
  143922. /**
  143923. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143924. * @param result output the box extent values
  143925. */
  143926. getDefaultQueryExtentToRef(result: Vector3): void;
  143927. /**
  143928. * Disposes
  143929. */
  143930. dispose(): void;
  143931. /**
  143932. * If this plugin is supported
  143933. * @returns true if plugin is supported
  143934. */
  143935. isSupported(): boolean;
  143936. }
  143937. /**
  143938. * Recast detour crowd implementation
  143939. */
  143940. export class RecastJSCrowd implements ICrowd {
  143941. /**
  143942. * Recast/detour plugin
  143943. */
  143944. bjsRECASTPlugin: RecastJSPlugin;
  143945. /**
  143946. * Link to the detour crowd
  143947. */
  143948. recastCrowd: any;
  143949. /**
  143950. * One transform per agent
  143951. */
  143952. transforms: TransformNode[];
  143953. /**
  143954. * All agents created
  143955. */
  143956. agents: number[];
  143957. /**
  143958. * Link to the scene is kept to unregister the crowd from the scene
  143959. */
  143960. private _scene;
  143961. /**
  143962. * Observer for crowd updates
  143963. */
  143964. private _onBeforeAnimationsObserver;
  143965. /**
  143966. * Constructor
  143967. * @param plugin recastJS plugin
  143968. * @param maxAgents the maximum agent count in the crowd
  143969. * @param maxAgentRadius the maximum radius an agent can have
  143970. * @param scene to attach the crowd to
  143971. * @returns the crowd you can add agents to
  143972. */
  143973. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143974. /**
  143975. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143976. * You can attach anything to that node. The node position is updated in the scene update tick.
  143977. * @param pos world position that will be constrained by the navigation mesh
  143978. * @param parameters agent parameters
  143979. * @param transform hooked to the agent that will be update by the scene
  143980. * @returns agent index
  143981. */
  143982. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143983. /**
  143984. * Returns the agent position in world space
  143985. * @param index agent index returned by addAgent
  143986. * @returns world space position
  143987. */
  143988. getAgentPosition(index: number): Vector3;
  143989. /**
  143990. * Returns the agent position result in world space
  143991. * @param index agent index returned by addAgent
  143992. * @param result output world space position
  143993. */
  143994. getAgentPositionToRef(index: number, result: Vector3): void;
  143995. /**
  143996. * Returns the agent velocity in world space
  143997. * @param index agent index returned by addAgent
  143998. * @returns world space velocity
  143999. */
  144000. getAgentVelocity(index: number): Vector3;
  144001. /**
  144002. * Returns the agent velocity result in world space
  144003. * @param index agent index returned by addAgent
  144004. * @param result output world space velocity
  144005. */
  144006. getAgentVelocityToRef(index: number, result: Vector3): void;
  144007. /**
  144008. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144009. * @param index agent index returned by addAgent
  144010. * @param destination targeted world position
  144011. */
  144012. agentGoto(index: number, destination: Vector3): void;
  144013. /**
  144014. * Teleport the agent to a new position
  144015. * @param index agent index returned by addAgent
  144016. * @param destination targeted world position
  144017. */
  144018. agentTeleport(index: number, destination: Vector3): void;
  144019. /**
  144020. * Update agent parameters
  144021. * @param index agent index returned by addAgent
  144022. * @param parameters agent parameters
  144023. */
  144024. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144025. /**
  144026. * remove a particular agent previously created
  144027. * @param index agent index returned by addAgent
  144028. */
  144029. removeAgent(index: number): void;
  144030. /**
  144031. * get the list of all agents attached to this crowd
  144032. * @returns list of agent indices
  144033. */
  144034. getAgents(): number[];
  144035. /**
  144036. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144037. * @param deltaTime in seconds
  144038. */
  144039. update(deltaTime: number): void;
  144040. /**
  144041. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144042. * The queries will try to find a solution within those bounds
  144043. * default is (1,1,1)
  144044. * @param extent x,y,z value that define the extent around the queries point of reference
  144045. */
  144046. setDefaultQueryExtent(extent: Vector3): void;
  144047. /**
  144048. * Get the Bounding box extent specified by setDefaultQueryExtent
  144049. * @returns the box extent values
  144050. */
  144051. getDefaultQueryExtent(): Vector3;
  144052. /**
  144053. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144054. * @param result output the box extent values
  144055. */
  144056. getDefaultQueryExtentToRef(result: Vector3): void;
  144057. /**
  144058. * Release all resources
  144059. */
  144060. dispose(): void;
  144061. }
  144062. }
  144063. declare module BABYLON {
  144064. /**
  144065. * Class used to enable access to IndexedDB
  144066. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144067. */
  144068. export class Database implements IOfflineProvider {
  144069. private _callbackManifestChecked;
  144070. private _currentSceneUrl;
  144071. private _db;
  144072. private _enableSceneOffline;
  144073. private _enableTexturesOffline;
  144074. private _manifestVersionFound;
  144075. private _mustUpdateRessources;
  144076. private _hasReachedQuota;
  144077. private _isSupported;
  144078. private _idbFactory;
  144079. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144080. private static IsUASupportingBlobStorage;
  144081. /**
  144082. * Gets a boolean indicating if Database storate is enabled (off by default)
  144083. */
  144084. static IDBStorageEnabled: boolean;
  144085. /**
  144086. * Gets a boolean indicating if scene must be saved in the database
  144087. */
  144088. get enableSceneOffline(): boolean;
  144089. /**
  144090. * Gets a boolean indicating if textures must be saved in the database
  144091. */
  144092. get enableTexturesOffline(): boolean;
  144093. /**
  144094. * Creates a new Database
  144095. * @param urlToScene defines the url to load the scene
  144096. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144097. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144098. */
  144099. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144100. private static _ParseURL;
  144101. private static _ReturnFullUrlLocation;
  144102. private _checkManifestFile;
  144103. /**
  144104. * Open the database and make it available
  144105. * @param successCallback defines the callback to call on success
  144106. * @param errorCallback defines the callback to call on error
  144107. */
  144108. open(successCallback: () => void, errorCallback: () => void): void;
  144109. /**
  144110. * Loads an image from the database
  144111. * @param url defines the url to load from
  144112. * @param image defines the target DOM image
  144113. */
  144114. loadImage(url: string, image: HTMLImageElement): void;
  144115. private _loadImageFromDBAsync;
  144116. private _saveImageIntoDBAsync;
  144117. private _checkVersionFromDB;
  144118. private _loadVersionFromDBAsync;
  144119. private _saveVersionIntoDBAsync;
  144120. /**
  144121. * Loads a file from database
  144122. * @param url defines the URL to load from
  144123. * @param sceneLoaded defines a callback to call on success
  144124. * @param progressCallBack defines a callback to call when progress changed
  144125. * @param errorCallback defines a callback to call on error
  144126. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144127. */
  144128. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144129. private _loadFileAsync;
  144130. private _saveFileAsync;
  144131. /**
  144132. * Validates if xhr data is correct
  144133. * @param xhr defines the request to validate
  144134. * @param dataType defines the expected data type
  144135. * @returns true if data is correct
  144136. */
  144137. private static _ValidateXHRData;
  144138. }
  144139. }
  144140. declare module BABYLON {
  144141. /** @hidden */
  144142. export var gpuUpdateParticlesPixelShader: {
  144143. name: string;
  144144. shader: string;
  144145. };
  144146. }
  144147. declare module BABYLON {
  144148. /** @hidden */
  144149. export var gpuUpdateParticlesVertexShader: {
  144150. name: string;
  144151. shader: string;
  144152. };
  144153. }
  144154. declare module BABYLON {
  144155. /** @hidden */
  144156. export var clipPlaneFragmentDeclaration2: {
  144157. name: string;
  144158. shader: string;
  144159. };
  144160. }
  144161. declare module BABYLON {
  144162. /** @hidden */
  144163. export var gpuRenderParticlesPixelShader: {
  144164. name: string;
  144165. shader: string;
  144166. };
  144167. }
  144168. declare module BABYLON {
  144169. /** @hidden */
  144170. export var clipPlaneVertexDeclaration2: {
  144171. name: string;
  144172. shader: string;
  144173. };
  144174. }
  144175. declare module BABYLON {
  144176. /** @hidden */
  144177. export var gpuRenderParticlesVertexShader: {
  144178. name: string;
  144179. shader: string;
  144180. };
  144181. }
  144182. declare module BABYLON {
  144183. /**
  144184. * This represents a GPU particle system in Babylon
  144185. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144186. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144187. */
  144188. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144189. /**
  144190. * The layer mask we are rendering the particles through.
  144191. */
  144192. layerMask: number;
  144193. private _capacity;
  144194. private _activeCount;
  144195. private _currentActiveCount;
  144196. private _accumulatedCount;
  144197. private _renderEffect;
  144198. private _updateEffect;
  144199. private _buffer0;
  144200. private _buffer1;
  144201. private _spriteBuffer;
  144202. private _updateVAO;
  144203. private _renderVAO;
  144204. private _targetIndex;
  144205. private _sourceBuffer;
  144206. private _targetBuffer;
  144207. private _engine;
  144208. private _currentRenderId;
  144209. private _started;
  144210. private _stopped;
  144211. private _timeDelta;
  144212. private _randomTexture;
  144213. private _randomTexture2;
  144214. private _attributesStrideSize;
  144215. private _updateEffectOptions;
  144216. private _randomTextureSize;
  144217. private _actualFrame;
  144218. private _customEffect;
  144219. private readonly _rawTextureWidth;
  144220. /**
  144221. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144222. */
  144223. static get IsSupported(): boolean;
  144224. /**
  144225. * An event triggered when the system is disposed.
  144226. */
  144227. onDisposeObservable: Observable<IParticleSystem>;
  144228. /**
  144229. * Gets the maximum number of particles active at the same time.
  144230. * @returns The max number of active particles.
  144231. */
  144232. getCapacity(): number;
  144233. /**
  144234. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144235. * to override the particles.
  144236. */
  144237. forceDepthWrite: boolean;
  144238. /**
  144239. * Gets or set the number of active particles
  144240. */
  144241. get activeParticleCount(): number;
  144242. set activeParticleCount(value: number);
  144243. private _preWarmDone;
  144244. /**
  144245. * Specifies if the particles are updated in emitter local space or world space.
  144246. */
  144247. isLocal: boolean;
  144248. /**
  144249. * Is this system ready to be used/rendered
  144250. * @return true if the system is ready
  144251. */
  144252. isReady(): boolean;
  144253. /**
  144254. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144255. * @returns True if it has been started, otherwise false.
  144256. */
  144257. isStarted(): boolean;
  144258. /**
  144259. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144260. * @returns True if it has been stopped, otherwise false.
  144261. */
  144262. isStopped(): boolean;
  144263. /**
  144264. * Gets a boolean indicating that the system is stopping
  144265. * @returns true if the system is currently stopping
  144266. */
  144267. isStopping(): boolean;
  144268. /**
  144269. * Gets the number of particles active at the same time.
  144270. * @returns The number of active particles.
  144271. */
  144272. getActiveCount(): number;
  144273. /**
  144274. * Starts the particle system and begins to emit
  144275. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144276. */
  144277. start(delay?: number): void;
  144278. /**
  144279. * Stops the particle system.
  144280. */
  144281. stop(): void;
  144282. /**
  144283. * Remove all active particles
  144284. */
  144285. reset(): void;
  144286. /**
  144287. * Returns the string "GPUParticleSystem"
  144288. * @returns a string containing the class name
  144289. */
  144290. getClassName(): string;
  144291. /**
  144292. * Gets the custom effect used to render the particles
  144293. * @param blendMode Blend mode for which the effect should be retrieved
  144294. * @returns The effect
  144295. */
  144296. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144297. /**
  144298. * Sets the custom effect used to render the particles
  144299. * @param effect The effect to set
  144300. * @param blendMode Blend mode for which the effect should be set
  144301. */
  144302. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144303. /** @hidden */
  144304. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144305. /**
  144306. * Observable that will be called just before the particles are drawn
  144307. */
  144308. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144309. /**
  144310. * Gets the name of the particle vertex shader
  144311. */
  144312. get vertexShaderName(): string;
  144313. private _colorGradientsTexture;
  144314. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144315. /**
  144316. * Adds a new color gradient
  144317. * @param gradient defines the gradient to use (between 0 and 1)
  144318. * @param color1 defines the color to affect to the specified gradient
  144319. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144320. * @returns the current particle system
  144321. */
  144322. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144323. private _refreshColorGradient;
  144324. /** Force the system to rebuild all gradients that need to be resync */
  144325. forceRefreshGradients(): void;
  144326. /**
  144327. * Remove a specific color gradient
  144328. * @param gradient defines the gradient to remove
  144329. * @returns the current particle system
  144330. */
  144331. removeColorGradient(gradient: number): GPUParticleSystem;
  144332. private _angularSpeedGradientsTexture;
  144333. private _sizeGradientsTexture;
  144334. private _velocityGradientsTexture;
  144335. private _limitVelocityGradientsTexture;
  144336. private _dragGradientsTexture;
  144337. private _addFactorGradient;
  144338. /**
  144339. * Adds a new size gradient
  144340. * @param gradient defines the gradient to use (between 0 and 1)
  144341. * @param factor defines the size factor to affect to the specified gradient
  144342. * @returns the current particle system
  144343. */
  144344. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144345. /**
  144346. * Remove a specific size gradient
  144347. * @param gradient defines the gradient to remove
  144348. * @returns the current particle system
  144349. */
  144350. removeSizeGradient(gradient: number): GPUParticleSystem;
  144351. private _refreshFactorGradient;
  144352. /**
  144353. * Adds a new angular speed gradient
  144354. * @param gradient defines the gradient to use (between 0 and 1)
  144355. * @param factor defines the angular speed to affect to the specified gradient
  144356. * @returns the current particle system
  144357. */
  144358. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144359. /**
  144360. * Remove a specific angular speed gradient
  144361. * @param gradient defines the gradient to remove
  144362. * @returns the current particle system
  144363. */
  144364. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144365. /**
  144366. * Adds a new velocity gradient
  144367. * @param gradient defines the gradient to use (between 0 and 1)
  144368. * @param factor defines the velocity to affect to the specified gradient
  144369. * @returns the current particle system
  144370. */
  144371. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144372. /**
  144373. * Remove a specific velocity gradient
  144374. * @param gradient defines the gradient to remove
  144375. * @returns the current particle system
  144376. */
  144377. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144378. /**
  144379. * Adds a new limit velocity gradient
  144380. * @param gradient defines the gradient to use (between 0 and 1)
  144381. * @param factor defines the limit velocity value to affect to the specified gradient
  144382. * @returns the current particle system
  144383. */
  144384. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144385. /**
  144386. * Remove a specific limit velocity gradient
  144387. * @param gradient defines the gradient to remove
  144388. * @returns the current particle system
  144389. */
  144390. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144391. /**
  144392. * Adds a new drag gradient
  144393. * @param gradient defines the gradient to use (between 0 and 1)
  144394. * @param factor defines the drag value to affect to the specified gradient
  144395. * @returns the current particle system
  144396. */
  144397. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144398. /**
  144399. * Remove a specific drag gradient
  144400. * @param gradient defines the gradient to remove
  144401. * @returns the current particle system
  144402. */
  144403. removeDragGradient(gradient: number): GPUParticleSystem;
  144404. /**
  144405. * Not supported by GPUParticleSystem
  144406. * @param gradient defines the gradient to use (between 0 and 1)
  144407. * @param factor defines the emit rate value to affect to the specified gradient
  144408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144409. * @returns the current particle system
  144410. */
  144411. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144412. /**
  144413. * Not supported by GPUParticleSystem
  144414. * @param gradient defines the gradient to remove
  144415. * @returns the current particle system
  144416. */
  144417. removeEmitRateGradient(gradient: number): IParticleSystem;
  144418. /**
  144419. * Not supported by GPUParticleSystem
  144420. * @param gradient defines the gradient to use (between 0 and 1)
  144421. * @param factor defines the start size value to affect to the specified gradient
  144422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144423. * @returns the current particle system
  144424. */
  144425. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144426. /**
  144427. * Not supported by GPUParticleSystem
  144428. * @param gradient defines the gradient to remove
  144429. * @returns the current particle system
  144430. */
  144431. removeStartSizeGradient(gradient: number): IParticleSystem;
  144432. /**
  144433. * Not supported by GPUParticleSystem
  144434. * @param gradient defines the gradient to use (between 0 and 1)
  144435. * @param min defines the color remap minimal range
  144436. * @param max defines the color remap maximal range
  144437. * @returns the current particle system
  144438. */
  144439. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144440. /**
  144441. * Not supported by GPUParticleSystem
  144442. * @param gradient defines the gradient to remove
  144443. * @returns the current particle system
  144444. */
  144445. removeColorRemapGradient(): IParticleSystem;
  144446. /**
  144447. * Not supported by GPUParticleSystem
  144448. * @param gradient defines the gradient to use (between 0 and 1)
  144449. * @param min defines the alpha remap minimal range
  144450. * @param max defines the alpha remap maximal range
  144451. * @returns the current particle system
  144452. */
  144453. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144454. /**
  144455. * Not supported by GPUParticleSystem
  144456. * @param gradient defines the gradient to remove
  144457. * @returns the current particle system
  144458. */
  144459. removeAlphaRemapGradient(): IParticleSystem;
  144460. /**
  144461. * Not supported by GPUParticleSystem
  144462. * @param gradient defines the gradient to use (between 0 and 1)
  144463. * @param color defines the color to affect to the specified gradient
  144464. * @returns the current particle system
  144465. */
  144466. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144467. /**
  144468. * Not supported by GPUParticleSystem
  144469. * @param gradient defines the gradient to remove
  144470. * @returns the current particle system
  144471. */
  144472. removeRampGradient(): IParticleSystem;
  144473. /**
  144474. * Not supported by GPUParticleSystem
  144475. * @returns the list of ramp gradients
  144476. */
  144477. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144478. /**
  144479. * Not supported by GPUParticleSystem
  144480. * Gets or sets a boolean indicating that ramp gradients must be used
  144481. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144482. */
  144483. get useRampGradients(): boolean;
  144484. set useRampGradients(value: boolean);
  144485. /**
  144486. * Not supported by GPUParticleSystem
  144487. * @param gradient defines the gradient to use (between 0 and 1)
  144488. * @param factor defines the life time factor to affect to the specified gradient
  144489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144490. * @returns the current particle system
  144491. */
  144492. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144493. /**
  144494. * Not supported by GPUParticleSystem
  144495. * @param gradient defines the gradient to remove
  144496. * @returns the current particle system
  144497. */
  144498. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144499. /**
  144500. * Instantiates a GPU particle system.
  144501. * 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.
  144502. * @param name The name of the particle system
  144503. * @param options The options used to create the system
  144504. * @param scene The scene the particle system belongs to
  144505. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144506. * @param customEffect a custom effect used to change the way particles are rendered by default
  144507. */
  144508. constructor(name: string, options: Partial<{
  144509. capacity: number;
  144510. randomTextureSize: number;
  144511. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144512. protected _reset(): void;
  144513. private _createUpdateVAO;
  144514. private _createRenderVAO;
  144515. private _initialize;
  144516. /** @hidden */
  144517. _recreateUpdateEffect(): void;
  144518. private _getEffect;
  144519. /**
  144520. * Fill the defines array according to the current settings of the particle system
  144521. * @param defines Array to be updated
  144522. * @param blendMode blend mode to take into account when updating the array
  144523. */
  144524. fillDefines(defines: Array<string>, blendMode?: number): void;
  144525. /**
  144526. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144527. * @param uniforms Uniforms array to fill
  144528. * @param attributes Attributes array to fill
  144529. * @param samplers Samplers array to fill
  144530. */
  144531. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144532. /** @hidden */
  144533. _recreateRenderEffect(): Effect;
  144534. /**
  144535. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144536. * @param preWarm defines if we are in the pre-warmimg phase
  144537. */
  144538. animate(preWarm?: boolean): void;
  144539. private _createFactorGradientTexture;
  144540. private _createSizeGradientTexture;
  144541. private _createAngularSpeedGradientTexture;
  144542. private _createVelocityGradientTexture;
  144543. private _createLimitVelocityGradientTexture;
  144544. private _createDragGradientTexture;
  144545. private _createColorGradientTexture;
  144546. /**
  144547. * Renders the particle system in its current state
  144548. * @param preWarm defines if the system should only update the particles but not render them
  144549. * @returns the current number of particles
  144550. */
  144551. render(preWarm?: boolean): number;
  144552. /**
  144553. * Rebuilds the particle system
  144554. */
  144555. rebuild(): void;
  144556. private _releaseBuffers;
  144557. private _releaseVAOs;
  144558. /**
  144559. * Disposes the particle system and free the associated resources
  144560. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  144561. */
  144562. dispose(disposeTexture?: boolean): void;
  144563. /**
  144564. * Clones the particle system.
  144565. * @param name The name of the cloned object
  144566. * @param newEmitter The new emitter to use
  144567. * @returns the cloned particle system
  144568. */
  144569. clone(name: string, newEmitter: any): GPUParticleSystem;
  144570. /**
  144571. * Serializes the particle system to a JSON object
  144572. * @param serializeTexture defines if the texture must be serialized as well
  144573. * @returns the JSON object
  144574. */
  144575. serialize(serializeTexture?: boolean): any;
  144576. /**
  144577. * Parses a JSON object to create a GPU particle system.
  144578. * @param parsedParticleSystem The JSON object to parse
  144579. * @param scene The scene to create the particle system in
  144580. * @param rootUrl The root url to use to load external dependencies like texture
  144581. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  144582. * @returns the parsed GPU particle system
  144583. */
  144584. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  144585. }
  144586. }
  144587. declare module BABYLON {
  144588. /**
  144589. * Represents a set of particle systems working together to create a specific effect
  144590. */
  144591. export class ParticleSystemSet implements IDisposable {
  144592. /**
  144593. * Gets or sets base Assets URL
  144594. */
  144595. static BaseAssetsUrl: string;
  144596. private _emitterCreationOptions;
  144597. private _emitterNode;
  144598. /**
  144599. * Gets the particle system list
  144600. */
  144601. systems: IParticleSystem[];
  144602. /**
  144603. * Gets the emitter node used with this set
  144604. */
  144605. get emitterNode(): Nullable<TransformNode>;
  144606. /**
  144607. * Creates a new emitter mesh as a sphere
  144608. * @param options defines the options used to create the sphere
  144609. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  144610. * @param scene defines the hosting scene
  144611. */
  144612. setEmitterAsSphere(options: {
  144613. diameter: number;
  144614. segments: number;
  144615. color: Color3;
  144616. }, renderingGroupId: number, scene: Scene): void;
  144617. /**
  144618. * Starts all particle systems of the set
  144619. * @param emitter defines an optional mesh to use as emitter for the particle systems
  144620. */
  144621. start(emitter?: AbstractMesh): void;
  144622. /**
  144623. * Release all associated resources
  144624. */
  144625. dispose(): void;
  144626. /**
  144627. * Serialize the set into a JSON compatible object
  144628. * @param serializeTexture defines if the texture must be serialized as well
  144629. * @returns a JSON compatible representation of the set
  144630. */
  144631. serialize(serializeTexture?: boolean): any;
  144632. /**
  144633. * Parse a new ParticleSystemSet from a serialized source
  144634. * @param data defines a JSON compatible representation of the set
  144635. * @param scene defines the hosting scene
  144636. * @param gpu defines if we want GPU particles or CPU particles
  144637. * @returns a new ParticleSystemSet
  144638. */
  144639. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144640. }
  144641. }
  144642. declare module BABYLON {
  144643. /**
  144644. * This class is made for on one-liner static method to help creating particle system set.
  144645. */
  144646. export class ParticleHelper {
  144647. /**
  144648. * Gets or sets base Assets URL
  144649. */
  144650. static BaseAssetsUrl: string;
  144651. /** Define the Url to load snippets */
  144652. static SnippetUrl: string;
  144653. /**
  144654. * Create a default particle system that you can tweak
  144655. * @param emitter defines the emitter to use
  144656. * @param capacity defines the system capacity (default is 500 particles)
  144657. * @param scene defines the hosting scene
  144658. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144659. * @returns the new Particle system
  144660. */
  144661. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144662. /**
  144663. * This is the main static method (one-liner) of this helper to create different particle systems
  144664. * @param type This string represents the type to the particle system to create
  144665. * @param scene The scene where the particle system should live
  144666. * @param gpu If the system will use gpu
  144667. * @returns the ParticleSystemSet created
  144668. */
  144669. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144670. /**
  144671. * Static function used to export a particle system to a ParticleSystemSet variable.
  144672. * Please note that the emitter shape is not exported
  144673. * @param systems defines the particle systems to export
  144674. * @returns the created particle system set
  144675. */
  144676. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144677. /**
  144678. * Creates a particle system from a snippet saved in a remote file
  144679. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144680. * @param url defines the url to load from
  144681. * @param scene defines the hosting scene
  144682. * @param gpu If the system will use gpu
  144683. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144684. * @returns a promise that will resolve to the new particle system
  144685. */
  144686. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144687. /**
  144688. * Creates a particle system from a snippet saved by the particle system editor
  144689. * @param snippetId defines the snippet to load
  144690. * @param scene defines the hosting scene
  144691. * @param gpu If the system will use gpu
  144692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144693. * @returns a promise that will resolve to the new particle system
  144694. */
  144695. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144696. }
  144697. }
  144698. declare module BABYLON {
  144699. interface Engine {
  144700. /**
  144701. * Create an effect to use with particle systems.
  144702. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144703. * the particle system for which you want to create a custom effect in the last parameter
  144704. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144705. * @param uniformsNames defines a list of attribute names
  144706. * @param samplers defines an array of string used to represent textures
  144707. * @param defines defines the string containing the defines to use to compile the shaders
  144708. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144709. * @param onCompiled defines a function to call when the effect creation is successful
  144710. * @param onError defines a function to call when the effect creation has failed
  144711. * @param particleSystem the particle system you want to create the effect for
  144712. * @returns the new Effect
  144713. */
  144714. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144715. }
  144716. interface Mesh {
  144717. /**
  144718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144719. * @returns an array of IParticleSystem
  144720. */
  144721. getEmittedParticleSystems(): IParticleSystem[];
  144722. /**
  144723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144724. * @returns an array of IParticleSystem
  144725. */
  144726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144727. }
  144728. }
  144729. declare module BABYLON {
  144730. /** Defines the 4 color options */
  144731. export enum PointColor {
  144732. /** color value */
  144733. Color = 2,
  144734. /** uv value */
  144735. UV = 1,
  144736. /** random value */
  144737. Random = 0,
  144738. /** stated value */
  144739. Stated = 3
  144740. }
  144741. /**
  144742. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144743. * 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.
  144744. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144745. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144746. *
  144747. * Full documentation here : TO BE ENTERED
  144748. */
  144749. export class PointsCloudSystem implements IDisposable {
  144750. /**
  144751. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144752. * Example : var p = SPS.particles[i];
  144753. */
  144754. particles: CloudPoint[];
  144755. /**
  144756. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144757. */
  144758. nbParticles: number;
  144759. /**
  144760. * This a counter for your own usage. It's not set by any SPS functions.
  144761. */
  144762. counter: number;
  144763. /**
  144764. * The PCS name. This name is also given to the underlying mesh.
  144765. */
  144766. name: string;
  144767. /**
  144768. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144769. */
  144770. mesh: Mesh;
  144771. /**
  144772. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144773. * Please read :
  144774. */
  144775. vars: any;
  144776. /**
  144777. * @hidden
  144778. */
  144779. _size: number;
  144780. private _scene;
  144781. private _promises;
  144782. private _positions;
  144783. private _indices;
  144784. private _normals;
  144785. private _colors;
  144786. private _uvs;
  144787. private _indices32;
  144788. private _positions32;
  144789. private _colors32;
  144790. private _uvs32;
  144791. private _updatable;
  144792. private _isVisibilityBoxLocked;
  144793. private _alwaysVisible;
  144794. private _groups;
  144795. private _groupCounter;
  144796. private _computeParticleColor;
  144797. private _computeParticleTexture;
  144798. private _computeParticleRotation;
  144799. private _computeBoundingBox;
  144800. private _isReady;
  144801. /**
  144802. * Creates a PCS (Points Cloud System) object
  144803. * @param name (String) is the PCS name, this will be the underlying mesh name
  144804. * @param pointSize (number) is the size for each point
  144805. * @param scene (Scene) is the scene in which the PCS is added
  144806. * @param options defines the options of the PCS e.g.
  144807. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144808. */
  144809. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144810. updatable?: boolean;
  144811. });
  144812. /**
  144813. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144814. * If no points were added to the PCS, the returned mesh is just a single point.
  144815. * @returns a promise for the created mesh
  144816. */
  144817. buildMeshAsync(): Promise<Mesh>;
  144818. /**
  144819. * @hidden
  144820. */
  144821. private _buildMesh;
  144822. private _addParticle;
  144823. private _randomUnitVector;
  144824. private _getColorIndicesForCoord;
  144825. private _setPointsColorOrUV;
  144826. private _colorFromTexture;
  144827. private _calculateDensity;
  144828. /**
  144829. * Adds points to the PCS in random positions within a unit sphere
  144830. * @param nb (positive integer) the number of particles to be created from this model
  144831. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144832. * @returns the number of groups in the system
  144833. */
  144834. addPoints(nb: number, pointFunction?: any): number;
  144835. /**
  144836. * Adds points to the PCS from the surface of the model shape
  144837. * @param mesh is any Mesh object that will be used as a surface model for the points
  144838. * @param nb (positive integer) the number of particles to be created from this model
  144839. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144840. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144841. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144842. * @returns the number of groups in the system
  144843. */
  144844. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144845. /**
  144846. * Adds points to the PCS inside the model shape
  144847. * @param mesh is any Mesh object that will be used as a surface model for the points
  144848. * @param nb (positive integer) the number of particles to be created from this model
  144849. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144850. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144851. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144852. * @returns the number of groups in the system
  144853. */
  144854. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144855. /**
  144856. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144857. * This method calls `updateParticle()` for each particle of the SPS.
  144858. * For an animated SPS, it is usually called within the render loop.
  144859. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144860. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144861. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144862. * @returns the PCS.
  144863. */
  144864. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144865. /**
  144866. * Disposes the PCS.
  144867. */
  144868. dispose(): void;
  144869. /**
  144870. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144871. * doc :
  144872. * @returns the PCS.
  144873. */
  144874. refreshVisibleSize(): PointsCloudSystem;
  144875. /**
  144876. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144877. * @param size the size (float) of the visibility box
  144878. * note : this doesn't lock the PCS mesh bounding box.
  144879. * doc :
  144880. */
  144881. setVisibilityBox(size: number): void;
  144882. /**
  144883. * Gets whether the PCS is always visible or not
  144884. * doc :
  144885. */
  144886. get isAlwaysVisible(): boolean;
  144887. /**
  144888. * Sets the PCS as always visible or not
  144889. * doc :
  144890. */
  144891. set isAlwaysVisible(val: boolean);
  144892. /**
  144893. * Tells to `setParticles()` to compute the particle rotations or not
  144894. * Default value : false. The PCS is faster when it's set to false
  144895. * Note : particle rotations are only applied to parent particles
  144896. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144897. */
  144898. set computeParticleRotation(val: boolean);
  144899. /**
  144900. * Tells to `setParticles()` to compute the particle colors or not.
  144901. * Default value : true. The PCS is faster when it's set to false.
  144902. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144903. */
  144904. set computeParticleColor(val: boolean);
  144905. set computeParticleTexture(val: boolean);
  144906. /**
  144907. * Gets if `setParticles()` computes the particle colors or not.
  144908. * Default value : false. The PCS is faster when it's set to false.
  144909. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144910. */
  144911. get computeParticleColor(): boolean;
  144912. /**
  144913. * Gets if `setParticles()` computes the particle textures or not.
  144914. * Default value : false. The PCS is faster when it's set to false.
  144915. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144916. */
  144917. get computeParticleTexture(): boolean;
  144918. /**
  144919. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144920. */
  144921. set computeBoundingBox(val: boolean);
  144922. /**
  144923. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144924. */
  144925. get computeBoundingBox(): boolean;
  144926. /**
  144927. * This function does nothing. It may be overwritten to set all the particle first values.
  144928. * The PCS doesn't call this function, you may have to call it by your own.
  144929. * doc :
  144930. */
  144931. initParticles(): void;
  144932. /**
  144933. * This function does nothing. It may be overwritten to recycle a particle
  144934. * The PCS doesn't call this function, you can to call it
  144935. * doc :
  144936. * @param particle The particle to recycle
  144937. * @returns the recycled particle
  144938. */
  144939. recycleParticle(particle: CloudPoint): CloudPoint;
  144940. /**
  144941. * Updates a particle : this function should be overwritten by the user.
  144942. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144943. * doc :
  144944. * @example : just set a particle position or velocity and recycle conditions
  144945. * @param particle The particle to update
  144946. * @returns the updated particle
  144947. */
  144948. updateParticle(particle: CloudPoint): CloudPoint;
  144949. /**
  144950. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144951. * This does nothing and may be overwritten by the user.
  144952. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144953. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144954. * @param update the boolean update value actually passed to setParticles()
  144955. */
  144956. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144957. /**
  144958. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144959. * This will be passed three parameters.
  144960. * This does nothing and may be overwritten by the user.
  144961. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144962. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144963. * @param update the boolean update value actually passed to setParticles()
  144964. */
  144965. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144966. }
  144967. }
  144968. declare module BABYLON {
  144969. /**
  144970. * Represents one particle of a points cloud system.
  144971. */
  144972. export class CloudPoint {
  144973. /**
  144974. * particle global index
  144975. */
  144976. idx: number;
  144977. /**
  144978. * The color of the particle
  144979. */
  144980. color: Nullable<Color4>;
  144981. /**
  144982. * The world space position of the particle.
  144983. */
  144984. position: Vector3;
  144985. /**
  144986. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144987. */
  144988. rotation: Vector3;
  144989. /**
  144990. * The world space rotation quaternion of the particle.
  144991. */
  144992. rotationQuaternion: Nullable<Quaternion>;
  144993. /**
  144994. * The uv of the particle.
  144995. */
  144996. uv: Nullable<Vector2>;
  144997. /**
  144998. * The current speed of the particle.
  144999. */
  145000. velocity: Vector3;
  145001. /**
  145002. * The pivot point in the particle local space.
  145003. */
  145004. pivot: Vector3;
  145005. /**
  145006. * Must the particle be translated from its pivot point in its local space ?
  145007. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145008. * Default : false
  145009. */
  145010. translateFromPivot: boolean;
  145011. /**
  145012. * Index of this particle in the global "positions" array (Internal use)
  145013. * @hidden
  145014. */
  145015. _pos: number;
  145016. /**
  145017. * @hidden Index of this particle in the global "indices" array (Internal use)
  145018. */
  145019. _ind: number;
  145020. /**
  145021. * Group this particle belongs to
  145022. */
  145023. _group: PointsGroup;
  145024. /**
  145025. * Group id of this particle
  145026. */
  145027. groupId: number;
  145028. /**
  145029. * Index of the particle in its group id (Internal use)
  145030. */
  145031. idxInGroup: number;
  145032. /**
  145033. * @hidden Particle BoundingInfo object (Internal use)
  145034. */
  145035. _boundingInfo: BoundingInfo;
  145036. /**
  145037. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145038. */
  145039. _pcs: PointsCloudSystem;
  145040. /**
  145041. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145042. */
  145043. _stillInvisible: boolean;
  145044. /**
  145045. * @hidden Last computed particle rotation matrix
  145046. */
  145047. _rotationMatrix: number[];
  145048. /**
  145049. * Parent particle Id, if any.
  145050. * Default null.
  145051. */
  145052. parentId: Nullable<number>;
  145053. /**
  145054. * @hidden Internal global position in the PCS.
  145055. */
  145056. _globalPosition: Vector3;
  145057. /**
  145058. * Creates a Point Cloud object.
  145059. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145060. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145061. * @param group (PointsGroup) is the group the particle belongs to
  145062. * @param groupId (integer) is the group identifier in the PCS.
  145063. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145064. * @param pcs defines the PCS it is associated to
  145065. */
  145066. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145067. /**
  145068. * get point size
  145069. */
  145070. get size(): Vector3;
  145071. /**
  145072. * Set point size
  145073. */
  145074. set size(scale: Vector3);
  145075. /**
  145076. * Legacy support, changed quaternion to rotationQuaternion
  145077. */
  145078. get quaternion(): Nullable<Quaternion>;
  145079. /**
  145080. * Legacy support, changed quaternion to rotationQuaternion
  145081. */
  145082. set quaternion(q: Nullable<Quaternion>);
  145083. /**
  145084. * Returns a boolean. True if the particle intersects a mesh, else false
  145085. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145086. * @param target is the object (point or mesh) what the intersection is computed against
  145087. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145088. * @returns true if it intersects
  145089. */
  145090. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145091. /**
  145092. * get the rotation matrix of the particle
  145093. * @hidden
  145094. */
  145095. getRotationMatrix(m: Matrix): void;
  145096. }
  145097. /**
  145098. * Represents a group of points in a points cloud system
  145099. * * PCS internal tool, don't use it manually.
  145100. */
  145101. export class PointsGroup {
  145102. /**
  145103. * The group id
  145104. * @hidden
  145105. */
  145106. groupID: number;
  145107. /**
  145108. * image data for group (internal use)
  145109. * @hidden
  145110. */
  145111. _groupImageData: Nullable<ArrayBufferView>;
  145112. /**
  145113. * Image Width (internal use)
  145114. * @hidden
  145115. */
  145116. _groupImgWidth: number;
  145117. /**
  145118. * Image Height (internal use)
  145119. * @hidden
  145120. */
  145121. _groupImgHeight: number;
  145122. /**
  145123. * Custom position function (internal use)
  145124. * @hidden
  145125. */
  145126. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145127. /**
  145128. * density per facet for surface points
  145129. * @hidden
  145130. */
  145131. _groupDensity: number[];
  145132. /**
  145133. * Only when points are colored by texture carries pointer to texture list array
  145134. * @hidden
  145135. */
  145136. _textureNb: number;
  145137. /**
  145138. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145139. * PCS internal tool, don't use it manually.
  145140. * @hidden
  145141. */
  145142. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145143. }
  145144. }
  145145. declare module BABYLON {
  145146. interface Scene {
  145147. /** @hidden (Backing field) */
  145148. _physicsEngine: Nullable<IPhysicsEngine>;
  145149. /** @hidden */
  145150. _physicsTimeAccumulator: number;
  145151. /**
  145152. * Gets the current physics engine
  145153. * @returns a IPhysicsEngine or null if none attached
  145154. */
  145155. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145156. /**
  145157. * Enables physics to the current scene
  145158. * @param gravity defines the scene's gravity for the physics engine
  145159. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145160. * @return a boolean indicating if the physics engine was initialized
  145161. */
  145162. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145163. /**
  145164. * Disables and disposes the physics engine associated with the scene
  145165. */
  145166. disablePhysicsEngine(): void;
  145167. /**
  145168. * Gets a boolean indicating if there is an active physics engine
  145169. * @returns a boolean indicating if there is an active physics engine
  145170. */
  145171. isPhysicsEnabled(): boolean;
  145172. /**
  145173. * Deletes a physics compound impostor
  145174. * @param compound defines the compound to delete
  145175. */
  145176. deleteCompoundImpostor(compound: any): void;
  145177. /**
  145178. * An event triggered when physic simulation is about to be run
  145179. */
  145180. onBeforePhysicsObservable: Observable<Scene>;
  145181. /**
  145182. * An event triggered when physic simulation has been done
  145183. */
  145184. onAfterPhysicsObservable: Observable<Scene>;
  145185. }
  145186. interface AbstractMesh {
  145187. /** @hidden */
  145188. _physicsImpostor: Nullable<PhysicsImpostor>;
  145189. /**
  145190. * Gets or sets impostor used for physic simulation
  145191. * @see http://doc.babylonjs.com/features/physics_engine
  145192. */
  145193. physicsImpostor: Nullable<PhysicsImpostor>;
  145194. /**
  145195. * Gets the current physics impostor
  145196. * @see http://doc.babylonjs.com/features/physics_engine
  145197. * @returns a physics impostor or null
  145198. */
  145199. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145200. /** Apply a physic impulse to the mesh
  145201. * @param force defines the force to apply
  145202. * @param contactPoint defines where to apply the force
  145203. * @returns the current mesh
  145204. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  145205. */
  145206. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145207. /**
  145208. * Creates a physic joint between two meshes
  145209. * @param otherMesh defines the other mesh to use
  145210. * @param pivot1 defines the pivot to use on this mesh
  145211. * @param pivot2 defines the pivot to use on the other mesh
  145212. * @param options defines additional options (can be plugin dependent)
  145213. * @returns the current mesh
  145214. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145215. */
  145216. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145217. /** @hidden */
  145218. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145219. }
  145220. /**
  145221. * Defines the physics engine scene component responsible to manage a physics engine
  145222. */
  145223. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145224. /**
  145225. * The component name helpful to identify the component in the list of scene components.
  145226. */
  145227. readonly name: string;
  145228. /**
  145229. * The scene the component belongs to.
  145230. */
  145231. scene: Scene;
  145232. /**
  145233. * Creates a new instance of the component for the given scene
  145234. * @param scene Defines the scene to register the component in
  145235. */
  145236. constructor(scene: Scene);
  145237. /**
  145238. * Registers the component in a given scene
  145239. */
  145240. register(): void;
  145241. /**
  145242. * Rebuilds the elements related to this component in case of
  145243. * context lost for instance.
  145244. */
  145245. rebuild(): void;
  145246. /**
  145247. * Disposes the component and the associated ressources
  145248. */
  145249. dispose(): void;
  145250. }
  145251. }
  145252. declare module BABYLON {
  145253. /**
  145254. * A helper for physics simulations
  145255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145256. */
  145257. export class PhysicsHelper {
  145258. private _scene;
  145259. private _physicsEngine;
  145260. /**
  145261. * Initializes the Physics helper
  145262. * @param scene Babylon.js scene
  145263. */
  145264. constructor(scene: Scene);
  145265. /**
  145266. * Applies a radial explosion impulse
  145267. * @param origin the origin of the explosion
  145268. * @param radiusOrEventOptions the radius or the options of radial explosion
  145269. * @param strength the explosion strength
  145270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145271. * @returns A physics radial explosion event, or null
  145272. */
  145273. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145274. /**
  145275. * Applies a radial explosion force
  145276. * @param origin the origin of the explosion
  145277. * @param radiusOrEventOptions the radius or the options of radial explosion
  145278. * @param strength the explosion strength
  145279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145280. * @returns A physics radial explosion event, or null
  145281. */
  145282. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145283. /**
  145284. * Creates a gravitational field
  145285. * @param origin the origin of the explosion
  145286. * @param radiusOrEventOptions the radius or the options of radial explosion
  145287. * @param strength the explosion strength
  145288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145289. * @returns A physics gravitational field event, or null
  145290. */
  145291. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145292. /**
  145293. * Creates a physics updraft event
  145294. * @param origin the origin of the updraft
  145295. * @param radiusOrEventOptions the radius or the options of the updraft
  145296. * @param strength the strength of the updraft
  145297. * @param height the height of the updraft
  145298. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145299. * @returns A physics updraft event, or null
  145300. */
  145301. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145302. /**
  145303. * Creates a physics vortex event
  145304. * @param origin the of the vortex
  145305. * @param radiusOrEventOptions the radius or the options of the vortex
  145306. * @param strength the strength of the vortex
  145307. * @param height the height of the vortex
  145308. * @returns a Physics vortex event, or null
  145309. * A physics vortex event or null
  145310. */
  145311. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145312. }
  145313. /**
  145314. * Represents a physics radial explosion event
  145315. */
  145316. class PhysicsRadialExplosionEvent {
  145317. private _scene;
  145318. private _options;
  145319. private _sphere;
  145320. private _dataFetched;
  145321. /**
  145322. * Initializes a radial explosioin event
  145323. * @param _scene BabylonJS scene
  145324. * @param _options The options for the vortex event
  145325. */
  145326. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145327. /**
  145328. * Returns the data related to the radial explosion event (sphere).
  145329. * @returns The radial explosion event data
  145330. */
  145331. getData(): PhysicsRadialExplosionEventData;
  145332. /**
  145333. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145334. * @param impostor A physics imposter
  145335. * @param origin the origin of the explosion
  145336. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145337. */
  145338. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145339. /**
  145340. * Triggers affecterd impostors callbacks
  145341. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145342. */
  145343. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145344. /**
  145345. * Disposes the sphere.
  145346. * @param force Specifies if the sphere should be disposed by force
  145347. */
  145348. dispose(force?: boolean): void;
  145349. /*** Helpers ***/
  145350. private _prepareSphere;
  145351. private _intersectsWithSphere;
  145352. }
  145353. /**
  145354. * Represents a gravitational field event
  145355. */
  145356. class PhysicsGravitationalFieldEvent {
  145357. private _physicsHelper;
  145358. private _scene;
  145359. private _origin;
  145360. private _options;
  145361. private _tickCallback;
  145362. private _sphere;
  145363. private _dataFetched;
  145364. /**
  145365. * Initializes the physics gravitational field event
  145366. * @param _physicsHelper A physics helper
  145367. * @param _scene BabylonJS scene
  145368. * @param _origin The origin position of the gravitational field event
  145369. * @param _options The options for the vortex event
  145370. */
  145371. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145372. /**
  145373. * Returns the data related to the gravitational field event (sphere).
  145374. * @returns A gravitational field event
  145375. */
  145376. getData(): PhysicsGravitationalFieldEventData;
  145377. /**
  145378. * Enables the gravitational field.
  145379. */
  145380. enable(): void;
  145381. /**
  145382. * Disables the gravitational field.
  145383. */
  145384. disable(): void;
  145385. /**
  145386. * Disposes the sphere.
  145387. * @param force The force to dispose from the gravitational field event
  145388. */
  145389. dispose(force?: boolean): void;
  145390. private _tick;
  145391. }
  145392. /**
  145393. * Represents a physics updraft event
  145394. */
  145395. class PhysicsUpdraftEvent {
  145396. private _scene;
  145397. private _origin;
  145398. private _options;
  145399. private _physicsEngine;
  145400. private _originTop;
  145401. private _originDirection;
  145402. private _tickCallback;
  145403. private _cylinder;
  145404. private _cylinderPosition;
  145405. private _dataFetched;
  145406. /**
  145407. * Initializes the physics updraft event
  145408. * @param _scene BabylonJS scene
  145409. * @param _origin The origin position of the updraft
  145410. * @param _options The options for the updraft event
  145411. */
  145412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145413. /**
  145414. * Returns the data related to the updraft event (cylinder).
  145415. * @returns A physics updraft event
  145416. */
  145417. getData(): PhysicsUpdraftEventData;
  145418. /**
  145419. * Enables the updraft.
  145420. */
  145421. enable(): void;
  145422. /**
  145423. * Disables the updraft.
  145424. */
  145425. disable(): void;
  145426. /**
  145427. * Disposes the cylinder.
  145428. * @param force Specifies if the updraft should be disposed by force
  145429. */
  145430. dispose(force?: boolean): void;
  145431. private getImpostorHitData;
  145432. private _tick;
  145433. /*** Helpers ***/
  145434. private _prepareCylinder;
  145435. private _intersectsWithCylinder;
  145436. }
  145437. /**
  145438. * Represents a physics vortex event
  145439. */
  145440. class PhysicsVortexEvent {
  145441. private _scene;
  145442. private _origin;
  145443. private _options;
  145444. private _physicsEngine;
  145445. private _originTop;
  145446. private _tickCallback;
  145447. private _cylinder;
  145448. private _cylinderPosition;
  145449. private _dataFetched;
  145450. /**
  145451. * Initializes the physics vortex event
  145452. * @param _scene The BabylonJS scene
  145453. * @param _origin The origin position of the vortex
  145454. * @param _options The options for the vortex event
  145455. */
  145456. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145457. /**
  145458. * Returns the data related to the vortex event (cylinder).
  145459. * @returns The physics vortex event data
  145460. */
  145461. getData(): PhysicsVortexEventData;
  145462. /**
  145463. * Enables the vortex.
  145464. */
  145465. enable(): void;
  145466. /**
  145467. * Disables the cortex.
  145468. */
  145469. disable(): void;
  145470. /**
  145471. * Disposes the sphere.
  145472. * @param force
  145473. */
  145474. dispose(force?: boolean): void;
  145475. private getImpostorHitData;
  145476. private _tick;
  145477. /*** Helpers ***/
  145478. private _prepareCylinder;
  145479. private _intersectsWithCylinder;
  145480. }
  145481. /**
  145482. * Options fot the radial explosion event
  145483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145484. */
  145485. export class PhysicsRadialExplosionEventOptions {
  145486. /**
  145487. * The radius of the sphere for the radial explosion.
  145488. */
  145489. radius: number;
  145490. /**
  145491. * The strenth of the explosion.
  145492. */
  145493. strength: number;
  145494. /**
  145495. * The strenght of the force in correspondence to the distance of the affected object
  145496. */
  145497. falloff: PhysicsRadialImpulseFalloff;
  145498. /**
  145499. * Sphere options for the radial explosion.
  145500. */
  145501. sphere: {
  145502. segments: number;
  145503. diameter: number;
  145504. };
  145505. /**
  145506. * Sphere options for the radial explosion.
  145507. */
  145508. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145509. }
  145510. /**
  145511. * Options fot the updraft event
  145512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145513. */
  145514. export class PhysicsUpdraftEventOptions {
  145515. /**
  145516. * The radius of the cylinder for the vortex
  145517. */
  145518. radius: number;
  145519. /**
  145520. * The strenth of the updraft.
  145521. */
  145522. strength: number;
  145523. /**
  145524. * The height of the cylinder for the updraft.
  145525. */
  145526. height: number;
  145527. /**
  145528. * The mode for the the updraft.
  145529. */
  145530. updraftMode: PhysicsUpdraftMode;
  145531. }
  145532. /**
  145533. * Options fot the vortex event
  145534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145535. */
  145536. export class PhysicsVortexEventOptions {
  145537. /**
  145538. * The radius of the cylinder for the vortex
  145539. */
  145540. radius: number;
  145541. /**
  145542. * The strenth of the vortex.
  145543. */
  145544. strength: number;
  145545. /**
  145546. * The height of the cylinder for the vortex.
  145547. */
  145548. height: number;
  145549. /**
  145550. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145551. */
  145552. centripetalForceThreshold: number;
  145553. /**
  145554. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145555. */
  145556. centripetalForceMultiplier: number;
  145557. /**
  145558. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  145559. */
  145560. centrifugalForceMultiplier: number;
  145561. /**
  145562. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  145563. */
  145564. updraftForceMultiplier: number;
  145565. }
  145566. /**
  145567. * The strenght of the force in correspondence to the distance of the affected object
  145568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145569. */
  145570. export enum PhysicsRadialImpulseFalloff {
  145571. /** Defines that impulse is constant in strength across it's whole radius */
  145572. Constant = 0,
  145573. /** Defines that impulse gets weaker if it's further from the origin */
  145574. Linear = 1
  145575. }
  145576. /**
  145577. * The strength of the force in correspondence to the distance of the affected object
  145578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145579. */
  145580. export enum PhysicsUpdraftMode {
  145581. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  145582. Center = 0,
  145583. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  145584. Perpendicular = 1
  145585. }
  145586. /**
  145587. * Interface for a physics hit data
  145588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145589. */
  145590. export interface PhysicsHitData {
  145591. /**
  145592. * The force applied at the contact point
  145593. */
  145594. force: Vector3;
  145595. /**
  145596. * The contact point
  145597. */
  145598. contactPoint: Vector3;
  145599. /**
  145600. * The distance from the origin to the contact point
  145601. */
  145602. distanceFromOrigin: number;
  145603. }
  145604. /**
  145605. * Interface for radial explosion event data
  145606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145607. */
  145608. export interface PhysicsRadialExplosionEventData {
  145609. /**
  145610. * A sphere used for the radial explosion event
  145611. */
  145612. sphere: Mesh;
  145613. }
  145614. /**
  145615. * Interface for gravitational field event data
  145616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145617. */
  145618. export interface PhysicsGravitationalFieldEventData {
  145619. /**
  145620. * A sphere mesh used for the gravitational field event
  145621. */
  145622. sphere: Mesh;
  145623. }
  145624. /**
  145625. * Interface for updraft event data
  145626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145627. */
  145628. export interface PhysicsUpdraftEventData {
  145629. /**
  145630. * A cylinder used for the updraft event
  145631. */
  145632. cylinder: Mesh;
  145633. }
  145634. /**
  145635. * Interface for vortex event data
  145636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145637. */
  145638. export interface PhysicsVortexEventData {
  145639. /**
  145640. * A cylinder used for the vortex event
  145641. */
  145642. cylinder: Mesh;
  145643. }
  145644. /**
  145645. * Interface for an affected physics impostor
  145646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145647. */
  145648. export interface PhysicsAffectedImpostorWithData {
  145649. /**
  145650. * The impostor affected by the effect
  145651. */
  145652. impostor: PhysicsImpostor;
  145653. /**
  145654. * The data about the hit/horce from the explosion
  145655. */
  145656. hitData: PhysicsHitData;
  145657. }
  145658. }
  145659. declare module BABYLON {
  145660. /** @hidden */
  145661. export var blackAndWhitePixelShader: {
  145662. name: string;
  145663. shader: string;
  145664. };
  145665. }
  145666. declare module BABYLON {
  145667. /**
  145668. * Post process used to render in black and white
  145669. */
  145670. export class BlackAndWhitePostProcess extends PostProcess {
  145671. /**
  145672. * Linear about to convert he result to black and white (default: 1)
  145673. */
  145674. degree: number;
  145675. /**
  145676. * Creates a black and white post process
  145677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145678. * @param name The name of the effect.
  145679. * @param options The required width/height ratio to downsize to before computing the render pass.
  145680. * @param camera The camera to apply the render pass to.
  145681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145682. * @param engine The engine which the post process will be applied. (default: current engine)
  145683. * @param reusable If the post process can be reused on the same frame. (default: false)
  145684. */
  145685. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145686. }
  145687. }
  145688. declare module BABYLON {
  145689. /**
  145690. * This represents a set of one or more post processes in Babylon.
  145691. * A post process can be used to apply a shader to a texture after it is rendered.
  145692. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145693. */
  145694. export class PostProcessRenderEffect {
  145695. private _postProcesses;
  145696. private _getPostProcesses;
  145697. private _singleInstance;
  145698. private _cameras;
  145699. private _indicesForCamera;
  145700. /**
  145701. * Name of the effect
  145702. * @hidden
  145703. */
  145704. _name: string;
  145705. /**
  145706. * Instantiates a post process render effect.
  145707. * A post process can be used to apply a shader to a texture after it is rendered.
  145708. * @param engine The engine the effect is tied to
  145709. * @param name The name of the effect
  145710. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145711. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145712. */
  145713. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145714. /**
  145715. * Checks if all the post processes in the effect are supported.
  145716. */
  145717. get isSupported(): boolean;
  145718. /**
  145719. * Updates the current state of the effect
  145720. * @hidden
  145721. */
  145722. _update(): void;
  145723. /**
  145724. * Attaches the effect on cameras
  145725. * @param cameras The camera to attach to.
  145726. * @hidden
  145727. */
  145728. _attachCameras(cameras: Camera): void;
  145729. /**
  145730. * Attaches the effect on cameras
  145731. * @param cameras The camera to attach to.
  145732. * @hidden
  145733. */
  145734. _attachCameras(cameras: Camera[]): void;
  145735. /**
  145736. * Detaches the effect on cameras
  145737. * @param cameras The camera to detatch from.
  145738. * @hidden
  145739. */
  145740. _detachCameras(cameras: Camera): void;
  145741. /**
  145742. * Detatches the effect on cameras
  145743. * @param cameras The camera to detatch from.
  145744. * @hidden
  145745. */
  145746. _detachCameras(cameras: Camera[]): void;
  145747. /**
  145748. * Enables the effect on given cameras
  145749. * @param cameras The camera to enable.
  145750. * @hidden
  145751. */
  145752. _enable(cameras: Camera): void;
  145753. /**
  145754. * Enables the effect on given cameras
  145755. * @param cameras The camera to enable.
  145756. * @hidden
  145757. */
  145758. _enable(cameras: Nullable<Camera[]>): void;
  145759. /**
  145760. * Disables the effect on the given cameras
  145761. * @param cameras The camera to disable.
  145762. * @hidden
  145763. */
  145764. _disable(cameras: Camera): void;
  145765. /**
  145766. * Disables the effect on the given cameras
  145767. * @param cameras The camera to disable.
  145768. * @hidden
  145769. */
  145770. _disable(cameras: Nullable<Camera[]>): void;
  145771. /**
  145772. * Gets a list of the post processes contained in the effect.
  145773. * @param camera The camera to get the post processes on.
  145774. * @returns The list of the post processes in the effect.
  145775. */
  145776. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145777. }
  145778. }
  145779. declare module BABYLON {
  145780. /** @hidden */
  145781. export var extractHighlightsPixelShader: {
  145782. name: string;
  145783. shader: string;
  145784. };
  145785. }
  145786. declare module BABYLON {
  145787. /**
  145788. * 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.
  145789. */
  145790. export class ExtractHighlightsPostProcess extends PostProcess {
  145791. /**
  145792. * The luminance threshold, pixels below this value will be set to black.
  145793. */
  145794. threshold: number;
  145795. /** @hidden */
  145796. _exposure: number;
  145797. /**
  145798. * Post process which has the input texture to be used when performing highlight extraction
  145799. * @hidden
  145800. */
  145801. _inputPostProcess: Nullable<PostProcess>;
  145802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145803. }
  145804. }
  145805. declare module BABYLON {
  145806. /** @hidden */
  145807. export var bloomMergePixelShader: {
  145808. name: string;
  145809. shader: string;
  145810. };
  145811. }
  145812. declare module BABYLON {
  145813. /**
  145814. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145815. */
  145816. export class BloomMergePostProcess extends PostProcess {
  145817. /** Weight of the bloom to be added to the original input. */
  145818. weight: number;
  145819. /**
  145820. * Creates a new instance of @see BloomMergePostProcess
  145821. * @param name The name of the effect.
  145822. * @param originalFromInput Post process which's input will be used for the merge.
  145823. * @param blurred Blurred highlights post process which's output will be used.
  145824. * @param weight Weight of the bloom to be added to the original input.
  145825. * @param options The required width/height ratio to downsize to before computing the render pass.
  145826. * @param camera The camera to apply the render pass to.
  145827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145828. * @param engine The engine which the post process will be applied. (default: current engine)
  145829. * @param reusable If the post process can be reused on the same frame. (default: false)
  145830. * @param textureType Type of textures used when performing the post process. (default: 0)
  145831. * @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)
  145832. */
  145833. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145834. /** Weight of the bloom to be added to the original input. */
  145835. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145836. }
  145837. }
  145838. declare module BABYLON {
  145839. /**
  145840. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145841. */
  145842. export class BloomEffect extends PostProcessRenderEffect {
  145843. private bloomScale;
  145844. /**
  145845. * @hidden Internal
  145846. */
  145847. _effects: Array<PostProcess>;
  145848. /**
  145849. * @hidden Internal
  145850. */
  145851. _downscale: ExtractHighlightsPostProcess;
  145852. private _blurX;
  145853. private _blurY;
  145854. private _merge;
  145855. /**
  145856. * The luminance threshold to find bright areas of the image to bloom.
  145857. */
  145858. get threshold(): number;
  145859. set threshold(value: number);
  145860. /**
  145861. * The strength of the bloom.
  145862. */
  145863. get weight(): number;
  145864. set weight(value: number);
  145865. /**
  145866. * Specifies the size of the bloom blur kernel, relative to the final output size
  145867. */
  145868. get kernel(): number;
  145869. set kernel(value: number);
  145870. /**
  145871. * Creates a new instance of @see BloomEffect
  145872. * @param scene The scene the effect belongs to.
  145873. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145874. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145875. * @param bloomWeight The the strength of bloom.
  145876. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145877. * @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)
  145878. */
  145879. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145880. /**
  145881. * Disposes each of the internal effects for a given camera.
  145882. * @param camera The camera to dispose the effect on.
  145883. */
  145884. disposeEffects(camera: Camera): void;
  145885. /**
  145886. * @hidden Internal
  145887. */
  145888. _updateEffects(): void;
  145889. /**
  145890. * Internal
  145891. * @returns if all the contained post processes are ready.
  145892. * @hidden
  145893. */
  145894. _isReady(): boolean;
  145895. }
  145896. }
  145897. declare module BABYLON {
  145898. /** @hidden */
  145899. export var chromaticAberrationPixelShader: {
  145900. name: string;
  145901. shader: string;
  145902. };
  145903. }
  145904. declare module BABYLON {
  145905. /**
  145906. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145907. */
  145908. export class ChromaticAberrationPostProcess extends PostProcess {
  145909. /**
  145910. * The amount of seperation of rgb channels (default: 30)
  145911. */
  145912. aberrationAmount: number;
  145913. /**
  145914. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145915. */
  145916. radialIntensity: number;
  145917. /**
  145918. * 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))
  145919. */
  145920. direction: Vector2;
  145921. /**
  145922. * 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))
  145923. */
  145924. centerPosition: Vector2;
  145925. /**
  145926. * Creates a new instance ChromaticAberrationPostProcess
  145927. * @param name The name of the effect.
  145928. * @param screenWidth The width of the screen to apply the effect on.
  145929. * @param screenHeight The height of the screen to apply the effect on.
  145930. * @param options The required width/height ratio to downsize to before computing the render pass.
  145931. * @param camera The camera to apply the render pass to.
  145932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145933. * @param engine The engine which the post process will be applied. (default: current engine)
  145934. * @param reusable If the post process can be reused on the same frame. (default: false)
  145935. * @param textureType Type of textures used when performing the post process. (default: 0)
  145936. * @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)
  145937. */
  145938. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145939. }
  145940. }
  145941. declare module BABYLON {
  145942. /** @hidden */
  145943. export var circleOfConfusionPixelShader: {
  145944. name: string;
  145945. shader: string;
  145946. };
  145947. }
  145948. declare module BABYLON {
  145949. /**
  145950. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145951. */
  145952. export class CircleOfConfusionPostProcess extends PostProcess {
  145953. /**
  145954. * 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.
  145955. */
  145956. lensSize: number;
  145957. /**
  145958. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145959. */
  145960. fStop: number;
  145961. /**
  145962. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145963. */
  145964. focusDistance: number;
  145965. /**
  145966. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145967. */
  145968. focalLength: number;
  145969. private _depthTexture;
  145970. /**
  145971. * Creates a new instance CircleOfConfusionPostProcess
  145972. * @param name The name of the effect.
  145973. * @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.
  145974. * @param options The required width/height ratio to downsize to before computing the render pass.
  145975. * @param camera The camera to apply the render pass to.
  145976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145977. * @param engine The engine which the post process will be applied. (default: current engine)
  145978. * @param reusable If the post process can be reused on the same frame. (default: false)
  145979. * @param textureType Type of textures used when performing the post process. (default: 0)
  145980. * @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)
  145981. */
  145982. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145983. /**
  145984. * 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.
  145985. */
  145986. set depthTexture(value: RenderTargetTexture);
  145987. }
  145988. }
  145989. declare module BABYLON {
  145990. /** @hidden */
  145991. export var colorCorrectionPixelShader: {
  145992. name: string;
  145993. shader: string;
  145994. };
  145995. }
  145996. declare module BABYLON {
  145997. /**
  145998. *
  145999. * This post-process allows the modification of rendered colors by using
  146000. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146001. *
  146002. * The object needs to be provided an url to a texture containing the color
  146003. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146004. * Use an image editing software to tweak the LUT to match your needs.
  146005. *
  146006. * For an example of a color LUT, see here:
  146007. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146008. * For explanations on color grading, see here:
  146009. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146010. *
  146011. */
  146012. export class ColorCorrectionPostProcess extends PostProcess {
  146013. private _colorTableTexture;
  146014. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146015. }
  146016. }
  146017. declare module BABYLON {
  146018. /** @hidden */
  146019. export var convolutionPixelShader: {
  146020. name: string;
  146021. shader: string;
  146022. };
  146023. }
  146024. declare module BABYLON {
  146025. /**
  146026. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146027. * input texture to perform effects such as edge detection or sharpening
  146028. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146029. */
  146030. export class ConvolutionPostProcess extends PostProcess {
  146031. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146032. kernel: number[];
  146033. /**
  146034. * Creates a new instance ConvolutionPostProcess
  146035. * @param name The name of the effect.
  146036. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146037. * @param options The required width/height ratio to downsize to before computing the render pass.
  146038. * @param camera The camera to apply the render pass to.
  146039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146040. * @param engine The engine which the post process will be applied. (default: current engine)
  146041. * @param reusable If the post process can be reused on the same frame. (default: false)
  146042. * @param textureType Type of textures used when performing the post process. (default: 0)
  146043. */
  146044. constructor(name: string,
  146045. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146046. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146047. /**
  146048. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146049. */
  146050. static EdgeDetect0Kernel: number[];
  146051. /**
  146052. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146053. */
  146054. static EdgeDetect1Kernel: number[];
  146055. /**
  146056. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146057. */
  146058. static EdgeDetect2Kernel: number[];
  146059. /**
  146060. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146061. */
  146062. static SharpenKernel: number[];
  146063. /**
  146064. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146065. */
  146066. static EmbossKernel: number[];
  146067. /**
  146068. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146069. */
  146070. static GaussianKernel: number[];
  146071. }
  146072. }
  146073. declare module BABYLON {
  146074. /**
  146075. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146076. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146077. * based on samples that have a large difference in distance than the center pixel.
  146078. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146079. */
  146080. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146081. direction: Vector2;
  146082. /**
  146083. * Creates a new instance CircleOfConfusionPostProcess
  146084. * @param name The name of the effect.
  146085. * @param scene The scene the effect belongs to.
  146086. * @param direction The direction the blur should be applied.
  146087. * @param kernel The size of the kernel used to blur.
  146088. * @param options The required width/height ratio to downsize to before computing the render pass.
  146089. * @param camera The camera to apply the render pass to.
  146090. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146091. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146093. * @param engine The engine which the post process will be applied. (default: current engine)
  146094. * @param reusable If the post process can be reused on the same frame. (default: false)
  146095. * @param textureType Type of textures used when performing the post process. (default: 0)
  146096. * @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)
  146097. */
  146098. 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);
  146099. }
  146100. }
  146101. declare module BABYLON {
  146102. /** @hidden */
  146103. export var depthOfFieldMergePixelShader: {
  146104. name: string;
  146105. shader: string;
  146106. };
  146107. }
  146108. declare module BABYLON {
  146109. /**
  146110. * Options to be set when merging outputs from the default pipeline.
  146111. */
  146112. export class DepthOfFieldMergePostProcessOptions {
  146113. /**
  146114. * The original image to merge on top of
  146115. */
  146116. originalFromInput: PostProcess;
  146117. /**
  146118. * Parameters to perform the merge of the depth of field effect
  146119. */
  146120. depthOfField?: {
  146121. circleOfConfusion: PostProcess;
  146122. blurSteps: Array<PostProcess>;
  146123. };
  146124. /**
  146125. * Parameters to perform the merge of bloom effect
  146126. */
  146127. bloom?: {
  146128. blurred: PostProcess;
  146129. weight: number;
  146130. };
  146131. }
  146132. /**
  146133. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146134. */
  146135. export class DepthOfFieldMergePostProcess extends PostProcess {
  146136. private blurSteps;
  146137. /**
  146138. * Creates a new instance of DepthOfFieldMergePostProcess
  146139. * @param name The name of the effect.
  146140. * @param originalFromInput Post process which's input will be used for the merge.
  146141. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146142. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146143. * @param options The required width/height ratio to downsize to before computing the render pass.
  146144. * @param camera The camera to apply the render pass to.
  146145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146146. * @param engine The engine which the post process will be applied. (default: current engine)
  146147. * @param reusable If the post process can be reused on the same frame. (default: false)
  146148. * @param textureType Type of textures used when performing the post process. (default: 0)
  146149. * @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)
  146150. */
  146151. 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);
  146152. /**
  146153. * Updates the effect with the current post process compile time values and recompiles the shader.
  146154. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146155. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146156. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146157. * @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
  146158. * @param onCompiled Called when the shader has been compiled.
  146159. * @param onError Called if there is an error when compiling a shader.
  146160. */
  146161. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146162. }
  146163. }
  146164. declare module BABYLON {
  146165. /**
  146166. * Specifies the level of max blur that should be applied when using the depth of field effect
  146167. */
  146168. export enum DepthOfFieldEffectBlurLevel {
  146169. /**
  146170. * Subtle blur
  146171. */
  146172. Low = 0,
  146173. /**
  146174. * Medium blur
  146175. */
  146176. Medium = 1,
  146177. /**
  146178. * Large blur
  146179. */
  146180. High = 2
  146181. }
  146182. /**
  146183. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146184. */
  146185. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146186. private _circleOfConfusion;
  146187. /**
  146188. * @hidden Internal, blurs from high to low
  146189. */
  146190. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146191. private _depthOfFieldBlurY;
  146192. private _dofMerge;
  146193. /**
  146194. * @hidden Internal post processes in depth of field effect
  146195. */
  146196. _effects: Array<PostProcess>;
  146197. /**
  146198. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146199. */
  146200. set focalLength(value: number);
  146201. get focalLength(): number;
  146202. /**
  146203. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146204. */
  146205. set fStop(value: number);
  146206. get fStop(): number;
  146207. /**
  146208. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146209. */
  146210. set focusDistance(value: number);
  146211. get focusDistance(): number;
  146212. /**
  146213. * 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.
  146214. */
  146215. set lensSize(value: number);
  146216. get lensSize(): number;
  146217. /**
  146218. * Creates a new instance DepthOfFieldEffect
  146219. * @param scene The scene the effect belongs to.
  146220. * @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.
  146221. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146222. * @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)
  146223. */
  146224. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146225. /**
  146226. * Get the current class name of the current effet
  146227. * @returns "DepthOfFieldEffect"
  146228. */
  146229. getClassName(): string;
  146230. /**
  146231. * 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.
  146232. */
  146233. set depthTexture(value: RenderTargetTexture);
  146234. /**
  146235. * Disposes each of the internal effects for a given camera.
  146236. * @param camera The camera to dispose the effect on.
  146237. */
  146238. disposeEffects(camera: Camera): void;
  146239. /**
  146240. * @hidden Internal
  146241. */
  146242. _updateEffects(): void;
  146243. /**
  146244. * Internal
  146245. * @returns if all the contained post processes are ready.
  146246. * @hidden
  146247. */
  146248. _isReady(): boolean;
  146249. }
  146250. }
  146251. declare module BABYLON {
  146252. /** @hidden */
  146253. export var displayPassPixelShader: {
  146254. name: string;
  146255. shader: string;
  146256. };
  146257. }
  146258. declare module BABYLON {
  146259. /**
  146260. * DisplayPassPostProcess which produces an output the same as it's input
  146261. */
  146262. export class DisplayPassPostProcess extends PostProcess {
  146263. /**
  146264. * Creates the DisplayPassPostProcess
  146265. * @param name The name of the effect.
  146266. * @param options The required width/height ratio to downsize to before computing the render pass.
  146267. * @param camera The camera to apply the render pass to.
  146268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146269. * @param engine The engine which the post process will be applied. (default: current engine)
  146270. * @param reusable If the post process can be reused on the same frame. (default: false)
  146271. */
  146272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146273. }
  146274. }
  146275. declare module BABYLON {
  146276. /** @hidden */
  146277. export var filterPixelShader: {
  146278. name: string;
  146279. shader: string;
  146280. };
  146281. }
  146282. declare module BABYLON {
  146283. /**
  146284. * Applies a kernel filter to the image
  146285. */
  146286. export class FilterPostProcess extends PostProcess {
  146287. /** The matrix to be applied to the image */
  146288. kernelMatrix: Matrix;
  146289. /**
  146290. *
  146291. * @param name The name of the effect.
  146292. * @param kernelMatrix The matrix to be applied to the image
  146293. * @param options The required width/height ratio to downsize to before computing the render pass.
  146294. * @param camera The camera to apply the render pass to.
  146295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146296. * @param engine The engine which the post process will be applied. (default: current engine)
  146297. * @param reusable If the post process can be reused on the same frame. (default: false)
  146298. */
  146299. constructor(name: string,
  146300. /** The matrix to be applied to the image */
  146301. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146302. }
  146303. }
  146304. declare module BABYLON {
  146305. /** @hidden */
  146306. export var fxaaPixelShader: {
  146307. name: string;
  146308. shader: string;
  146309. };
  146310. }
  146311. declare module BABYLON {
  146312. /** @hidden */
  146313. export var fxaaVertexShader: {
  146314. name: string;
  146315. shader: string;
  146316. };
  146317. }
  146318. declare module BABYLON {
  146319. /**
  146320. * Fxaa post process
  146321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146322. */
  146323. export class FxaaPostProcess extends PostProcess {
  146324. /** @hidden */
  146325. texelWidth: number;
  146326. /** @hidden */
  146327. texelHeight: number;
  146328. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146329. private _getDefines;
  146330. }
  146331. }
  146332. declare module BABYLON {
  146333. /** @hidden */
  146334. export var grainPixelShader: {
  146335. name: string;
  146336. shader: string;
  146337. };
  146338. }
  146339. declare module BABYLON {
  146340. /**
  146341. * The GrainPostProcess adds noise to the image at mid luminance levels
  146342. */
  146343. export class GrainPostProcess extends PostProcess {
  146344. /**
  146345. * The intensity of the grain added (default: 30)
  146346. */
  146347. intensity: number;
  146348. /**
  146349. * If the grain should be randomized on every frame
  146350. */
  146351. animated: boolean;
  146352. /**
  146353. * Creates a new instance of @see GrainPostProcess
  146354. * @param name The name of the effect.
  146355. * @param options The required width/height ratio to downsize to before computing the render pass.
  146356. * @param camera The camera to apply the render pass to.
  146357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146358. * @param engine The engine which the post process will be applied. (default: current engine)
  146359. * @param reusable If the post process can be reused on the same frame. (default: false)
  146360. * @param textureType Type of textures used when performing the post process. (default: 0)
  146361. * @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)
  146362. */
  146363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146364. }
  146365. }
  146366. declare module BABYLON {
  146367. /** @hidden */
  146368. export var highlightsPixelShader: {
  146369. name: string;
  146370. shader: string;
  146371. };
  146372. }
  146373. declare module BABYLON {
  146374. /**
  146375. * Extracts highlights from the image
  146376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146377. */
  146378. export class HighlightsPostProcess extends PostProcess {
  146379. /**
  146380. * Extracts highlights from the image
  146381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146382. * @param name The name of the effect.
  146383. * @param options The required width/height ratio to downsize to before computing the render pass.
  146384. * @param camera The camera to apply the render pass to.
  146385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146386. * @param engine The engine which the post process will be applied. (default: current engine)
  146387. * @param reusable If the post process can be reused on the same frame. (default: false)
  146388. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146389. */
  146390. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146391. }
  146392. }
  146393. declare module BABYLON {
  146394. /** @hidden */
  146395. export var mrtFragmentDeclaration: {
  146396. name: string;
  146397. shader: string;
  146398. };
  146399. }
  146400. declare module BABYLON {
  146401. /** @hidden */
  146402. export var geometryPixelShader: {
  146403. name: string;
  146404. shader: string;
  146405. };
  146406. }
  146407. declare module BABYLON {
  146408. /** @hidden */
  146409. export var geometryVertexShader: {
  146410. name: string;
  146411. shader: string;
  146412. };
  146413. }
  146414. declare module BABYLON {
  146415. /** @hidden */
  146416. interface ISavedTransformationMatrix {
  146417. world: Matrix;
  146418. viewProjection: Matrix;
  146419. }
  146420. /**
  146421. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146422. */
  146423. export class GeometryBufferRenderer {
  146424. /**
  146425. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146426. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146427. */
  146428. static readonly POSITION_TEXTURE_TYPE: number;
  146429. /**
  146430. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146431. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146432. */
  146433. static readonly VELOCITY_TEXTURE_TYPE: number;
  146434. /**
  146435. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146436. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146437. */
  146438. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146439. /**
  146440. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146441. * in order to compute objects velocities when enableVelocity is set to "true"
  146442. * @hidden
  146443. */
  146444. _previousTransformationMatrices: {
  146445. [index: number]: ISavedTransformationMatrix;
  146446. };
  146447. /**
  146448. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146449. * in order to compute objects velocities when enableVelocity is set to "true"
  146450. * @hidden
  146451. */
  146452. _previousBonesTransformationMatrices: {
  146453. [index: number]: Float32Array;
  146454. };
  146455. /**
  146456. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146457. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146458. */
  146459. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146460. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146461. renderTransparentMeshes: boolean;
  146462. private _scene;
  146463. private _multiRenderTarget;
  146464. private _ratio;
  146465. private _enablePosition;
  146466. private _enableVelocity;
  146467. private _enableReflectivity;
  146468. private _positionIndex;
  146469. private _velocityIndex;
  146470. private _reflectivityIndex;
  146471. protected _effect: Effect;
  146472. protected _cachedDefines: string;
  146473. /**
  146474. * Set the render list (meshes to be rendered) used in the G buffer.
  146475. */
  146476. set renderList(meshes: Mesh[]);
  146477. /**
  146478. * Gets wether or not G buffer are supported by the running hardware.
  146479. * This requires draw buffer supports
  146480. */
  146481. get isSupported(): boolean;
  146482. /**
  146483. * Returns the index of the given texture type in the G-Buffer textures array
  146484. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146485. * @returns the index of the given texture type in the G-Buffer textures array
  146486. */
  146487. getTextureIndex(textureType: number): number;
  146488. /**
  146489. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146490. */
  146491. get enablePosition(): boolean;
  146492. /**
  146493. * Sets whether or not objects positions are enabled for the G buffer.
  146494. */
  146495. set enablePosition(enable: boolean);
  146496. /**
  146497. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146498. */
  146499. get enableVelocity(): boolean;
  146500. /**
  146501. * Sets wether or not objects velocities are enabled for the G buffer.
  146502. */
  146503. set enableVelocity(enable: boolean);
  146504. /**
  146505. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146506. */
  146507. get enableReflectivity(): boolean;
  146508. /**
  146509. * Sets wether or not objects roughness are enabled for the G buffer.
  146510. */
  146511. set enableReflectivity(enable: boolean);
  146512. /**
  146513. * Gets the scene associated with the buffer.
  146514. */
  146515. get scene(): Scene;
  146516. /**
  146517. * Gets the ratio used by the buffer during its creation.
  146518. * How big is the buffer related to the main canvas.
  146519. */
  146520. get ratio(): number;
  146521. /** @hidden */
  146522. static _SceneComponentInitialization: (scene: Scene) => void;
  146523. /**
  146524. * Creates a new G Buffer for the scene
  146525. * @param scene The scene the buffer belongs to
  146526. * @param ratio How big is the buffer related to the main canvas.
  146527. */
  146528. constructor(scene: Scene, ratio?: number);
  146529. /**
  146530. * Checks wether everything is ready to render a submesh to the G buffer.
  146531. * @param subMesh the submesh to check readiness for
  146532. * @param useInstances is the mesh drawn using instance or not
  146533. * @returns true if ready otherwise false
  146534. */
  146535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146536. /**
  146537. * Gets the current underlying G Buffer.
  146538. * @returns the buffer
  146539. */
  146540. getGBuffer(): MultiRenderTarget;
  146541. /**
  146542. * Gets the number of samples used to render the buffer (anti aliasing).
  146543. */
  146544. get samples(): number;
  146545. /**
  146546. * Sets the number of samples used to render the buffer (anti aliasing).
  146547. */
  146548. set samples(value: number);
  146549. /**
  146550. * Disposes the renderer and frees up associated resources.
  146551. */
  146552. dispose(): void;
  146553. protected _createRenderTargets(): void;
  146554. private _copyBonesTransformationMatrices;
  146555. }
  146556. }
  146557. declare module BABYLON {
  146558. interface Scene {
  146559. /** @hidden (Backing field) */
  146560. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146561. /**
  146562. * Gets or Sets the current geometry buffer associated to the scene.
  146563. */
  146564. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146565. /**
  146566. * Enables a GeometryBufferRender and associates it with the scene
  146567. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  146568. * @returns the GeometryBufferRenderer
  146569. */
  146570. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  146571. /**
  146572. * Disables the GeometryBufferRender associated with the scene
  146573. */
  146574. disableGeometryBufferRenderer(): void;
  146575. }
  146576. /**
  146577. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  146578. * in several rendering techniques.
  146579. */
  146580. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  146581. /**
  146582. * The component name helpful to identify the component in the list of scene components.
  146583. */
  146584. readonly name: string;
  146585. /**
  146586. * The scene the component belongs to.
  146587. */
  146588. scene: Scene;
  146589. /**
  146590. * Creates a new instance of the component for the given scene
  146591. * @param scene Defines the scene to register the component in
  146592. */
  146593. constructor(scene: Scene);
  146594. /**
  146595. * Registers the component in a given scene
  146596. */
  146597. register(): void;
  146598. /**
  146599. * Rebuilds the elements related to this component in case of
  146600. * context lost for instance.
  146601. */
  146602. rebuild(): void;
  146603. /**
  146604. * Disposes the component and the associated ressources
  146605. */
  146606. dispose(): void;
  146607. private _gatherRenderTargets;
  146608. }
  146609. }
  146610. declare module BABYLON {
  146611. /** @hidden */
  146612. export var motionBlurPixelShader: {
  146613. name: string;
  146614. shader: string;
  146615. };
  146616. }
  146617. declare module BABYLON {
  146618. /**
  146619. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  146620. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  146621. * As an example, all you have to do is to create the post-process:
  146622. * var mb = new BABYLON.MotionBlurPostProcess(
  146623. * 'mb', // The name of the effect.
  146624. * scene, // The scene containing the objects to blur according to their velocity.
  146625. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146626. * camera // The camera to apply the render pass to.
  146627. * );
  146628. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146629. */
  146630. export class MotionBlurPostProcess extends PostProcess {
  146631. /**
  146632. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146633. */
  146634. motionStrength: number;
  146635. /**
  146636. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146637. */
  146638. get motionBlurSamples(): number;
  146639. /**
  146640. * Sets the number of iterations to be used for motion blur quality
  146641. */
  146642. set motionBlurSamples(samples: number);
  146643. private _motionBlurSamples;
  146644. private _geometryBufferRenderer;
  146645. /**
  146646. * Creates a new instance MotionBlurPostProcess
  146647. * @param name The name of the effect.
  146648. * @param scene The scene containing the objects to blur according to their velocity.
  146649. * @param options The required width/height ratio to downsize to before computing the render pass.
  146650. * @param camera The camera to apply the render pass to.
  146651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146652. * @param engine The engine which the post process will be applied. (default: current engine)
  146653. * @param reusable If the post process can be reused on the same frame. (default: false)
  146654. * @param textureType Type of textures used when performing the post process. (default: 0)
  146655. * @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)
  146656. */
  146657. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146658. /**
  146659. * Excludes the given skinned mesh from computing bones velocities.
  146660. * 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.
  146661. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146662. */
  146663. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146664. /**
  146665. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146666. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146667. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146668. */
  146669. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146670. /**
  146671. * Disposes the post process.
  146672. * @param camera The camera to dispose the post process on.
  146673. */
  146674. dispose(camera?: Camera): void;
  146675. }
  146676. }
  146677. declare module BABYLON {
  146678. /** @hidden */
  146679. export var refractionPixelShader: {
  146680. name: string;
  146681. shader: string;
  146682. };
  146683. }
  146684. declare module BABYLON {
  146685. /**
  146686. * Post process which applies a refractin texture
  146687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146688. */
  146689. export class RefractionPostProcess extends PostProcess {
  146690. /** the base color of the refraction (used to taint the rendering) */
  146691. color: Color3;
  146692. /** simulated refraction depth */
  146693. depth: number;
  146694. /** the coefficient of the base color (0 to remove base color tainting) */
  146695. colorLevel: number;
  146696. private _refTexture;
  146697. private _ownRefractionTexture;
  146698. /**
  146699. * Gets or sets the refraction texture
  146700. * Please note that you are responsible for disposing the texture if you set it manually
  146701. */
  146702. get refractionTexture(): Texture;
  146703. set refractionTexture(value: Texture);
  146704. /**
  146705. * Initializes the RefractionPostProcess
  146706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146707. * @param name The name of the effect.
  146708. * @param refractionTextureUrl Url of the refraction texture to use
  146709. * @param color the base color of the refraction (used to taint the rendering)
  146710. * @param depth simulated refraction depth
  146711. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146712. * @param camera The camera to apply the render pass to.
  146713. * @param options The required width/height ratio to downsize to before computing the render pass.
  146714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146715. * @param engine The engine which the post process will be applied. (default: current engine)
  146716. * @param reusable If the post process can be reused on the same frame. (default: false)
  146717. */
  146718. constructor(name: string, refractionTextureUrl: string,
  146719. /** the base color of the refraction (used to taint the rendering) */
  146720. color: Color3,
  146721. /** simulated refraction depth */
  146722. depth: number,
  146723. /** the coefficient of the base color (0 to remove base color tainting) */
  146724. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146725. /**
  146726. * Disposes of the post process
  146727. * @param camera Camera to dispose post process on
  146728. */
  146729. dispose(camera: Camera): void;
  146730. }
  146731. }
  146732. declare module BABYLON {
  146733. /** @hidden */
  146734. export var sharpenPixelShader: {
  146735. name: string;
  146736. shader: string;
  146737. };
  146738. }
  146739. declare module BABYLON {
  146740. /**
  146741. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146742. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146743. */
  146744. export class SharpenPostProcess extends PostProcess {
  146745. /**
  146746. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146747. */
  146748. colorAmount: number;
  146749. /**
  146750. * How much sharpness should be applied (default: 0.3)
  146751. */
  146752. edgeAmount: number;
  146753. /**
  146754. * Creates a new instance ConvolutionPostProcess
  146755. * @param name The name of the effect.
  146756. * @param options The required width/height ratio to downsize to before computing the render pass.
  146757. * @param camera The camera to apply the render pass to.
  146758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146759. * @param engine The engine which the post process will be applied. (default: current engine)
  146760. * @param reusable If the post process can be reused on the same frame. (default: false)
  146761. * @param textureType Type of textures used when performing the post process. (default: 0)
  146762. * @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)
  146763. */
  146764. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146765. }
  146766. }
  146767. declare module BABYLON {
  146768. /**
  146769. * PostProcessRenderPipeline
  146770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146771. */
  146772. export class PostProcessRenderPipeline {
  146773. private engine;
  146774. private _renderEffects;
  146775. private _renderEffectsForIsolatedPass;
  146776. /**
  146777. * List of inspectable custom properties (used by the Inspector)
  146778. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146779. */
  146780. inspectableCustomProperties: IInspectable[];
  146781. /**
  146782. * @hidden
  146783. */
  146784. protected _cameras: Camera[];
  146785. /** @hidden */
  146786. _name: string;
  146787. /**
  146788. * Gets pipeline name
  146789. */
  146790. get name(): string;
  146791. /** Gets the list of attached cameras */
  146792. get cameras(): Camera[];
  146793. /**
  146794. * Initializes a PostProcessRenderPipeline
  146795. * @param engine engine to add the pipeline to
  146796. * @param name name of the pipeline
  146797. */
  146798. constructor(engine: Engine, name: string);
  146799. /**
  146800. * Gets the class name
  146801. * @returns "PostProcessRenderPipeline"
  146802. */
  146803. getClassName(): string;
  146804. /**
  146805. * If all the render effects in the pipeline are supported
  146806. */
  146807. get isSupported(): boolean;
  146808. /**
  146809. * Adds an effect to the pipeline
  146810. * @param renderEffect the effect to add
  146811. */
  146812. addEffect(renderEffect: PostProcessRenderEffect): void;
  146813. /** @hidden */
  146814. _rebuild(): void;
  146815. /** @hidden */
  146816. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146817. /** @hidden */
  146818. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146819. /** @hidden */
  146820. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146821. /** @hidden */
  146822. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146823. /** @hidden */
  146824. _attachCameras(cameras: Camera, unique: boolean): void;
  146825. /** @hidden */
  146826. _attachCameras(cameras: Camera[], unique: boolean): void;
  146827. /** @hidden */
  146828. _detachCameras(cameras: Camera): void;
  146829. /** @hidden */
  146830. _detachCameras(cameras: Nullable<Camera[]>): void;
  146831. /** @hidden */
  146832. _update(): void;
  146833. /** @hidden */
  146834. _reset(): void;
  146835. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146836. /**
  146837. * Disposes of the pipeline
  146838. */
  146839. dispose(): void;
  146840. }
  146841. }
  146842. declare module BABYLON {
  146843. /**
  146844. * PostProcessRenderPipelineManager class
  146845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146846. */
  146847. export class PostProcessRenderPipelineManager {
  146848. private _renderPipelines;
  146849. /**
  146850. * Initializes a PostProcessRenderPipelineManager
  146851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146852. */
  146853. constructor();
  146854. /**
  146855. * Gets the list of supported render pipelines
  146856. */
  146857. get supportedPipelines(): PostProcessRenderPipeline[];
  146858. /**
  146859. * Adds a pipeline to the manager
  146860. * @param renderPipeline The pipeline to add
  146861. */
  146862. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146863. /**
  146864. * Attaches a camera to the pipeline
  146865. * @param renderPipelineName The name of the pipeline to attach to
  146866. * @param cameras the camera to attach
  146867. * @param unique if the camera can be attached multiple times to the pipeline
  146868. */
  146869. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146870. /**
  146871. * Detaches a camera from the pipeline
  146872. * @param renderPipelineName The name of the pipeline to detach from
  146873. * @param cameras the camera to detach
  146874. */
  146875. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146876. /**
  146877. * Enables an effect by name on a pipeline
  146878. * @param renderPipelineName the name of the pipeline to enable the effect in
  146879. * @param renderEffectName the name of the effect to enable
  146880. * @param cameras the cameras that the effect should be enabled on
  146881. */
  146882. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146883. /**
  146884. * Disables an effect by name on a pipeline
  146885. * @param renderPipelineName the name of the pipeline to disable the effect in
  146886. * @param renderEffectName the name of the effect to disable
  146887. * @param cameras the cameras that the effect should be disabled on
  146888. */
  146889. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146890. /**
  146891. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146892. */
  146893. update(): void;
  146894. /** @hidden */
  146895. _rebuild(): void;
  146896. /**
  146897. * Disposes of the manager and pipelines
  146898. */
  146899. dispose(): void;
  146900. }
  146901. }
  146902. declare module BABYLON {
  146903. interface Scene {
  146904. /** @hidden (Backing field) */
  146905. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146906. /**
  146907. * Gets the postprocess render pipeline manager
  146908. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146909. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146910. */
  146911. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146912. }
  146913. /**
  146914. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146915. */
  146916. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146917. /**
  146918. * The component name helpfull to identify the component in the list of scene components.
  146919. */
  146920. readonly name: string;
  146921. /**
  146922. * The scene the component belongs to.
  146923. */
  146924. scene: Scene;
  146925. /**
  146926. * Creates a new instance of the component for the given scene
  146927. * @param scene Defines the scene to register the component in
  146928. */
  146929. constructor(scene: Scene);
  146930. /**
  146931. * Registers the component in a given scene
  146932. */
  146933. register(): void;
  146934. /**
  146935. * Rebuilds the elements related to this component in case of
  146936. * context lost for instance.
  146937. */
  146938. rebuild(): void;
  146939. /**
  146940. * Disposes the component and the associated ressources
  146941. */
  146942. dispose(): void;
  146943. private _gatherRenderTargets;
  146944. }
  146945. }
  146946. declare module BABYLON {
  146947. /**
  146948. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146949. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146950. */
  146951. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146952. private _scene;
  146953. private _camerasToBeAttached;
  146954. /**
  146955. * ID of the sharpen post process,
  146956. */
  146957. private readonly SharpenPostProcessId;
  146958. /**
  146959. * @ignore
  146960. * ID of the image processing post process;
  146961. */
  146962. readonly ImageProcessingPostProcessId: string;
  146963. /**
  146964. * @ignore
  146965. * ID of the Fast Approximate Anti-Aliasing post process;
  146966. */
  146967. readonly FxaaPostProcessId: string;
  146968. /**
  146969. * ID of the chromatic aberration post process,
  146970. */
  146971. private readonly ChromaticAberrationPostProcessId;
  146972. /**
  146973. * ID of the grain post process
  146974. */
  146975. private readonly GrainPostProcessId;
  146976. /**
  146977. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146978. */
  146979. sharpen: SharpenPostProcess;
  146980. private _sharpenEffect;
  146981. private bloom;
  146982. /**
  146983. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146984. */
  146985. depthOfField: DepthOfFieldEffect;
  146986. /**
  146987. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146988. */
  146989. fxaa: FxaaPostProcess;
  146990. /**
  146991. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146992. */
  146993. imageProcessing: ImageProcessingPostProcess;
  146994. /**
  146995. * Chromatic aberration post process which will shift rgb colors in the image
  146996. */
  146997. chromaticAberration: ChromaticAberrationPostProcess;
  146998. private _chromaticAberrationEffect;
  146999. /**
  147000. * Grain post process which add noise to the image
  147001. */
  147002. grain: GrainPostProcess;
  147003. private _grainEffect;
  147004. /**
  147005. * Glow post process which adds a glow to emissive areas of the image
  147006. */
  147007. private _glowLayer;
  147008. /**
  147009. * Animations which can be used to tweak settings over a period of time
  147010. */
  147011. animations: Animation[];
  147012. private _imageProcessingConfigurationObserver;
  147013. private _sharpenEnabled;
  147014. private _bloomEnabled;
  147015. private _depthOfFieldEnabled;
  147016. private _depthOfFieldBlurLevel;
  147017. private _fxaaEnabled;
  147018. private _imageProcessingEnabled;
  147019. private _defaultPipelineTextureType;
  147020. private _bloomScale;
  147021. private _chromaticAberrationEnabled;
  147022. private _grainEnabled;
  147023. private _buildAllowed;
  147024. /**
  147025. * Gets active scene
  147026. */
  147027. get scene(): Scene;
  147028. /**
  147029. * Enable or disable the sharpen process from the pipeline
  147030. */
  147031. set sharpenEnabled(enabled: boolean);
  147032. get sharpenEnabled(): boolean;
  147033. private _resizeObserver;
  147034. private _hardwareScaleLevel;
  147035. private _bloomKernel;
  147036. /**
  147037. * Specifies the size of the bloom blur kernel, relative to the final output size
  147038. */
  147039. get bloomKernel(): number;
  147040. set bloomKernel(value: number);
  147041. /**
  147042. * Specifies the weight of the bloom in the final rendering
  147043. */
  147044. private _bloomWeight;
  147045. /**
  147046. * Specifies the luma threshold for the area that will be blurred by the bloom
  147047. */
  147048. private _bloomThreshold;
  147049. private _hdr;
  147050. /**
  147051. * The strength of the bloom.
  147052. */
  147053. set bloomWeight(value: number);
  147054. get bloomWeight(): number;
  147055. /**
  147056. * The strength of the bloom.
  147057. */
  147058. set bloomThreshold(value: number);
  147059. get bloomThreshold(): number;
  147060. /**
  147061. * The scale of the bloom, lower value will provide better performance.
  147062. */
  147063. set bloomScale(value: number);
  147064. get bloomScale(): number;
  147065. /**
  147066. * Enable or disable the bloom from the pipeline
  147067. */
  147068. set bloomEnabled(enabled: boolean);
  147069. get bloomEnabled(): boolean;
  147070. private _rebuildBloom;
  147071. /**
  147072. * If the depth of field is enabled.
  147073. */
  147074. get depthOfFieldEnabled(): boolean;
  147075. set depthOfFieldEnabled(enabled: boolean);
  147076. /**
  147077. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147078. */
  147079. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147080. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147081. /**
  147082. * If the anti aliasing is enabled.
  147083. */
  147084. set fxaaEnabled(enabled: boolean);
  147085. get fxaaEnabled(): boolean;
  147086. private _samples;
  147087. /**
  147088. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147089. */
  147090. set samples(sampleCount: number);
  147091. get samples(): number;
  147092. /**
  147093. * If image processing is enabled.
  147094. */
  147095. set imageProcessingEnabled(enabled: boolean);
  147096. get imageProcessingEnabled(): boolean;
  147097. /**
  147098. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147099. */
  147100. set glowLayerEnabled(enabled: boolean);
  147101. get glowLayerEnabled(): boolean;
  147102. /**
  147103. * Gets the glow layer (or null if not defined)
  147104. */
  147105. get glowLayer(): Nullable<GlowLayer>;
  147106. /**
  147107. * Enable or disable the chromaticAberration process from the pipeline
  147108. */
  147109. set chromaticAberrationEnabled(enabled: boolean);
  147110. get chromaticAberrationEnabled(): boolean;
  147111. /**
  147112. * Enable or disable the grain process from the pipeline
  147113. */
  147114. set grainEnabled(enabled: boolean);
  147115. get grainEnabled(): boolean;
  147116. /**
  147117. * @constructor
  147118. * @param name - The rendering pipeline name (default: "")
  147119. * @param hdr - If high dynamic range textures should be used (default: true)
  147120. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147121. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147122. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147123. */
  147124. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147125. /**
  147126. * Get the class name
  147127. * @returns "DefaultRenderingPipeline"
  147128. */
  147129. getClassName(): string;
  147130. /**
  147131. * Force the compilation of the entire pipeline.
  147132. */
  147133. prepare(): void;
  147134. private _hasCleared;
  147135. private _prevPostProcess;
  147136. private _prevPrevPostProcess;
  147137. private _setAutoClearAndTextureSharing;
  147138. private _depthOfFieldSceneObserver;
  147139. private _buildPipeline;
  147140. private _disposePostProcesses;
  147141. /**
  147142. * Adds a camera to the pipeline
  147143. * @param camera the camera to be added
  147144. */
  147145. addCamera(camera: Camera): void;
  147146. /**
  147147. * Removes a camera from the pipeline
  147148. * @param camera the camera to remove
  147149. */
  147150. removeCamera(camera: Camera): void;
  147151. /**
  147152. * Dispose of the pipeline and stop all post processes
  147153. */
  147154. dispose(): void;
  147155. /**
  147156. * Serialize the rendering pipeline (Used when exporting)
  147157. * @returns the serialized object
  147158. */
  147159. serialize(): any;
  147160. /**
  147161. * Parse the serialized pipeline
  147162. * @param source Source pipeline.
  147163. * @param scene The scene to load the pipeline to.
  147164. * @param rootUrl The URL of the serialized pipeline.
  147165. * @returns An instantiated pipeline from the serialized object.
  147166. */
  147167. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147168. }
  147169. }
  147170. declare module BABYLON {
  147171. /** @hidden */
  147172. export var lensHighlightsPixelShader: {
  147173. name: string;
  147174. shader: string;
  147175. };
  147176. }
  147177. declare module BABYLON {
  147178. /** @hidden */
  147179. export var depthOfFieldPixelShader: {
  147180. name: string;
  147181. shader: string;
  147182. };
  147183. }
  147184. declare module BABYLON {
  147185. /**
  147186. * BABYLON.JS Chromatic Aberration GLSL Shader
  147187. * Author: Olivier Guyot
  147188. * Separates very slightly R, G and B colors on the edges of the screen
  147189. * Inspired by Francois Tarlier & Martins Upitis
  147190. */
  147191. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147192. /**
  147193. * @ignore
  147194. * The chromatic aberration PostProcess id in the pipeline
  147195. */
  147196. LensChromaticAberrationEffect: string;
  147197. /**
  147198. * @ignore
  147199. * The highlights enhancing PostProcess id in the pipeline
  147200. */
  147201. HighlightsEnhancingEffect: string;
  147202. /**
  147203. * @ignore
  147204. * The depth-of-field PostProcess id in the pipeline
  147205. */
  147206. LensDepthOfFieldEffect: string;
  147207. private _scene;
  147208. private _depthTexture;
  147209. private _grainTexture;
  147210. private _chromaticAberrationPostProcess;
  147211. private _highlightsPostProcess;
  147212. private _depthOfFieldPostProcess;
  147213. private _edgeBlur;
  147214. private _grainAmount;
  147215. private _chromaticAberration;
  147216. private _distortion;
  147217. private _highlightsGain;
  147218. private _highlightsThreshold;
  147219. private _dofDistance;
  147220. private _dofAperture;
  147221. private _dofDarken;
  147222. private _dofPentagon;
  147223. private _blurNoise;
  147224. /**
  147225. * @constructor
  147226. *
  147227. * Effect parameters are as follow:
  147228. * {
  147229. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147230. * edge_blur: number; // from 0 to x (1 for realism)
  147231. * distortion: number; // from 0 to x (1 for realism)
  147232. * grain_amount: number; // from 0 to 1
  147233. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147234. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147235. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147236. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147237. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147238. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147239. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147240. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147241. * }
  147242. * Note: if an effect parameter is unset, effect is disabled
  147243. *
  147244. * @param name The rendering pipeline name
  147245. * @param parameters - An object containing all parameters (see above)
  147246. * @param scene The scene linked to this pipeline
  147247. * @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)
  147248. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147249. */
  147250. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147251. /**
  147252. * Get the class name
  147253. * @returns "LensRenderingPipeline"
  147254. */
  147255. getClassName(): string;
  147256. /**
  147257. * Gets associated scene
  147258. */
  147259. get scene(): Scene;
  147260. /**
  147261. * Gets or sets the edge blur
  147262. */
  147263. get edgeBlur(): number;
  147264. set edgeBlur(value: number);
  147265. /**
  147266. * Gets or sets the grain amount
  147267. */
  147268. get grainAmount(): number;
  147269. set grainAmount(value: number);
  147270. /**
  147271. * Gets or sets the chromatic aberration amount
  147272. */
  147273. get chromaticAberration(): number;
  147274. set chromaticAberration(value: number);
  147275. /**
  147276. * Gets or sets the depth of field aperture
  147277. */
  147278. get dofAperture(): number;
  147279. set dofAperture(value: number);
  147280. /**
  147281. * Gets or sets the edge distortion
  147282. */
  147283. get edgeDistortion(): number;
  147284. set edgeDistortion(value: number);
  147285. /**
  147286. * Gets or sets the depth of field distortion
  147287. */
  147288. get dofDistortion(): number;
  147289. set dofDistortion(value: number);
  147290. /**
  147291. * Gets or sets the darken out of focus amount
  147292. */
  147293. get darkenOutOfFocus(): number;
  147294. set darkenOutOfFocus(value: number);
  147295. /**
  147296. * Gets or sets a boolean indicating if blur noise is enabled
  147297. */
  147298. get blurNoise(): boolean;
  147299. set blurNoise(value: boolean);
  147300. /**
  147301. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147302. */
  147303. get pentagonBokeh(): boolean;
  147304. set pentagonBokeh(value: boolean);
  147305. /**
  147306. * Gets or sets the highlight grain amount
  147307. */
  147308. get highlightsGain(): number;
  147309. set highlightsGain(value: number);
  147310. /**
  147311. * Gets or sets the highlight threshold
  147312. */
  147313. get highlightsThreshold(): number;
  147314. set highlightsThreshold(value: number);
  147315. /**
  147316. * Sets the amount of blur at the edges
  147317. * @param amount blur amount
  147318. */
  147319. setEdgeBlur(amount: number): void;
  147320. /**
  147321. * Sets edge blur to 0
  147322. */
  147323. disableEdgeBlur(): void;
  147324. /**
  147325. * Sets the amout of grain
  147326. * @param amount Amount of grain
  147327. */
  147328. setGrainAmount(amount: number): void;
  147329. /**
  147330. * Set grain amount to 0
  147331. */
  147332. disableGrain(): void;
  147333. /**
  147334. * Sets the chromatic aberration amount
  147335. * @param amount amount of chromatic aberration
  147336. */
  147337. setChromaticAberration(amount: number): void;
  147338. /**
  147339. * Sets chromatic aberration amount to 0
  147340. */
  147341. disableChromaticAberration(): void;
  147342. /**
  147343. * Sets the EdgeDistortion amount
  147344. * @param amount amount of EdgeDistortion
  147345. */
  147346. setEdgeDistortion(amount: number): void;
  147347. /**
  147348. * Sets edge distortion to 0
  147349. */
  147350. disableEdgeDistortion(): void;
  147351. /**
  147352. * Sets the FocusDistance amount
  147353. * @param amount amount of FocusDistance
  147354. */
  147355. setFocusDistance(amount: number): void;
  147356. /**
  147357. * Disables depth of field
  147358. */
  147359. disableDepthOfField(): void;
  147360. /**
  147361. * Sets the Aperture amount
  147362. * @param amount amount of Aperture
  147363. */
  147364. setAperture(amount: number): void;
  147365. /**
  147366. * Sets the DarkenOutOfFocus amount
  147367. * @param amount amount of DarkenOutOfFocus
  147368. */
  147369. setDarkenOutOfFocus(amount: number): void;
  147370. private _pentagonBokehIsEnabled;
  147371. /**
  147372. * Creates a pentagon bokeh effect
  147373. */
  147374. enablePentagonBokeh(): void;
  147375. /**
  147376. * Disables the pentagon bokeh effect
  147377. */
  147378. disablePentagonBokeh(): void;
  147379. /**
  147380. * Enables noise blur
  147381. */
  147382. enableNoiseBlur(): void;
  147383. /**
  147384. * Disables noise blur
  147385. */
  147386. disableNoiseBlur(): void;
  147387. /**
  147388. * Sets the HighlightsGain amount
  147389. * @param amount amount of HighlightsGain
  147390. */
  147391. setHighlightsGain(amount: number): void;
  147392. /**
  147393. * Sets the HighlightsThreshold amount
  147394. * @param amount amount of HighlightsThreshold
  147395. */
  147396. setHighlightsThreshold(amount: number): void;
  147397. /**
  147398. * Disables highlights
  147399. */
  147400. disableHighlights(): void;
  147401. /**
  147402. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147403. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147404. */
  147405. dispose(disableDepthRender?: boolean): void;
  147406. private _createChromaticAberrationPostProcess;
  147407. private _createHighlightsPostProcess;
  147408. private _createDepthOfFieldPostProcess;
  147409. private _createGrainTexture;
  147410. }
  147411. }
  147412. declare module BABYLON {
  147413. /** @hidden */
  147414. export var ssao2PixelShader: {
  147415. name: string;
  147416. shader: string;
  147417. };
  147418. }
  147419. declare module BABYLON {
  147420. /** @hidden */
  147421. export var ssaoCombinePixelShader: {
  147422. name: string;
  147423. shader: string;
  147424. };
  147425. }
  147426. declare module BABYLON {
  147427. /**
  147428. * Render pipeline to produce ssao effect
  147429. */
  147430. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147431. /**
  147432. * @ignore
  147433. * The PassPostProcess id in the pipeline that contains the original scene color
  147434. */
  147435. SSAOOriginalSceneColorEffect: string;
  147436. /**
  147437. * @ignore
  147438. * The SSAO PostProcess id in the pipeline
  147439. */
  147440. SSAORenderEffect: string;
  147441. /**
  147442. * @ignore
  147443. * The horizontal blur PostProcess id in the pipeline
  147444. */
  147445. SSAOBlurHRenderEffect: string;
  147446. /**
  147447. * @ignore
  147448. * The vertical blur PostProcess id in the pipeline
  147449. */
  147450. SSAOBlurVRenderEffect: string;
  147451. /**
  147452. * @ignore
  147453. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147454. */
  147455. SSAOCombineRenderEffect: string;
  147456. /**
  147457. * The output strength of the SSAO post-process. Default value is 1.0.
  147458. */
  147459. totalStrength: number;
  147460. /**
  147461. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147462. */
  147463. maxZ: number;
  147464. /**
  147465. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147466. */
  147467. minZAspect: number;
  147468. private _samples;
  147469. /**
  147470. * Number of samples used for the SSAO calculations. Default value is 8
  147471. */
  147472. set samples(n: number);
  147473. get samples(): number;
  147474. private _textureSamples;
  147475. /**
  147476. * Number of samples to use for antialiasing
  147477. */
  147478. set textureSamples(n: number);
  147479. get textureSamples(): number;
  147480. /**
  147481. * Ratio object used for SSAO ratio and blur ratio
  147482. */
  147483. private _ratio;
  147484. /**
  147485. * Dynamically generated sphere sampler.
  147486. */
  147487. private _sampleSphere;
  147488. /**
  147489. * Blur filter offsets
  147490. */
  147491. private _samplerOffsets;
  147492. private _expensiveBlur;
  147493. /**
  147494. * If bilateral blur should be used
  147495. */
  147496. set expensiveBlur(b: boolean);
  147497. get expensiveBlur(): boolean;
  147498. /**
  147499. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147500. */
  147501. radius: number;
  147502. /**
  147503. * The base color of the SSAO post-process
  147504. * The final result is "base + ssao" between [0, 1]
  147505. */
  147506. base: number;
  147507. /**
  147508. * Support test.
  147509. */
  147510. static get IsSupported(): boolean;
  147511. private _scene;
  147512. private _depthTexture;
  147513. private _normalTexture;
  147514. private _randomTexture;
  147515. private _originalColorPostProcess;
  147516. private _ssaoPostProcess;
  147517. private _blurHPostProcess;
  147518. private _blurVPostProcess;
  147519. private _ssaoCombinePostProcess;
  147520. /**
  147521. * Gets active scene
  147522. */
  147523. get scene(): Scene;
  147524. /**
  147525. * @constructor
  147526. * @param name The rendering pipeline name
  147527. * @param scene The scene linked to this pipeline
  147528. * @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 }
  147529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147530. */
  147531. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147532. /**
  147533. * Get the class name
  147534. * @returns "SSAO2RenderingPipeline"
  147535. */
  147536. getClassName(): string;
  147537. /**
  147538. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147539. */
  147540. dispose(disableGeometryBufferRenderer?: boolean): void;
  147541. private _createBlurPostProcess;
  147542. /** @hidden */
  147543. _rebuild(): void;
  147544. private _bits;
  147545. private _radicalInverse_VdC;
  147546. private _hammersley;
  147547. private _hemisphereSample_uniform;
  147548. private _generateHemisphere;
  147549. private _createSSAOPostProcess;
  147550. private _createSSAOCombinePostProcess;
  147551. private _createRandomTexture;
  147552. /**
  147553. * Serialize the rendering pipeline (Used when exporting)
  147554. * @returns the serialized object
  147555. */
  147556. serialize(): any;
  147557. /**
  147558. * Parse the serialized pipeline
  147559. * @param source Source pipeline.
  147560. * @param scene The scene to load the pipeline to.
  147561. * @param rootUrl The URL of the serialized pipeline.
  147562. * @returns An instantiated pipeline from the serialized object.
  147563. */
  147564. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  147565. }
  147566. }
  147567. declare module BABYLON {
  147568. /** @hidden */
  147569. export var ssaoPixelShader: {
  147570. name: string;
  147571. shader: string;
  147572. };
  147573. }
  147574. declare module BABYLON {
  147575. /**
  147576. * Render pipeline to produce ssao effect
  147577. */
  147578. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  147579. /**
  147580. * @ignore
  147581. * The PassPostProcess id in the pipeline that contains the original scene color
  147582. */
  147583. SSAOOriginalSceneColorEffect: string;
  147584. /**
  147585. * @ignore
  147586. * The SSAO PostProcess id in the pipeline
  147587. */
  147588. SSAORenderEffect: string;
  147589. /**
  147590. * @ignore
  147591. * The horizontal blur PostProcess id in the pipeline
  147592. */
  147593. SSAOBlurHRenderEffect: string;
  147594. /**
  147595. * @ignore
  147596. * The vertical blur PostProcess id in the pipeline
  147597. */
  147598. SSAOBlurVRenderEffect: string;
  147599. /**
  147600. * @ignore
  147601. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147602. */
  147603. SSAOCombineRenderEffect: string;
  147604. /**
  147605. * The output strength of the SSAO post-process. Default value is 1.0.
  147606. */
  147607. totalStrength: number;
  147608. /**
  147609. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  147610. */
  147611. radius: number;
  147612. /**
  147613. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  147614. * Must not be equal to fallOff and superior to fallOff.
  147615. * Default value is 0.0075
  147616. */
  147617. area: number;
  147618. /**
  147619. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  147620. * Must not be equal to area and inferior to area.
  147621. * Default value is 0.000001
  147622. */
  147623. fallOff: number;
  147624. /**
  147625. * The base color of the SSAO post-process
  147626. * The final result is "base + ssao" between [0, 1]
  147627. */
  147628. base: number;
  147629. private _scene;
  147630. private _depthTexture;
  147631. private _randomTexture;
  147632. private _originalColorPostProcess;
  147633. private _ssaoPostProcess;
  147634. private _blurHPostProcess;
  147635. private _blurVPostProcess;
  147636. private _ssaoCombinePostProcess;
  147637. private _firstUpdate;
  147638. /**
  147639. * Gets active scene
  147640. */
  147641. get scene(): Scene;
  147642. /**
  147643. * @constructor
  147644. * @param name - The rendering pipeline name
  147645. * @param scene - The scene linked to this pipeline
  147646. * @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 }
  147647. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147648. */
  147649. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147650. /**
  147651. * Get the class name
  147652. * @returns "SSAORenderingPipeline"
  147653. */
  147654. getClassName(): string;
  147655. /**
  147656. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147657. */
  147658. dispose(disableDepthRender?: boolean): void;
  147659. private _createBlurPostProcess;
  147660. /** @hidden */
  147661. _rebuild(): void;
  147662. private _createSSAOPostProcess;
  147663. private _createSSAOCombinePostProcess;
  147664. private _createRandomTexture;
  147665. }
  147666. }
  147667. declare module BABYLON {
  147668. /** @hidden */
  147669. export var screenSpaceReflectionPixelShader: {
  147670. name: string;
  147671. shader: string;
  147672. };
  147673. }
  147674. declare module BABYLON {
  147675. /**
  147676. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147677. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147678. */
  147679. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147680. /**
  147681. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147682. */
  147683. threshold: number;
  147684. /**
  147685. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147686. */
  147687. strength: number;
  147688. /**
  147689. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147690. */
  147691. reflectionSpecularFalloffExponent: number;
  147692. /**
  147693. * 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]
  147694. */
  147695. step: number;
  147696. /**
  147697. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147698. */
  147699. roughnessFactor: number;
  147700. private _geometryBufferRenderer;
  147701. private _enableSmoothReflections;
  147702. private _reflectionSamples;
  147703. private _smoothSteps;
  147704. /**
  147705. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147706. * @param name The name of the effect.
  147707. * @param scene The scene containing the objects to calculate reflections.
  147708. * @param options The required width/height ratio to downsize to before computing the render pass.
  147709. * @param camera The camera to apply the render pass to.
  147710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147711. * @param engine The engine which the post process will be applied. (default: current engine)
  147712. * @param reusable If the post process can be reused on the same frame. (default: false)
  147713. * @param textureType Type of textures used when performing the post process. (default: 0)
  147714. * @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)
  147715. */
  147716. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147717. /**
  147718. * Gets wether or not smoothing reflections is enabled.
  147719. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147720. */
  147721. get enableSmoothReflections(): boolean;
  147722. /**
  147723. * Sets wether or not smoothing reflections is enabled.
  147724. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147725. */
  147726. set enableSmoothReflections(enabled: boolean);
  147727. /**
  147728. * Gets the number of samples taken while computing reflections. More samples count is high,
  147729. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147730. */
  147731. get reflectionSamples(): number;
  147732. /**
  147733. * Sets the number of samples taken while computing reflections. More samples count is high,
  147734. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147735. */
  147736. set reflectionSamples(samples: number);
  147737. /**
  147738. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147739. * more the post-process will require GPU power and can generate a drop in FPS.
  147740. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147741. */
  147742. get smoothSteps(): number;
  147743. set smoothSteps(steps: number);
  147744. private _updateEffectDefines;
  147745. }
  147746. }
  147747. declare module BABYLON {
  147748. /** @hidden */
  147749. export var standardPixelShader: {
  147750. name: string;
  147751. shader: string;
  147752. };
  147753. }
  147754. declare module BABYLON {
  147755. /**
  147756. * Standard rendering pipeline
  147757. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147758. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147759. */
  147760. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147761. /**
  147762. * Public members
  147763. */
  147764. /**
  147765. * Post-process which contains the original scene color before the pipeline applies all the effects
  147766. */
  147767. originalPostProcess: Nullable<PostProcess>;
  147768. /**
  147769. * Post-process used to down scale an image x4
  147770. */
  147771. downSampleX4PostProcess: Nullable<PostProcess>;
  147772. /**
  147773. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147774. */
  147775. brightPassPostProcess: Nullable<PostProcess>;
  147776. /**
  147777. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147778. */
  147779. blurHPostProcesses: PostProcess[];
  147780. /**
  147781. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147782. */
  147783. blurVPostProcesses: PostProcess[];
  147784. /**
  147785. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147786. */
  147787. textureAdderPostProcess: Nullable<PostProcess>;
  147788. /**
  147789. * Post-process used to create volumetric lighting effect
  147790. */
  147791. volumetricLightPostProcess: Nullable<PostProcess>;
  147792. /**
  147793. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147794. */
  147795. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147796. /**
  147797. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147798. */
  147799. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147800. /**
  147801. * Post-process used to merge the volumetric light effect and the real scene color
  147802. */
  147803. volumetricLightMergePostProces: Nullable<PostProcess>;
  147804. /**
  147805. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147806. */
  147807. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147808. /**
  147809. * Base post-process used to calculate the average luminance of the final image for HDR
  147810. */
  147811. luminancePostProcess: Nullable<PostProcess>;
  147812. /**
  147813. * Post-processes used to create down sample post-processes in order to get
  147814. * the average luminance of the final image for HDR
  147815. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147816. */
  147817. luminanceDownSamplePostProcesses: PostProcess[];
  147818. /**
  147819. * Post-process used to create a HDR effect (light adaptation)
  147820. */
  147821. hdrPostProcess: Nullable<PostProcess>;
  147822. /**
  147823. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147824. */
  147825. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147826. /**
  147827. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147828. */
  147829. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147830. /**
  147831. * Post-process used to merge the final HDR post-process and the real scene color
  147832. */
  147833. hdrFinalPostProcess: Nullable<PostProcess>;
  147834. /**
  147835. * Post-process used to create a lens flare effect
  147836. */
  147837. lensFlarePostProcess: Nullable<PostProcess>;
  147838. /**
  147839. * Post-process that merges the result of the lens flare post-process and the real scene color
  147840. */
  147841. lensFlareComposePostProcess: Nullable<PostProcess>;
  147842. /**
  147843. * Post-process used to create a motion blur effect
  147844. */
  147845. motionBlurPostProcess: Nullable<PostProcess>;
  147846. /**
  147847. * Post-process used to create a depth of field effect
  147848. */
  147849. depthOfFieldPostProcess: Nullable<PostProcess>;
  147850. /**
  147851. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147852. */
  147853. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147854. /**
  147855. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147856. */
  147857. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147858. /**
  147859. * Represents the brightness threshold in order to configure the illuminated surfaces
  147860. */
  147861. brightThreshold: number;
  147862. /**
  147863. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147864. */
  147865. blurWidth: number;
  147866. /**
  147867. * Sets if the blur for highlighted surfaces must be only horizontal
  147868. */
  147869. horizontalBlur: boolean;
  147870. /**
  147871. * Gets the overall exposure used by the pipeline
  147872. */
  147873. get exposure(): number;
  147874. /**
  147875. * Sets the overall exposure used by the pipeline
  147876. */
  147877. set exposure(value: number);
  147878. /**
  147879. * Texture used typically to simulate "dirty" on camera lens
  147880. */
  147881. lensTexture: Nullable<Texture>;
  147882. /**
  147883. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147884. */
  147885. volumetricLightCoefficient: number;
  147886. /**
  147887. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147888. */
  147889. volumetricLightPower: number;
  147890. /**
  147891. * Used the set the blur intensity to smooth the volumetric lights
  147892. */
  147893. volumetricLightBlurScale: number;
  147894. /**
  147895. * Light (spot or directional) used to generate the volumetric lights rays
  147896. * The source light must have a shadow generate so the pipeline can get its
  147897. * depth map
  147898. */
  147899. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147900. /**
  147901. * For eye adaptation, represents the minimum luminance the eye can see
  147902. */
  147903. hdrMinimumLuminance: number;
  147904. /**
  147905. * For eye adaptation, represents the decrease luminance speed
  147906. */
  147907. hdrDecreaseRate: number;
  147908. /**
  147909. * For eye adaptation, represents the increase luminance speed
  147910. */
  147911. hdrIncreaseRate: number;
  147912. /**
  147913. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147914. */
  147915. get hdrAutoExposure(): boolean;
  147916. /**
  147917. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147918. */
  147919. set hdrAutoExposure(value: boolean);
  147920. /**
  147921. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147922. */
  147923. lensColorTexture: Nullable<Texture>;
  147924. /**
  147925. * The overall strengh for the lens flare effect
  147926. */
  147927. lensFlareStrength: number;
  147928. /**
  147929. * Dispersion coefficient for lens flare ghosts
  147930. */
  147931. lensFlareGhostDispersal: number;
  147932. /**
  147933. * Main lens flare halo width
  147934. */
  147935. lensFlareHaloWidth: number;
  147936. /**
  147937. * Based on the lens distortion effect, defines how much the lens flare result
  147938. * is distorted
  147939. */
  147940. lensFlareDistortionStrength: number;
  147941. /**
  147942. * Configures the blur intensity used for for lens flare (halo)
  147943. */
  147944. lensFlareBlurWidth: number;
  147945. /**
  147946. * Lens star texture must be used to simulate rays on the flares and is available
  147947. * in the documentation
  147948. */
  147949. lensStarTexture: Nullable<Texture>;
  147950. /**
  147951. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147952. * flare effect by taking account of the dirt texture
  147953. */
  147954. lensFlareDirtTexture: Nullable<Texture>;
  147955. /**
  147956. * Represents the focal length for the depth of field effect
  147957. */
  147958. depthOfFieldDistance: number;
  147959. /**
  147960. * Represents the blur intensity for the blurred part of the depth of field effect
  147961. */
  147962. depthOfFieldBlurWidth: number;
  147963. /**
  147964. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147965. */
  147966. get motionStrength(): number;
  147967. /**
  147968. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147969. */
  147970. set motionStrength(strength: number);
  147971. /**
  147972. * Gets wether or not the motion blur post-process is object based or screen based.
  147973. */
  147974. get objectBasedMotionBlur(): boolean;
  147975. /**
  147976. * Sets wether or not the motion blur post-process should be object based or screen based
  147977. */
  147978. set objectBasedMotionBlur(value: boolean);
  147979. /**
  147980. * List of animations for the pipeline (IAnimatable implementation)
  147981. */
  147982. animations: Animation[];
  147983. /**
  147984. * Private members
  147985. */
  147986. private _scene;
  147987. private _currentDepthOfFieldSource;
  147988. private _basePostProcess;
  147989. private _fixedExposure;
  147990. private _currentExposure;
  147991. private _hdrAutoExposure;
  147992. private _hdrCurrentLuminance;
  147993. private _motionStrength;
  147994. private _isObjectBasedMotionBlur;
  147995. private _floatTextureType;
  147996. private _camerasToBeAttached;
  147997. private _ratio;
  147998. private _bloomEnabled;
  147999. private _depthOfFieldEnabled;
  148000. private _vlsEnabled;
  148001. private _lensFlareEnabled;
  148002. private _hdrEnabled;
  148003. private _motionBlurEnabled;
  148004. private _fxaaEnabled;
  148005. private _screenSpaceReflectionsEnabled;
  148006. private _motionBlurSamples;
  148007. private _volumetricLightStepsCount;
  148008. private _samples;
  148009. /**
  148010. * @ignore
  148011. * Specifies if the bloom pipeline is enabled
  148012. */
  148013. get BloomEnabled(): boolean;
  148014. set BloomEnabled(enabled: boolean);
  148015. /**
  148016. * @ignore
  148017. * Specifies if the depth of field pipeline is enabed
  148018. */
  148019. get DepthOfFieldEnabled(): boolean;
  148020. set DepthOfFieldEnabled(enabled: boolean);
  148021. /**
  148022. * @ignore
  148023. * Specifies if the lens flare pipeline is enabed
  148024. */
  148025. get LensFlareEnabled(): boolean;
  148026. set LensFlareEnabled(enabled: boolean);
  148027. /**
  148028. * @ignore
  148029. * Specifies if the HDR pipeline is enabled
  148030. */
  148031. get HDREnabled(): boolean;
  148032. set HDREnabled(enabled: boolean);
  148033. /**
  148034. * @ignore
  148035. * Specifies if the volumetric lights scattering effect is enabled
  148036. */
  148037. get VLSEnabled(): boolean;
  148038. set VLSEnabled(enabled: boolean);
  148039. /**
  148040. * @ignore
  148041. * Specifies if the motion blur effect is enabled
  148042. */
  148043. get MotionBlurEnabled(): boolean;
  148044. set MotionBlurEnabled(enabled: boolean);
  148045. /**
  148046. * Specifies if anti-aliasing is enabled
  148047. */
  148048. get fxaaEnabled(): boolean;
  148049. set fxaaEnabled(enabled: boolean);
  148050. /**
  148051. * Specifies if screen space reflections are enabled.
  148052. */
  148053. get screenSpaceReflectionsEnabled(): boolean;
  148054. set screenSpaceReflectionsEnabled(enabled: boolean);
  148055. /**
  148056. * Specifies the number of steps used to calculate the volumetric lights
  148057. * Typically in interval [50, 200]
  148058. */
  148059. get volumetricLightStepsCount(): number;
  148060. set volumetricLightStepsCount(count: number);
  148061. /**
  148062. * Specifies the number of samples used for the motion blur effect
  148063. * Typically in interval [16, 64]
  148064. */
  148065. get motionBlurSamples(): number;
  148066. set motionBlurSamples(samples: number);
  148067. /**
  148068. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148069. */
  148070. get samples(): number;
  148071. set samples(sampleCount: number);
  148072. /**
  148073. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148074. * @constructor
  148075. * @param name The rendering pipeline name
  148076. * @param scene The scene linked to this pipeline
  148077. * @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)
  148078. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148080. */
  148081. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148082. private _buildPipeline;
  148083. private _createDownSampleX4PostProcess;
  148084. private _createBrightPassPostProcess;
  148085. private _createBlurPostProcesses;
  148086. private _createTextureAdderPostProcess;
  148087. private _createVolumetricLightPostProcess;
  148088. private _createLuminancePostProcesses;
  148089. private _createHdrPostProcess;
  148090. private _createLensFlarePostProcess;
  148091. private _createDepthOfFieldPostProcess;
  148092. private _createMotionBlurPostProcess;
  148093. private _getDepthTexture;
  148094. private _disposePostProcesses;
  148095. /**
  148096. * Dispose of the pipeline and stop all post processes
  148097. */
  148098. dispose(): void;
  148099. /**
  148100. * Serialize the rendering pipeline (Used when exporting)
  148101. * @returns the serialized object
  148102. */
  148103. serialize(): any;
  148104. /**
  148105. * Parse the serialized pipeline
  148106. * @param source Source pipeline.
  148107. * @param scene The scene to load the pipeline to.
  148108. * @param rootUrl The URL of the serialized pipeline.
  148109. * @returns An instantiated pipeline from the serialized object.
  148110. */
  148111. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148112. /**
  148113. * Luminance steps
  148114. */
  148115. static LuminanceSteps: number;
  148116. }
  148117. }
  148118. declare module BABYLON {
  148119. /** @hidden */
  148120. export var stereoscopicInterlacePixelShader: {
  148121. name: string;
  148122. shader: string;
  148123. };
  148124. }
  148125. declare module BABYLON {
  148126. /**
  148127. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148128. */
  148129. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148130. private _stepSize;
  148131. private _passedProcess;
  148132. /**
  148133. * Initializes a StereoscopicInterlacePostProcessI
  148134. * @param name The name of the effect.
  148135. * @param rigCameras The rig cameras to be appled to the post process
  148136. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148137. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148139. * @param engine The engine which the post process will be applied. (default: current engine)
  148140. * @param reusable If the post process can be reused on the same frame. (default: false)
  148141. */
  148142. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148143. }
  148144. /**
  148145. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148146. */
  148147. export class StereoscopicInterlacePostProcess extends PostProcess {
  148148. private _stepSize;
  148149. private _passedProcess;
  148150. /**
  148151. * Initializes a StereoscopicInterlacePostProcess
  148152. * @param name The name of the effect.
  148153. * @param rigCameras The rig cameras to be appled to the post process
  148154. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148156. * @param engine The engine which the post process will be applied. (default: current engine)
  148157. * @param reusable If the post process can be reused on the same frame. (default: false)
  148158. */
  148159. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148160. }
  148161. }
  148162. declare module BABYLON {
  148163. /** @hidden */
  148164. export var tonemapPixelShader: {
  148165. name: string;
  148166. shader: string;
  148167. };
  148168. }
  148169. declare module BABYLON {
  148170. /** Defines operator used for tonemapping */
  148171. export enum TonemappingOperator {
  148172. /** Hable */
  148173. Hable = 0,
  148174. /** Reinhard */
  148175. Reinhard = 1,
  148176. /** HejiDawson */
  148177. HejiDawson = 2,
  148178. /** Photographic */
  148179. Photographic = 3
  148180. }
  148181. /**
  148182. * Defines a post process to apply tone mapping
  148183. */
  148184. export class TonemapPostProcess extends PostProcess {
  148185. private _operator;
  148186. /** Defines the required exposure adjustement */
  148187. exposureAdjustment: number;
  148188. /**
  148189. * Creates a new TonemapPostProcess
  148190. * @param name defines the name of the postprocess
  148191. * @param _operator defines the operator to use
  148192. * @param exposureAdjustment defines the required exposure adjustement
  148193. * @param camera defines the camera to use (can be null)
  148194. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148195. * @param engine defines the hosting engine (can be ignore if camera is set)
  148196. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148197. */
  148198. constructor(name: string, _operator: TonemappingOperator,
  148199. /** Defines the required exposure adjustement */
  148200. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148201. }
  148202. }
  148203. declare module BABYLON {
  148204. /** @hidden */
  148205. export var volumetricLightScatteringPixelShader: {
  148206. name: string;
  148207. shader: string;
  148208. };
  148209. }
  148210. declare module BABYLON {
  148211. /** @hidden */
  148212. export var volumetricLightScatteringPassVertexShader: {
  148213. name: string;
  148214. shader: string;
  148215. };
  148216. }
  148217. declare module BABYLON {
  148218. /** @hidden */
  148219. export var volumetricLightScatteringPassPixelShader: {
  148220. name: string;
  148221. shader: string;
  148222. };
  148223. }
  148224. declare module BABYLON {
  148225. /**
  148226. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148227. */
  148228. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148229. private _volumetricLightScatteringPass;
  148230. private _volumetricLightScatteringRTT;
  148231. private _viewPort;
  148232. private _screenCoordinates;
  148233. private _cachedDefines;
  148234. /**
  148235. * If not undefined, the mesh position is computed from the attached node position
  148236. */
  148237. attachedNode: {
  148238. position: Vector3;
  148239. };
  148240. /**
  148241. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148242. */
  148243. customMeshPosition: Vector3;
  148244. /**
  148245. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148246. */
  148247. useCustomMeshPosition: boolean;
  148248. /**
  148249. * If the post-process should inverse the light scattering direction
  148250. */
  148251. invert: boolean;
  148252. /**
  148253. * The internal mesh used by the post-process
  148254. */
  148255. mesh: Mesh;
  148256. /**
  148257. * @hidden
  148258. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148259. */
  148260. get useDiffuseColor(): boolean;
  148261. set useDiffuseColor(useDiffuseColor: boolean);
  148262. /**
  148263. * Array containing the excluded meshes not rendered in the internal pass
  148264. */
  148265. excludedMeshes: AbstractMesh[];
  148266. /**
  148267. * Controls the overall intensity of the post-process
  148268. */
  148269. exposure: number;
  148270. /**
  148271. * Dissipates each sample's contribution in range [0, 1]
  148272. */
  148273. decay: number;
  148274. /**
  148275. * Controls the overall intensity of each sample
  148276. */
  148277. weight: number;
  148278. /**
  148279. * Controls the density of each sample
  148280. */
  148281. density: number;
  148282. /**
  148283. * @constructor
  148284. * @param name The post-process name
  148285. * @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)
  148286. * @param camera The camera that the post-process will be attached to
  148287. * @param mesh The mesh used to create the light scattering
  148288. * @param samples The post-process quality, default 100
  148289. * @param samplingModeThe post-process filtering mode
  148290. * @param engine The babylon engine
  148291. * @param reusable If the post-process is reusable
  148292. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148293. */
  148294. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148295. /**
  148296. * Returns the string "VolumetricLightScatteringPostProcess"
  148297. * @returns "VolumetricLightScatteringPostProcess"
  148298. */
  148299. getClassName(): string;
  148300. private _isReady;
  148301. /**
  148302. * Sets the new light position for light scattering effect
  148303. * @param position The new custom light position
  148304. */
  148305. setCustomMeshPosition(position: Vector3): void;
  148306. /**
  148307. * Returns the light position for light scattering effect
  148308. * @return Vector3 The custom light position
  148309. */
  148310. getCustomMeshPosition(): Vector3;
  148311. /**
  148312. * Disposes the internal assets and detaches the post-process from the camera
  148313. */
  148314. dispose(camera: Camera): void;
  148315. /**
  148316. * Returns the render target texture used by the post-process
  148317. * @return the render target texture used by the post-process
  148318. */
  148319. getPass(): RenderTargetTexture;
  148320. private _meshExcluded;
  148321. private _createPass;
  148322. private _updateMeshScreenCoordinates;
  148323. /**
  148324. * Creates a default mesh for the Volumeric Light Scattering post-process
  148325. * @param name The mesh name
  148326. * @param scene The scene where to create the mesh
  148327. * @return the default mesh
  148328. */
  148329. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148330. }
  148331. }
  148332. declare module BABYLON {
  148333. interface Scene {
  148334. /** @hidden (Backing field) */
  148335. _boundingBoxRenderer: BoundingBoxRenderer;
  148336. /** @hidden (Backing field) */
  148337. _forceShowBoundingBoxes: boolean;
  148338. /**
  148339. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148340. */
  148341. forceShowBoundingBoxes: boolean;
  148342. /**
  148343. * Gets the bounding box renderer associated with the scene
  148344. * @returns a BoundingBoxRenderer
  148345. */
  148346. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148347. }
  148348. interface AbstractMesh {
  148349. /** @hidden (Backing field) */
  148350. _showBoundingBox: boolean;
  148351. /**
  148352. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148353. */
  148354. showBoundingBox: boolean;
  148355. }
  148356. /**
  148357. * Component responsible of rendering the bounding box of the meshes in a scene.
  148358. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148359. */
  148360. export class BoundingBoxRenderer implements ISceneComponent {
  148361. /**
  148362. * The component name helpfull to identify the component in the list of scene components.
  148363. */
  148364. readonly name: string;
  148365. /**
  148366. * The scene the component belongs to.
  148367. */
  148368. scene: Scene;
  148369. /**
  148370. * Color of the bounding box lines placed in front of an object
  148371. */
  148372. frontColor: Color3;
  148373. /**
  148374. * Color of the bounding box lines placed behind an object
  148375. */
  148376. backColor: Color3;
  148377. /**
  148378. * Defines if the renderer should show the back lines or not
  148379. */
  148380. showBackLines: boolean;
  148381. /**
  148382. * Observable raised before rendering a bounding box
  148383. */
  148384. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148385. /**
  148386. * Observable raised after rendering a bounding box
  148387. */
  148388. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148389. /**
  148390. * @hidden
  148391. */
  148392. renderList: SmartArray<BoundingBox>;
  148393. private _colorShader;
  148394. private _vertexBuffers;
  148395. private _indexBuffer;
  148396. private _fillIndexBuffer;
  148397. private _fillIndexData;
  148398. /**
  148399. * Instantiates a new bounding box renderer in a scene.
  148400. * @param scene the scene the renderer renders in
  148401. */
  148402. constructor(scene: Scene);
  148403. /**
  148404. * Registers the component in a given scene
  148405. */
  148406. register(): void;
  148407. private _evaluateSubMesh;
  148408. private _activeMesh;
  148409. private _prepareRessources;
  148410. private _createIndexBuffer;
  148411. /**
  148412. * Rebuilds the elements related to this component in case of
  148413. * context lost for instance.
  148414. */
  148415. rebuild(): void;
  148416. /**
  148417. * @hidden
  148418. */
  148419. reset(): void;
  148420. /**
  148421. * Render the bounding boxes of a specific rendering group
  148422. * @param renderingGroupId defines the rendering group to render
  148423. */
  148424. render(renderingGroupId: number): void;
  148425. /**
  148426. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148427. * @param mesh Define the mesh to render the occlusion bounding box for
  148428. */
  148429. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148430. /**
  148431. * Dispose and release the resources attached to this renderer.
  148432. */
  148433. dispose(): void;
  148434. }
  148435. }
  148436. declare module BABYLON {
  148437. interface Scene {
  148438. /** @hidden (Backing field) */
  148439. _depthRenderer: {
  148440. [id: string]: DepthRenderer;
  148441. };
  148442. /**
  148443. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148444. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148445. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148446. * @returns the created depth renderer
  148447. */
  148448. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148449. /**
  148450. * Disables a depth renderer for a given camera
  148451. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148452. */
  148453. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148454. }
  148455. /**
  148456. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148457. * in several rendering techniques.
  148458. */
  148459. export class DepthRendererSceneComponent implements ISceneComponent {
  148460. /**
  148461. * The component name helpfull to identify the component in the list of scene components.
  148462. */
  148463. readonly name: string;
  148464. /**
  148465. * The scene the component belongs to.
  148466. */
  148467. scene: Scene;
  148468. /**
  148469. * Creates a new instance of the component for the given scene
  148470. * @param scene Defines the scene to register the component in
  148471. */
  148472. constructor(scene: Scene);
  148473. /**
  148474. * Registers the component in a given scene
  148475. */
  148476. register(): void;
  148477. /**
  148478. * Rebuilds the elements related to this component in case of
  148479. * context lost for instance.
  148480. */
  148481. rebuild(): void;
  148482. /**
  148483. * Disposes the component and the associated ressources
  148484. */
  148485. dispose(): void;
  148486. private _gatherRenderTargets;
  148487. private _gatherActiveCameraRenderTargets;
  148488. }
  148489. }
  148490. declare module BABYLON {
  148491. /** @hidden */
  148492. export var outlinePixelShader: {
  148493. name: string;
  148494. shader: string;
  148495. };
  148496. }
  148497. declare module BABYLON {
  148498. /** @hidden */
  148499. export var outlineVertexShader: {
  148500. name: string;
  148501. shader: string;
  148502. };
  148503. }
  148504. declare module BABYLON {
  148505. interface Scene {
  148506. /** @hidden */
  148507. _outlineRenderer: OutlineRenderer;
  148508. /**
  148509. * Gets the outline renderer associated with the scene
  148510. * @returns a OutlineRenderer
  148511. */
  148512. getOutlineRenderer(): OutlineRenderer;
  148513. }
  148514. interface AbstractMesh {
  148515. /** @hidden (Backing field) */
  148516. _renderOutline: boolean;
  148517. /**
  148518. * Gets or sets a boolean indicating if the outline must be rendered as well
  148519. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  148520. */
  148521. renderOutline: boolean;
  148522. /** @hidden (Backing field) */
  148523. _renderOverlay: boolean;
  148524. /**
  148525. * Gets or sets a boolean indicating if the overlay must be rendered as well
  148526. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  148527. */
  148528. renderOverlay: boolean;
  148529. }
  148530. /**
  148531. * This class is responsible to draw bothe outline/overlay of meshes.
  148532. * It should not be used directly but through the available method on mesh.
  148533. */
  148534. export class OutlineRenderer implements ISceneComponent {
  148535. /**
  148536. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  148537. */
  148538. private static _StencilReference;
  148539. /**
  148540. * The name of the component. Each component must have a unique name.
  148541. */
  148542. name: string;
  148543. /**
  148544. * The scene the component belongs to.
  148545. */
  148546. scene: Scene;
  148547. /**
  148548. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  148549. */
  148550. zOffset: number;
  148551. private _engine;
  148552. private _effect;
  148553. private _cachedDefines;
  148554. private _savedDepthWrite;
  148555. /**
  148556. * Instantiates a new outline renderer. (There could be only one per scene).
  148557. * @param scene Defines the scene it belongs to
  148558. */
  148559. constructor(scene: Scene);
  148560. /**
  148561. * Register the component to one instance of a scene.
  148562. */
  148563. register(): void;
  148564. /**
  148565. * Rebuilds the elements related to this component in case of
  148566. * context lost for instance.
  148567. */
  148568. rebuild(): void;
  148569. /**
  148570. * Disposes the component and the associated ressources.
  148571. */
  148572. dispose(): void;
  148573. /**
  148574. * Renders the outline in the canvas.
  148575. * @param subMesh Defines the sumesh to render
  148576. * @param batch Defines the batch of meshes in case of instances
  148577. * @param useOverlay Defines if the rendering is for the overlay or the outline
  148578. */
  148579. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  148580. /**
  148581. * Returns whether or not the outline renderer is ready for a given submesh.
  148582. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  148583. * @param subMesh Defines the submesh to check readyness for
  148584. * @param useInstances Defines wheter wee are trying to render instances or not
  148585. * @returns true if ready otherwise false
  148586. */
  148587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148588. private _beforeRenderingMesh;
  148589. private _afterRenderingMesh;
  148590. }
  148591. }
  148592. declare module BABYLON {
  148593. /**
  148594. * Defines the basic options interface of a Sprite Frame Source Size.
  148595. */
  148596. export interface ISpriteJSONSpriteSourceSize {
  148597. /**
  148598. * number of the original width of the Frame
  148599. */
  148600. w: number;
  148601. /**
  148602. * number of the original height of the Frame
  148603. */
  148604. h: number;
  148605. }
  148606. /**
  148607. * Defines the basic options interface of a Sprite Frame Data.
  148608. */
  148609. export interface ISpriteJSONSpriteFrameData {
  148610. /**
  148611. * number of the x offset of the Frame
  148612. */
  148613. x: number;
  148614. /**
  148615. * number of the y offset of the Frame
  148616. */
  148617. y: number;
  148618. /**
  148619. * number of the width of the Frame
  148620. */
  148621. w: number;
  148622. /**
  148623. * number of the height of the Frame
  148624. */
  148625. h: number;
  148626. }
  148627. /**
  148628. * Defines the basic options interface of a JSON Sprite.
  148629. */
  148630. export interface ISpriteJSONSprite {
  148631. /**
  148632. * string name of the Frame
  148633. */
  148634. filename: string;
  148635. /**
  148636. * ISpriteJSONSpriteFrame basic object of the frame data
  148637. */
  148638. frame: ISpriteJSONSpriteFrameData;
  148639. /**
  148640. * boolean to flag is the frame was rotated.
  148641. */
  148642. rotated: boolean;
  148643. /**
  148644. * boolean to flag is the frame was trimmed.
  148645. */
  148646. trimmed: boolean;
  148647. /**
  148648. * ISpriteJSONSpriteFrame basic object of the source data
  148649. */
  148650. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148651. /**
  148652. * ISpriteJSONSpriteFrame basic object of the source data
  148653. */
  148654. sourceSize: ISpriteJSONSpriteSourceSize;
  148655. }
  148656. /**
  148657. * Defines the basic options interface of a JSON atlas.
  148658. */
  148659. export interface ISpriteJSONAtlas {
  148660. /**
  148661. * Array of objects that contain the frame data.
  148662. */
  148663. frames: Array<ISpriteJSONSprite>;
  148664. /**
  148665. * object basic object containing the sprite meta data.
  148666. */
  148667. meta?: object;
  148668. }
  148669. }
  148670. declare module BABYLON {
  148671. /** @hidden */
  148672. export var spriteMapPixelShader: {
  148673. name: string;
  148674. shader: string;
  148675. };
  148676. }
  148677. declare module BABYLON {
  148678. /** @hidden */
  148679. export var spriteMapVertexShader: {
  148680. name: string;
  148681. shader: string;
  148682. };
  148683. }
  148684. declare module BABYLON {
  148685. /**
  148686. * Defines the basic options interface of a SpriteMap
  148687. */
  148688. export interface ISpriteMapOptions {
  148689. /**
  148690. * Vector2 of the number of cells in the grid.
  148691. */
  148692. stageSize?: Vector2;
  148693. /**
  148694. * Vector2 of the size of the output plane in World Units.
  148695. */
  148696. outputSize?: Vector2;
  148697. /**
  148698. * Vector3 of the position of the output plane in World Units.
  148699. */
  148700. outputPosition?: Vector3;
  148701. /**
  148702. * Vector3 of the rotation of the output plane.
  148703. */
  148704. outputRotation?: Vector3;
  148705. /**
  148706. * number of layers that the system will reserve in resources.
  148707. */
  148708. layerCount?: number;
  148709. /**
  148710. * number of max animation frames a single cell will reserve in resources.
  148711. */
  148712. maxAnimationFrames?: number;
  148713. /**
  148714. * number cell index of the base tile when the system compiles.
  148715. */
  148716. baseTile?: number;
  148717. /**
  148718. * boolean flip the sprite after its been repositioned by the framing data.
  148719. */
  148720. flipU?: boolean;
  148721. /**
  148722. * Vector3 scalar of the global RGB values of the SpriteMap.
  148723. */
  148724. colorMultiply?: Vector3;
  148725. }
  148726. /**
  148727. * Defines the IDisposable interface in order to be cleanable from resources.
  148728. */
  148729. export interface ISpriteMap extends IDisposable {
  148730. /**
  148731. * String name of the SpriteMap.
  148732. */
  148733. name: string;
  148734. /**
  148735. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148736. */
  148737. atlasJSON: ISpriteJSONAtlas;
  148738. /**
  148739. * Texture of the SpriteMap.
  148740. */
  148741. spriteSheet: Texture;
  148742. /**
  148743. * The parameters to initialize the SpriteMap with.
  148744. */
  148745. options: ISpriteMapOptions;
  148746. }
  148747. /**
  148748. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148749. */
  148750. export class SpriteMap implements ISpriteMap {
  148751. /** The Name of the spriteMap */
  148752. name: string;
  148753. /** The JSON file with the frame and meta data */
  148754. atlasJSON: ISpriteJSONAtlas;
  148755. /** The systems Sprite Sheet Texture */
  148756. spriteSheet: Texture;
  148757. /** Arguments passed with the Constructor */
  148758. options: ISpriteMapOptions;
  148759. /** Public Sprite Storage array, parsed from atlasJSON */
  148760. sprites: Array<ISpriteJSONSprite>;
  148761. /** Returns the Number of Sprites in the System */
  148762. get spriteCount(): number;
  148763. /** Returns the Position of Output Plane*/
  148764. get position(): Vector3;
  148765. /** Returns the Position of Output Plane*/
  148766. set position(v: Vector3);
  148767. /** Returns the Rotation of Output Plane*/
  148768. get rotation(): Vector3;
  148769. /** Returns the Rotation of Output Plane*/
  148770. set rotation(v: Vector3);
  148771. /** Sets the AnimationMap*/
  148772. get animationMap(): RawTexture;
  148773. /** Sets the AnimationMap*/
  148774. set animationMap(v: RawTexture);
  148775. /** Scene that the SpriteMap was created in */
  148776. private _scene;
  148777. /** Texture Buffer of Float32 that holds tile frame data*/
  148778. private _frameMap;
  148779. /** Texture Buffers of Float32 that holds tileMap data*/
  148780. private _tileMaps;
  148781. /** Texture Buffer of Float32 that holds Animation Data*/
  148782. private _animationMap;
  148783. /** Custom ShaderMaterial Central to the System*/
  148784. private _material;
  148785. /** Custom ShaderMaterial Central to the System*/
  148786. private _output;
  148787. /** Systems Time Ticker*/
  148788. private _time;
  148789. /**
  148790. * Creates a new SpriteMap
  148791. * @param name defines the SpriteMaps Name
  148792. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148793. * @param spriteSheet is the Texture that the Sprites are on.
  148794. * @param options a basic deployment configuration
  148795. * @param scene The Scene that the map is deployed on
  148796. */
  148797. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148798. /**
  148799. * Returns tileID location
  148800. * @returns Vector2 the cell position ID
  148801. */
  148802. getTileID(): Vector2;
  148803. /**
  148804. * Gets the UV location of the mouse over the SpriteMap.
  148805. * @returns Vector2 the UV position of the mouse interaction
  148806. */
  148807. getMousePosition(): Vector2;
  148808. /**
  148809. * Creates the "frame" texture Buffer
  148810. * -------------------------------------
  148811. * Structure of frames
  148812. * "filename": "Falling-Water-2.png",
  148813. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148814. * "rotated": true,
  148815. * "trimmed": true,
  148816. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148817. * "sourceSize": {"w":32,"h":32}
  148818. * @returns RawTexture of the frameMap
  148819. */
  148820. private _createFrameBuffer;
  148821. /**
  148822. * Creates the tileMap texture Buffer
  148823. * @param buffer normally and array of numbers, or a false to generate from scratch
  148824. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148825. * @returns RawTexture of the tileMap
  148826. */
  148827. private _createTileBuffer;
  148828. /**
  148829. * Modifies the data of the tileMaps
  148830. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148831. * @param pos is the iVector2 Coordinates of the Tile
  148832. * @param tile The SpriteIndex of the new Tile
  148833. */
  148834. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148835. /**
  148836. * Creates the animationMap texture Buffer
  148837. * @param buffer normally and array of numbers, or a false to generate from scratch
  148838. * @returns RawTexture of the animationMap
  148839. */
  148840. private _createTileAnimationBuffer;
  148841. /**
  148842. * Modifies the data of the animationMap
  148843. * @param cellID is the Index of the Sprite
  148844. * @param _frame is the target Animation frame
  148845. * @param toCell is the Target Index of the next frame of the animation
  148846. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148847. * @param speed is a global scalar of the time variable on the map.
  148848. */
  148849. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148850. /**
  148851. * Exports the .tilemaps file
  148852. */
  148853. saveTileMaps(): void;
  148854. /**
  148855. * Imports the .tilemaps file
  148856. * @param url of the .tilemaps file
  148857. */
  148858. loadTileMaps(url: string): void;
  148859. /**
  148860. * Release associated resources
  148861. */
  148862. dispose(): void;
  148863. }
  148864. }
  148865. declare module BABYLON {
  148866. /**
  148867. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148868. * @see http://doc.babylonjs.com/babylon101/sprites
  148869. */
  148870. export class SpritePackedManager extends SpriteManager {
  148871. /** defines the packed manager's name */
  148872. name: string;
  148873. /**
  148874. * Creates a new sprite manager from a packed sprite sheet
  148875. * @param name defines the manager's name
  148876. * @param imgUrl defines the sprite sheet url
  148877. * @param capacity defines the maximum allowed number of sprites
  148878. * @param scene defines the hosting scene
  148879. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148880. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148881. * @param samplingMode defines the smapling mode to use with spritesheet
  148882. * @param fromPacked set to true; do not alter
  148883. */
  148884. constructor(
  148885. /** defines the packed manager's name */
  148886. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148887. }
  148888. }
  148889. declare module BABYLON {
  148890. /**
  148891. * Defines the list of states available for a task inside a AssetsManager
  148892. */
  148893. export enum AssetTaskState {
  148894. /**
  148895. * Initialization
  148896. */
  148897. INIT = 0,
  148898. /**
  148899. * Running
  148900. */
  148901. RUNNING = 1,
  148902. /**
  148903. * Done
  148904. */
  148905. DONE = 2,
  148906. /**
  148907. * Error
  148908. */
  148909. ERROR = 3
  148910. }
  148911. /**
  148912. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148913. */
  148914. export abstract class AbstractAssetTask {
  148915. /**
  148916. * Task name
  148917. */ name: string;
  148918. /**
  148919. * Callback called when the task is successful
  148920. */
  148921. onSuccess: (task: any) => void;
  148922. /**
  148923. * Callback called when the task is not successful
  148924. */
  148925. onError: (task: any, message?: string, exception?: any) => void;
  148926. /**
  148927. * Creates a new AssetsManager
  148928. * @param name defines the name of the task
  148929. */
  148930. constructor(
  148931. /**
  148932. * Task name
  148933. */ name: string);
  148934. private _isCompleted;
  148935. private _taskState;
  148936. private _errorObject;
  148937. /**
  148938. * Get if the task is completed
  148939. */
  148940. get isCompleted(): boolean;
  148941. /**
  148942. * Gets the current state of the task
  148943. */
  148944. get taskState(): AssetTaskState;
  148945. /**
  148946. * Gets the current error object (if task is in error)
  148947. */
  148948. get errorObject(): {
  148949. message?: string;
  148950. exception?: any;
  148951. };
  148952. /**
  148953. * Internal only
  148954. * @hidden
  148955. */
  148956. _setErrorObject(message?: string, exception?: any): void;
  148957. /**
  148958. * Execute the current task
  148959. * @param scene defines the scene where you want your assets to be loaded
  148960. * @param onSuccess is a callback called when the task is successfully executed
  148961. * @param onError is a callback called if an error occurs
  148962. */
  148963. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148964. /**
  148965. * Execute the current task
  148966. * @param scene defines the scene where you want your assets to be loaded
  148967. * @param onSuccess is a callback called when the task is successfully executed
  148968. * @param onError is a callback called if an error occurs
  148969. */
  148970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148971. /**
  148972. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148973. * This can be used with failed tasks that have the reason for failure fixed.
  148974. */
  148975. reset(): void;
  148976. private onErrorCallback;
  148977. private onDoneCallback;
  148978. }
  148979. /**
  148980. * Define the interface used by progress events raised during assets loading
  148981. */
  148982. export interface IAssetsProgressEvent {
  148983. /**
  148984. * Defines the number of remaining tasks to process
  148985. */
  148986. remainingCount: number;
  148987. /**
  148988. * Defines the total number of tasks
  148989. */
  148990. totalCount: number;
  148991. /**
  148992. * Defines the task that was just processed
  148993. */
  148994. task: AbstractAssetTask;
  148995. }
  148996. /**
  148997. * Class used to share progress information about assets loading
  148998. */
  148999. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149000. /**
  149001. * Defines the number of remaining tasks to process
  149002. */
  149003. remainingCount: number;
  149004. /**
  149005. * Defines the total number of tasks
  149006. */
  149007. totalCount: number;
  149008. /**
  149009. * Defines the task that was just processed
  149010. */
  149011. task: AbstractAssetTask;
  149012. /**
  149013. * Creates a AssetsProgressEvent
  149014. * @param remainingCount defines the number of remaining tasks to process
  149015. * @param totalCount defines the total number of tasks
  149016. * @param task defines the task that was just processed
  149017. */
  149018. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149019. }
  149020. /**
  149021. * Define a task used by AssetsManager to load meshes
  149022. */
  149023. export class MeshAssetTask extends AbstractAssetTask {
  149024. /**
  149025. * Defines the name of the task
  149026. */
  149027. name: string;
  149028. /**
  149029. * Defines the list of mesh's names you want to load
  149030. */
  149031. meshesNames: any;
  149032. /**
  149033. * Defines the root url to use as a base to load your meshes and associated resources
  149034. */
  149035. rootUrl: string;
  149036. /**
  149037. * Defines the filename or File of the scene to load from
  149038. */
  149039. sceneFilename: string | File;
  149040. /**
  149041. * Gets the list of loaded meshes
  149042. */
  149043. loadedMeshes: Array<AbstractMesh>;
  149044. /**
  149045. * Gets the list of loaded particle systems
  149046. */
  149047. loadedParticleSystems: Array<IParticleSystem>;
  149048. /**
  149049. * Gets the list of loaded skeletons
  149050. */
  149051. loadedSkeletons: Array<Skeleton>;
  149052. /**
  149053. * Gets the list of loaded animation groups
  149054. */
  149055. loadedAnimationGroups: Array<AnimationGroup>;
  149056. /**
  149057. * Callback called when the task is successful
  149058. */
  149059. onSuccess: (task: MeshAssetTask) => void;
  149060. /**
  149061. * Callback called when the task is successful
  149062. */
  149063. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149064. /**
  149065. * Creates a new MeshAssetTask
  149066. * @param name defines the name of the task
  149067. * @param meshesNames defines the list of mesh's names you want to load
  149068. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149069. * @param sceneFilename defines the filename or File of the scene to load from
  149070. */
  149071. constructor(
  149072. /**
  149073. * Defines the name of the task
  149074. */
  149075. name: string,
  149076. /**
  149077. * Defines the list of mesh's names you want to load
  149078. */
  149079. meshesNames: any,
  149080. /**
  149081. * Defines the root url to use as a base to load your meshes and associated resources
  149082. */
  149083. rootUrl: string,
  149084. /**
  149085. * Defines the filename or File of the scene to load from
  149086. */
  149087. sceneFilename: string | File);
  149088. /**
  149089. * Execute the current task
  149090. * @param scene defines the scene where you want your assets to be loaded
  149091. * @param onSuccess is a callback called when the task is successfully executed
  149092. * @param onError is a callback called if an error occurs
  149093. */
  149094. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149095. }
  149096. /**
  149097. * Define a task used by AssetsManager to load text content
  149098. */
  149099. export class TextFileAssetTask extends AbstractAssetTask {
  149100. /**
  149101. * Defines the name of the task
  149102. */
  149103. name: string;
  149104. /**
  149105. * Defines the location of the file to load
  149106. */
  149107. url: string;
  149108. /**
  149109. * Gets the loaded text string
  149110. */
  149111. text: string;
  149112. /**
  149113. * Callback called when the task is successful
  149114. */
  149115. onSuccess: (task: TextFileAssetTask) => void;
  149116. /**
  149117. * Callback called when the task is successful
  149118. */
  149119. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149120. /**
  149121. * Creates a new TextFileAssetTask object
  149122. * @param name defines the name of the task
  149123. * @param url defines the location of the file to load
  149124. */
  149125. constructor(
  149126. /**
  149127. * Defines the name of the task
  149128. */
  149129. name: string,
  149130. /**
  149131. * Defines the location of the file to load
  149132. */
  149133. url: string);
  149134. /**
  149135. * Execute the current task
  149136. * @param scene defines the scene where you want your assets to be loaded
  149137. * @param onSuccess is a callback called when the task is successfully executed
  149138. * @param onError is a callback called if an error occurs
  149139. */
  149140. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149141. }
  149142. /**
  149143. * Define a task used by AssetsManager to load binary data
  149144. */
  149145. export class BinaryFileAssetTask extends AbstractAssetTask {
  149146. /**
  149147. * Defines the name of the task
  149148. */
  149149. name: string;
  149150. /**
  149151. * Defines the location of the file to load
  149152. */
  149153. url: string;
  149154. /**
  149155. * Gets the lodaded data (as an array buffer)
  149156. */
  149157. data: ArrayBuffer;
  149158. /**
  149159. * Callback called when the task is successful
  149160. */
  149161. onSuccess: (task: BinaryFileAssetTask) => void;
  149162. /**
  149163. * Callback called when the task is successful
  149164. */
  149165. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149166. /**
  149167. * Creates a new BinaryFileAssetTask object
  149168. * @param name defines the name of the new task
  149169. * @param url defines the location of the file to load
  149170. */
  149171. constructor(
  149172. /**
  149173. * Defines the name of the task
  149174. */
  149175. name: string,
  149176. /**
  149177. * Defines the location of the file to load
  149178. */
  149179. url: string);
  149180. /**
  149181. * Execute the current task
  149182. * @param scene defines the scene where you want your assets to be loaded
  149183. * @param onSuccess is a callback called when the task is successfully executed
  149184. * @param onError is a callback called if an error occurs
  149185. */
  149186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149187. }
  149188. /**
  149189. * Define a task used by AssetsManager to load images
  149190. */
  149191. export class ImageAssetTask extends AbstractAssetTask {
  149192. /**
  149193. * Defines the name of the task
  149194. */
  149195. name: string;
  149196. /**
  149197. * Defines the location of the image to load
  149198. */
  149199. url: string;
  149200. /**
  149201. * Gets the loaded images
  149202. */
  149203. image: HTMLImageElement;
  149204. /**
  149205. * Callback called when the task is successful
  149206. */
  149207. onSuccess: (task: ImageAssetTask) => void;
  149208. /**
  149209. * Callback called when the task is successful
  149210. */
  149211. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149212. /**
  149213. * Creates a new ImageAssetTask
  149214. * @param name defines the name of the task
  149215. * @param url defines the location of the image to load
  149216. */
  149217. constructor(
  149218. /**
  149219. * Defines the name of the task
  149220. */
  149221. name: string,
  149222. /**
  149223. * Defines the location of the image to load
  149224. */
  149225. url: string);
  149226. /**
  149227. * Execute the current task
  149228. * @param scene defines the scene where you want your assets to be loaded
  149229. * @param onSuccess is a callback called when the task is successfully executed
  149230. * @param onError is a callback called if an error occurs
  149231. */
  149232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149233. }
  149234. /**
  149235. * Defines the interface used by texture loading tasks
  149236. */
  149237. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149238. /**
  149239. * Gets the loaded texture
  149240. */
  149241. texture: TEX;
  149242. }
  149243. /**
  149244. * Define a task used by AssetsManager to load 2D textures
  149245. */
  149246. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149247. /**
  149248. * Defines the name of the task
  149249. */
  149250. name: string;
  149251. /**
  149252. * Defines the location of the file to load
  149253. */
  149254. url: string;
  149255. /**
  149256. * Defines if mipmap should not be generated (default is false)
  149257. */
  149258. noMipmap?: boolean | undefined;
  149259. /**
  149260. * Defines if texture must be inverted on Y axis (default is true)
  149261. */
  149262. invertY: boolean;
  149263. /**
  149264. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149265. */
  149266. samplingMode: number;
  149267. /**
  149268. * Gets the loaded texture
  149269. */
  149270. texture: Texture;
  149271. /**
  149272. * Callback called when the task is successful
  149273. */
  149274. onSuccess: (task: TextureAssetTask) => void;
  149275. /**
  149276. * Callback called when the task is successful
  149277. */
  149278. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  149279. /**
  149280. * Creates a new TextureAssetTask object
  149281. * @param name defines the name of the task
  149282. * @param url defines the location of the file to load
  149283. * @param noMipmap defines if mipmap should not be generated (default is false)
  149284. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149285. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149286. */
  149287. constructor(
  149288. /**
  149289. * Defines the name of the task
  149290. */
  149291. name: string,
  149292. /**
  149293. * Defines the location of the file to load
  149294. */
  149295. url: string,
  149296. /**
  149297. * Defines if mipmap should not be generated (default is false)
  149298. */
  149299. noMipmap?: boolean | undefined,
  149300. /**
  149301. * Defines if texture must be inverted on Y axis (default is true)
  149302. */
  149303. invertY?: boolean,
  149304. /**
  149305. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149306. */
  149307. samplingMode?: number);
  149308. /**
  149309. * Execute the current task
  149310. * @param scene defines the scene where you want your assets to be loaded
  149311. * @param onSuccess is a callback called when the task is successfully executed
  149312. * @param onError is a callback called if an error occurs
  149313. */
  149314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149315. }
  149316. /**
  149317. * Define a task used by AssetsManager to load cube textures
  149318. */
  149319. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  149320. /**
  149321. * Defines the name of the task
  149322. */
  149323. name: string;
  149324. /**
  149325. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149326. */
  149327. url: string;
  149328. /**
  149329. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149330. */
  149331. extensions?: string[] | undefined;
  149332. /**
  149333. * Defines if mipmaps should not be generated (default is false)
  149334. */
  149335. noMipmap?: boolean | undefined;
  149336. /**
  149337. * Defines the explicit list of files (undefined by default)
  149338. */
  149339. files?: string[] | undefined;
  149340. /**
  149341. * Gets the loaded texture
  149342. */
  149343. texture: CubeTexture;
  149344. /**
  149345. * Callback called when the task is successful
  149346. */
  149347. onSuccess: (task: CubeTextureAssetTask) => void;
  149348. /**
  149349. * Callback called when the task is successful
  149350. */
  149351. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  149352. /**
  149353. * Creates a new CubeTextureAssetTask
  149354. * @param name defines the name of the task
  149355. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149356. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149357. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149358. * @param files defines the explicit list of files (undefined by default)
  149359. */
  149360. constructor(
  149361. /**
  149362. * Defines the name of the task
  149363. */
  149364. name: string,
  149365. /**
  149366. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149367. */
  149368. url: string,
  149369. /**
  149370. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149371. */
  149372. extensions?: string[] | undefined,
  149373. /**
  149374. * Defines if mipmaps should not be generated (default is false)
  149375. */
  149376. noMipmap?: boolean | undefined,
  149377. /**
  149378. * Defines the explicit list of files (undefined by default)
  149379. */
  149380. files?: string[] | undefined);
  149381. /**
  149382. * Execute the current task
  149383. * @param scene defines the scene where you want your assets to be loaded
  149384. * @param onSuccess is a callback called when the task is successfully executed
  149385. * @param onError is a callback called if an error occurs
  149386. */
  149387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149388. }
  149389. /**
  149390. * Define a task used by AssetsManager to load HDR cube textures
  149391. */
  149392. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  149393. /**
  149394. * Defines the name of the task
  149395. */
  149396. name: string;
  149397. /**
  149398. * Defines the location of the file to load
  149399. */
  149400. url: string;
  149401. /**
  149402. * Defines the desired size (the more it increases the longer the generation will be)
  149403. */
  149404. size: number;
  149405. /**
  149406. * Defines if mipmaps should not be generated (default is false)
  149407. */
  149408. noMipmap: boolean;
  149409. /**
  149410. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149411. */
  149412. generateHarmonics: boolean;
  149413. /**
  149414. * 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)
  149415. */
  149416. gammaSpace: boolean;
  149417. /**
  149418. * Internal Use Only
  149419. */
  149420. reserved: boolean;
  149421. /**
  149422. * Gets the loaded texture
  149423. */
  149424. texture: HDRCubeTexture;
  149425. /**
  149426. * Callback called when the task is successful
  149427. */
  149428. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  149429. /**
  149430. * Callback called when the task is successful
  149431. */
  149432. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  149433. /**
  149434. * Creates a new HDRCubeTextureAssetTask object
  149435. * @param name defines the name of the task
  149436. * @param url defines the location of the file to load
  149437. * @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.
  149438. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149439. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149440. * @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)
  149441. * @param reserved Internal use only
  149442. */
  149443. constructor(
  149444. /**
  149445. * Defines the name of the task
  149446. */
  149447. name: string,
  149448. /**
  149449. * Defines the location of the file to load
  149450. */
  149451. url: string,
  149452. /**
  149453. * Defines the desired size (the more it increases the longer the generation will be)
  149454. */
  149455. size: number,
  149456. /**
  149457. * Defines if mipmaps should not be generated (default is false)
  149458. */
  149459. noMipmap?: boolean,
  149460. /**
  149461. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149462. */
  149463. generateHarmonics?: boolean,
  149464. /**
  149465. * 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)
  149466. */
  149467. gammaSpace?: boolean,
  149468. /**
  149469. * Internal Use Only
  149470. */
  149471. reserved?: boolean);
  149472. /**
  149473. * Execute the current task
  149474. * @param scene defines the scene where you want your assets to be loaded
  149475. * @param onSuccess is a callback called when the task is successfully executed
  149476. * @param onError is a callback called if an error occurs
  149477. */
  149478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149479. }
  149480. /**
  149481. * Define a task used by AssetsManager to load Equirectangular cube textures
  149482. */
  149483. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  149484. /**
  149485. * Defines the name of the task
  149486. */
  149487. name: string;
  149488. /**
  149489. * Defines the location of the file to load
  149490. */
  149491. url: string;
  149492. /**
  149493. * Defines the desired size (the more it increases the longer the generation will be)
  149494. */
  149495. size: number;
  149496. /**
  149497. * Defines if mipmaps should not be generated (default is false)
  149498. */
  149499. noMipmap: boolean;
  149500. /**
  149501. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149502. * but the standard material would require them in Gamma space) (default is true)
  149503. */
  149504. gammaSpace: boolean;
  149505. /**
  149506. * Gets the loaded texture
  149507. */
  149508. texture: EquiRectangularCubeTexture;
  149509. /**
  149510. * Callback called when the task is successful
  149511. */
  149512. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  149513. /**
  149514. * Callback called when the task is successful
  149515. */
  149516. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  149517. /**
  149518. * Creates a new EquiRectangularCubeTextureAssetTask object
  149519. * @param name defines the name of the task
  149520. * @param url defines the location of the file to load
  149521. * @param size defines the desired size (the more it increases the longer the generation will be)
  149522. * If the size is omitted this implies you are using a preprocessed cubemap.
  149523. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149524. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  149525. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  149526. * (default is true)
  149527. */
  149528. constructor(
  149529. /**
  149530. * Defines the name of the task
  149531. */
  149532. name: string,
  149533. /**
  149534. * Defines the location of the file to load
  149535. */
  149536. url: string,
  149537. /**
  149538. * Defines the desired size (the more it increases the longer the generation will be)
  149539. */
  149540. size: number,
  149541. /**
  149542. * Defines if mipmaps should not be generated (default is false)
  149543. */
  149544. noMipmap?: boolean,
  149545. /**
  149546. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149547. * but the standard material would require them in Gamma space) (default is true)
  149548. */
  149549. gammaSpace?: boolean);
  149550. /**
  149551. * Execute the current task
  149552. * @param scene defines the scene where you want your assets to be loaded
  149553. * @param onSuccess is a callback called when the task is successfully executed
  149554. * @param onError is a callback called if an error occurs
  149555. */
  149556. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149557. }
  149558. /**
  149559. * This class can be used to easily import assets into a scene
  149560. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  149561. */
  149562. export class AssetsManager {
  149563. private _scene;
  149564. private _isLoading;
  149565. protected _tasks: AbstractAssetTask[];
  149566. protected _waitingTasksCount: number;
  149567. protected _totalTasksCount: number;
  149568. /**
  149569. * Callback called when all tasks are processed
  149570. */
  149571. onFinish: (tasks: AbstractAssetTask[]) => void;
  149572. /**
  149573. * Callback called when a task is successful
  149574. */
  149575. onTaskSuccess: (task: AbstractAssetTask) => void;
  149576. /**
  149577. * Callback called when a task had an error
  149578. */
  149579. onTaskError: (task: AbstractAssetTask) => void;
  149580. /**
  149581. * Callback called when a task is done (whatever the result is)
  149582. */
  149583. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  149584. /**
  149585. * Observable called when all tasks are processed
  149586. */
  149587. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  149588. /**
  149589. * Observable called when a task had an error
  149590. */
  149591. onTaskErrorObservable: Observable<AbstractAssetTask>;
  149592. /**
  149593. * Observable called when all tasks were executed
  149594. */
  149595. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  149596. /**
  149597. * Observable called when a task is done (whatever the result is)
  149598. */
  149599. onProgressObservable: Observable<IAssetsProgressEvent>;
  149600. /**
  149601. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  149602. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  149603. */
  149604. useDefaultLoadingScreen: boolean;
  149605. /**
  149606. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  149607. * when all assets have been downloaded.
  149608. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  149609. */
  149610. autoHideLoadingUI: boolean;
  149611. /**
  149612. * Creates a new AssetsManager
  149613. * @param scene defines the scene to work on
  149614. */
  149615. constructor(scene: Scene);
  149616. /**
  149617. * Add a MeshAssetTask to the list of active tasks
  149618. * @param taskName defines the name of the new task
  149619. * @param meshesNames defines the name of meshes to load
  149620. * @param rootUrl defines the root url to use to locate files
  149621. * @param sceneFilename defines the filename of the scene file
  149622. * @returns a new MeshAssetTask object
  149623. */
  149624. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149625. /**
  149626. * Add a TextFileAssetTask to the list of active tasks
  149627. * @param taskName defines the name of the new task
  149628. * @param url defines the url of the file to load
  149629. * @returns a new TextFileAssetTask object
  149630. */
  149631. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149632. /**
  149633. * Add a BinaryFileAssetTask to the list of active tasks
  149634. * @param taskName defines the name of the new task
  149635. * @param url defines the url of the file to load
  149636. * @returns a new BinaryFileAssetTask object
  149637. */
  149638. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149639. /**
  149640. * Add a ImageAssetTask to the list of active tasks
  149641. * @param taskName defines the name of the new task
  149642. * @param url defines the url of the file to load
  149643. * @returns a new ImageAssetTask object
  149644. */
  149645. addImageTask(taskName: string, url: string): ImageAssetTask;
  149646. /**
  149647. * Add a TextureAssetTask to the list of active tasks
  149648. * @param taskName defines the name of the new task
  149649. * @param url defines the url of the file to load
  149650. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149651. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149652. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149653. * @returns a new TextureAssetTask object
  149654. */
  149655. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149656. /**
  149657. * Add a CubeTextureAssetTask to the list of active tasks
  149658. * @param taskName defines the name of the new task
  149659. * @param url defines the url of the file to load
  149660. * @param extensions defines the extension to use to load the cube map (can be null)
  149661. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149662. * @param files defines the list of files to load (can be null)
  149663. * @returns a new CubeTextureAssetTask object
  149664. */
  149665. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149666. /**
  149667. *
  149668. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149669. * @param taskName defines the name of the new task
  149670. * @param url defines the url of the file to load
  149671. * @param size defines the size you want for the cubemap (can be null)
  149672. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149673. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149674. * @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)
  149675. * @param reserved Internal use only
  149676. * @returns a new HDRCubeTextureAssetTask object
  149677. */
  149678. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149679. /**
  149680. *
  149681. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149682. * @param taskName defines the name of the new task
  149683. * @param url defines the url of the file to load
  149684. * @param size defines the size you want for the cubemap (can be null)
  149685. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149686. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149687. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149688. * @returns a new EquiRectangularCubeTextureAssetTask object
  149689. */
  149690. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149691. /**
  149692. * Remove a task from the assets manager.
  149693. * @param task the task to remove
  149694. */
  149695. removeTask(task: AbstractAssetTask): void;
  149696. private _decreaseWaitingTasksCount;
  149697. private _runTask;
  149698. /**
  149699. * Reset the AssetsManager and remove all tasks
  149700. * @return the current instance of the AssetsManager
  149701. */
  149702. reset(): AssetsManager;
  149703. /**
  149704. * Start the loading process
  149705. * @return the current instance of the AssetsManager
  149706. */
  149707. load(): AssetsManager;
  149708. /**
  149709. * Start the loading process as an async operation
  149710. * @return a promise returning the list of failed tasks
  149711. */
  149712. loadAsync(): Promise<void>;
  149713. }
  149714. }
  149715. declare module BABYLON {
  149716. /**
  149717. * Wrapper class for promise with external resolve and reject.
  149718. */
  149719. export class Deferred<T> {
  149720. /**
  149721. * The promise associated with this deferred object.
  149722. */
  149723. readonly promise: Promise<T>;
  149724. private _resolve;
  149725. private _reject;
  149726. /**
  149727. * The resolve method of the promise associated with this deferred object.
  149728. */
  149729. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149730. /**
  149731. * The reject method of the promise associated with this deferred object.
  149732. */
  149733. get reject(): (reason?: any) => void;
  149734. /**
  149735. * Constructor for this deferred object.
  149736. */
  149737. constructor();
  149738. }
  149739. }
  149740. declare module BABYLON {
  149741. /**
  149742. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149743. */
  149744. export class MeshExploder {
  149745. private _centerMesh;
  149746. private _meshes;
  149747. private _meshesOrigins;
  149748. private _toCenterVectors;
  149749. private _scaledDirection;
  149750. private _newPosition;
  149751. private _centerPosition;
  149752. /**
  149753. * Explodes meshes from a center mesh.
  149754. * @param meshes The meshes to explode.
  149755. * @param centerMesh The mesh to be center of explosion.
  149756. */
  149757. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149758. private _setCenterMesh;
  149759. /**
  149760. * Get class name
  149761. * @returns "MeshExploder"
  149762. */
  149763. getClassName(): string;
  149764. /**
  149765. * "Exploded meshes"
  149766. * @returns Array of meshes with the centerMesh at index 0.
  149767. */
  149768. getMeshes(): Array<Mesh>;
  149769. /**
  149770. * Explodes meshes giving a specific direction
  149771. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149772. */
  149773. explode(direction?: number): void;
  149774. }
  149775. }
  149776. declare module BABYLON {
  149777. /**
  149778. * Class used to help managing file picking and drag'n'drop
  149779. */
  149780. export class FilesInput {
  149781. /**
  149782. * List of files ready to be loaded
  149783. */
  149784. static get FilesToLoad(): {
  149785. [key: string]: File;
  149786. };
  149787. /**
  149788. * Callback called when a file is processed
  149789. */
  149790. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  149791. private _engine;
  149792. private _currentScene;
  149793. private _sceneLoadedCallback;
  149794. private _progressCallback;
  149795. private _additionalRenderLoopLogicCallback;
  149796. private _textureLoadingCallback;
  149797. private _startingProcessingFilesCallback;
  149798. private _onReloadCallback;
  149799. private _errorCallback;
  149800. private _elementToMonitor;
  149801. private _sceneFileToLoad;
  149802. private _filesToLoad;
  149803. /**
  149804. * Creates a new FilesInput
  149805. * @param engine defines the rendering engine
  149806. * @param scene defines the hosting scene
  149807. * @param sceneLoadedCallback callback called when scene is loaded
  149808. * @param progressCallback callback called to track progress
  149809. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149810. * @param textureLoadingCallback callback called when a texture is loading
  149811. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149812. * @param onReloadCallback callback called when a reload is requested
  149813. * @param errorCallback callback call if an error occurs
  149814. */
  149815. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  149816. private _dragEnterHandler;
  149817. private _dragOverHandler;
  149818. private _dropHandler;
  149819. /**
  149820. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149821. * @param elementToMonitor defines the DOM element to track
  149822. */
  149823. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149824. /** Gets the current list of files to load */
  149825. get filesToLoad(): File[];
  149826. /**
  149827. * Release all associated resources
  149828. */
  149829. dispose(): void;
  149830. private renderFunction;
  149831. private drag;
  149832. private drop;
  149833. private _traverseFolder;
  149834. private _processFiles;
  149835. /**
  149836. * Load files from a drop event
  149837. * @param event defines the drop event to use as source
  149838. */
  149839. loadFiles(event: any): void;
  149840. private _processReload;
  149841. /**
  149842. * Reload the current scene from the loaded files
  149843. */
  149844. reload(): void;
  149845. }
  149846. }
  149847. declare module BABYLON {
  149848. /**
  149849. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149851. */
  149852. export class SceneOptimization {
  149853. /**
  149854. * Defines the priority of this optimization (0 by default which means first in the list)
  149855. */
  149856. priority: number;
  149857. /**
  149858. * Gets a string describing the action executed by the current optimization
  149859. * @returns description string
  149860. */
  149861. getDescription(): string;
  149862. /**
  149863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149864. * @param scene defines the current scene where to apply this optimization
  149865. * @param optimizer defines the current optimizer
  149866. * @returns true if everything that can be done was applied
  149867. */
  149868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149869. /**
  149870. * Creates the SceneOptimization object
  149871. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149872. * @param desc defines the description associated with the optimization
  149873. */
  149874. constructor(
  149875. /**
  149876. * Defines the priority of this optimization (0 by default which means first in the list)
  149877. */
  149878. priority?: number);
  149879. }
  149880. /**
  149881. * Defines an optimization used to reduce the size of render target textures
  149882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149883. */
  149884. export class TextureOptimization extends SceneOptimization {
  149885. /**
  149886. * Defines the priority of this optimization (0 by default which means first in the list)
  149887. */
  149888. priority: number;
  149889. /**
  149890. * 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
  149891. */
  149892. maximumSize: number;
  149893. /**
  149894. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149895. */
  149896. step: number;
  149897. /**
  149898. * Gets a string describing the action executed by the current optimization
  149899. * @returns description string
  149900. */
  149901. getDescription(): string;
  149902. /**
  149903. * Creates the TextureOptimization object
  149904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149905. * @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
  149906. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149907. */
  149908. constructor(
  149909. /**
  149910. * Defines the priority of this optimization (0 by default which means first in the list)
  149911. */
  149912. priority?: number,
  149913. /**
  149914. * 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
  149915. */
  149916. maximumSize?: number,
  149917. /**
  149918. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149919. */
  149920. step?: number);
  149921. /**
  149922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149923. * @param scene defines the current scene where to apply this optimization
  149924. * @param optimizer defines the current optimizer
  149925. * @returns true if everything that can be done was applied
  149926. */
  149927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149928. }
  149929. /**
  149930. * Defines an optimization used to increase or decrease the rendering resolution
  149931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149932. */
  149933. export class HardwareScalingOptimization extends SceneOptimization {
  149934. /**
  149935. * Defines the priority of this optimization (0 by default which means first in the list)
  149936. */
  149937. priority: number;
  149938. /**
  149939. * Defines the maximum scale to use (2 by default)
  149940. */
  149941. maximumScale: number;
  149942. /**
  149943. * Defines the step to use between two passes (0.5 by default)
  149944. */
  149945. step: number;
  149946. private _currentScale;
  149947. private _directionOffset;
  149948. /**
  149949. * Gets a string describing the action executed by the current optimization
  149950. * @return description string
  149951. */
  149952. getDescription(): string;
  149953. /**
  149954. * Creates the HardwareScalingOptimization object
  149955. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149956. * @param maximumScale defines the maximum scale to use (2 by default)
  149957. * @param step defines the step to use between two passes (0.5 by default)
  149958. */
  149959. constructor(
  149960. /**
  149961. * Defines the priority of this optimization (0 by default which means first in the list)
  149962. */
  149963. priority?: number,
  149964. /**
  149965. * Defines the maximum scale to use (2 by default)
  149966. */
  149967. maximumScale?: number,
  149968. /**
  149969. * Defines the step to use between two passes (0.5 by default)
  149970. */
  149971. step?: number);
  149972. /**
  149973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149974. * @param scene defines the current scene where to apply this optimization
  149975. * @param optimizer defines the current optimizer
  149976. * @returns true if everything that can be done was applied
  149977. */
  149978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149979. }
  149980. /**
  149981. * Defines an optimization used to remove shadows
  149982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149983. */
  149984. export class ShadowsOptimization extends SceneOptimization {
  149985. /**
  149986. * Gets a string describing the action executed by the current optimization
  149987. * @return description string
  149988. */
  149989. getDescription(): string;
  149990. /**
  149991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149992. * @param scene defines the current scene where to apply this optimization
  149993. * @param optimizer defines the current optimizer
  149994. * @returns true if everything that can be done was applied
  149995. */
  149996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149997. }
  149998. /**
  149999. * Defines an optimization used to turn post-processes off
  150000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150001. */
  150002. export class PostProcessesOptimization extends SceneOptimization {
  150003. /**
  150004. * Gets a string describing the action executed by the current optimization
  150005. * @return description string
  150006. */
  150007. getDescription(): string;
  150008. /**
  150009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150010. * @param scene defines the current scene where to apply this optimization
  150011. * @param optimizer defines the current optimizer
  150012. * @returns true if everything that can be done was applied
  150013. */
  150014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150015. }
  150016. /**
  150017. * Defines an optimization used to turn lens flares off
  150018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150019. */
  150020. export class LensFlaresOptimization extends SceneOptimization {
  150021. /**
  150022. * Gets a string describing the action executed by the current optimization
  150023. * @return description string
  150024. */
  150025. getDescription(): string;
  150026. /**
  150027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150028. * @param scene defines the current scene where to apply this optimization
  150029. * @param optimizer defines the current optimizer
  150030. * @returns true if everything that can be done was applied
  150031. */
  150032. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150033. }
  150034. /**
  150035. * Defines an optimization based on user defined callback.
  150036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150037. */
  150038. export class CustomOptimization extends SceneOptimization {
  150039. /**
  150040. * Callback called to apply the custom optimization.
  150041. */
  150042. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150043. /**
  150044. * Callback called to get custom description
  150045. */
  150046. onGetDescription: () => string;
  150047. /**
  150048. * Gets a string describing the action executed by the current optimization
  150049. * @returns description string
  150050. */
  150051. getDescription(): string;
  150052. /**
  150053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150054. * @param scene defines the current scene where to apply this optimization
  150055. * @param optimizer defines the current optimizer
  150056. * @returns true if everything that can be done was applied
  150057. */
  150058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150059. }
  150060. /**
  150061. * Defines an optimization used to turn particles off
  150062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150063. */
  150064. export class ParticlesOptimization extends SceneOptimization {
  150065. /**
  150066. * Gets a string describing the action executed by the current optimization
  150067. * @return description string
  150068. */
  150069. getDescription(): string;
  150070. /**
  150071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150072. * @param scene defines the current scene where to apply this optimization
  150073. * @param optimizer defines the current optimizer
  150074. * @returns true if everything that can be done was applied
  150075. */
  150076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150077. }
  150078. /**
  150079. * Defines an optimization used to turn render targets off
  150080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150081. */
  150082. export class RenderTargetsOptimization extends SceneOptimization {
  150083. /**
  150084. * Gets a string describing the action executed by the current optimization
  150085. * @return description string
  150086. */
  150087. getDescription(): string;
  150088. /**
  150089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150090. * @param scene defines the current scene where to apply this optimization
  150091. * @param optimizer defines the current optimizer
  150092. * @returns true if everything that can be done was applied
  150093. */
  150094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150095. }
  150096. /**
  150097. * Defines an optimization used to merge meshes with compatible materials
  150098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150099. */
  150100. export class MergeMeshesOptimization extends SceneOptimization {
  150101. private static _UpdateSelectionTree;
  150102. /**
  150103. * Gets or sets a boolean which defines if optimization octree has to be updated
  150104. */
  150105. static get UpdateSelectionTree(): boolean;
  150106. /**
  150107. * Gets or sets a boolean which defines if optimization octree has to be updated
  150108. */
  150109. static set UpdateSelectionTree(value: boolean);
  150110. /**
  150111. * Gets a string describing the action executed by the current optimization
  150112. * @return description string
  150113. */
  150114. getDescription(): string;
  150115. private _canBeMerged;
  150116. /**
  150117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150118. * @param scene defines the current scene where to apply this optimization
  150119. * @param optimizer defines the current optimizer
  150120. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150121. * @returns true if everything that can be done was applied
  150122. */
  150123. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150124. }
  150125. /**
  150126. * Defines a list of options used by SceneOptimizer
  150127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150128. */
  150129. export class SceneOptimizerOptions {
  150130. /**
  150131. * Defines the target frame rate to reach (60 by default)
  150132. */
  150133. targetFrameRate: number;
  150134. /**
  150135. * Defines the interval between two checkes (2000ms by default)
  150136. */
  150137. trackerDuration: number;
  150138. /**
  150139. * Gets the list of optimizations to apply
  150140. */
  150141. optimizations: SceneOptimization[];
  150142. /**
  150143. * Creates a new list of options used by SceneOptimizer
  150144. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150145. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150146. */
  150147. constructor(
  150148. /**
  150149. * Defines the target frame rate to reach (60 by default)
  150150. */
  150151. targetFrameRate?: number,
  150152. /**
  150153. * Defines the interval between two checkes (2000ms by default)
  150154. */
  150155. trackerDuration?: number);
  150156. /**
  150157. * Add a new optimization
  150158. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150159. * @returns the current SceneOptimizerOptions
  150160. */
  150161. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150162. /**
  150163. * Add a new custom optimization
  150164. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150165. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150166. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150167. * @returns the current SceneOptimizerOptions
  150168. */
  150169. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150170. /**
  150171. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150172. * @param targetFrameRate defines the target frame rate (60 by default)
  150173. * @returns a SceneOptimizerOptions object
  150174. */
  150175. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150176. /**
  150177. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150178. * @param targetFrameRate defines the target frame rate (60 by default)
  150179. * @returns a SceneOptimizerOptions object
  150180. */
  150181. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150182. /**
  150183. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150184. * @param targetFrameRate defines the target frame rate (60 by default)
  150185. * @returns a SceneOptimizerOptions object
  150186. */
  150187. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150188. }
  150189. /**
  150190. * Class used to run optimizations in order to reach a target frame rate
  150191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150192. */
  150193. export class SceneOptimizer implements IDisposable {
  150194. private _isRunning;
  150195. private _options;
  150196. private _scene;
  150197. private _currentPriorityLevel;
  150198. private _targetFrameRate;
  150199. private _trackerDuration;
  150200. private _currentFrameRate;
  150201. private _sceneDisposeObserver;
  150202. private _improvementMode;
  150203. /**
  150204. * Defines an observable called when the optimizer reaches the target frame rate
  150205. */
  150206. onSuccessObservable: Observable<SceneOptimizer>;
  150207. /**
  150208. * Defines an observable called when the optimizer enables an optimization
  150209. */
  150210. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150211. /**
  150212. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150213. */
  150214. onFailureObservable: Observable<SceneOptimizer>;
  150215. /**
  150216. * Gets a boolean indicating if the optimizer is in improvement mode
  150217. */
  150218. get isInImprovementMode(): boolean;
  150219. /**
  150220. * Gets the current priority level (0 at start)
  150221. */
  150222. get currentPriorityLevel(): number;
  150223. /**
  150224. * Gets the current frame rate checked by the SceneOptimizer
  150225. */
  150226. get currentFrameRate(): number;
  150227. /**
  150228. * Gets or sets the current target frame rate (60 by default)
  150229. */
  150230. get targetFrameRate(): number;
  150231. /**
  150232. * Gets or sets the current target frame rate (60 by default)
  150233. */
  150234. set targetFrameRate(value: number);
  150235. /**
  150236. * Gets or sets the current interval between two checks (every 2000ms by default)
  150237. */
  150238. get trackerDuration(): number;
  150239. /**
  150240. * Gets or sets the current interval between two checks (every 2000ms by default)
  150241. */
  150242. set trackerDuration(value: number);
  150243. /**
  150244. * Gets the list of active optimizations
  150245. */
  150246. get optimizations(): SceneOptimization[];
  150247. /**
  150248. * Creates a new SceneOptimizer
  150249. * @param scene defines the scene to work on
  150250. * @param options defines the options to use with the SceneOptimizer
  150251. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150252. * @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)
  150253. */
  150254. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150255. /**
  150256. * Stops the current optimizer
  150257. */
  150258. stop(): void;
  150259. /**
  150260. * Reset the optimizer to initial step (current priority level = 0)
  150261. */
  150262. reset(): void;
  150263. /**
  150264. * Start the optimizer. By default it will try to reach a specific framerate
  150265. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150266. */
  150267. start(): void;
  150268. private _checkCurrentState;
  150269. /**
  150270. * Release all resources
  150271. */
  150272. dispose(): void;
  150273. /**
  150274. * Helper function to create a SceneOptimizer with one single line of code
  150275. * @param scene defines the scene to work on
  150276. * @param options defines the options to use with the SceneOptimizer
  150277. * @param onSuccess defines a callback to call on success
  150278. * @param onFailure defines a callback to call on failure
  150279. * @returns the new SceneOptimizer object
  150280. */
  150281. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  150282. }
  150283. }
  150284. declare module BABYLON {
  150285. /**
  150286. * Class used to serialize a scene into a string
  150287. */
  150288. export class SceneSerializer {
  150289. /**
  150290. * Clear cache used by a previous serialization
  150291. */
  150292. static ClearCache(): void;
  150293. /**
  150294. * Serialize a scene into a JSON compatible object
  150295. * @param scene defines the scene to serialize
  150296. * @returns a JSON compatible object
  150297. */
  150298. static Serialize(scene: Scene): any;
  150299. /**
  150300. * Serialize a mesh into a JSON compatible object
  150301. * @param toSerialize defines the mesh to serialize
  150302. * @param withParents defines if parents must be serialized as well
  150303. * @param withChildren defines if children must be serialized as well
  150304. * @returns a JSON compatible object
  150305. */
  150306. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  150307. }
  150308. }
  150309. declare module BABYLON {
  150310. /**
  150311. * Class used to host texture specific utilities
  150312. */
  150313. export class TextureTools {
  150314. /**
  150315. * Uses the GPU to create a copy texture rescaled at a given size
  150316. * @param texture Texture to copy from
  150317. * @param width defines the desired width
  150318. * @param height defines the desired height
  150319. * @param useBilinearMode defines if bilinear mode has to be used
  150320. * @return the generated texture
  150321. */
  150322. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  150323. }
  150324. }
  150325. declare module BABYLON {
  150326. /**
  150327. * This represents the different options available for the video capture.
  150328. */
  150329. export interface VideoRecorderOptions {
  150330. /** Defines the mime type of the video. */
  150331. mimeType: string;
  150332. /** Defines the FPS the video should be recorded at. */
  150333. fps: number;
  150334. /** Defines the chunk size for the recording data. */
  150335. recordChunckSize: number;
  150336. /** The audio tracks to attach to the recording. */
  150337. audioTracks?: MediaStreamTrack[];
  150338. }
  150339. /**
  150340. * This can help with recording videos from BabylonJS.
  150341. * This is based on the available WebRTC functionalities of the browser.
  150342. *
  150343. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  150344. */
  150345. export class VideoRecorder {
  150346. private static readonly _defaultOptions;
  150347. /**
  150348. * Returns whether or not the VideoRecorder is available in your browser.
  150349. * @param engine Defines the Babylon Engine.
  150350. * @returns true if supported otherwise false.
  150351. */
  150352. static IsSupported(engine: Engine): boolean;
  150353. private readonly _options;
  150354. private _canvas;
  150355. private _mediaRecorder;
  150356. private _recordedChunks;
  150357. private _fileName;
  150358. private _resolve;
  150359. private _reject;
  150360. /**
  150361. * True when a recording is already in progress.
  150362. */
  150363. get isRecording(): boolean;
  150364. /**
  150365. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  150366. * @param engine Defines the BabylonJS Engine you wish to record.
  150367. * @param options Defines options that can be used to customize the capture.
  150368. */
  150369. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  150370. /**
  150371. * Stops the current recording before the default capture timeout passed in the startRecording function.
  150372. */
  150373. stopRecording(): void;
  150374. /**
  150375. * Starts recording the canvas for a max duration specified in parameters.
  150376. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  150377. * If null no automatic download will start and you can rely on the promise to get the data back.
  150378. * @param maxDuration Defines the maximum recording time in seconds.
  150379. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  150380. * @return A promise callback at the end of the recording with the video data in Blob.
  150381. */
  150382. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  150383. /**
  150384. * Releases internal resources used during the recording.
  150385. */
  150386. dispose(): void;
  150387. private _handleDataAvailable;
  150388. private _handleError;
  150389. private _handleStop;
  150390. }
  150391. }
  150392. declare module BABYLON {
  150393. /**
  150394. * Class containing a set of static utilities functions for screenshots
  150395. */
  150396. export class ScreenshotTools {
  150397. /**
  150398. * Captures a screenshot of the current rendering
  150399. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150400. * @param engine defines the rendering engine
  150401. * @param camera defines the source camera
  150402. * @param size This parameter can be set to a single number or to an object with the
  150403. * following (optional) properties: precision, width, height. If a single number is passed,
  150404. * it will be used for both width and height. If an object is passed, the screenshot size
  150405. * will be derived from the parameters. The precision property is a multiplier allowing
  150406. * rendering at a higher or lower resolution
  150407. * @param successCallback defines the callback receives a single parameter which contains the
  150408. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150409. * src parameter of an <img> to display it
  150410. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150411. * Check your browser for supported MIME types
  150412. */
  150413. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  150414. /**
  150415. * Captures a screenshot of the current rendering
  150416. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150417. * @param engine defines the rendering engine
  150418. * @param camera defines the source camera
  150419. * @param size This parameter can be set to a single number or to an object with the
  150420. * following (optional) properties: precision, width, height. If a single number is passed,
  150421. * it will be used for both width and height. If an object is passed, the screenshot size
  150422. * will be derived from the parameters. The precision property is a multiplier allowing
  150423. * rendering at a higher or lower resolution
  150424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150425. * Check your browser for supported MIME types
  150426. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150427. * to the src parameter of an <img> to display it
  150428. */
  150429. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  150430. /**
  150431. * Generates an image screenshot from the specified camera.
  150432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150433. * @param engine The engine to use for rendering
  150434. * @param camera The camera to use for rendering
  150435. * @param size This parameter can be set to a single number or to an object with the
  150436. * following (optional) properties: precision, width, height. If a single number is passed,
  150437. * it will be used for both width and height. If an object is passed, the screenshot size
  150438. * will be derived from the parameters. The precision property is a multiplier allowing
  150439. * rendering at a higher or lower resolution
  150440. * @param successCallback The callback receives a single parameter which contains the
  150441. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150442. * src parameter of an <img> to display it
  150443. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150444. * Check your browser for supported MIME types
  150445. * @param samples Texture samples (default: 1)
  150446. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150447. * @param fileName A name for for the downloaded file.
  150448. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150449. */
  150450. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  150451. /**
  150452. * Generates an image screenshot from the specified camera.
  150453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150454. * @param engine The engine to use for rendering
  150455. * @param camera The camera to use for rendering
  150456. * @param size This parameter can be set to a single number or to an object with the
  150457. * following (optional) properties: precision, width, height. If a single number is passed,
  150458. * it will be used for both width and height. If an object is passed, the screenshot size
  150459. * will be derived from the parameters. The precision property is a multiplier allowing
  150460. * rendering at a higher or lower resolution
  150461. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150462. * Check your browser for supported MIME types
  150463. * @param samples Texture samples (default: 1)
  150464. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150465. * @param fileName A name for for the downloaded file.
  150466. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150467. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150468. * to the src parameter of an <img> to display it
  150469. */
  150470. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  150471. /**
  150472. * Gets height and width for screenshot size
  150473. * @private
  150474. */
  150475. private static _getScreenshotSize;
  150476. }
  150477. }
  150478. declare module BABYLON {
  150479. /**
  150480. * Interface for a data buffer
  150481. */
  150482. export interface IDataBuffer {
  150483. /**
  150484. * Reads bytes from the data buffer.
  150485. * @param byteOffset The byte offset to read
  150486. * @param byteLength The byte length to read
  150487. * @returns A promise that resolves when the bytes are read
  150488. */
  150489. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  150490. /**
  150491. * The byte length of the buffer.
  150492. */
  150493. readonly byteLength: number;
  150494. }
  150495. /**
  150496. * Utility class for reading from a data buffer
  150497. */
  150498. export class DataReader {
  150499. /**
  150500. * The data buffer associated with this data reader.
  150501. */
  150502. readonly buffer: IDataBuffer;
  150503. /**
  150504. * The current byte offset from the beginning of the data buffer.
  150505. */
  150506. byteOffset: number;
  150507. private _dataView;
  150508. private _dataByteOffset;
  150509. /**
  150510. * Constructor
  150511. * @param buffer The buffer to read
  150512. */
  150513. constructor(buffer: IDataBuffer);
  150514. /**
  150515. * Loads the given byte length.
  150516. * @param byteLength The byte length to load
  150517. * @returns A promise that resolves when the load is complete
  150518. */
  150519. loadAsync(byteLength: number): Promise<void>;
  150520. /**
  150521. * Read a unsigned 32-bit integer from the currently loaded data range.
  150522. * @returns The 32-bit integer read
  150523. */
  150524. readUint32(): number;
  150525. /**
  150526. * Read a byte array from the currently loaded data range.
  150527. * @param byteLength The byte length to read
  150528. * @returns The byte array read
  150529. */
  150530. readUint8Array(byteLength: number): Uint8Array;
  150531. /**
  150532. * Read a string from the currently loaded data range.
  150533. * @param byteLength The byte length to read
  150534. * @returns The string read
  150535. */
  150536. readString(byteLength: number): string;
  150537. /**
  150538. * Skips the given byte length the currently loaded data range.
  150539. * @param byteLength The byte length to skip
  150540. */
  150541. skipBytes(byteLength: number): void;
  150542. }
  150543. }
  150544. declare module BABYLON {
  150545. /**
  150546. * Class for storing data to local storage if available or in-memory storage otherwise
  150547. */
  150548. export class DataStorage {
  150549. private static _Storage;
  150550. private static _GetStorage;
  150551. /**
  150552. * Reads a string from the data storage
  150553. * @param key The key to read
  150554. * @param defaultValue The value if the key doesn't exist
  150555. * @returns The string value
  150556. */
  150557. static ReadString(key: string, defaultValue: string): string;
  150558. /**
  150559. * Writes a string to the data storage
  150560. * @param key The key to write
  150561. * @param value The value to write
  150562. */
  150563. static WriteString(key: string, value: string): void;
  150564. /**
  150565. * Reads a boolean from the data storage
  150566. * @param key The key to read
  150567. * @param defaultValue The value if the key doesn't exist
  150568. * @returns The boolean value
  150569. */
  150570. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  150571. /**
  150572. * Writes a boolean to the data storage
  150573. * @param key The key to write
  150574. * @param value The value to write
  150575. */
  150576. static WriteBoolean(key: string, value: boolean): void;
  150577. /**
  150578. * Reads a number from the data storage
  150579. * @param key The key to read
  150580. * @param defaultValue The value if the key doesn't exist
  150581. * @returns The number value
  150582. */
  150583. static ReadNumber(key: string, defaultValue: number): number;
  150584. /**
  150585. * Writes a number to the data storage
  150586. * @param key The key to write
  150587. * @param value The value to write
  150588. */
  150589. static WriteNumber(key: string, value: number): void;
  150590. }
  150591. }
  150592. declare module BABYLON {
  150593. /**
  150594. * An interface for all Hit test features
  150595. */
  150596. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  150597. /**
  150598. * Triggered when new babylon (transformed) hit test results are available
  150599. */
  150600. onHitTestResultObservable: Observable<T[]>;
  150601. }
  150602. /**
  150603. * Options used for hit testing
  150604. */
  150605. export interface IWebXRLegacyHitTestOptions {
  150606. /**
  150607. * Only test when user interacted with the scene. Default - hit test every frame
  150608. */
  150609. testOnPointerDownOnly?: boolean;
  150610. /**
  150611. * The node to use to transform the local results to world coordinates
  150612. */
  150613. worldParentNode?: TransformNode;
  150614. }
  150615. /**
  150616. * Interface defining the babylon result of raycasting/hit-test
  150617. */
  150618. export interface IWebXRLegacyHitResult {
  150619. /**
  150620. * Transformation matrix that can be applied to a node that will put it in the hit point location
  150621. */
  150622. transformationMatrix: Matrix;
  150623. /**
  150624. * The native hit test result
  150625. */
  150626. xrHitResult: XRHitResult | XRHitTestResult;
  150627. }
  150628. /**
  150629. * The currently-working hit-test module.
  150630. * Hit test (or Ray-casting) is used to interact with the real world.
  150631. * For further information read here - https://github.com/immersive-web/hit-test
  150632. */
  150633. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150634. /**
  150635. * options to use when constructing this feature
  150636. */
  150637. readonly options: IWebXRLegacyHitTestOptions;
  150638. private _direction;
  150639. private _mat;
  150640. private _onSelectEnabled;
  150641. private _origin;
  150642. /**
  150643. * The module's name
  150644. */
  150645. static readonly Name: string;
  150646. /**
  150647. * The (Babylon) version of this module.
  150648. * This is an integer representing the implementation version.
  150649. * This number does not correspond to the WebXR specs version
  150650. */
  150651. static readonly Version: number;
  150652. /**
  150653. * Populated with the last native XR Hit Results
  150654. */
  150655. lastNativeXRHitResults: XRHitResult[];
  150656. /**
  150657. * Triggered when new babylon (transformed) hit test results are available
  150658. */
  150659. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150660. /**
  150661. * Creates a new instance of the (legacy version) hit test feature
  150662. * @param _xrSessionManager an instance of WebXRSessionManager
  150663. * @param options options to use when constructing this feature
  150664. */
  150665. constructor(_xrSessionManager: WebXRSessionManager,
  150666. /**
  150667. * options to use when constructing this feature
  150668. */
  150669. options?: IWebXRLegacyHitTestOptions);
  150670. /**
  150671. * execute a hit test with an XR Ray
  150672. *
  150673. * @param xrSession a native xrSession that will execute this hit test
  150674. * @param xrRay the ray (position and direction) to use for ray-casting
  150675. * @param referenceSpace native XR reference space to use for the hit-test
  150676. * @param filter filter function that will filter the results
  150677. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150678. */
  150679. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150680. /**
  150681. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150682. * @param event the (select) event to use to select with
  150683. * @param referenceSpace the reference space to use for this hit test
  150684. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150685. */
  150686. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150687. /**
  150688. * attach this feature
  150689. * Will usually be called by the features manager
  150690. *
  150691. * @returns true if successful.
  150692. */
  150693. attach(): boolean;
  150694. /**
  150695. * detach this feature.
  150696. * Will usually be called by the features manager
  150697. *
  150698. * @returns true if successful.
  150699. */
  150700. detach(): boolean;
  150701. /**
  150702. * Dispose this feature and all of the resources attached
  150703. */
  150704. dispose(): void;
  150705. protected _onXRFrame(frame: XRFrame): void;
  150706. private _onHitTestResults;
  150707. private _onSelect;
  150708. }
  150709. }
  150710. declare module BABYLON {
  150711. /**
  150712. * Options used for hit testing (version 2)
  150713. */
  150714. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150715. /**
  150716. * Do not create a permanent hit test. Will usually be used when only
  150717. * transient inputs are needed.
  150718. */
  150719. disablePermanentHitTest?: boolean;
  150720. /**
  150721. * Enable transient (for example touch-based) hit test inspections
  150722. */
  150723. enableTransientHitTest?: boolean;
  150724. /**
  150725. * Offset ray for the permanent hit test
  150726. */
  150727. offsetRay?: Vector3;
  150728. /**
  150729. * Offset ray for the transient hit test
  150730. */
  150731. transientOffsetRay?: Vector3;
  150732. /**
  150733. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150734. */
  150735. useReferenceSpace?: boolean;
  150736. }
  150737. /**
  150738. * Interface defining the babylon result of hit-test
  150739. */
  150740. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150741. /**
  150742. * The input source that generated this hit test (if transient)
  150743. */
  150744. inputSource?: XRInputSource;
  150745. /**
  150746. * Is this a transient hit test
  150747. */
  150748. isTransient?: boolean;
  150749. /**
  150750. * Position of the hit test result
  150751. */
  150752. position: Vector3;
  150753. /**
  150754. * Rotation of the hit test result
  150755. */
  150756. rotationQuaternion: Quaternion;
  150757. /**
  150758. * The native hit test result
  150759. */
  150760. xrHitResult: XRHitTestResult;
  150761. }
  150762. /**
  150763. * The currently-working hit-test module.
  150764. * Hit test (or Ray-casting) is used to interact with the real world.
  150765. * For further information read here - https://github.com/immersive-web/hit-test
  150766. *
  150767. * Tested on chrome (mobile) 80.
  150768. */
  150769. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150770. /**
  150771. * options to use when constructing this feature
  150772. */
  150773. readonly options: IWebXRHitTestOptions;
  150774. private _tmpMat;
  150775. private _tmpPos;
  150776. private _tmpQuat;
  150777. private _transientXrHitTestSource;
  150778. private _xrHitTestSource;
  150779. private initHitTestSource;
  150780. /**
  150781. * The module's name
  150782. */
  150783. static readonly Name: string;
  150784. /**
  150785. * The (Babylon) version of this module.
  150786. * This is an integer representing the implementation version.
  150787. * This number does not correspond to the WebXR specs version
  150788. */
  150789. static readonly Version: number;
  150790. /**
  150791. * When set to true, each hit test will have its own position/rotation objects
  150792. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150793. * the developers will clone them or copy them as they see fit.
  150794. */
  150795. autoCloneTransformation: boolean;
  150796. /**
  150797. * Triggered when new babylon (transformed) hit test results are available
  150798. */
  150799. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150800. /**
  150801. * Use this to temporarily pause hit test checks.
  150802. */
  150803. paused: boolean;
  150804. /**
  150805. * Creates a new instance of the hit test feature
  150806. * @param _xrSessionManager an instance of WebXRSessionManager
  150807. * @param options options to use when constructing this feature
  150808. */
  150809. constructor(_xrSessionManager: WebXRSessionManager,
  150810. /**
  150811. * options to use when constructing this feature
  150812. */
  150813. options?: IWebXRHitTestOptions);
  150814. /**
  150815. * attach this feature
  150816. * Will usually be called by the features manager
  150817. *
  150818. * @returns true if successful.
  150819. */
  150820. attach(): boolean;
  150821. /**
  150822. * detach this feature.
  150823. * Will usually be called by the features manager
  150824. *
  150825. * @returns true if successful.
  150826. */
  150827. detach(): boolean;
  150828. /**
  150829. * Dispose this feature and all of the resources attached
  150830. */
  150831. dispose(): void;
  150832. protected _onXRFrame(frame: XRFrame): void;
  150833. private _processWebXRHitTestResult;
  150834. }
  150835. }
  150836. declare module BABYLON {
  150837. /**
  150838. * Configuration options of the anchor system
  150839. */
  150840. export interface IWebXRAnchorSystemOptions {
  150841. /**
  150842. * a node that will be used to convert local to world coordinates
  150843. */
  150844. worldParentNode?: TransformNode;
  150845. /**
  150846. * If set to true a reference of the created anchors will be kept until the next session starts
  150847. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150848. */
  150849. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150850. }
  150851. /**
  150852. * A babylon container for an XR Anchor
  150853. */
  150854. export interface IWebXRAnchor {
  150855. /**
  150856. * A babylon-assigned ID for this anchor
  150857. */
  150858. id: number;
  150859. /**
  150860. * Transformation matrix to apply to an object attached to this anchor
  150861. */
  150862. transformationMatrix: Matrix;
  150863. /**
  150864. * The native anchor object
  150865. */
  150866. xrAnchor: XRAnchor;
  150867. /**
  150868. * if defined, this object will be constantly updated by the anchor's position and rotation
  150869. */
  150870. attachedNode?: TransformNode;
  150871. }
  150872. /**
  150873. * An implementation of the anchor system for WebXR.
  150874. * For further information see https://github.com/immersive-web/anchors/
  150875. */
  150876. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150877. private _options;
  150878. private _lastFrameDetected;
  150879. private _trackedAnchors;
  150880. private _referenceSpaceForFrameAnchors;
  150881. private _futureAnchors;
  150882. /**
  150883. * The module's name
  150884. */
  150885. static readonly Name: string;
  150886. /**
  150887. * The (Babylon) version of this module.
  150888. * This is an integer representing the implementation version.
  150889. * This number does not correspond to the WebXR specs version
  150890. */
  150891. static readonly Version: number;
  150892. /**
  150893. * Observers registered here will be executed when a new anchor was added to the session
  150894. */
  150895. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150896. /**
  150897. * Observers registered here will be executed when an anchor was removed from the session
  150898. */
  150899. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150900. /**
  150901. * Observers registered here will be executed when an existing anchor updates
  150902. * This can execute N times every frame
  150903. */
  150904. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150905. /**
  150906. * Set the reference space to use for anchor creation, when not using a hit test.
  150907. * Will default to the session's reference space if not defined
  150908. */
  150909. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150910. /**
  150911. * constructs a new anchor system
  150912. * @param _xrSessionManager an instance of WebXRSessionManager
  150913. * @param _options configuration object for this feature
  150914. */
  150915. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150916. private _tmpVector;
  150917. private _tmpQuaternion;
  150918. private _populateTmpTransformation;
  150919. /**
  150920. * Create a new anchor point using a hit test result at a specific point in the scene
  150921. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150922. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150923. *
  150924. * @param hitTestResult The hit test result to use for this anchor creation
  150925. * @param position an optional position offset for this anchor
  150926. * @param rotationQuaternion an optional rotation offset for this anchor
  150927. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150928. */
  150929. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150930. /**
  150931. * Add a new anchor at a specific position and rotation
  150932. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150933. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150934. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150935. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150936. *
  150937. * @param position the position in which to add an anchor
  150938. * @param rotationQuaternion an optional rotation for the anchor transformation
  150939. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150940. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150941. */
  150942. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150943. /**
  150944. * detach this feature.
  150945. * Will usually be called by the features manager
  150946. *
  150947. * @returns true if successful.
  150948. */
  150949. detach(): boolean;
  150950. /**
  150951. * Dispose this feature and all of the resources attached
  150952. */
  150953. dispose(): void;
  150954. protected _onXRFrame(frame: XRFrame): void;
  150955. /**
  150956. * avoiding using Array.find for global support.
  150957. * @param xrAnchor the plane to find in the array
  150958. */
  150959. private _findIndexInAnchorArray;
  150960. private _updateAnchorWithXRFrame;
  150961. private _createAnchorAtTransformation;
  150962. }
  150963. }
  150964. declare module BABYLON {
  150965. /**
  150966. * Options used in the plane detector module
  150967. */
  150968. export interface IWebXRPlaneDetectorOptions {
  150969. /**
  150970. * The node to use to transform the local results to world coordinates
  150971. */
  150972. worldParentNode?: TransformNode;
  150973. /**
  150974. * If set to true a reference of the created planes will be kept until the next session starts
  150975. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150976. */
  150977. doNotRemovePlanesOnSessionEnded?: boolean;
  150978. }
  150979. /**
  150980. * A babylon interface for a WebXR plane.
  150981. * A Plane is actually a polygon, built from N points in space
  150982. *
  150983. * Supported in chrome 79, not supported in canary 81 ATM
  150984. */
  150985. export interface IWebXRPlane {
  150986. /**
  150987. * a babylon-assigned ID for this polygon
  150988. */
  150989. id: number;
  150990. /**
  150991. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150992. */
  150993. polygonDefinition: Array<Vector3>;
  150994. /**
  150995. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150996. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150997. */
  150998. transformationMatrix: Matrix;
  150999. /**
  151000. * the native xr-plane object
  151001. */
  151002. xrPlane: XRPlane;
  151003. }
  151004. /**
  151005. * The plane detector is used to detect planes in the real world when in AR
  151006. * For more information see https://github.com/immersive-web/real-world-geometry/
  151007. */
  151008. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151009. private _options;
  151010. private _detectedPlanes;
  151011. private _enabled;
  151012. private _lastFrameDetected;
  151013. /**
  151014. * The module's name
  151015. */
  151016. static readonly Name: string;
  151017. /**
  151018. * The (Babylon) version of this module.
  151019. * This is an integer representing the implementation version.
  151020. * This number does not correspond to the WebXR specs version
  151021. */
  151022. static readonly Version: number;
  151023. /**
  151024. * Observers registered here will be executed when a new plane was added to the session
  151025. */
  151026. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151027. /**
  151028. * Observers registered here will be executed when a plane is no longer detected in the session
  151029. */
  151030. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151031. /**
  151032. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151033. * This can execute N times every frame
  151034. */
  151035. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151036. /**
  151037. * construct a new Plane Detector
  151038. * @param _xrSessionManager an instance of xr Session manager
  151039. * @param _options configuration to use when constructing this feature
  151040. */
  151041. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151042. /**
  151043. * detach this feature.
  151044. * Will usually be called by the features manager
  151045. *
  151046. * @returns true if successful.
  151047. */
  151048. detach(): boolean;
  151049. /**
  151050. * Dispose this feature and all of the resources attached
  151051. */
  151052. dispose(): void;
  151053. protected _onXRFrame(frame: XRFrame): void;
  151054. private _init;
  151055. private _updatePlaneWithXRPlane;
  151056. /**
  151057. * avoiding using Array.find for global support.
  151058. * @param xrPlane the plane to find in the array
  151059. */
  151060. private findIndexInPlaneArray;
  151061. }
  151062. }
  151063. declare module BABYLON {
  151064. /**
  151065. * Options interface for the background remover plugin
  151066. */
  151067. export interface IWebXRBackgroundRemoverOptions {
  151068. /**
  151069. * Further background meshes to disable when entering AR
  151070. */
  151071. backgroundMeshes?: AbstractMesh[];
  151072. /**
  151073. * flags to configure the removal of the environment helper.
  151074. * If not set, the entire background will be removed. If set, flags should be set as well.
  151075. */
  151076. environmentHelperRemovalFlags?: {
  151077. /**
  151078. * Should the skybox be removed (default false)
  151079. */
  151080. skyBox?: boolean;
  151081. /**
  151082. * Should the ground be removed (default false)
  151083. */
  151084. ground?: boolean;
  151085. };
  151086. /**
  151087. * don't disable the environment helper
  151088. */
  151089. ignoreEnvironmentHelper?: boolean;
  151090. }
  151091. /**
  151092. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151093. */
  151094. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151095. /**
  151096. * read-only options to be used in this module
  151097. */
  151098. readonly options: IWebXRBackgroundRemoverOptions;
  151099. /**
  151100. * The module's name
  151101. */
  151102. static readonly Name: string;
  151103. /**
  151104. * The (Babylon) version of this module.
  151105. * This is an integer representing the implementation version.
  151106. * This number does not correspond to the WebXR specs version
  151107. */
  151108. static readonly Version: number;
  151109. /**
  151110. * registered observers will be triggered when the background state changes
  151111. */
  151112. onBackgroundStateChangedObservable: Observable<boolean>;
  151113. /**
  151114. * constructs a new background remover module
  151115. * @param _xrSessionManager the session manager for this module
  151116. * @param options read-only options to be used in this module
  151117. */
  151118. constructor(_xrSessionManager: WebXRSessionManager,
  151119. /**
  151120. * read-only options to be used in this module
  151121. */
  151122. options?: IWebXRBackgroundRemoverOptions);
  151123. /**
  151124. * attach this feature
  151125. * Will usually be called by the features manager
  151126. *
  151127. * @returns true if successful.
  151128. */
  151129. attach(): boolean;
  151130. /**
  151131. * detach this feature.
  151132. * Will usually be called by the features manager
  151133. *
  151134. * @returns true if successful.
  151135. */
  151136. detach(): boolean;
  151137. /**
  151138. * Dispose this feature and all of the resources attached
  151139. */
  151140. dispose(): void;
  151141. protected _onXRFrame(_xrFrame: XRFrame): void;
  151142. private _setBackgroundState;
  151143. }
  151144. }
  151145. declare module BABYLON {
  151146. /**
  151147. * Options for the controller physics feature
  151148. */
  151149. export class IWebXRControllerPhysicsOptions {
  151150. /**
  151151. * Should the headset get its own impostor
  151152. */
  151153. enableHeadsetImpostor?: boolean;
  151154. /**
  151155. * Optional parameters for the headset impostor
  151156. */
  151157. headsetImpostorParams?: {
  151158. /**
  151159. * The type of impostor to create. Default is sphere
  151160. */
  151161. impostorType: number;
  151162. /**
  151163. * the size of the impostor. Defaults to 10cm
  151164. */
  151165. impostorSize?: number | {
  151166. width: number;
  151167. height: number;
  151168. depth: number;
  151169. };
  151170. /**
  151171. * Friction definitions
  151172. */
  151173. friction?: number;
  151174. /**
  151175. * Restitution
  151176. */
  151177. restitution?: number;
  151178. };
  151179. /**
  151180. * The physics properties of the future impostors
  151181. */
  151182. physicsProperties?: {
  151183. /**
  151184. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151185. * Note that this requires a physics engine that supports mesh impostors!
  151186. */
  151187. useControllerMesh?: boolean;
  151188. /**
  151189. * The type of impostor to create. Default is sphere
  151190. */
  151191. impostorType?: number;
  151192. /**
  151193. * the size of the impostor. Defaults to 10cm
  151194. */
  151195. impostorSize?: number | {
  151196. width: number;
  151197. height: number;
  151198. depth: number;
  151199. };
  151200. /**
  151201. * Friction definitions
  151202. */
  151203. friction?: number;
  151204. /**
  151205. * Restitution
  151206. */
  151207. restitution?: number;
  151208. };
  151209. /**
  151210. * the xr input to use with this pointer selection
  151211. */
  151212. xrInput: WebXRInput;
  151213. }
  151214. /**
  151215. * Add physics impostor to your webxr controllers,
  151216. * including naive calculation of their linear and angular velocity
  151217. */
  151218. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151219. private readonly _options;
  151220. private _attachController;
  151221. private _controllers;
  151222. private _debugMode;
  151223. private _delta;
  151224. private _headsetImpostor?;
  151225. private _headsetMesh?;
  151226. private _lastTimestamp;
  151227. private _tmpQuaternion;
  151228. private _tmpVector;
  151229. /**
  151230. * The module's name
  151231. */
  151232. static readonly Name: string;
  151233. /**
  151234. * The (Babylon) version of this module.
  151235. * This is an integer representing the implementation version.
  151236. * This number does not correspond to the webxr specs version
  151237. */
  151238. static readonly Version: number;
  151239. /**
  151240. * Construct a new Controller Physics Feature
  151241. * @param _xrSessionManager the corresponding xr session manager
  151242. * @param _options options to create this feature with
  151243. */
  151244. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151245. /**
  151246. * @hidden
  151247. * enable debugging - will show console outputs and the impostor mesh
  151248. */
  151249. _enablePhysicsDebug(): void;
  151250. /**
  151251. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151252. * @param xrController the controller to add
  151253. */
  151254. addController(xrController: WebXRInputSource): void;
  151255. /**
  151256. * attach this feature
  151257. * Will usually be called by the features manager
  151258. *
  151259. * @returns true if successful.
  151260. */
  151261. attach(): boolean;
  151262. /**
  151263. * detach this feature.
  151264. * Will usually be called by the features manager
  151265. *
  151266. * @returns true if successful.
  151267. */
  151268. detach(): boolean;
  151269. /**
  151270. * Get the headset impostor, if enabled
  151271. * @returns the impostor
  151272. */
  151273. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151274. /**
  151275. * Get the physics impostor of a specific controller.
  151276. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  151277. * @param controller the controller or the controller id of which to get the impostor
  151278. * @returns the impostor or null
  151279. */
  151280. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  151281. /**
  151282. * Update the physics properties provided in the constructor
  151283. * @param newProperties the new properties object
  151284. */
  151285. setPhysicsProperties(newProperties: {
  151286. impostorType?: number;
  151287. impostorSize?: number | {
  151288. width: number;
  151289. height: number;
  151290. depth: number;
  151291. };
  151292. friction?: number;
  151293. restitution?: number;
  151294. }): void;
  151295. protected _onXRFrame(_xrFrame: any): void;
  151296. private _detachController;
  151297. }
  151298. }
  151299. declare module BABYLON {
  151300. /**
  151301. * The motion controller class for all microsoft mixed reality controllers
  151302. */
  151303. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  151304. protected readonly _mapping: {
  151305. defaultButton: {
  151306. valueNodeName: string;
  151307. unpressedNodeName: string;
  151308. pressedNodeName: string;
  151309. };
  151310. defaultAxis: {
  151311. valueNodeName: string;
  151312. minNodeName: string;
  151313. maxNodeName: string;
  151314. };
  151315. buttons: {
  151316. "xr-standard-trigger": {
  151317. rootNodeName: string;
  151318. componentProperty: string;
  151319. states: string[];
  151320. };
  151321. "xr-standard-squeeze": {
  151322. rootNodeName: string;
  151323. componentProperty: string;
  151324. states: string[];
  151325. };
  151326. "xr-standard-touchpad": {
  151327. rootNodeName: string;
  151328. labelAnchorNodeName: string;
  151329. touchPointNodeName: string;
  151330. };
  151331. "xr-standard-thumbstick": {
  151332. rootNodeName: string;
  151333. componentProperty: string;
  151334. states: string[];
  151335. };
  151336. };
  151337. axes: {
  151338. "xr-standard-touchpad": {
  151339. "x-axis": {
  151340. rootNodeName: string;
  151341. };
  151342. "y-axis": {
  151343. rootNodeName: string;
  151344. };
  151345. };
  151346. "xr-standard-thumbstick": {
  151347. "x-axis": {
  151348. rootNodeName: string;
  151349. };
  151350. "y-axis": {
  151351. rootNodeName: string;
  151352. };
  151353. };
  151354. };
  151355. };
  151356. /**
  151357. * The base url used to load the left and right controller models
  151358. */
  151359. static MODEL_BASE_URL: string;
  151360. /**
  151361. * The name of the left controller model file
  151362. */
  151363. static MODEL_LEFT_FILENAME: string;
  151364. /**
  151365. * The name of the right controller model file
  151366. */
  151367. static MODEL_RIGHT_FILENAME: string;
  151368. profileId: string;
  151369. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151370. protected _getFilenameAndPath(): {
  151371. filename: string;
  151372. path: string;
  151373. };
  151374. protected _getModelLoadingConstraints(): boolean;
  151375. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151376. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151377. protected _updateModel(): void;
  151378. }
  151379. }
  151380. declare module BABYLON {
  151381. /**
  151382. * The motion controller class for oculus touch (quest, rift).
  151383. * This class supports legacy mapping as well the standard xr mapping
  151384. */
  151385. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  151386. private _forceLegacyControllers;
  151387. private _modelRootNode;
  151388. /**
  151389. * The base url used to load the left and right controller models
  151390. */
  151391. static MODEL_BASE_URL: string;
  151392. /**
  151393. * The name of the left controller model file
  151394. */
  151395. static MODEL_LEFT_FILENAME: string;
  151396. /**
  151397. * The name of the right controller model file
  151398. */
  151399. static MODEL_RIGHT_FILENAME: string;
  151400. /**
  151401. * Base Url for the Quest controller model.
  151402. */
  151403. static QUEST_MODEL_BASE_URL: string;
  151404. profileId: string;
  151405. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  151406. protected _getFilenameAndPath(): {
  151407. filename: string;
  151408. path: string;
  151409. };
  151410. protected _getModelLoadingConstraints(): boolean;
  151411. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151412. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151413. protected _updateModel(): void;
  151414. /**
  151415. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  151416. * between the touch and touch 2.
  151417. */
  151418. private _isQuest;
  151419. }
  151420. }
  151421. declare module BABYLON {
  151422. /**
  151423. * The motion controller class for the standard HTC-Vive controllers
  151424. */
  151425. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  151426. private _modelRootNode;
  151427. /**
  151428. * The base url used to load the left and right controller models
  151429. */
  151430. static MODEL_BASE_URL: string;
  151431. /**
  151432. * File name for the controller model.
  151433. */
  151434. static MODEL_FILENAME: string;
  151435. profileId: string;
  151436. /**
  151437. * Create a new Vive motion controller object
  151438. * @param scene the scene to use to create this controller
  151439. * @param gamepadObject the corresponding gamepad object
  151440. * @param handedness the handedness of the controller
  151441. */
  151442. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151443. protected _getFilenameAndPath(): {
  151444. filename: string;
  151445. path: string;
  151446. };
  151447. protected _getModelLoadingConstraints(): boolean;
  151448. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151449. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151450. protected _updateModel(): void;
  151451. }
  151452. }
  151453. declare module BABYLON {
  151454. /**
  151455. * A cursor which tracks a point on a path
  151456. */
  151457. export class PathCursor {
  151458. private path;
  151459. /**
  151460. * Stores path cursor callbacks for when an onchange event is triggered
  151461. */
  151462. private _onchange;
  151463. /**
  151464. * The value of the path cursor
  151465. */
  151466. value: number;
  151467. /**
  151468. * The animation array of the path cursor
  151469. */
  151470. animations: Animation[];
  151471. /**
  151472. * Initializes the path cursor
  151473. * @param path The path to track
  151474. */
  151475. constructor(path: Path2);
  151476. /**
  151477. * Gets the cursor point on the path
  151478. * @returns A point on the path cursor at the cursor location
  151479. */
  151480. getPoint(): Vector3;
  151481. /**
  151482. * Moves the cursor ahead by the step amount
  151483. * @param step The amount to move the cursor forward
  151484. * @returns This path cursor
  151485. */
  151486. moveAhead(step?: number): PathCursor;
  151487. /**
  151488. * Moves the cursor behind by the step amount
  151489. * @param step The amount to move the cursor back
  151490. * @returns This path cursor
  151491. */
  151492. moveBack(step?: number): PathCursor;
  151493. /**
  151494. * Moves the cursor by the step amount
  151495. * If the step amount is greater than one, an exception is thrown
  151496. * @param step The amount to move the cursor
  151497. * @returns This path cursor
  151498. */
  151499. move(step: number): PathCursor;
  151500. /**
  151501. * Ensures that the value is limited between zero and one
  151502. * @returns This path cursor
  151503. */
  151504. private ensureLimits;
  151505. /**
  151506. * Runs onchange callbacks on change (used by the animation engine)
  151507. * @returns This path cursor
  151508. */
  151509. private raiseOnChange;
  151510. /**
  151511. * Executes a function on change
  151512. * @param f A path cursor onchange callback
  151513. * @returns This path cursor
  151514. */
  151515. onchange(f: (cursor: PathCursor) => void): PathCursor;
  151516. }
  151517. }
  151518. declare module BABYLON {
  151519. /** @hidden */
  151520. export var blurPixelShader: {
  151521. name: string;
  151522. shader: string;
  151523. };
  151524. }
  151525. declare module BABYLON {
  151526. /** @hidden */
  151527. export var pointCloudVertexDeclaration: {
  151528. name: string;
  151529. shader: string;
  151530. };
  151531. }
  151532. // Mixins
  151533. interface Window {
  151534. mozIndexedDB: IDBFactory;
  151535. webkitIndexedDB: IDBFactory;
  151536. msIndexedDB: IDBFactory;
  151537. webkitURL: typeof URL;
  151538. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  151539. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  151540. WebGLRenderingContext: WebGLRenderingContext;
  151541. MSGesture: MSGesture;
  151542. CANNON: any;
  151543. AudioContext: AudioContext;
  151544. webkitAudioContext: AudioContext;
  151545. PointerEvent: any;
  151546. Math: Math;
  151547. Uint8Array: Uint8ArrayConstructor;
  151548. Float32Array: Float32ArrayConstructor;
  151549. mozURL: typeof URL;
  151550. msURL: typeof URL;
  151551. VRFrameData: any; // WebVR, from specs 1.1
  151552. DracoDecoderModule: any;
  151553. setImmediate(handler: (...args: any[]) => void): number;
  151554. }
  151555. interface HTMLCanvasElement {
  151556. requestPointerLock(): void;
  151557. msRequestPointerLock?(): void;
  151558. mozRequestPointerLock?(): void;
  151559. webkitRequestPointerLock?(): void;
  151560. /** Track wether a record is in progress */
  151561. isRecording: boolean;
  151562. /** Capture Stream method defined by some browsers */
  151563. captureStream(fps?: number): MediaStream;
  151564. }
  151565. interface CanvasRenderingContext2D {
  151566. msImageSmoothingEnabled: boolean;
  151567. }
  151568. interface MouseEvent {
  151569. mozMovementX: number;
  151570. mozMovementY: number;
  151571. webkitMovementX: number;
  151572. webkitMovementY: number;
  151573. msMovementX: number;
  151574. msMovementY: number;
  151575. }
  151576. interface Navigator {
  151577. mozGetVRDevices: (any: any) => any;
  151578. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151579. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151580. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151581. webkitGetGamepads(): Gamepad[];
  151582. msGetGamepads(): Gamepad[];
  151583. webkitGamepads(): Gamepad[];
  151584. }
  151585. interface HTMLVideoElement {
  151586. mozSrcObject: any;
  151587. }
  151588. interface Math {
  151589. fround(x: number): number;
  151590. imul(a: number, b: number): number;
  151591. }
  151592. interface WebGLRenderingContext {
  151593. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  151594. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  151595. vertexAttribDivisor(index: number, divisor: number): void;
  151596. createVertexArray(): any;
  151597. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  151598. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  151599. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  151600. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  151601. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  151602. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  151603. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  151604. // Queries
  151605. createQuery(): WebGLQuery;
  151606. deleteQuery(query: WebGLQuery): void;
  151607. beginQuery(target: number, query: WebGLQuery): void;
  151608. endQuery(target: number): void;
  151609. getQueryParameter(query: WebGLQuery, pname: number): any;
  151610. getQuery(target: number, pname: number): any;
  151611. MAX_SAMPLES: number;
  151612. RGBA8: number;
  151613. READ_FRAMEBUFFER: number;
  151614. DRAW_FRAMEBUFFER: number;
  151615. UNIFORM_BUFFER: number;
  151616. HALF_FLOAT_OES: number;
  151617. RGBA16F: number;
  151618. RGBA32F: number;
  151619. R32F: number;
  151620. RG32F: number;
  151621. RGB32F: number;
  151622. R16F: number;
  151623. RG16F: number;
  151624. RGB16F: number;
  151625. RED: number;
  151626. RG: number;
  151627. R8: number;
  151628. RG8: number;
  151629. UNSIGNED_INT_24_8: number;
  151630. DEPTH24_STENCIL8: number;
  151631. MIN: number;
  151632. MAX: number;
  151633. /* Multiple Render Targets */
  151634. drawBuffers(buffers: number[]): void;
  151635. readBuffer(src: number): void;
  151636. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151637. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151638. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151639. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151640. // Occlusion Query
  151641. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151642. ANY_SAMPLES_PASSED: number;
  151643. QUERY_RESULT_AVAILABLE: number;
  151644. QUERY_RESULT: number;
  151645. }
  151646. interface WebGLProgram {
  151647. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151648. }
  151649. interface EXT_disjoint_timer_query {
  151650. QUERY_COUNTER_BITS_EXT: number;
  151651. TIME_ELAPSED_EXT: number;
  151652. TIMESTAMP_EXT: number;
  151653. GPU_DISJOINT_EXT: number;
  151654. QUERY_RESULT_EXT: number;
  151655. QUERY_RESULT_AVAILABLE_EXT: number;
  151656. queryCounterEXT(query: WebGLQuery, target: number): void;
  151657. createQueryEXT(): WebGLQuery;
  151658. beginQueryEXT(target: number, query: WebGLQuery): void;
  151659. endQueryEXT(target: number): void;
  151660. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151661. deleteQueryEXT(query: WebGLQuery): void;
  151662. }
  151663. interface WebGLUniformLocation {
  151664. _currentState: any;
  151665. }
  151666. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151667. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151668. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151669. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151670. interface WebGLRenderingContext {
  151671. readonly RASTERIZER_DISCARD: number;
  151672. readonly DEPTH_COMPONENT24: number;
  151673. readonly TEXTURE_3D: number;
  151674. readonly TEXTURE_2D_ARRAY: number;
  151675. readonly TEXTURE_COMPARE_FUNC: number;
  151676. readonly TEXTURE_COMPARE_MODE: number;
  151677. readonly COMPARE_REF_TO_TEXTURE: number;
  151678. readonly TEXTURE_WRAP_R: number;
  151679. readonly HALF_FLOAT: number;
  151680. readonly RGB8: number;
  151681. readonly RED_INTEGER: number;
  151682. readonly RG_INTEGER: number;
  151683. readonly RGB_INTEGER: number;
  151684. readonly RGBA_INTEGER: number;
  151685. readonly R8_SNORM: number;
  151686. readonly RG8_SNORM: number;
  151687. readonly RGB8_SNORM: number;
  151688. readonly RGBA8_SNORM: number;
  151689. readonly R8I: number;
  151690. readonly RG8I: number;
  151691. readonly RGB8I: number;
  151692. readonly RGBA8I: number;
  151693. readonly R8UI: number;
  151694. readonly RG8UI: number;
  151695. readonly RGB8UI: number;
  151696. readonly RGBA8UI: number;
  151697. readonly R16I: number;
  151698. readonly RG16I: number;
  151699. readonly RGB16I: number;
  151700. readonly RGBA16I: number;
  151701. readonly R16UI: number;
  151702. readonly RG16UI: number;
  151703. readonly RGB16UI: number;
  151704. readonly RGBA16UI: number;
  151705. readonly R32I: number;
  151706. readonly RG32I: number;
  151707. readonly RGB32I: number;
  151708. readonly RGBA32I: number;
  151709. readonly R32UI: number;
  151710. readonly RG32UI: number;
  151711. readonly RGB32UI: number;
  151712. readonly RGBA32UI: number;
  151713. readonly RGB10_A2UI: number;
  151714. readonly R11F_G11F_B10F: number;
  151715. readonly RGB9_E5: number;
  151716. readonly RGB10_A2: number;
  151717. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151718. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151719. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151720. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151721. readonly DEPTH_COMPONENT32F: number;
  151722. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151723. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151724. 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;
  151725. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151726. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151727. readonly TRANSFORM_FEEDBACK: number;
  151728. readonly INTERLEAVED_ATTRIBS: number;
  151729. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151730. createTransformFeedback(): WebGLTransformFeedback;
  151731. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151732. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151733. beginTransformFeedback(primitiveMode: number): void;
  151734. endTransformFeedback(): void;
  151735. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151736. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151737. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151738. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151739. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151740. }
  151741. interface ImageBitmap {
  151742. readonly width: number;
  151743. readonly height: number;
  151744. close(): void;
  151745. }
  151746. interface WebGLQuery extends WebGLObject {
  151747. }
  151748. declare var WebGLQuery: {
  151749. prototype: WebGLQuery;
  151750. new(): WebGLQuery;
  151751. };
  151752. interface WebGLSampler extends WebGLObject {
  151753. }
  151754. declare var WebGLSampler: {
  151755. prototype: WebGLSampler;
  151756. new(): WebGLSampler;
  151757. };
  151758. interface WebGLSync extends WebGLObject {
  151759. }
  151760. declare var WebGLSync: {
  151761. prototype: WebGLSync;
  151762. new(): WebGLSync;
  151763. };
  151764. interface WebGLTransformFeedback extends WebGLObject {
  151765. }
  151766. declare var WebGLTransformFeedback: {
  151767. prototype: WebGLTransformFeedback;
  151768. new(): WebGLTransformFeedback;
  151769. };
  151770. interface WebGLVertexArrayObject extends WebGLObject {
  151771. }
  151772. declare var WebGLVertexArrayObject: {
  151773. prototype: WebGLVertexArrayObject;
  151774. new(): WebGLVertexArrayObject;
  151775. };
  151776. // Type definitions for WebVR API
  151777. // Project: https://w3c.github.io/webvr/
  151778. // Definitions by: six a <https://github.com/lostfictions>
  151779. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151780. interface VRDisplay extends EventTarget {
  151781. /**
  151782. * Dictionary of capabilities describing the VRDisplay.
  151783. */
  151784. readonly capabilities: VRDisplayCapabilities;
  151785. /**
  151786. * z-depth defining the far plane of the eye view frustum
  151787. * enables mapping of values in the render target depth
  151788. * attachment to scene coordinates. Initially set to 10000.0.
  151789. */
  151790. depthFar: number;
  151791. /**
  151792. * z-depth defining the near plane of the eye view frustum
  151793. * enables mapping of values in the render target depth
  151794. * attachment to scene coordinates. Initially set to 0.01.
  151795. */
  151796. depthNear: number;
  151797. /**
  151798. * An identifier for this distinct VRDisplay. Used as an
  151799. * association point in the Gamepad API.
  151800. */
  151801. readonly displayId: number;
  151802. /**
  151803. * A display name, a user-readable name identifying it.
  151804. */
  151805. readonly displayName: string;
  151806. readonly isConnected: boolean;
  151807. readonly isPresenting: boolean;
  151808. /**
  151809. * If this VRDisplay supports room-scale experiences, the optional
  151810. * stage attribute contains details on the room-scale parameters.
  151811. */
  151812. readonly stageParameters: VRStageParameters | null;
  151813. /**
  151814. * Passing the value returned by `requestAnimationFrame` to
  151815. * `cancelAnimationFrame` will unregister the callback.
  151816. * @param handle Define the hanle of the request to cancel
  151817. */
  151818. cancelAnimationFrame(handle: number): void;
  151819. /**
  151820. * Stops presenting to the VRDisplay.
  151821. * @returns a promise to know when it stopped
  151822. */
  151823. exitPresent(): Promise<void>;
  151824. /**
  151825. * Return the current VREyeParameters for the given eye.
  151826. * @param whichEye Define the eye we want the parameter for
  151827. * @returns the eye parameters
  151828. */
  151829. getEyeParameters(whichEye: string): VREyeParameters;
  151830. /**
  151831. * Populates the passed VRFrameData with the information required to render
  151832. * the current frame.
  151833. * @param frameData Define the data structure to populate
  151834. * @returns true if ok otherwise false
  151835. */
  151836. getFrameData(frameData: VRFrameData): boolean;
  151837. /**
  151838. * Get the layers currently being presented.
  151839. * @returns the list of VR layers
  151840. */
  151841. getLayers(): VRLayer[];
  151842. /**
  151843. * Return a VRPose containing the future predicted pose of the VRDisplay
  151844. * when the current frame will be presented. The value returned will not
  151845. * change until JavaScript has returned control to the browser.
  151846. *
  151847. * The VRPose will contain the position, orientation, velocity,
  151848. * and acceleration of each of these properties.
  151849. * @returns the pose object
  151850. */
  151851. getPose(): VRPose;
  151852. /**
  151853. * Return the current instantaneous pose of the VRDisplay, with no
  151854. * prediction applied.
  151855. * @returns the current instantaneous pose
  151856. */
  151857. getImmediatePose(): VRPose;
  151858. /**
  151859. * The callback passed to `requestAnimationFrame` will be called
  151860. * any time a new frame should be rendered. When the VRDisplay is
  151861. * presenting the callback will be called at the native refresh
  151862. * rate of the HMD. When not presenting this function acts
  151863. * identically to how window.requestAnimationFrame acts. Content should
  151864. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151865. * asynchronously from other displays and at differing refresh rates.
  151866. * @param callback Define the eaction to run next frame
  151867. * @returns the request handle it
  151868. */
  151869. requestAnimationFrame(callback: FrameRequestCallback): number;
  151870. /**
  151871. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151872. * Repeat calls while already presenting will update the VRLayers being displayed.
  151873. * @param layers Define the list of layer to present
  151874. * @returns a promise to know when the request has been fulfilled
  151875. */
  151876. requestPresent(layers: VRLayer[]): Promise<void>;
  151877. /**
  151878. * Reset the pose for this display, treating its current position and
  151879. * orientation as the "origin/zero" values. VRPose.position,
  151880. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151881. * updated when calling resetPose(). This should be called in only
  151882. * sitting-space experiences.
  151883. */
  151884. resetPose(): void;
  151885. /**
  151886. * The VRLayer provided to the VRDisplay will be captured and presented
  151887. * in the HMD. Calling this function has the same effect on the source
  151888. * canvas as any other operation that uses its source image, and canvases
  151889. * created without preserveDrawingBuffer set to true will be cleared.
  151890. * @param pose Define the pose to submit
  151891. */
  151892. submitFrame(pose?: VRPose): void;
  151893. }
  151894. declare var VRDisplay: {
  151895. prototype: VRDisplay;
  151896. new(): VRDisplay;
  151897. };
  151898. interface VRLayer {
  151899. leftBounds?: number[] | Float32Array | null;
  151900. rightBounds?: number[] | Float32Array | null;
  151901. source?: HTMLCanvasElement | null;
  151902. }
  151903. interface VRDisplayCapabilities {
  151904. readonly canPresent: boolean;
  151905. readonly hasExternalDisplay: boolean;
  151906. readonly hasOrientation: boolean;
  151907. readonly hasPosition: boolean;
  151908. readonly maxLayers: number;
  151909. }
  151910. interface VREyeParameters {
  151911. /** @deprecated */
  151912. readonly fieldOfView: VRFieldOfView;
  151913. readonly offset: Float32Array;
  151914. readonly renderHeight: number;
  151915. readonly renderWidth: number;
  151916. }
  151917. interface VRFieldOfView {
  151918. readonly downDegrees: number;
  151919. readonly leftDegrees: number;
  151920. readonly rightDegrees: number;
  151921. readonly upDegrees: number;
  151922. }
  151923. interface VRFrameData {
  151924. readonly leftProjectionMatrix: Float32Array;
  151925. readonly leftViewMatrix: Float32Array;
  151926. readonly pose: VRPose;
  151927. readonly rightProjectionMatrix: Float32Array;
  151928. readonly rightViewMatrix: Float32Array;
  151929. readonly timestamp: number;
  151930. }
  151931. interface VRPose {
  151932. readonly angularAcceleration: Float32Array | null;
  151933. readonly angularVelocity: Float32Array | null;
  151934. readonly linearAcceleration: Float32Array | null;
  151935. readonly linearVelocity: Float32Array | null;
  151936. readonly orientation: Float32Array | null;
  151937. readonly position: Float32Array | null;
  151938. readonly timestamp: number;
  151939. }
  151940. interface VRStageParameters {
  151941. sittingToStandingTransform?: Float32Array;
  151942. sizeX?: number;
  151943. sizeY?: number;
  151944. }
  151945. interface Navigator {
  151946. getVRDisplays(): Promise<VRDisplay[]>;
  151947. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151948. }
  151949. interface Window {
  151950. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151951. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151952. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151953. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151954. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151955. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151956. }
  151957. interface Gamepad {
  151958. readonly displayId: number;
  151959. }
  151960. type XRSessionMode =
  151961. | "inline"
  151962. | "immersive-vr"
  151963. | "immersive-ar";
  151964. type XRReferenceSpaceType =
  151965. | "viewer"
  151966. | "local"
  151967. | "local-floor"
  151968. | "bounded-floor"
  151969. | "unbounded";
  151970. type XREnvironmentBlendMode =
  151971. | "opaque"
  151972. | "additive"
  151973. | "alpha-blend";
  151974. type XRVisibilityState =
  151975. | "visible"
  151976. | "visible-blurred"
  151977. | "hidden";
  151978. type XRHandedness =
  151979. | "none"
  151980. | "left"
  151981. | "right";
  151982. type XRTargetRayMode =
  151983. | "gaze"
  151984. | "tracked-pointer"
  151985. | "screen";
  151986. type XREye =
  151987. | "none"
  151988. | "left"
  151989. | "right";
  151990. type XREventType =
  151991. | "devicechange"
  151992. | "visibilitychange"
  151993. | "end"
  151994. | "inputsourceschange"
  151995. | "select"
  151996. | "selectstart"
  151997. | "selectend"
  151998. | "squeeze"
  151999. | "squeezestart"
  152000. | "squeezeend"
  152001. | "reset";
  152002. interface XRSpace extends EventTarget {
  152003. }
  152004. interface XRRenderState {
  152005. depthNear?: number;
  152006. depthFar?: number;
  152007. inlineVerticalFieldOfView?: number;
  152008. baseLayer?: XRWebGLLayer;
  152009. }
  152010. interface XRInputSource {
  152011. handedness: XRHandedness;
  152012. targetRayMode: XRTargetRayMode;
  152013. targetRaySpace: XRSpace;
  152014. gripSpace: XRSpace | undefined;
  152015. gamepad: Gamepad | undefined;
  152016. profiles: Array<string>;
  152017. }
  152018. interface XRSessionInit {
  152019. optionalFeatures?: string[];
  152020. requiredFeatures?: string[];
  152021. }
  152022. interface XRSession {
  152023. addEventListener: Function;
  152024. removeEventListener: Function;
  152025. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152026. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152027. requestAnimationFrame: Function;
  152028. end(): Promise<void>;
  152029. renderState: XRRenderState;
  152030. inputSources: Array<XRInputSource>;
  152031. // hit test
  152032. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152033. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152034. // legacy AR hit test
  152035. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152036. // legacy plane detection
  152037. updateWorldTrackingState(options: {
  152038. planeDetectionState?: { enabled: boolean; }
  152039. }): void;
  152040. }
  152041. interface XRReferenceSpace extends XRSpace {
  152042. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152043. onreset: any;
  152044. }
  152045. type XRPlaneSet = Set<XRPlane>;
  152046. type XRAnchorSet = Set<XRAnchor>;
  152047. interface XRFrame {
  152048. session: XRSession;
  152049. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152050. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152051. // AR
  152052. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152053. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152054. // Anchors
  152055. trackedAnchors?: XRAnchorSet;
  152056. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152057. // Planes
  152058. worldInformation: {
  152059. detectedPlanes?: XRPlaneSet;
  152060. };
  152061. }
  152062. interface XRViewerPose extends XRPose {
  152063. views: Array<XRView>;
  152064. }
  152065. interface XRPose {
  152066. transform: XRRigidTransform;
  152067. emulatedPosition: boolean;
  152068. }
  152069. interface XRWebGLLayerOptions {
  152070. antialias?: boolean;
  152071. depth?: boolean;
  152072. stencil?: boolean;
  152073. alpha?: boolean;
  152074. multiview?: boolean;
  152075. framebufferScaleFactor?: number;
  152076. }
  152077. declare var XRWebGLLayer: {
  152078. prototype: XRWebGLLayer;
  152079. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152080. };
  152081. interface XRWebGLLayer {
  152082. framebuffer: WebGLFramebuffer;
  152083. framebufferWidth: number;
  152084. framebufferHeight: number;
  152085. getViewport: Function;
  152086. }
  152087. declare class XRRigidTransform {
  152088. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152089. position: DOMPointReadOnly;
  152090. orientation: DOMPointReadOnly;
  152091. matrix: Float32Array;
  152092. inverse: XRRigidTransform;
  152093. }
  152094. interface XRView {
  152095. eye: XREye;
  152096. projectionMatrix: Float32Array;
  152097. transform: XRRigidTransform;
  152098. }
  152099. interface XRInputSourceChangeEvent {
  152100. session: XRSession;
  152101. removed: Array<XRInputSource>;
  152102. added: Array<XRInputSource>;
  152103. }
  152104. interface XRInputSourceEvent extends Event {
  152105. readonly frame: XRFrame;
  152106. readonly inputSource: XRInputSource;
  152107. }
  152108. // Experimental(er) features
  152109. declare class XRRay {
  152110. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152111. origin: DOMPointReadOnly;
  152112. direction: DOMPointReadOnly;
  152113. matrix: Float32Array;
  152114. }
  152115. declare enum XRHitTestTrackableType {
  152116. "point",
  152117. "plane"
  152118. }
  152119. interface XRHitResult {
  152120. hitMatrix: Float32Array;
  152121. }
  152122. interface XRTransientInputHitTestResult {
  152123. readonly inputSource: XRInputSource;
  152124. readonly results: Array<XRHitTestResult>;
  152125. }
  152126. interface XRHitTestResult {
  152127. getPose(baseSpace: XRSpace): XRPose | undefined;
  152128. // When anchor system is enabled
  152129. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152130. }
  152131. interface XRHitTestSource {
  152132. cancel(): void;
  152133. }
  152134. interface XRTransientInputHitTestSource {
  152135. cancel(): void;
  152136. }
  152137. interface XRHitTestOptionsInit {
  152138. space: XRSpace;
  152139. entityTypes?: Array<XRHitTestTrackableType>;
  152140. offsetRay?: XRRay;
  152141. }
  152142. interface XRTransientInputHitTestOptionsInit {
  152143. profile: string;
  152144. entityTypes?: Array<XRHitTestTrackableType>;
  152145. offsetRay?: XRRay;
  152146. }
  152147. interface XRAnchor {
  152148. anchorSpace: XRSpace;
  152149. delete(): void;
  152150. }
  152151. interface XRPlane {
  152152. orientation: "Horizontal" | "Vertical";
  152153. planeSpace: XRSpace;
  152154. polygon: Array<DOMPointReadOnly>;
  152155. lastChangedTime: number;
  152156. }